Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 19 | #include <linux/kernel.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 20 | #include <linux/etherdevice.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 21 | #include <linux/string.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 22 | #include <linux/pci_ids.h> |
Greg Kroah-Hartman | a1c16ed | 2010-10-21 11:17:44 -0700 | [diff] [blame] | 23 | #include <bcmdefs.h> |
Brett Rudley | c6ac24e | 2010-10-26 11:55:23 -0700 | [diff] [blame] | 24 | #include <linux/module.h> |
| 25 | #include <linux/pci.h> |
| 26 | #include <linux/sched.h> |
Greg Kroah-Hartman | a1c16ed | 2010-10-21 11:17:44 -0700 | [diff] [blame] | 27 | #include <osl.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 28 | #define WLC_MAXBSSCFG 1 /* single BSS configs */ |
| 29 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 30 | #include <wlc_cfg.h> |
| 31 | #include <net/mac80211.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 32 | #include <phy_version.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 33 | #include <bcmutils.h> |
| 34 | #include <pcicfg.h> |
| 35 | #include <wlioctl.h> |
| 36 | #include <wlc_key.h> |
Brett Rudley | a52ba66 | 2010-10-26 09:17:06 -0700 | [diff] [blame] | 37 | #include <sbhndpio.h> |
| 38 | #include <sbhnddma.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 39 | #include <wlc_channel.h> |
| 40 | #include <wlc_pub.h> |
| 41 | #include <wlc_scb.h> |
| 42 | #include <wl_dbg.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 43 | #include <wl_export.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 44 | |
| 45 | #include <wl_mac80211.h> |
| 46 | #include <linux/firmware.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 47 | #include <wl_ucode.h> |
| 48 | #include <d11ucode_ext.h> |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 49 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 50 | |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 51 | static void wl_timer(unsigned long data); |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 52 | static void _wl_timer(wl_timer_t *t); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 53 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | |
Jason Cooper | 7e85c72 | 2010-09-14 09:45:38 -0400 | [diff] [blame] | 69 | static int wl_found; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 70 | |
| 71 | struct ieee80211_tkip_data { |
| 72 | #define TKIP_KEY_LEN 32 |
| 73 | u8 key[TKIP_KEY_LEN]; |
| 74 | int key_set; |
| 75 | |
| 76 | u32 tx_iv32; |
| 77 | u16 tx_iv16; |
| 78 | u16 tx_ttak[5]; |
| 79 | int tx_phase1_done; |
| 80 | |
| 81 | u32 rx_iv32; |
| 82 | u16 rx_iv16; |
| 83 | u16 rx_ttak[5]; |
| 84 | int rx_phase1_done; |
| 85 | u32 rx_iv32_new; |
| 86 | u16 rx_iv16_new; |
| 87 | |
| 88 | u32 dot11RSNAStatsTKIPReplays; |
| 89 | u32 dot11RSNAStatsTKIPICVErrors; |
| 90 | u32 dot11RSNAStatsTKIPLocalMICFailures; |
| 91 | |
| 92 | int key_idx; |
| 93 | |
| 94 | struct crypto_tfm *tfm_arc4; |
| 95 | struct crypto_tfm *tfm_michael; |
| 96 | |
| 97 | /* scratch buffers for virt_to_page() (crypto API) */ |
| 98 | u8 rx_hdr[16], tx_hdr[16]; |
| 99 | }; |
| 100 | |
Greg Kroah-Hartman | 1a3bf74 | 2010-10-07 16:34:51 -0700 | [diff] [blame] | 101 | #define WL_DEV_IF(dev) ((wl_if_t *)netdev_priv(dev)) |
Jason Cooper | 39dcff3 | 2010-09-14 09:45:41 -0400 | [diff] [blame] | 102 | #define WL_INFO(dev) ((wl_info_t *)(WL_DEV_IF(dev)->wl)) /* points to wl */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 103 | static int wl_request_fw(wl_info_t *wl, struct pci_dev *pdev); |
| 104 | static void wl_release_fw(wl_info_t *wl); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 105 | |
| 106 | /* local prototypes */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 107 | static int wl_start(struct sk_buff *skb, wl_info_t *wl); |
| 108 | static int wl_start_int(wl_info_t *wl, struct ieee80211_hw *hw, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 109 | struct sk_buff *skb); |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 110 | static void wl_dpc(unsigned long data); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 111 | |
| 112 | MODULE_AUTHOR("Broadcom Corporation"); |
| 113 | MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver."); |
| 114 | MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); |
| 115 | MODULE_LICENSE("Dual BSD/GPL"); |
| 116 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 117 | /* recognized PCI IDs */ |
| 118 | static struct pci_device_id wl_id_table[] = { |
| 119 | {PCI_VENDOR_ID_BROADCOM, 0x4357, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 43225 2G */ |
| 120 | {PCI_VENDOR_ID_BROADCOM, 0x4353, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 43224 DUAL */ |
| 121 | {PCI_VENDOR_ID_BROADCOM, 0x4727, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* 4313 DUAL */ |
| 122 | {0} |
| 123 | }; |
| 124 | |
| 125 | MODULE_DEVICE_TABLE(pci, wl_id_table); |
Brett Rudley | 6f0c5bc | 2010-09-29 17:11:11 -0700 | [diff] [blame] | 126 | static void wl_remove(struct pci_dev *pdev); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 127 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 128 | |
| 129 | #ifdef BCMDBG |
| 130 | static int msglevel = 0xdeadbeef; |
| 131 | module_param(msglevel, int, 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 132 | static int phymsglevel = 0xdeadbeef; |
| 133 | module_param(phymsglevel, int, 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 134 | #endif /* BCMDBG */ |
| 135 | |
Jason Cooper | 0d706ef | 2010-09-14 09:45:39 -0400 | [diff] [blame] | 136 | #define HW_TO_WL(hw) (hw->priv) |
| 137 | #define WL_TO_HW(wl) (wl->pub->ieee_hw) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 138 | static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 139 | static int wl_ops_start(struct ieee80211_hw *hw); |
| 140 | static void wl_ops_stop(struct ieee80211_hw *hw); |
| 141 | static int wl_ops_add_interface(struct ieee80211_hw *hw, |
| 142 | struct ieee80211_vif *vif); |
| 143 | static void wl_ops_remove_interface(struct ieee80211_hw *hw, |
| 144 | struct ieee80211_vif *vif); |
| 145 | static int wl_ops_config(struct ieee80211_hw *hw, u32 changed); |
| 146 | static void wl_ops_bss_info_changed(struct ieee80211_hw *hw, |
| 147 | struct ieee80211_vif *vif, |
| 148 | struct ieee80211_bss_conf *info, |
| 149 | u32 changed); |
| 150 | static void wl_ops_configure_filter(struct ieee80211_hw *hw, |
| 151 | unsigned int changed_flags, |
| 152 | unsigned int *total_flags, u64 multicast); |
| 153 | static int wl_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, |
| 154 | bool set); |
| 155 | static void wl_ops_sw_scan_start(struct ieee80211_hw *hw); |
| 156 | static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw); |
| 157 | static void wl_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf); |
| 158 | static int wl_ops_get_stats(struct ieee80211_hw *hw, |
| 159 | struct ieee80211_low_level_stats *stats); |
| 160 | static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value); |
| 161 | static void wl_ops_sta_notify(struct ieee80211_hw *hw, |
| 162 | struct ieee80211_vif *vif, |
| 163 | enum sta_notify_cmd cmd, |
| 164 | struct ieee80211_sta *sta); |
| 165 | static int wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, |
| 166 | const struct ieee80211_tx_queue_params *params); |
| 167 | static u64 wl_ops_get_tsf(struct ieee80211_hw *hw); |
| 168 | static int wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 169 | struct ieee80211_sta *sta); |
| 170 | static int wl_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 171 | struct ieee80211_sta *sta); |
| 172 | static int wl_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 173 | enum ieee80211_ampdu_mlme_action action, |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 174 | struct ieee80211_sta *sta, u16 tid, u16 *ssn); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 175 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 176 | static int wl_ops_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
| 177 | { |
| 178 | int status; |
| 179 | wl_info_t *wl = hw->priv; |
| 180 | WL_LOCK(wl); |
| 181 | if (!wl->pub->up) { |
| 182 | WL_ERROR(("ops->tx called while down\n")); |
| 183 | status = -ENETDOWN; |
| 184 | goto done; |
| 185 | } |
| 186 | status = wl_start(skb, wl); |
| 187 | done: |
| 188 | WL_UNLOCK(wl); |
| 189 | return status; |
| 190 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 191 | |
| 192 | static int wl_ops_start(struct ieee80211_hw *hw) |
| 193 | { |
| 194 | wl_info_t *wl = hw->priv; |
| 195 | /* struct ieee80211_channel *curchan = hw->conf.channel; */ |
| 196 | WL_NONE(("%s : Initial channel: %d\n", __func__, curchan->hw_value)); |
| 197 | |
| 198 | WL_LOCK(wl); |
| 199 | ieee80211_wake_queues(hw); |
| 200 | WL_UNLOCK(wl); |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static void wl_ops_stop(struct ieee80211_hw *hw) |
| 206 | { |
| 207 | wl_info_t *wl = hw->priv; |
| 208 | ASSERT(wl); |
| 209 | WL_LOCK(wl); |
| 210 | wl_down(wl); |
| 211 | ieee80211_stop_queues(hw); |
| 212 | WL_UNLOCK(wl); |
| 213 | |
| 214 | return; |
| 215 | } |
| 216 | |
| 217 | static int |
| 218 | wl_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 219 | { |
| 220 | wl_info_t *wl; |
| 221 | int err; |
| 222 | |
| 223 | /* Just STA for now */ |
| 224 | if (vif->type != NL80211_IFTYPE_AP && |
| 225 | vif->type != NL80211_IFTYPE_MESH_POINT && |
| 226 | vif->type != NL80211_IFTYPE_STATION && |
| 227 | vif->type != NL80211_IFTYPE_WDS && |
| 228 | vif->type != NL80211_IFTYPE_ADHOC) { |
| 229 | WL_ERROR(("%s: Attempt to add type %d, only STA for now\n", |
| 230 | __func__, vif->type)); |
| 231 | return -EOPNOTSUPP; |
| 232 | } |
| 233 | |
| 234 | wl = HW_TO_WL(hw); |
| 235 | WL_LOCK(wl); |
| 236 | err = wl_up(wl); |
| 237 | WL_UNLOCK(wl); |
| 238 | |
| 239 | if (err != 0) |
| 240 | WL_ERROR(("%s: wl_up() returned %d\n", __func__, err)); |
| 241 | return err; |
| 242 | } |
| 243 | |
| 244 | static void |
| 245 | wl_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif) |
| 246 | { |
| 247 | return; |
| 248 | } |
| 249 | |
| 250 | static int |
| 251 | ieee_set_channel(struct ieee80211_hw *hw, struct ieee80211_channel *chan, |
| 252 | enum nl80211_channel_type type) |
| 253 | { |
| 254 | wl_info_t *wl = HW_TO_WL(hw); |
| 255 | int err = 0; |
| 256 | |
| 257 | switch (type) { |
| 258 | case NL80211_CHAN_HT20: |
| 259 | case NL80211_CHAN_NO_HT: |
| 260 | WL_LOCK(wl); |
| 261 | err = wlc_set(wl->wlc, WLC_SET_CHANNEL, chan->hw_value); |
| 262 | WL_UNLOCK(wl); |
| 263 | break; |
| 264 | case NL80211_CHAN_HT40MINUS: |
| 265 | case NL80211_CHAN_HT40PLUS: |
| 266 | WL_ERROR(("%s: Need to implement 40 Mhz Channels!\n", |
| 267 | __func__)); |
| 268 | break; |
| 269 | } |
| 270 | |
| 271 | if (err) |
| 272 | return -EIO; |
| 273 | return err; |
| 274 | } |
| 275 | |
| 276 | static int wl_ops_config(struct ieee80211_hw *hw, u32 changed) |
| 277 | { |
| 278 | struct ieee80211_conf *conf = &hw->conf; |
| 279 | wl_info_t *wl = HW_TO_WL(hw); |
| 280 | int err = 0; |
| 281 | int new_int; |
| 282 | |
| 283 | if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) { |
| 284 | WL_NONE(("%s: Setting listen interval to %d\n", |
| 285 | __func__, conf->listen_interval)); |
| 286 | if (wlc_iovar_setint |
| 287 | (wl->wlc, "bcn_li_bcn", conf->listen_interval)) { |
| 288 | WL_ERROR(("%s: Error setting listen_interval\n", |
| 289 | __func__)); |
| 290 | err = -EIO; |
| 291 | goto config_out; |
| 292 | } |
| 293 | wlc_iovar_getint(wl->wlc, "bcn_li_bcn", &new_int); |
| 294 | ASSERT(new_int == conf->listen_interval); |
| 295 | } |
| 296 | if (changed & IEEE80211_CONF_CHANGE_MONITOR) |
| 297 | WL_NONE(("Need to set monitor mode\n")); |
| 298 | if (changed & IEEE80211_CONF_CHANGE_PS) |
| 299 | WL_NONE(("Need to set Power-save mode\n")); |
| 300 | |
| 301 | if (changed & IEEE80211_CONF_CHANGE_POWER) { |
| 302 | WL_NONE(("%s: Setting tx power to %d dbm\n", __func__, |
| 303 | conf->power_level)); |
| 304 | if (wlc_iovar_setint |
| 305 | (wl->wlc, "qtxpower", conf->power_level * 4)) { |
| 306 | WL_ERROR(("%s: Error setting power_level\n", __func__)); |
| 307 | err = -EIO; |
| 308 | goto config_out; |
| 309 | } |
| 310 | wlc_iovar_getint(wl->wlc, "qtxpower", &new_int); |
| 311 | if (new_int != (conf->power_level * 4)) |
| 312 | WL_ERROR(("%s: Power level req != actual, %d %d\n", |
| 313 | __func__, conf->power_level * 4, new_int)); |
| 314 | } |
| 315 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { |
| 316 | err = ieee_set_channel(hw, conf->channel, conf->channel_type); |
| 317 | } |
| 318 | if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS) { |
| 319 | WL_NONE(("%s: srl %d, lrl %d\n", __func__, |
| 320 | conf->short_frame_max_tx_count, |
| 321 | conf->long_frame_max_tx_count)); |
| 322 | if (wlc_set |
| 323 | (wl->wlc, WLC_SET_SRL, |
| 324 | conf->short_frame_max_tx_count) < 0) { |
| 325 | WL_ERROR(("%s: Error setting srl\n", __func__)); |
| 326 | err = -EIO; |
| 327 | goto config_out; |
| 328 | } |
| 329 | if (wlc_set(wl->wlc, WLC_SET_LRL, conf->long_frame_max_tx_count) |
| 330 | < 0) { |
| 331 | WL_ERROR(("%s: Error setting lrl\n", __func__)); |
| 332 | err = -EIO; |
| 333 | goto config_out; |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | config_out: |
| 338 | return err; |
| 339 | } |
| 340 | |
| 341 | static void |
| 342 | wl_ops_bss_info_changed(struct ieee80211_hw *hw, |
| 343 | struct ieee80211_vif *vif, |
| 344 | struct ieee80211_bss_conf *info, u32 changed) |
| 345 | { |
| 346 | wl_info_t *wl = HW_TO_WL(hw); |
| 347 | int val; |
| 348 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 349 | |
| 350 | if (changed & BSS_CHANGED_ASSOC) { |
| 351 | WL_ERROR(("Associated:\t%s\n", info->assoc ? "True" : "False")); |
| 352 | /* association status changed (associated/disassociated) |
| 353 | * also implies a change in the AID. |
| 354 | */ |
| 355 | } |
| 356 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { |
| 357 | WL_NONE(("Use_cts_prot:\t%s Implement me\n", |
| 358 | info->use_cts_prot ? "True" : "False")); |
| 359 | /* CTS protection changed */ |
| 360 | } |
| 361 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { |
| 362 | WL_NONE(("Short preamble:\t%s Implement me\n", |
| 363 | info->use_short_preamble ? "True" : "False")); |
| 364 | /* preamble changed */ |
| 365 | } |
| 366 | if (changed & BSS_CHANGED_ERP_SLOT) { |
| 367 | WL_NONE(("Changing short slot:\t%s\n", |
| 368 | info->use_short_slot ? "True" : "False")); |
| 369 | if (info->use_short_slot) |
| 370 | val = 1; |
| 371 | else |
| 372 | val = 0; |
| 373 | wlc_set(wl->wlc, WLC_SET_SHORTSLOT_OVERRIDE, val); |
| 374 | /* slot timing changed */ |
| 375 | } |
| 376 | |
| 377 | if (changed & BSS_CHANGED_HT) { |
| 378 | WL_NONE(("%s: HT mode - Implement me\n", __func__)); |
| 379 | /* 802.11n parameters changed */ |
| 380 | } |
| 381 | if (changed & BSS_CHANGED_BASIC_RATES) { |
| 382 | WL_NONE(("Need to change Basic Rates:\t0x%x! Implement me\n", |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 383 | (u32) info->basic_rates)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 384 | /* Basic rateset changed */ |
| 385 | } |
| 386 | if (changed & BSS_CHANGED_BEACON_INT) { |
| 387 | WL_NONE(("Beacon Interval:\t%d Implement me\n", |
| 388 | info->beacon_int)); |
| 389 | /* Beacon interval changed */ |
| 390 | } |
| 391 | if (changed & BSS_CHANGED_BSSID) { |
Andy Shevchenko | ba07d0c | 2010-10-11 16:58:33 +0300 | [diff] [blame] | 392 | WL_NONE(("new BSSID:\taid %d bss:%pM\n", info->aid, |
| 393 | info->bssid)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 394 | /* BSSID changed, for whatever reason (IBSS and managed mode) */ |
| 395 | /* FIXME: need to store bssid in bsscfg */ |
| 396 | wlc_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, |
| 397 | (struct ether_addr *)info->bssid); |
| 398 | } |
| 399 | if (changed & BSS_CHANGED_BEACON) { |
| 400 | WL_ERROR(("BSS_CHANGED_BEACON\n")); |
| 401 | /* Beacon data changed, retrieve new beacon (beaconing modes) */ |
| 402 | } |
| 403 | if (changed & BSS_CHANGED_BEACON_ENABLED) { |
| 404 | WL_ERROR(("Beacon enabled:\t%s\n", |
| 405 | info->enable_beacon ? "True" : "False")); |
| 406 | /* Beaconing should be enabled/disabled (beaconing modes) */ |
| 407 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 408 | return; |
| 409 | } |
| 410 | |
| 411 | static void |
| 412 | wl_ops_configure_filter(struct ieee80211_hw *hw, |
| 413 | unsigned int changed_flags, |
| 414 | unsigned int *total_flags, u64 multicast) |
| 415 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 416 | wl_info_t *wl = hw->priv; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 417 | |
| 418 | changed_flags &= MAC_FILTERS; |
| 419 | *total_flags &= MAC_FILTERS; |
| 420 | if (changed_flags & FIF_PROMISC_IN_BSS) |
| 421 | WL_ERROR(("FIF_PROMISC_IN_BSS\n")); |
| 422 | if (changed_flags & FIF_ALLMULTI) |
| 423 | WL_ERROR(("FIF_ALLMULTI\n")); |
| 424 | if (changed_flags & FIF_FCSFAIL) |
| 425 | WL_ERROR(("FIF_FCSFAIL\n")); |
| 426 | if (changed_flags & FIF_PLCPFAIL) |
| 427 | WL_ERROR(("FIF_PLCPFAIL\n")); |
| 428 | if (changed_flags & FIF_CONTROL) |
| 429 | WL_ERROR(("FIF_CONTROL\n")); |
| 430 | if (changed_flags & FIF_OTHER_BSS) |
| 431 | WL_ERROR(("FIF_OTHER_BSS\n")); |
| 432 | if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { |
| 433 | WL_NONE(("FIF_BCN_PRBRESP_PROMISC\n")); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 434 | WL_LOCK(wl); |
| 435 | if (*total_flags & FIF_BCN_PRBRESP_PROMISC) { |
| 436 | wl->pub->mac80211_state |= MAC80211_PROMISC_BCNS; |
| 437 | wlc_mac_bcn_promisc_change(wl->wlc, 1); |
| 438 | } else { |
| 439 | wlc_mac_bcn_promisc_change(wl->wlc, 0); |
| 440 | wl->pub->mac80211_state &= ~MAC80211_PROMISC_BCNS; |
| 441 | } |
| 442 | WL_UNLOCK(wl); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 443 | } |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | static int |
| 448 | wl_ops_set_tim(struct ieee80211_hw *hw, struct ieee80211_sta *sta, bool set) |
| 449 | { |
| 450 | WL_ERROR(("%s: Enter\n", __func__)); |
| 451 | return 0; |
| 452 | } |
| 453 | |
| 454 | static void wl_ops_sw_scan_start(struct ieee80211_hw *hw) |
| 455 | { |
| 456 | WL_NONE(("Scan Start\n")); |
| 457 | return; |
| 458 | } |
| 459 | |
| 460 | static void wl_ops_sw_scan_complete(struct ieee80211_hw *hw) |
| 461 | { |
| 462 | WL_NONE(("Scan Complete\n")); |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | static void wl_ops_set_tsf(struct ieee80211_hw *hw, u64 tsf) |
| 467 | { |
| 468 | WL_ERROR(("%s: Enter\n", __func__)); |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | static int |
| 473 | wl_ops_get_stats(struct ieee80211_hw *hw, |
| 474 | struct ieee80211_low_level_stats *stats) |
| 475 | { |
| 476 | WL_ERROR(("%s: Enter\n", __func__)); |
| 477 | return 0; |
| 478 | } |
| 479 | |
| 480 | static int wl_ops_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
| 481 | { |
| 482 | WL_ERROR(("%s: Enter\n", __func__)); |
| 483 | return 0; |
| 484 | } |
| 485 | |
| 486 | static void |
| 487 | wl_ops_sta_notify(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 488 | enum sta_notify_cmd cmd, struct ieee80211_sta *sta) |
| 489 | { |
| 490 | WL_NONE(("%s: Enter\n", __func__)); |
| 491 | switch (cmd) { |
| 492 | default: |
| 493 | WL_ERROR(("%s: Uknown cmd = %d\n", __func__, cmd)); |
| 494 | break; |
| 495 | } |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | static int |
| 500 | wl_ops_conf_tx(struct ieee80211_hw *hw, u16 queue, |
| 501 | const struct ieee80211_tx_queue_params *params) |
| 502 | { |
| 503 | wl_info_t *wl = hw->priv; |
| 504 | |
| 505 | WL_NONE(("%s: Enter (WME config)\n", __func__)); |
| 506 | WL_NONE(("queue %d, txop %d, cwmin %d, cwmax %d, aifs %d\n", queue, |
| 507 | params->txop, params->cw_min, params->cw_max, params->aifs)); |
| 508 | |
| 509 | WL_LOCK(wl); |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 510 | wlc_wme_setparams(wl->wlc, queue, (void *)params, true); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 511 | WL_UNLOCK(wl); |
| 512 | |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | static u64 wl_ops_get_tsf(struct ieee80211_hw *hw) |
| 517 | { |
| 518 | WL_ERROR(("%s: Enter\n", __func__)); |
| 519 | return 0; |
| 520 | } |
| 521 | |
| 522 | static int |
| 523 | wl_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 524 | struct ieee80211_sta *sta) |
| 525 | { |
| 526 | struct scb *scb; |
| 527 | |
| 528 | int i; |
| 529 | wl_info_t *wl = hw->priv; |
| 530 | |
| 531 | /* Init the scb */ |
| 532 | scb = (struct scb *)sta->drv_priv; |
Brett Rudley | 9249ede | 2010-11-30 20:09:49 -0800 | [diff] [blame^] | 533 | memset(scb, 0, sizeof(struct scb)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 534 | for (i = 0; i < NUMPRIO; i++) |
| 535 | scb->seqctl[i] = 0xFFFF; |
| 536 | scb->seqctl_nonqos = 0xFFFF; |
| 537 | scb->magic = SCB_MAGIC; |
| 538 | |
| 539 | wl->pub->global_scb = scb; |
| 540 | wl->pub->global_ampdu = &(scb->scb_ampdu); |
| 541 | wl->pub->global_ampdu->scb = scb; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 542 | wl->pub->global_ampdu->max_pdu = 16; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 543 | pktq_init(&scb->scb_ampdu.txq, AMPDU_MAX_SCB_TID, |
| 544 | AMPDU_MAX_SCB_TID * PKTQ_LEN_DEFAULT); |
| 545 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 546 | sta->ht_cap.ht_supported = true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 547 | sta->ht_cap.ampdu_factor = AMPDU_RX_FACTOR_64K; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 548 | sta->ht_cap.ampdu_density = AMPDU_DEF_MPDU_DENSITY; |
| 549 | sta->ht_cap.cap = IEEE80211_HT_CAP_GRN_FLD | |
| 550 | IEEE80211_HT_CAP_SGI_20 | |
| 551 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT; |
| 552 | |
| 553 | /* minstrel_ht initiates addBA on our behalf by calling ieee80211_start_tx_ba_session() */ |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | static int |
| 558 | wl_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
| 559 | struct ieee80211_sta *sta) |
| 560 | { |
| 561 | WL_NONE(("%s: Enter\n", __func__)); |
| 562 | return 0; |
| 563 | } |
| 564 | |
| 565 | static int |
| 566 | wl_ampdu_action(struct ieee80211_hw *hw, |
| 567 | struct ieee80211_vif *vif, |
| 568 | enum ieee80211_ampdu_mlme_action action, |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 569 | struct ieee80211_sta *sta, u16 tid, u16 *ssn) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 570 | { |
| 571 | #if defined(BCMDBG) |
| 572 | struct scb *scb = (struct scb *)sta->drv_priv; |
| 573 | #endif |
| 574 | wl_info_t *wl = hw->priv; |
| 575 | |
| 576 | ASSERT(scb->magic == SCB_MAGIC); |
| 577 | switch (action) { |
| 578 | case IEEE80211_AMPDU_RX_START: |
| 579 | WL_NONE(("%s: action = IEEE80211_AMPDU_RX_START\n", __func__)); |
| 580 | break; |
| 581 | case IEEE80211_AMPDU_RX_STOP: |
| 582 | WL_NONE(("%s: action = IEEE80211_AMPDU_RX_STOP\n", __func__)); |
| 583 | break; |
| 584 | case IEEE80211_AMPDU_TX_START: |
| 585 | if (!wlc_aggregatable(wl->wlc, tid)) { |
| 586 | /* WL_ERROR(("START: tid %d is not agg' able, return FAILURE to stack\n", tid)); */ |
| 587 | return -1; |
| 588 | } |
| 589 | /* XXX: Use the starting sequence number provided ... */ |
| 590 | *ssn = 0; |
| 591 | ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
| 592 | break; |
| 593 | |
| 594 | case IEEE80211_AMPDU_TX_STOP: |
| 595 | ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); |
| 596 | break; |
| 597 | case IEEE80211_AMPDU_TX_OPERATIONAL: |
| 598 | /* Not sure what to do here */ |
| 599 | /* Power save wakeup */ |
| 600 | WL_NONE(("%s: action = IEEE80211_AMPDU_TX_OPERATIONAL\n", |
| 601 | __func__)); |
| 602 | break; |
| 603 | default: |
| 604 | WL_ERROR(("%s: Invalid command, ignoring\n", __func__)); |
| 605 | } |
| 606 | |
| 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | static const struct ieee80211_ops wl_ops = { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 611 | .tx = wl_ops_tx, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 612 | .start = wl_ops_start, |
| 613 | .stop = wl_ops_stop, |
| 614 | .add_interface = wl_ops_add_interface, |
| 615 | .remove_interface = wl_ops_remove_interface, |
| 616 | .config = wl_ops_config, |
| 617 | .bss_info_changed = wl_ops_bss_info_changed, |
| 618 | .configure_filter = wl_ops_configure_filter, |
| 619 | .set_tim = wl_ops_set_tim, |
| 620 | .sw_scan_start = wl_ops_sw_scan_start, |
| 621 | .sw_scan_complete = wl_ops_sw_scan_complete, |
| 622 | .set_tsf = wl_ops_set_tsf, |
| 623 | .get_stats = wl_ops_get_stats, |
| 624 | .set_rts_threshold = wl_ops_set_rts_threshold, |
| 625 | .sta_notify = wl_ops_sta_notify, |
| 626 | .conf_tx = wl_ops_conf_tx, |
| 627 | .get_tsf = wl_ops_get_tsf, |
| 628 | .sta_add = wl_sta_add, |
| 629 | .sta_remove = wl_sta_remove, |
| 630 | .ampdu_action = wl_ampdu_action, |
| 631 | }; |
| 632 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 633 | static int wl_set_hint(wl_info_t *wl, char *abbrev) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 634 | { |
| 635 | WL_ERROR(("%s: Sending country code %c%c to MAC80211\n", __func__, |
| 636 | abbrev[0], abbrev[1])); |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 637 | return regulatory_hint(wl->pub->ieee_hw->wiphy, abbrev); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | /** |
| 641 | * attach to the WL device. |
| 642 | * |
| 643 | * Attach to the WL device identified by vendor and device parameters. |
| 644 | * regs is a host accessible memory address pointing to WL device registers. |
| 645 | * |
| 646 | * wl_attach is not defined as static because in the case where no bus |
| 647 | * is defined, wl_attach will never be called, and thus, gcc will issue |
| 648 | * a warning that this function is defined but not used if we declare |
| 649 | * it as static. |
| 650 | */ |
Greg Kroah-Hartman | 7d4df48 | 2010-10-07 17:04:47 -0700 | [diff] [blame] | 651 | static wl_info_t *wl_attach(u16 vendor, u16 device, unsigned long regs, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 652 | uint bustype, void *btparam, uint irq) |
| 653 | { |
| 654 | wl_info_t *wl; |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame] | 655 | struct osl_info *osh; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 656 | int unit, err; |
| 657 | |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 658 | unsigned long base_addr; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 659 | struct ieee80211_hw *hw; |
Greg Kroah-Hartman | 41feb5e | 2010-10-05 10:09:00 -0700 | [diff] [blame] | 660 | u8 perm[ETH_ALEN]; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 661 | |
Brett Rudley | 06fc884 | 2010-11-10 17:19:41 -0800 | [diff] [blame] | 662 | unit = wl_found; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 663 | err = 0; |
| 664 | |
| 665 | if (unit < 0) { |
| 666 | WL_ERROR(("wl%d: unit number overflow, exiting\n", unit)); |
| 667 | return NULL; |
| 668 | } |
| 669 | |
Brett Rudley | 997dd24 | 2010-11-03 19:53:59 -0700 | [diff] [blame] | 670 | osh = osl_attach(btparam, bustype); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 671 | ASSERT(osh); |
| 672 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 673 | /* allocate private info */ |
| 674 | hw = pci_get_drvdata(btparam); /* btparam == pdev */ |
| 675 | wl = hw->priv; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 676 | ASSERT(wl); |
| 677 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 678 | wl->osh = osh; |
| 679 | atomic_set(&wl->callbacks, 0); |
| 680 | |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 681 | /* setup the bottom half handler */ |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 682 | tasklet_init(&wl->tasklet, wl_dpc, (unsigned long) wl); |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 683 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 684 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 685 | |
| 686 | base_addr = regs; |
| 687 | |
| 688 | if (bustype == PCI_BUS) { |
Brett Rudley | 06fc884 | 2010-11-10 17:19:41 -0800 | [diff] [blame] | 689 | wl->piomode = false; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 690 | } else if (bustype == RPC_BUS) { |
| 691 | /* Do nothing */ |
| 692 | } else { |
| 693 | bustype = PCI_BUS; |
| 694 | WL_TRACE(("force to PCI\n")); |
| 695 | } |
| 696 | wl->bcm_bustype = bustype; |
| 697 | |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 698 | wl->regsva = ioremap_nocache(base_addr, PCI_BAR0_WINSZ); |
| 699 | if (wl->regsva == NULL) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 700 | WL_ERROR(("wl%d: ioremap() failed\n", unit)); |
| 701 | goto fail; |
| 702 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 703 | spin_lock_init(&wl->lock); |
| 704 | spin_lock_init(&wl->isr_lock); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 705 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 706 | /* prepare ucode */ |
| 707 | if (wl_request_fw(wl, (struct pci_dev *)btparam)) { |
Brett Rudley | 683b505 | 2010-09-28 11:34:44 -0700 | [diff] [blame] | 708 | printf("%s: Failed to find firmware usually in %s\n", |
| 709 | KBUILD_MODNAME, "/lib/firmware/brcm"); |
| 710 | wl_release_fw(wl); |
| 711 | wl_remove((struct pci_dev *)btparam); |
| 712 | goto fail1; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 713 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 714 | |
| 715 | /* common load-time initialization */ |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 716 | wl->wlc = wlc_attach((void *)wl, vendor, device, unit, wl->piomode, osh, |
| 717 | wl->regsva, wl->bcm_bustype, btparam, &err); |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 718 | wl_release_fw(wl); |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 719 | if (!wl->wlc) { |
Brett Rudley | 4766ae6 | 2010-10-27 15:47:53 -0700 | [diff] [blame] | 720 | printf("%s: wlc_attach() failed with code %d\n", |
| 721 | KBUILD_MODNAME, err); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 722 | goto fail; |
| 723 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 724 | wl->pub = wlc_pub(wl->wlc); |
| 725 | |
| 726 | wl->pub->ieee_hw = hw; |
| 727 | ASSERT(wl->pub->ieee_hw); |
| 728 | ASSERT(wl->pub->ieee_hw->priv == wl); |
| 729 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 730 | |
Brett Rudley | 06fc884 | 2010-11-10 17:19:41 -0800 | [diff] [blame] | 731 | if (wlc_iovar_setint(wl->wlc, "mpc", 0)) { |
| 732 | WL_ERROR(("wl%d: Error setting MPC variable to 0\n", |
| 733 | unit)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 734 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 735 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 736 | /* register our interrupt handler */ |
| 737 | if (request_irq(irq, wl_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { |
| 738 | WL_ERROR(("wl%d: request_irq() failed\n", unit)); |
| 739 | goto fail; |
| 740 | } |
| 741 | wl->irq = irq; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 742 | |
| 743 | /* register module */ |
| 744 | wlc_module_register(wl->pub, NULL, "linux", wl, NULL, wl_linux_watchdog, |
| 745 | NULL); |
| 746 | |
| 747 | if (ieee_hw_init(hw)) { |
| 748 | WL_ERROR(("wl%d: %s: ieee_hw_init failed!\n", unit, __func__)); |
| 749 | goto fail; |
| 750 | } |
| 751 | |
| 752 | bcopy(&wl->pub->cur_etheraddr, perm, ETHER_ADDR_LEN); |
| 753 | ASSERT(is_valid_ether_addr(perm)); |
| 754 | SET_IEEE80211_PERM_ADDR(hw, perm); |
| 755 | |
| 756 | err = ieee80211_register_hw(hw); |
| 757 | if (err) { |
| 758 | WL_ERROR(("%s: ieee80211_register_hw failed, status %d\n", |
| 759 | __func__, err)); |
| 760 | } |
| 761 | |
| 762 | if (wl->pub->srom_ccode[0]) |
| 763 | err = wl_set_hint(wl, wl->pub->srom_ccode); |
| 764 | else |
| 765 | err = wl_set_hint(wl, "US"); |
| 766 | if (err) { |
| 767 | WL_ERROR(("%s: regulatory_hint failed, status %d\n", __func__, |
| 768 | err)); |
| 769 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 770 | WL_ERROR(("wl%d: Broadcom BCM43xx 802.11 MAC80211 Driver " |
Brett Rudley | 4766ae6 | 2010-10-27 15:47:53 -0700 | [diff] [blame] | 771 | " (" PHY_VERSION_STR ")", unit)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 772 | |
| 773 | #ifdef BCMDBG |
Brett Rudley | 06fc884 | 2010-11-10 17:19:41 -0800 | [diff] [blame] | 774 | printf(" (Compiled at " __TIME__ " on " __DATE__ ")"); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 775 | #endif /* BCMDBG */ |
| 776 | printf("\n"); |
| 777 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 778 | wl_found++; |
| 779 | return wl; |
| 780 | |
| 781 | fail: |
| 782 | wl_free(wl); |
Brett Rudley | 9e56568 | 2010-09-28 17:35:39 -0700 | [diff] [blame] | 783 | fail1: |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 784 | return NULL; |
| 785 | } |
| 786 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 787 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 788 | |
| 789 | #define CHAN2GHZ(channel, freqency, chflags) { \ |
| 790 | .band = IEEE80211_BAND_2GHZ, \ |
| 791 | .center_freq = (freqency), \ |
| 792 | .hw_value = (channel), \ |
| 793 | .flags = chflags, \ |
| 794 | .max_antenna_gain = 0, \ |
| 795 | .max_power = 19, \ |
| 796 | } |
| 797 | |
| 798 | static struct ieee80211_channel wl_2ghz_chantable[] = { |
| 799 | CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS), |
| 800 | CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS), |
| 801 | CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS), |
| 802 | CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS), |
| 803 | CHAN2GHZ(5, 2432, 0), |
| 804 | CHAN2GHZ(6, 2437, 0), |
| 805 | CHAN2GHZ(7, 2442, 0), |
| 806 | CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS), |
| 807 | CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS), |
| 808 | CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS), |
| 809 | CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS), |
| 810 | CHAN2GHZ(12, 2467, |
| 811 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | |
| 812 | IEEE80211_CHAN_NO_HT40PLUS), |
| 813 | CHAN2GHZ(13, 2472, |
| 814 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | |
| 815 | IEEE80211_CHAN_NO_HT40PLUS), |
| 816 | CHAN2GHZ(14, 2484, |
| 817 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS | |
| 818 | IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) |
| 819 | }; |
| 820 | |
| 821 | #define CHAN5GHZ(channel, chflags) { \ |
| 822 | .band = IEEE80211_BAND_5GHZ, \ |
| 823 | .center_freq = 5000 + 5*(channel), \ |
| 824 | .hw_value = (channel), \ |
| 825 | .flags = chflags, \ |
| 826 | .max_antenna_gain = 0, \ |
| 827 | .max_power = 21, \ |
| 828 | } |
| 829 | |
| 830 | static struct ieee80211_channel wl_5ghz_nphy_chantable[] = { |
| 831 | /* UNII-1 */ |
| 832 | CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS), |
| 833 | CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS), |
| 834 | CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS), |
| 835 | CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS), |
| 836 | /* UNII-2 */ |
| 837 | CHAN5GHZ(52, |
| 838 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 839 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 840 | CHAN5GHZ(56, |
| 841 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 842 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 843 | CHAN5GHZ(60, |
| 844 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 845 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 846 | CHAN5GHZ(64, |
| 847 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 848 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 849 | /* MID */ |
| 850 | CHAN5GHZ(100, |
| 851 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 852 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 853 | CHAN5GHZ(104, |
| 854 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 855 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 856 | CHAN5GHZ(108, |
| 857 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 858 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 859 | CHAN5GHZ(112, |
| 860 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 861 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 862 | CHAN5GHZ(116, |
| 863 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 864 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 865 | CHAN5GHZ(120, |
| 866 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 867 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 868 | CHAN5GHZ(124, |
| 869 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 870 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 871 | CHAN5GHZ(128, |
| 872 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 873 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 874 | CHAN5GHZ(132, |
| 875 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 876 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS), |
| 877 | CHAN5GHZ(136, |
| 878 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 879 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS), |
| 880 | CHAN5GHZ(140, |
| 881 | IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS | |
| 882 | IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS | |
| 883 | IEEE80211_CHAN_NO_HT40MINUS), |
| 884 | /* UNII-3 */ |
| 885 | CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS), |
| 886 | CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS), |
| 887 | CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS), |
| 888 | CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS), |
| 889 | CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS) |
| 890 | }; |
| 891 | |
| 892 | #define RATE(rate100m, _flags) { \ |
| 893 | .bitrate = (rate100m), \ |
| 894 | .flags = (_flags), \ |
| 895 | .hw_value = (rate100m / 5), \ |
| 896 | } |
| 897 | |
| 898 | static struct ieee80211_rate wl_legacy_ratetable[] = { |
| 899 | RATE(10, 0), |
| 900 | RATE(20, IEEE80211_RATE_SHORT_PREAMBLE), |
| 901 | RATE(55, IEEE80211_RATE_SHORT_PREAMBLE), |
| 902 | RATE(110, IEEE80211_RATE_SHORT_PREAMBLE), |
| 903 | RATE(60, 0), |
| 904 | RATE(90, 0), |
| 905 | RATE(120, 0), |
| 906 | RATE(180, 0), |
| 907 | RATE(240, 0), |
| 908 | RATE(360, 0), |
| 909 | RATE(480, 0), |
| 910 | RATE(540, 0), |
| 911 | }; |
| 912 | |
| 913 | static struct ieee80211_supported_band wl_band_2GHz_nphy = { |
| 914 | .band = IEEE80211_BAND_2GHZ, |
| 915 | .channels = wl_2ghz_chantable, |
| 916 | .n_channels = ARRAY_SIZE(wl_2ghz_chantable), |
| 917 | .bitrates = wl_legacy_ratetable, |
| 918 | .n_bitrates = ARRAY_SIZE(wl_legacy_ratetable), |
| 919 | .ht_cap = { |
| 920 | /* from include/linux/ieee80211.h */ |
| 921 | .cap = IEEE80211_HT_CAP_GRN_FLD | |
| 922 | IEEE80211_HT_CAP_SGI_20 | |
| 923 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 924 | .ht_supported = true, |
| 925 | .ampdu_factor = AMPDU_RX_FACTOR_64K, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 926 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, |
| 927 | .mcs = { |
| 928 | /* placeholders for now */ |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 929 | .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, |
| 930 | .rx_highest = 500, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 931 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED} |
| 932 | } |
| 933 | }; |
| 934 | |
| 935 | static struct ieee80211_supported_band wl_band_5GHz_nphy = { |
| 936 | .band = IEEE80211_BAND_5GHZ, |
| 937 | .channels = wl_5ghz_nphy_chantable, |
| 938 | .n_channels = ARRAY_SIZE(wl_5ghz_nphy_chantable), |
| 939 | .bitrates = wl_legacy_ratetable + 4, |
| 940 | .n_bitrates = ARRAY_SIZE(wl_legacy_ratetable) - 4, |
| 941 | .ht_cap = { |
| 942 | /* use IEEE80211_HT_CAP_* from include/linux/ieee80211.h */ |
| 943 | .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_40MHZ_INTOLERANT, /* No 40 mhz yet */ |
| 944 | .ht_supported = true, |
| 945 | .ampdu_factor = AMPDU_RX_FACTOR_64K, |
| 946 | .ampdu_density = AMPDU_DEF_MPDU_DENSITY, |
| 947 | .mcs = { |
| 948 | /* placeholders for now */ |
| 949 | .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0}, |
| 950 | .rx_highest = 500, |
| 951 | .tx_params = IEEE80211_HT_MCS_TX_DEFINED} |
| 952 | } |
| 953 | }; |
| 954 | |
| 955 | static int ieee_hw_rate_init(struct ieee80211_hw *hw) |
| 956 | { |
| 957 | wl_info_t *wl = HW_TO_WL(hw); |
| 958 | int has_5g; |
| 959 | char phy_list[4]; |
| 960 | |
| 961 | has_5g = 0; |
| 962 | |
| 963 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL; |
| 964 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL; |
| 965 | |
| 966 | if (wlc_get(wl->wlc, WLC_GET_PHYLIST, (int *)&phy_list) < 0) { |
| 967 | WL_ERROR(("Phy list failed\n")); |
| 968 | } |
| 969 | WL_NONE(("%s: phylist = %c\n", __func__, phy_list[0])); |
| 970 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 971 | if (phy_list[0] == 'n' || phy_list[0] == 'c') { |
| 972 | if (phy_list[0] == 'c') { |
| 973 | /* Single stream */ |
| 974 | wl_band_2GHz_nphy.ht_cap.mcs.rx_mask[1] = 0; |
| 975 | wl_band_2GHz_nphy.ht_cap.mcs.rx_highest = 72; |
| 976 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 977 | hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl_band_2GHz_nphy; |
| 978 | } else { |
| 979 | BUG(); |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 980 | return -1; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | /* Assume all bands use the same phy. True for 11n devices. */ |
| 984 | if (NBANDS_PUB(wl->pub) > 1) { |
| 985 | has_5g++; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 986 | if (phy_list[0] == 'n' || phy_list[0] == 'c') { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 987 | hw->wiphy->bands[IEEE80211_BAND_5GHZ] = |
| 988 | &wl_band_5GHz_nphy; |
| 989 | } else { |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 990 | return -1; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 991 | } |
| 992 | } |
| 993 | |
| 994 | WL_NONE(("%s: 2ghz = %d, 5ghz = %d\n", __func__, 1, has_5g)); |
| 995 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 996 | return 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 997 | } |
| 998 | |
| 999 | static int ieee_hw_init(struct ieee80211_hw *hw) |
| 1000 | { |
| 1001 | hw->flags = IEEE80211_HW_SIGNAL_DBM |
| 1002 | /* | IEEE80211_HW_CONNECTION_MONITOR What is this? */ |
| 1003 | | IEEE80211_HW_REPORTS_TX_ACK_STATUS |
| 1004 | | IEEE80211_HW_AMPDU_AGGREGATION; |
| 1005 | |
| 1006 | hw->extra_tx_headroom = wlc_get_header_len(); |
| 1007 | /* FIXME: should get this from wlc->machwcap */ |
| 1008 | hw->queues = 4; |
| 1009 | /* FIXME: this doesn't seem to be used properly in minstrel_ht. |
| 1010 | * mac80211/status.c:ieee80211_tx_status() checks this value, |
| 1011 | * but mac80211/rc80211_minstrel_ht.c:minstrel_ht_get_rate() |
| 1012 | * appears to always set 3 rates |
| 1013 | */ |
| 1014 | hw->max_rates = 2; /* Primary rate and 1 fallback rate */ |
| 1015 | |
| 1016 | hw->channel_change_time = 7 * 1000; /* channel change time is dependant on chip and band */ |
| 1017 | hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); |
| 1018 | |
| 1019 | hw->rate_control_algorithm = "minstrel_ht"; |
| 1020 | |
| 1021 | hw->sta_data_size = sizeof(struct scb); |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1022 | return ieee_hw_rate_init(hw); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1023 | } |
| 1024 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1025 | /** |
| 1026 | * determines if a device is a WL device, and if so, attaches it. |
| 1027 | * |
| 1028 | * This function determines if a device pointed to by pdev is a WL device, |
| 1029 | * and if so, performs a wl_attach() on it. |
| 1030 | * |
| 1031 | */ |
| 1032 | int __devinit |
| 1033 | wl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) |
| 1034 | { |
| 1035 | int rc; |
| 1036 | wl_info_t *wl; |
| 1037 | struct ieee80211_hw *hw; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1038 | u32 val; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1039 | |
| 1040 | ASSERT(pdev); |
| 1041 | |
| 1042 | WL_TRACE(("%s: bus %d slot %d func %d irq %d\n", __func__, |
| 1043 | pdev->bus->number, PCI_SLOT(pdev->devfn), |
| 1044 | PCI_FUNC(pdev->devfn), pdev->irq)); |
| 1045 | |
| 1046 | if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) || |
| 1047 | (((pdev->device & 0xff00) != 0x4300) && |
| 1048 | ((pdev->device & 0xff00) != 0x4700) && |
| 1049 | ((pdev->device < 43000) || (pdev->device > 43999)))) |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1050 | return -ENODEV; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1051 | |
| 1052 | rc = pci_enable_device(pdev); |
| 1053 | if (rc) { |
| 1054 | WL_ERROR(("%s: Cannot enable device %d-%d_%d\n", __func__, |
| 1055 | pdev->bus->number, PCI_SLOT(pdev->devfn), |
| 1056 | PCI_FUNC(pdev->devfn))); |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1057 | return -ENODEV; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1058 | } |
| 1059 | pci_set_master(pdev); |
| 1060 | |
| 1061 | pci_read_config_dword(pdev, 0x40, &val); |
| 1062 | if ((val & 0x0000ff00) != 0) |
| 1063 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); |
| 1064 | |
| 1065 | hw = ieee80211_alloc_hw(sizeof(wl_info_t), &wl_ops); |
| 1066 | if (!hw) { |
| 1067 | WL_ERROR(("%s: ieee80211_alloc_hw failed\n", __func__)); |
| 1068 | rc = -ENOMEM; |
| 1069 | goto err_1; |
| 1070 | } |
| 1071 | |
| 1072 | SET_IEEE80211_DEV(hw, &pdev->dev); |
| 1073 | |
| 1074 | pci_set_drvdata(pdev, hw); |
| 1075 | |
Brett Rudley | 9249ede | 2010-11-30 20:09:49 -0800 | [diff] [blame^] | 1076 | memset(hw->priv, 0, sizeof(*wl)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1077 | |
| 1078 | wl = wl_attach(pdev->vendor, pdev->device, pci_resource_start(pdev, 0), |
| 1079 | PCI_BUS, pdev, pdev->irq); |
| 1080 | |
Brett Rudley | 683b505 | 2010-09-28 11:34:44 -0700 | [diff] [blame] | 1081 | if (!wl) { |
| 1082 | WL_ERROR(("%s: %s: wl_attach failed!\n", |
| 1083 | KBUILD_MODNAME, __func__)); |
| 1084 | return -ENODEV; |
| 1085 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1086 | return 0; |
| 1087 | err_1: |
| 1088 | WL_ERROR(("%s: err_1: Major hoarkage\n", __func__)); |
| 1089 | return 0; |
| 1090 | } |
| 1091 | |
| 1092 | #ifdef LINUXSTA_PS |
Greg Kroah-Hartman | 878a667 | 2010-10-07 16:28:15 -0700 | [diff] [blame] | 1093 | static int wl_suspend(struct pci_dev *pdev, pm_message_t state) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1094 | { |
| 1095 | wl_info_t *wl; |
| 1096 | struct ieee80211_hw *hw; |
| 1097 | |
| 1098 | WL_TRACE(("wl: wl_suspend\n")); |
| 1099 | |
| 1100 | hw = pci_get_drvdata(pdev); |
| 1101 | wl = HW_TO_WL(hw); |
| 1102 | if (!wl) { |
| 1103 | WL_ERROR(("wl: wl_suspend: pci_get_drvdata failed\n")); |
| 1104 | return -ENODEV; |
| 1105 | } |
| 1106 | |
| 1107 | WL_LOCK(wl); |
| 1108 | wl_down(wl); |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 1109 | wl->pub->hw_up = false; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1110 | WL_UNLOCK(wl); |
Greg Kroah-Hartman | 8ba9cfd | 2010-10-07 16:23:24 -0700 | [diff] [blame] | 1111 | pci_save_state(pdev, wl->pci_psstate); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1112 | pci_disable_device(pdev); |
| 1113 | return pci_set_power_state(pdev, PCI_D3hot); |
| 1114 | } |
| 1115 | |
| 1116 | static int wl_resume(struct pci_dev *pdev) |
| 1117 | { |
| 1118 | wl_info_t *wl; |
| 1119 | struct ieee80211_hw *hw; |
| 1120 | int err = 0; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1121 | u32 val; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1122 | |
| 1123 | WL_TRACE(("wl: wl_resume\n")); |
| 1124 | hw = pci_get_drvdata(pdev); |
| 1125 | wl = HW_TO_WL(hw); |
| 1126 | if (!wl) { |
| 1127 | WL_ERROR(("wl: wl_resume: pci_get_drvdata failed\n")); |
| 1128 | return -ENODEV; |
| 1129 | } |
| 1130 | |
| 1131 | err = pci_set_power_state(pdev, PCI_D0); |
| 1132 | if (err) |
| 1133 | return err; |
| 1134 | |
Greg Kroah-Hartman | 8ba9cfd | 2010-10-07 16:23:24 -0700 | [diff] [blame] | 1135 | pci_restore_state(pdev, wl->pci_psstate); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1136 | |
| 1137 | err = pci_enable_device(pdev); |
| 1138 | if (err) |
| 1139 | return err; |
| 1140 | |
| 1141 | pci_set_master(pdev); |
| 1142 | |
| 1143 | pci_read_config_dword(pdev, 0x40, &val); |
| 1144 | if ((val & 0x0000ff00) != 0) |
| 1145 | pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); |
| 1146 | |
| 1147 | WL_LOCK(wl); |
| 1148 | err = wl_up(wl); |
| 1149 | WL_UNLOCK(wl); |
| 1150 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1151 | return err; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1152 | } |
| 1153 | #endif /* LINUXSTA_PS */ |
| 1154 | |
Brett Rudley | 6f0c5bc | 2010-09-29 17:11:11 -0700 | [diff] [blame] | 1155 | static void wl_remove(struct pci_dev *pdev) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1156 | { |
| 1157 | wl_info_t *wl; |
| 1158 | struct ieee80211_hw *hw; |
| 1159 | |
| 1160 | hw = pci_get_drvdata(pdev); |
| 1161 | wl = HW_TO_WL(hw); |
| 1162 | if (!wl) { |
| 1163 | WL_ERROR(("wl: wl_remove: pci_get_drvdata failed\n")); |
| 1164 | return; |
| 1165 | } |
| 1166 | if (!wlc_chipmatch(pdev->vendor, pdev->device)) { |
| 1167 | WL_ERROR(("wl: wl_remove: wlc_chipmatch failed\n")); |
| 1168 | return; |
| 1169 | } |
Brett Rudley | 683b505 | 2010-09-28 11:34:44 -0700 | [diff] [blame] | 1170 | if (wl->wlc) { |
| 1171 | ieee80211_unregister_hw(hw); |
| 1172 | WL_LOCK(wl); |
| 1173 | wl_down(wl); |
| 1174 | WL_UNLOCK(wl); |
| 1175 | WL_NONE(("%s: Down\n", __func__)); |
| 1176 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1177 | pci_disable_device(pdev); |
| 1178 | |
| 1179 | wl_free(wl); |
| 1180 | |
| 1181 | pci_set_drvdata(pdev, NULL); |
| 1182 | ieee80211_free_hw(hw); |
| 1183 | } |
| 1184 | |
| 1185 | static struct pci_driver wl_pci_driver = { |
Jason Cooper | 5fee254 | 2010-09-14 09:45:51 -0400 | [diff] [blame] | 1186 | .name = "brcm80211", |
| 1187 | .probe = wl_pci_probe, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1188 | #ifdef LINUXSTA_PS |
Jason Cooper | 5fee254 | 2010-09-14 09:45:51 -0400 | [diff] [blame] | 1189 | .suspend = wl_suspend, |
| 1190 | .resume = wl_resume, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1191 | #endif /* LINUXSTA_PS */ |
Jason Cooper | 5fee254 | 2010-09-14 09:45:51 -0400 | [diff] [blame] | 1192 | .remove = __devexit_p(wl_remove), |
| 1193 | .id_table = wl_id_table, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1194 | }; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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) |
Andy Shevchenko | 48c51a8 | 2010-09-15 12:47:18 +0300 | [diff] [blame] | 1213 | wl_msg_level = simple_strtoul(var, NULL, 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1214 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1215 | { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1216 | extern u32 phyhal_msg_level; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1217 | |
| 1218 | if (phymsglevel != 0xdeadbeef) |
| 1219 | phyhal_msg_level = phymsglevel; |
| 1220 | else { |
| 1221 | char *var = getvar(NULL, "phy_msglevel"); |
| 1222 | if (var) |
Andy Shevchenko | 48c51a8 | 2010-09-15 12:47:18 +0300 | [diff] [blame] | 1223 | phyhal_msg_level = simple_strtoul(var, NULL, 0); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1224 | } |
| 1225 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1226 | #endif /* BCMDBG */ |
| 1227 | |
Greg Kroah-Hartman | 8ba9cfd | 2010-10-07 16:23:24 -0700 | [diff] [blame] | 1228 | error = pci_register_driver(&wl_pci_driver); |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 1229 | if (!error) |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1230 | return 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1231 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1232 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1233 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1234 | return error; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1246 | pci_unregister_driver(&wl_pci_driver); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1247 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1260 | void wl_free(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1261 | { |
| 1262 | wl_timer_t *t, *next; |
Brett Rudley | e69284f | 2010-11-16 15:45:48 -0800 | [diff] [blame] | 1263 | struct osl_info *osh; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1264 | |
| 1265 | ASSERT(wl); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1266 | /* free ucode data */ |
| 1267 | if (wl->fw.fw_cnt) |
| 1268 | wl_ucode_data_free(); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1269 | if (wl->irq) |
| 1270 | free_irq(wl->irq, wl); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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) |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 1297 | kfree(t->name); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1298 | #endif |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 1299 | kfree(t); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1300 | } |
| 1301 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | */ |
Brett Rudley | fa7a1db | 2010-11-23 15:30:02 -0800 | [diff] [blame] | 1308 | if (wl->regsva && wl->bcm_bustype != SDIO_BUS && |
| 1309 | wl->bcm_bustype != JTAG_BUS) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1310 | iounmap((void *)wl->regsva); |
| 1311 | } |
| 1312 | wl->regsva = NULL; |
| 1313 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1314 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1315 | osl_detach(osh); |
| 1316 | } |
| 1317 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1318 | /* transmit a packet */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1319 | static int BCMFASTPATH wl_start(struct sk_buff *skb, wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1320 | { |
| 1321 | if (!wl) |
| 1322 | return -ENETDOWN; |
| 1323 | |
| 1324 | return wl_start_int(wl, WL_TO_HW(wl), skb); |
| 1325 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1326 | |
| 1327 | static int BCMFASTPATH |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1328 | wl_start_int(wl_info_t *wl, struct ieee80211_hw *hw, struct sk_buff *skb) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1329 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1330 | wlc_sendpkt_mac80211(wl->wlc, skb, hw); |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1331 | return NETDEV_TX_OK; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1332 | } |
| 1333 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1334 | void wl_txflowcontrol(wl_info_t *wl, struct wl_if *wlif, bool state, int prio) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1335 | { |
| 1336 | WL_ERROR(("Shouldn't be here %s\n", __func__)); |
| 1337 | } |
| 1338 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1339 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1340 | void wl_init(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1341 | { |
| 1342 | WL_TRACE(("wl%d: wl_init\n", wl->pub->unit)); |
| 1343 | |
| 1344 | wl_reset(wl); |
| 1345 | |
| 1346 | wlc_init(wl->wlc); |
| 1347 | } |
| 1348 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1349 | uint wl_reset(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1350 | { |
| 1351 | WL_TRACE(("wl%d: wl_reset\n", wl->pub->unit)); |
| 1352 | |
| 1353 | wlc_reset(wl->wlc); |
| 1354 | |
| 1355 | /* dpc will not be rescheduled */ |
| 1356 | wl->resched = 0; |
| 1357 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1358 | return 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1359 | } |
| 1360 | |
| 1361 | /* |
| 1362 | * These are interrupt on/off entry points. Disable interrupts |
| 1363 | * during interrupt state transition. |
| 1364 | */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1365 | void BCMFASTPATH wl_intrson(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1366 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1367 | unsigned long flags; |
| 1368 | |
| 1369 | INT_LOCK(wl, flags); |
| 1370 | wlc_intrson(wl->wlc); |
| 1371 | INT_UNLOCK(wl, flags); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1372 | } |
| 1373 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1374 | bool wl_alloc_dma_resources(wl_info_t *wl, uint addrwidth) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1375 | { |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 1376 | return true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1377 | } |
| 1378 | |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1379 | u32 BCMFASTPATH wl_intrsoff(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1380 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1381 | unsigned long flags; |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1382 | u32 status; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1383 | |
| 1384 | INT_LOCK(wl, flags); |
| 1385 | status = wlc_intrsoff(wl->wlc); |
| 1386 | INT_UNLOCK(wl, flags); |
| 1387 | return status; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1388 | } |
| 1389 | |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1390 | void wl_intrsrestore(wl_info_t *wl, u32 macintmask) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1391 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1392 | unsigned long flags; |
| 1393 | |
| 1394 | INT_LOCK(wl, flags); |
| 1395 | wlc_intrsrestore(wl->wlc, macintmask); |
| 1396 | INT_UNLOCK(wl, flags); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1397 | } |
| 1398 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1399 | int wl_up(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1400 | { |
| 1401 | int error = 0; |
| 1402 | |
| 1403 | if (wl->pub->up) |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1404 | return 0; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1405 | |
| 1406 | error = wlc_up(wl->wlc); |
| 1407 | |
Jason Cooper | 90ea229 | 2010-09-14 09:45:32 -0400 | [diff] [blame] | 1408 | return error; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1409 | } |
| 1410 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1411 | void wl_down(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1426 | |
| 1427 | WL_LOCK(wl); |
| 1428 | } |
| 1429 | |
| 1430 | irqreturn_t BCMFASTPATH wl_isr(int irq, void *dev_id) |
| 1431 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1432 | wl_info_t *wl; |
| 1433 | bool ours, wantdpc; |
| 1434 | unsigned long flags; |
| 1435 | |
| 1436 | wl = (wl_info_t *) dev_id; |
| 1437 | |
| 1438 | WL_ISRLOCK(wl, flags); |
| 1439 | |
| 1440 | /* call common first level interrupt handler */ |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 1441 | ours = wlc_isr(wl->wlc, &wantdpc); |
| 1442 | if (ours) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1443 | /* if more to do... */ |
| 1444 | if (wantdpc) { |
| 1445 | |
| 1446 | /* ...and call the second level interrupt handler */ |
| 1447 | /* schedule dpc */ |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 1448 | ASSERT(wl->resched == false); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1449 | tasklet_schedule(&wl->tasklet); |
| 1450 | } |
| 1451 | } |
| 1452 | |
| 1453 | WL_ISRUNLOCK(wl, flags); |
| 1454 | |
| 1455 | return IRQ_RETVAL(ours); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1456 | } |
| 1457 | |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 1458 | static void BCMFASTPATH wl_dpc(unsigned long data) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1459 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1460 | wl_info_t *wl; |
| 1461 | |
| 1462 | wl = (wl_info_t *) data; |
| 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 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 1476 | wl->resched = wlc_dpc(wl->wlc, true); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1493 | } |
| 1494 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1495 | static void wl_link_up(wl_info_t *wl, char *ifname) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1496 | { |
| 1497 | WL_ERROR(("wl%d: link up (%s)\n", wl->pub->unit, ifname)); |
| 1498 | } |
| 1499 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1500 | static void wl_link_down(wl_info_t *wl, char *ifname) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1501 | { |
| 1502 | WL_ERROR(("wl%d: link down (%s)\n", wl->pub->unit, ifname)); |
| 1503 | } |
| 1504 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1505 | void wl_event(wl_info_t *wl, char *ifname, wlc_event_t *e) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 1521 | static void wl_timer(unsigned long data) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1522 | { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1523 | _wl_timer((wl_timer_t *) data); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1524 | } |
| 1525 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1526 | static void _wl_timer(wl_timer_t *t) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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); |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 1535 | t->set = true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1536 | } else |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 1537 | t->set = false; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1538 | |
| 1539 | t->fn(t->arg); |
| 1540 | } |
| 1541 | |
| 1542 | atomic_dec(&t->wl->callbacks); |
| 1543 | |
| 1544 | WL_UNLOCK(t->wl); |
| 1545 | } |
| 1546 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1547 | wl_timer_t *wl_init_timer(wl_info_t *wl, void (*fn) (void *arg), void *arg, |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1548 | const char *name) |
| 1549 | { |
| 1550 | wl_timer_t *t; |
| 1551 | |
mike.rapoport@gmail.com | 5fcc1fc | 2010-10-13 00:09:10 +0200 | [diff] [blame] | 1552 | t = kmalloc(sizeof(wl_timer_t), GFP_ATOMIC); |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 1553 | if (!t) { |
mike.rapoport@gmail.com | 97e17d0 | 2010-10-13 00:09:09 +0200 | [diff] [blame] | 1554 | WL_ERROR(("wl%d: wl_init_timer: out of memory\n", wl->pub->unit)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1555 | return 0; |
| 1556 | } |
| 1557 | |
Brett Rudley | 9249ede | 2010-11-30 20:09:49 -0800 | [diff] [blame^] | 1558 | memset(t, 0, sizeof(wl_timer_t)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1559 | |
| 1560 | init_timer(&t->timer); |
Greg Kroah-Hartman | 3deea90 | 2010-10-05 11:15:47 -0700 | [diff] [blame] | 1561 | t->timer.data = (unsigned long) t; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 |
mike.rapoport@gmail.com | 5fcc1fc | 2010-10-13 00:09:10 +0200 | [diff] [blame] | 1570 | t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC); |
Jason Cooper | ca8c1e5 | 2010-09-14 09:45:33 -0400 | [diff] [blame] | 1571 | if (t->name) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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 | */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1581 | void wl_add_timer(wl_info_t *wl, wl_timer_t *t, uint ms, int periodic) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1582 | { |
| 1583 | #ifdef BCMDBG |
| 1584 | if (t->set) { |
| 1585 | WL_ERROR(("%s: Already set. Name: %s, per %d\n", |
| 1586 | __func__, t->name, periodic)); |
| 1587 | } |
| 1588 | #endif |
| 1589 | ASSERT(!t->set); |
| 1590 | |
| 1591 | t->ms = ms; |
| 1592 | t->periodic = (bool) periodic; |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 1593 | t->set = true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1594 | t->timer.expires = jiffies + ms * HZ / 1000; |
| 1595 | |
| 1596 | atomic_inc(&wl->callbacks); |
| 1597 | add_timer(&t->timer); |
| 1598 | } |
| 1599 | |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 1600 | /* return true if timer successfully deleted, false if still pending */ |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1601 | bool wl_del_timer(wl_info_t *wl, wl_timer_t *t) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1602 | { |
| 1603 | if (t->set) { |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 1604 | t->set = false; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1605 | if (!del_timer(&t->timer)) { |
Greg Kroah-Hartman | 0965ae8 | 2010-10-12 12:50:15 -0700 | [diff] [blame] | 1606 | return false; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1607 | } |
| 1608 | atomic_dec(&wl->callbacks); |
| 1609 | } |
| 1610 | |
Greg Kroah-Hartman | 0f0881b | 2010-10-12 12:15:18 -0700 | [diff] [blame] | 1611 | return true; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1612 | } |
| 1613 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1614 | void wl_free_timer(wl_info_t *wl, wl_timer_t *t) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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) |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 1625 | kfree(t->name); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1626 | #endif |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 1627 | kfree(t); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 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) |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 1638 | kfree(t->name); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1639 | #endif |
mike.rapoport@gmail.com | 182acb3 | 2010-10-13 00:09:12 +0200 | [diff] [blame] | 1640 | kfree(t); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1641 | return; |
| 1642 | } |
| 1643 | tmp = tmp->next; |
| 1644 | } |
| 1645 | |
| 1646 | } |
| 1647 | |
| 1648 | static int wl_linux_watchdog(void *ctx) |
| 1649 | { |
| 1650 | wl_info_t *wl = (wl_info_t *) ctx; |
| 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 { |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1685 | u32 offset; |
| 1686 | u32 len; |
| 1687 | u32 idx; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1688 | }; |
| 1689 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1690 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1691 | char *wl_firmwares[WL_MAX_FW] = { |
| 1692 | "brcm/bcm43xx", |
| 1693 | NULL |
| 1694 | }; |
| 1695 | |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1696 | int wl_ucode_init_buf(wl_info_t *wl, void **pbuf, u32 idx) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1697 | { |
| 1698 | int i, entry; |
Greg Kroah-Hartman | 41feb5e | 2010-10-05 10:09:00 -0700 | [diff] [blame] | 1699 | const u8 *pdata; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1700 | struct wl_fw_hdr *hdr; |
| 1701 | for (i = 0; i < wl->fw.fw_cnt; i++) { |
| 1702 | hdr = (struct wl_fw_hdr *)wl->fw.fw_hdr[i]->data; |
| 1703 | for (entry = 0; entry < wl->fw.hdr_num_entries[i]; |
| 1704 | entry++, hdr++) { |
| 1705 | if (hdr->idx == idx) { |
| 1706 | pdata = wl->fw.fw_bin[i]->data + hdr->offset; |
| 1707 | *pbuf = kmalloc(hdr->len, GFP_ATOMIC); |
| 1708 | if (*pbuf == NULL) { |
| 1709 | printf("fail to alloc %d bytes\n", |
| 1710 | hdr->len); |
| 1711 | } |
| 1712 | bcopy(pdata, *pbuf, hdr->len); |
| 1713 | return 0; |
| 1714 | } |
| 1715 | } |
| 1716 | } |
| 1717 | printf("ERROR: ucode buf tag:%d can not be found!\n", idx); |
| 1718 | *pbuf = NULL; |
| 1719 | return -1; |
| 1720 | } |
| 1721 | |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1722 | int wl_ucode_init_uint(wl_info_t *wl, u32 *data, u32 idx) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1723 | { |
| 1724 | int i, entry; |
Greg Kroah-Hartman | 41feb5e | 2010-10-05 10:09:00 -0700 | [diff] [blame] | 1725 | const u8 *pdata; |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1726 | struct wl_fw_hdr *hdr; |
| 1727 | for (i = 0; i < wl->fw.fw_cnt; i++) { |
| 1728 | hdr = (struct wl_fw_hdr *)wl->fw.fw_hdr[i]->data; |
| 1729 | for (entry = 0; entry < wl->fw.hdr_num_entries[i]; |
| 1730 | entry++, hdr++) { |
| 1731 | if (hdr->idx == idx) { |
| 1732 | pdata = wl->fw.fw_bin[i]->data + hdr->offset; |
| 1733 | ASSERT(hdr->len == 4); |
Greg Kroah-Hartman | 66cbd3a | 2010-10-08 11:05:47 -0700 | [diff] [blame] | 1734 | *data = *((u32 *) pdata); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1735 | return 0; |
| 1736 | } |
| 1737 | } |
| 1738 | } |
| 1739 | printf("ERROR: ucode tag:%d can not be found!\n", idx); |
| 1740 | return -1; |
| 1741 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1742 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1743 | static int wl_request_fw(wl_info_t *wl, struct pci_dev *pdev) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1744 | { |
| 1745 | int status; |
| 1746 | struct device *device = &pdev->dev; |
| 1747 | char fw_name[100]; |
| 1748 | int i; |
| 1749 | |
Brett Rudley | 9249ede | 2010-11-30 20:09:49 -0800 | [diff] [blame^] | 1750 | memset((void *)&wl->fw, 0, sizeof(struct wl_firmware)); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1751 | for (i = 0; i < WL_MAX_FW; i++) { |
| 1752 | if (wl_firmwares[i] == NULL) |
| 1753 | break; |
| 1754 | sprintf(fw_name, "%s-%d.fw", wl_firmwares[i], |
| 1755 | UCODE_LOADER_API_VER); |
| 1756 | WL_NONE(("request fw %s\n", fw_name)); |
| 1757 | status = request_firmware(&wl->fw.fw_bin[i], fw_name, device); |
| 1758 | if (status) { |
Brett Rudley | 683b505 | 2010-09-28 11:34:44 -0700 | [diff] [blame] | 1759 | printf("%s: fail to load firmware %s\n", |
| 1760 | KBUILD_MODNAME, fw_name); |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 1761 | wl_release_fw(wl); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1762 | return status; |
| 1763 | } |
| 1764 | WL_NONE(("request fw %s\n", fw_name)); |
| 1765 | sprintf(fw_name, "%s_hdr-%d.fw", wl_firmwares[i], |
| 1766 | UCODE_LOADER_API_VER); |
| 1767 | status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device); |
| 1768 | if (status) { |
Brett Rudley | 683b505 | 2010-09-28 11:34:44 -0700 | [diff] [blame] | 1769 | printf("%s: fail to load firmware %s\n", |
| 1770 | KBUILD_MODNAME, fw_name); |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 1771 | wl_release_fw(wl); |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1772 | return status; |
| 1773 | } |
| 1774 | wl->fw.hdr_num_entries[i] = |
| 1775 | wl->fw.fw_hdr[i]->size / (sizeof(struct wl_fw_hdr)); |
| 1776 | WL_NONE(("request fw %s find: %d entries\n", fw_name, |
| 1777 | wl->fw.hdr_num_entries[i])); |
| 1778 | } |
| 1779 | wl->fw.fw_cnt = i; |
| 1780 | wl_ucode_data_init(wl); |
| 1781 | return 0; |
| 1782 | } |
| 1783 | |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1784 | void wl_ucode_free_buf(void *p) |
| 1785 | { |
| 1786 | kfree(p); |
| 1787 | } |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1788 | |
Jason Cooper | 7cc4a4c | 2010-09-14 09:45:30 -0400 | [diff] [blame] | 1789 | static void wl_release_fw(wl_info_t *wl) |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1790 | { |
| 1791 | int i; |
Ben Hutchings | eb4764c | 2010-09-10 01:38:18 +0100 | [diff] [blame] | 1792 | for (i = 0; i < WL_MAX_FW; i++) { |
Henry Ptasinski | a9533e7 | 2010-09-08 21:04:42 -0700 | [diff] [blame] | 1793 | release_firmware(wl->fw.fw_bin[i]); |
| 1794 | release_firmware(wl->fw.fw_hdr[i]); |
| 1795 | } |
| 1796 | } |