2 * Copyright (c) 2010 Broadcom Corporation
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.
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.
17 #define __UNDEF_NO_VERSION__
18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/etherdevice.h>
21 #include <linux/sched.h>
22 #include <linux/firmware.h>
23 #include <linux/interrupt.h>
24 #include <linux/module.h>
25 #include <linux/bcma/bcma.h>
26 #include <net/mac80211.h>
28 #include "phy/phy_int.h"
33 #include "ucode_loader.h"
34 #include "mac80211_if.h"
37 #define N_TX_QUEUES 4 /* #tx queues on mac80211<->driver interface */
39 /* Flags we support */
40 #define MAC_FILTERS (FIF_PROMISC_IN_BSS | \
45 FIF_BCN_PRBRESP_PROMISC | \
48 #define CHAN2GHZ(channel, freqency, chflags) { \
49 .band = IEEE80211_BAND_2GHZ, \
50 .center_freq = (freqency), \
51 .hw_value = (channel), \
53 .max_antenna_gain = 0, \
57 #define CHAN5GHZ(channel, chflags) { \
58 .band = IEEE80211_BAND_5GHZ, \
59 .center_freq = 5000 + 5*(channel), \
60 .hw_value = (channel), \
62 .max_antenna_gain = 0, \
66 #define RATE(rate100m, _flags) { \
67 .bitrate = (rate100m), \
69 .hw_value = (rate100m / 5), \
78 static const char * const brcms_firmwares[MAX_FW_IMAGES] = {
83 static int n_adapters_found;
85 MODULE_AUTHOR("Broadcom Corporation");
86 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver.");
87 MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
88 MODULE_LICENSE("Dual BSD/GPL");
89 /* This needs to be adjusted when brcms_firmwares changes */
90 MODULE_FIRMWARE("brcm/bcm43xx-0.fw");
91 MODULE_FIRMWARE("brcm/bcm43xx_hdr-0.fw");
93 /* recognized BCMA Core IDs */
94 static struct bcma_device_id brcms_coreid_table[] = {
95 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 23, BCMA_ANY_CLASS),
96 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211, 24, BCMA_ANY_CLASS),
99 MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
102 static int msglevel = 0xdeadbeef;
103 module_param(msglevel, int, 0);
106 static struct ieee80211_channel brcms_2ghz_chantable[] = {
107 CHAN2GHZ(1, 2412, IEEE80211_CHAN_NO_HT40MINUS),
108 CHAN2GHZ(2, 2417, IEEE80211_CHAN_NO_HT40MINUS),
109 CHAN2GHZ(3, 2422, IEEE80211_CHAN_NO_HT40MINUS),
110 CHAN2GHZ(4, 2427, IEEE80211_CHAN_NO_HT40MINUS),
111 CHAN2GHZ(5, 2432, 0),
112 CHAN2GHZ(6, 2437, 0),
113 CHAN2GHZ(7, 2442, 0),
114 CHAN2GHZ(8, 2447, IEEE80211_CHAN_NO_HT40PLUS),
115 CHAN2GHZ(9, 2452, IEEE80211_CHAN_NO_HT40PLUS),
116 CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS),
117 CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS),
119 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
120 IEEE80211_CHAN_NO_HT40PLUS),
122 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
123 IEEE80211_CHAN_NO_HT40PLUS),
125 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
126 IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS |
127 IEEE80211_CHAN_NO_OFDM)
130 static struct ieee80211_channel brcms_5ghz_nphy_chantable[] = {
132 CHAN5GHZ(36, IEEE80211_CHAN_NO_HT40MINUS),
133 CHAN5GHZ(40, IEEE80211_CHAN_NO_HT40PLUS),
134 CHAN5GHZ(44, IEEE80211_CHAN_NO_HT40MINUS),
135 CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS),
138 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
139 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
141 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
142 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
144 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
145 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
147 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
148 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
151 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
152 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
154 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
155 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
157 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
158 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
160 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
161 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
163 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
164 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
166 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
167 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
169 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
170 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
172 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
173 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
175 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
176 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
178 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
179 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
181 IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
182 IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS |
183 IEEE80211_CHAN_NO_HT40MINUS),
185 CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS),
186 CHAN5GHZ(153, IEEE80211_CHAN_NO_HT40PLUS),
187 CHAN5GHZ(157, IEEE80211_CHAN_NO_HT40MINUS),
188 CHAN5GHZ(161, IEEE80211_CHAN_NO_HT40PLUS),
189 CHAN5GHZ(165, IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS)
193 * The rate table is used for both 2.4G and 5G rates. The
194 * latter being a subset as it does not support CCK rates.
196 static struct ieee80211_rate legacy_ratetable[] = {
198 RATE(20, IEEE80211_RATE_SHORT_PREAMBLE),
199 RATE(55, IEEE80211_RATE_SHORT_PREAMBLE),
200 RATE(110, IEEE80211_RATE_SHORT_PREAMBLE),
211 static const struct ieee80211_supported_band brcms_band_2GHz_nphy_template = {
212 .band = IEEE80211_BAND_2GHZ,
213 .channels = brcms_2ghz_chantable,
214 .n_channels = ARRAY_SIZE(brcms_2ghz_chantable),
215 .bitrates = legacy_ratetable,
216 .n_bitrates = ARRAY_SIZE(legacy_ratetable),
218 /* from include/linux/ieee80211.h */
219 .cap = IEEE80211_HT_CAP_GRN_FLD |
220 IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40,
221 .ht_supported = true,
222 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
223 .ampdu_density = AMPDU_DEF_MPDU_DENSITY,
225 /* placeholders for now */
226 .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
227 .rx_highest = cpu_to_le16(500),
228 .tx_params = IEEE80211_HT_MCS_TX_DEFINED}
232 static const struct ieee80211_supported_band brcms_band_5GHz_nphy_template = {
233 .band = IEEE80211_BAND_5GHZ,
234 .channels = brcms_5ghz_nphy_chantable,
235 .n_channels = ARRAY_SIZE(brcms_5ghz_nphy_chantable),
236 .bitrates = legacy_ratetable + BRCMS_LEGACY_5G_RATE_OFFSET,
237 .n_bitrates = ARRAY_SIZE(legacy_ratetable) -
238 BRCMS_LEGACY_5G_RATE_OFFSET,
240 .cap = IEEE80211_HT_CAP_GRN_FLD | IEEE80211_HT_CAP_SGI_20 |
241 IEEE80211_HT_CAP_SGI_40,
242 .ht_supported = true,
243 .ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K,
244 .ampdu_density = AMPDU_DEF_MPDU_DENSITY,
246 /* placeholders for now */
247 .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
248 .rx_highest = cpu_to_le16(500),
249 .tx_params = IEEE80211_HT_MCS_TX_DEFINED}
253 /* flags the given rate in rateset as requested */
254 static void brcms_set_basic_rate(struct brcm_rateset *rs, u16 rate, bool is_br)
258 for (i = 0; i < rs->count; i++) {
259 if (rate != (rs->rates[i] & 0x7f))
263 rs->rates[i] |= BRCMS_RATE_FLAG;
265 rs->rates[i] &= BRCMS_RATE_MASK;
270 static void brcms_ops_tx(struct ieee80211_hw *hw,
271 struct ieee80211_tx_control *control,
274 struct brcms_info *wl = hw->priv;
275 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
277 spin_lock_bh(&wl->lock);
279 wiphy_err(wl->wiphy, "ops->tx called while down\n");
283 brcms_c_sendpkt_mac80211(wl->wlc, skb, hw);
284 tx_info->rate_driver_data[0] = control->sta;
286 spin_unlock_bh(&wl->lock);
289 static int brcms_ops_start(struct ieee80211_hw *hw)
291 struct brcms_info *wl = hw->priv;
295 ieee80211_wake_queues(hw);
296 spin_lock_bh(&wl->lock);
297 blocked = brcms_rfkill_set_hw_state(wl);
298 spin_unlock_bh(&wl->lock);
300 wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
302 spin_lock_bh(&wl->lock);
303 /* avoid acknowledging frames before a non-monitor device is added */
313 spin_unlock_bh(&wl->lock);
316 wiphy_err(hw->wiphy, "%s: brcms_up() returned %d\n", __func__,
321 static void brcms_ops_stop(struct ieee80211_hw *hw)
323 struct brcms_info *wl = hw->priv;
326 ieee80211_stop_queues(hw);
331 spin_lock_bh(&wl->lock);
332 status = brcms_c_chipmatch(wl->wlc->hw->d11core);
333 spin_unlock_bh(&wl->lock);
336 "wl: brcms_ops_stop: chipmatch failed\n");
340 /* put driver in down state */
341 spin_lock_bh(&wl->lock);
343 spin_unlock_bh(&wl->lock);
347 brcms_ops_add_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
349 struct brcms_info *wl = hw->priv;
351 /* Just STA for now */
352 if (vif->type != NL80211_IFTYPE_STATION) {
353 wiphy_err(hw->wiphy, "%s: Attempt to add type %d, only"
354 " STA for now\n", __func__, vif->type);
359 brcms_c_mute(wl->wlc, false);
365 brcms_ops_remove_interface(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
369 static int brcms_ops_config(struct ieee80211_hw *hw, u32 changed)
371 struct ieee80211_conf *conf = &hw->conf;
372 struct brcms_info *wl = hw->priv;
375 struct wiphy *wiphy = hw->wiphy;
377 spin_lock_bh(&wl->lock);
378 if (changed & IEEE80211_CONF_CHANGE_LISTEN_INTERVAL) {
379 brcms_c_set_beacon_listen_interval(wl->wlc,
380 conf->listen_interval);
382 if (changed & IEEE80211_CONF_CHANGE_MONITOR)
383 wiphy_dbg(wiphy, "%s: change monitor mode: %s\n",
384 __func__, conf->flags & IEEE80211_CONF_MONITOR ?
386 if (changed & IEEE80211_CONF_CHANGE_PS)
387 wiphy_err(wiphy, "%s: change power-save mode: %s (implement)\n",
388 __func__, conf->flags & IEEE80211_CONF_PS ?
391 if (changed & IEEE80211_CONF_CHANGE_POWER) {
392 err = brcms_c_set_tx_power(wl->wlc, conf->power_level);
394 wiphy_err(wiphy, "%s: Error setting power_level\n",
398 new_int = brcms_c_get_tx_power(wl->wlc);
399 if (new_int != conf->power_level)
400 wiphy_err(wiphy, "%s: Power level req != actual, %d %d"
401 "\n", __func__, conf->power_level,
404 if (changed & IEEE80211_CONF_CHANGE_CHANNEL) {
405 if (conf->channel_type == NL80211_CHAN_HT20 ||
406 conf->channel_type == NL80211_CHAN_NO_HT)
407 err = brcms_c_set_channel(wl->wlc,
408 conf->channel->hw_value);
412 if (changed & IEEE80211_CONF_CHANGE_RETRY_LIMITS)
413 err = brcms_c_set_rate_limit(wl->wlc,
414 conf->short_frame_max_tx_count,
415 conf->long_frame_max_tx_count);
418 spin_unlock_bh(&wl->lock);
423 brcms_ops_bss_info_changed(struct ieee80211_hw *hw,
424 struct ieee80211_vif *vif,
425 struct ieee80211_bss_conf *info, u32 changed)
427 struct brcms_info *wl = hw->priv;
428 struct wiphy *wiphy = hw->wiphy;
430 if (changed & BSS_CHANGED_ASSOC) {
431 /* association status changed (associated/disassociated)
432 * also implies a change in the AID.
434 wiphy_err(wiphy, "%s: %s: %sassociated\n", KBUILD_MODNAME,
435 __func__, info->assoc ? "" : "dis");
436 spin_lock_bh(&wl->lock);
437 brcms_c_associate_upd(wl->wlc, info->assoc);
438 spin_unlock_bh(&wl->lock);
440 if (changed & BSS_CHANGED_ERP_SLOT) {
443 /* slot timing changed */
444 if (info->use_short_slot)
448 spin_lock_bh(&wl->lock);
449 brcms_c_set_shortslot_override(wl->wlc, val);
450 spin_unlock_bh(&wl->lock);
453 if (changed & BSS_CHANGED_HT) {
454 /* 802.11n parameters changed */
455 u16 mode = info->ht_operation_mode;
457 spin_lock_bh(&wl->lock);
458 brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_CFG,
459 mode & IEEE80211_HT_OP_MODE_PROTECTION);
460 brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_NONGF,
461 mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT);
462 brcms_c_protection_upd(wl->wlc, BRCMS_PROT_N_OBSS,
463 mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT);
464 spin_unlock_bh(&wl->lock);
466 if (changed & BSS_CHANGED_BASIC_RATES) {
467 struct ieee80211_supported_band *bi;
470 struct brcm_rateset rs;
473 /* retrieve the current rates */
474 spin_lock_bh(&wl->lock);
475 brcms_c_get_current_rateset(wl->wlc, &rs);
476 spin_unlock_bh(&wl->lock);
478 br_mask = info->basic_rates;
479 bi = hw->wiphy->bands[brcms_c_get_curband(wl->wlc)];
480 for (i = 0; i < bi->n_bitrates; i++) {
481 /* convert to internal rate value */
482 rate = (bi->bitrates[i].bitrate << 1) / 10;
484 /* set/clear basic rate flag */
485 brcms_set_basic_rate(&rs, rate, br_mask & 1);
489 /* update the rate set */
490 spin_lock_bh(&wl->lock);
491 error = brcms_c_set_rateset(wl->wlc, &rs);
492 spin_unlock_bh(&wl->lock);
494 wiphy_err(wiphy, "changing basic rates failed: %d\n",
497 if (changed & BSS_CHANGED_BEACON_INT) {
498 /* Beacon interval changed */
499 spin_lock_bh(&wl->lock);
500 brcms_c_set_beacon_period(wl->wlc, info->beacon_int);
501 spin_unlock_bh(&wl->lock);
503 if (changed & BSS_CHANGED_BSSID) {
504 /* BSSID changed, for whatever reason (IBSS and managed mode) */
505 spin_lock_bh(&wl->lock);
506 brcms_c_set_addrmatch(wl->wlc, RCM_BSSID_OFFSET, info->bssid);
507 spin_unlock_bh(&wl->lock);
509 if (changed & BSS_CHANGED_BEACON)
510 /* Beacon data changed, retrieve new beacon (beaconing modes) */
511 wiphy_err(wiphy, "%s: beacon changed\n", __func__);
513 if (changed & BSS_CHANGED_BEACON_ENABLED) {
514 /* Beaconing should be enabled/disabled (beaconing modes) */
515 wiphy_err(wiphy, "%s: Beacon enabled: %s\n", __func__,
516 info->enable_beacon ? "true" : "false");
519 if (changed & BSS_CHANGED_CQM) {
520 /* Connection quality monitor config changed */
521 wiphy_err(wiphy, "%s: cqm change: threshold %d, hys %d "
522 " (implement)\n", __func__, info->cqm_rssi_thold,
523 info->cqm_rssi_hyst);
526 if (changed & BSS_CHANGED_IBSS) {
527 /* IBSS join status changed */
528 wiphy_err(wiphy, "%s: IBSS joined: %s (implement)\n", __func__,
529 info->ibss_joined ? "true" : "false");
532 if (changed & BSS_CHANGED_ARP_FILTER) {
533 /* Hardware ARP filter address list or state changed */
534 wiphy_err(wiphy, "%s: arp filtering: enabled %s, count %d"
535 " (implement)\n", __func__, info->arp_filter_enabled ?
536 "true" : "false", info->arp_addr_cnt);
539 if (changed & BSS_CHANGED_QOS) {
541 * QoS for this association was enabled/disabled.
542 * Note that it is only ever disabled for station mode.
544 wiphy_err(wiphy, "%s: qos enabled: %s (implement)\n", __func__,
545 info->qos ? "true" : "false");
551 brcms_ops_configure_filter(struct ieee80211_hw *hw,
552 unsigned int changed_flags,
553 unsigned int *total_flags, u64 multicast)
555 struct brcms_info *wl = hw->priv;
556 struct wiphy *wiphy = hw->wiphy;
558 changed_flags &= MAC_FILTERS;
559 *total_flags &= MAC_FILTERS;
561 if (changed_flags & FIF_PROMISC_IN_BSS)
562 wiphy_dbg(wiphy, "FIF_PROMISC_IN_BSS\n");
563 if (changed_flags & FIF_ALLMULTI)
564 wiphy_dbg(wiphy, "FIF_ALLMULTI\n");
565 if (changed_flags & FIF_FCSFAIL)
566 wiphy_dbg(wiphy, "FIF_FCSFAIL\n");
567 if (changed_flags & FIF_CONTROL)
568 wiphy_dbg(wiphy, "FIF_CONTROL\n");
569 if (changed_flags & FIF_OTHER_BSS)
570 wiphy_dbg(wiphy, "FIF_OTHER_BSS\n");
571 if (changed_flags & FIF_PSPOLL)
572 wiphy_dbg(wiphy, "FIF_PSPOLL\n");
573 if (changed_flags & FIF_BCN_PRBRESP_PROMISC)
574 wiphy_dbg(wiphy, "FIF_BCN_PRBRESP_PROMISC\n");
576 spin_lock_bh(&wl->lock);
577 brcms_c_mac_promisc(wl->wlc, *total_flags);
578 spin_unlock_bh(&wl->lock);
582 static void brcms_ops_sw_scan_start(struct ieee80211_hw *hw)
584 struct brcms_info *wl = hw->priv;
585 spin_lock_bh(&wl->lock);
586 brcms_c_scan_start(wl->wlc);
587 spin_unlock_bh(&wl->lock);
591 static void brcms_ops_sw_scan_complete(struct ieee80211_hw *hw)
593 struct brcms_info *wl = hw->priv;
594 spin_lock_bh(&wl->lock);
595 brcms_c_scan_stop(wl->wlc);
596 spin_unlock_bh(&wl->lock);
601 brcms_ops_conf_tx(struct ieee80211_hw *hw, struct ieee80211_vif *vif, u16 queue,
602 const struct ieee80211_tx_queue_params *params)
604 struct brcms_info *wl = hw->priv;
606 spin_lock_bh(&wl->lock);
607 brcms_c_wme_setparams(wl->wlc, queue, params, true);
608 spin_unlock_bh(&wl->lock);
614 brcms_ops_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
615 struct ieee80211_sta *sta)
617 struct brcms_info *wl = hw->priv;
618 struct scb *scb = &wl->wlc->pri_scb;
620 brcms_c_init_scb(scb);
622 wl->pub->global_ampdu = &(scb->scb_ampdu);
623 wl->pub->global_ampdu->scb = scb;
624 wl->pub->global_ampdu->max_pdu = 16;
627 * minstrel_ht initiates addBA on our behalf by calling
628 * ieee80211_start_tx_ba_session()
634 brcms_ops_ampdu_action(struct ieee80211_hw *hw,
635 struct ieee80211_vif *vif,
636 enum ieee80211_ampdu_mlme_action action,
637 struct ieee80211_sta *sta, u16 tid, u16 *ssn,
640 struct brcms_info *wl = hw->priv;
641 struct scb *scb = &wl->wlc->pri_scb;
644 if (WARN_ON(scb->magic != SCB_MAGIC))
647 case IEEE80211_AMPDU_RX_START:
649 case IEEE80211_AMPDU_RX_STOP:
651 case IEEE80211_AMPDU_TX_START:
652 spin_lock_bh(&wl->lock);
653 status = brcms_c_aggregatable(wl->wlc, tid);
654 spin_unlock_bh(&wl->lock);
656 wiphy_err(wl->wiphy, "START: tid %d is not agg\'able\n",
660 ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
663 case IEEE80211_AMPDU_TX_STOP:
664 spin_lock_bh(&wl->lock);
665 brcms_c_ampdu_flush(wl->wlc, sta, tid);
666 spin_unlock_bh(&wl->lock);
667 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
669 case IEEE80211_AMPDU_TX_OPERATIONAL:
671 * BA window size from ADDBA response ('buf_size') defines how
672 * many outstanding MPDUs are allowed for the BA stream by
673 * recipient and traffic class. 'ampdu_factor' gives maximum
676 spin_lock_bh(&wl->lock);
677 brcms_c_ampdu_tx_operational(wl->wlc, tid, buf_size,
678 (1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
679 sta->ht_cap.ampdu_factor)) - 1);
680 spin_unlock_bh(&wl->lock);
681 /* Power save wakeup */
684 wiphy_err(wl->wiphy, "%s: Invalid command, ignoring\n",
691 static void brcms_ops_rfkill_poll(struct ieee80211_hw *hw)
693 struct brcms_info *wl = hw->priv;
696 spin_lock_bh(&wl->lock);
697 blocked = brcms_c_check_radio_disabled(wl->wlc);
698 spin_unlock_bh(&wl->lock);
700 wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
703 static void brcms_ops_flush(struct ieee80211_hw *hw, bool drop)
705 struct brcms_info *wl = hw->priv;
707 no_printk("%s: drop = %s\n", __func__, drop ? "true" : "false");
709 /* wait for packet queue and dma fifos to run empty */
710 spin_lock_bh(&wl->lock);
711 brcms_c_wait_for_tx_completion(wl->wlc, drop);
712 spin_unlock_bh(&wl->lock);
715 static const struct ieee80211_ops brcms_ops = {
717 .start = brcms_ops_start,
718 .stop = brcms_ops_stop,
719 .add_interface = brcms_ops_add_interface,
720 .remove_interface = brcms_ops_remove_interface,
721 .config = brcms_ops_config,
722 .bss_info_changed = brcms_ops_bss_info_changed,
723 .configure_filter = brcms_ops_configure_filter,
724 .sw_scan_start = brcms_ops_sw_scan_start,
725 .sw_scan_complete = brcms_ops_sw_scan_complete,
726 .conf_tx = brcms_ops_conf_tx,
727 .sta_add = brcms_ops_sta_add,
728 .ampdu_action = brcms_ops_ampdu_action,
729 .rfkill_poll = brcms_ops_rfkill_poll,
730 .flush = brcms_ops_flush,
733 void brcms_dpc(unsigned long data)
735 struct brcms_info *wl;
737 wl = (struct brcms_info *) data;
739 spin_lock_bh(&wl->lock);
741 /* call the common second level interrupt handler */
746 spin_lock_irqsave(&wl->isr_lock, flags);
747 brcms_c_intrsupd(wl->wlc);
748 spin_unlock_irqrestore(&wl->isr_lock, flags);
751 wl->resched = brcms_c_dpc(wl->wlc, true);
754 /* brcms_c_dpc() may bring the driver down */
758 /* re-schedule dpc */
760 tasklet_schedule(&wl->tasklet);
762 /* re-enable interrupts */
766 spin_unlock_bh(&wl->lock);
770 * Precondition: Since this function is called in brcms_pci_probe() context,
771 * no locking is required.
773 static int brcms_request_fw(struct brcms_info *wl, struct bcma_device *pdev)
776 struct device *device = &pdev->dev;
780 memset(&wl->fw, 0, sizeof(struct brcms_firmware));
781 for (i = 0; i < MAX_FW_IMAGES; i++) {
782 if (brcms_firmwares[i] == NULL)
784 sprintf(fw_name, "%s-%d.fw", brcms_firmwares[i],
785 UCODE_LOADER_API_VER);
786 status = request_firmware(&wl->fw.fw_bin[i], fw_name, device);
788 wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n",
789 KBUILD_MODNAME, fw_name);
792 sprintf(fw_name, "%s_hdr-%d.fw", brcms_firmwares[i],
793 UCODE_LOADER_API_VER);
794 status = request_firmware(&wl->fw.fw_hdr[i], fw_name, device);
796 wiphy_err(wl->wiphy, "%s: fail to load firmware %s\n",
797 KBUILD_MODNAME, fw_name);
800 wl->fw.hdr_num_entries[i] =
801 wl->fw.fw_hdr[i]->size / (sizeof(struct firmware_hdr));
804 return brcms_ucode_data_init(wl, &wl->ucode);
808 * Precondition: Since this function is called in brcms_pci_probe() context,
809 * no locking is required.
811 static void brcms_release_fw(struct brcms_info *wl)
814 for (i = 0; i < MAX_FW_IMAGES; i++) {
815 release_firmware(wl->fw.fw_bin[i]);
816 release_firmware(wl->fw.fw_hdr[i]);
821 * This function frees the WL per-device resources.
823 * This function frees resources owned by the WL device pointed to
824 * by the wl parameter.
826 * precondition: can both be called locked and unlocked
829 static void brcms_free(struct brcms_info *wl)
831 struct brcms_timer *t, *next;
833 /* free ucode data */
835 brcms_ucode_data_free(&wl->ucode);
837 free_irq(wl->irq, wl);
840 tasklet_kill(&wl->tasklet);
843 brcms_c_module_unregister(wl->pub, "linux", wl);
845 /* free common resources */
847 brcms_c_detach(wl->wlc);
852 /* virtual interface deletion is deferred so we cannot spinwait */
854 /* wait for all pending callbacks to complete */
855 while (atomic_read(&wl->callbacks) > 0)
859 for (t = wl->timers; t; t = next) {
869 * called from both kernel as from this kernel module (error flow on attach)
870 * precondition: perimeter lock is not acquired.
872 static void brcms_remove(struct bcma_device *pdev)
874 struct ieee80211_hw *hw = bcma_get_drvdata(pdev);
875 struct brcms_info *wl = hw->priv;
878 wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, false);
879 wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
880 ieee80211_unregister_hw(hw);
885 bcma_set_drvdata(pdev, NULL);
886 ieee80211_free_hw(hw);
889 static irqreturn_t brcms_isr(int irq, void *dev_id)
891 struct brcms_info *wl;
894 wl = (struct brcms_info *) dev_id;
896 spin_lock(&wl->isr_lock);
898 /* call common first level interrupt handler */
899 ours = brcms_c_isr(wl->wlc, &wantdpc);
901 /* if more to do... */
904 /* ...and call the second level interrupt handler */
906 tasklet_schedule(&wl->tasklet);
910 spin_unlock(&wl->isr_lock);
912 return IRQ_RETVAL(ours);
916 * is called in brcms_pci_probe() context, therefore no locking required.
918 static int ieee_hw_rate_init(struct ieee80211_hw *hw)
920 struct brcms_info *wl = hw->priv;
921 struct brcms_c_info *wlc = wl->wlc;
922 struct ieee80211_supported_band *band;
926 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = NULL;
927 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = NULL;
929 phy_type = brcms_c_get_phy_type(wl->wlc, 0);
930 if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) {
931 band = &wlc->bandstate[BAND_2G_INDEX]->band;
932 *band = brcms_band_2GHz_nphy_template;
933 if (phy_type == PHY_TYPE_LCN) {
935 band->ht_cap.mcs.rx_mask[1] = 0;
936 band->ht_cap.mcs.rx_highest = cpu_to_le16(72);
938 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = band;
943 /* Assume all bands use the same phy. True for 11n devices. */
944 if (wl->pub->_nbands > 1) {
946 if (phy_type == PHY_TYPE_N || phy_type == PHY_TYPE_LCN) {
947 band = &wlc->bandstate[BAND_5G_INDEX]->band;
948 *band = brcms_band_5GHz_nphy_template;
949 hw->wiphy->bands[IEEE80211_BAND_5GHZ] = band;
958 * is called in brcms_pci_probe() context, therefore no locking required.
960 static int ieee_hw_init(struct ieee80211_hw *hw)
962 hw->flags = IEEE80211_HW_SIGNAL_DBM
963 /* | IEEE80211_HW_CONNECTION_MONITOR What is this? */
964 | IEEE80211_HW_REPORTS_TX_ACK_STATUS
965 | IEEE80211_HW_AMPDU_AGGREGATION;
967 hw->extra_tx_headroom = brcms_c_get_header_len();
968 hw->queues = N_TX_QUEUES;
969 hw->max_rates = 2; /* Primary rate and 1 fallback rate */
971 /* channel change time is dependent on chip and band */
972 hw->channel_change_time = 7 * 1000;
973 hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
975 hw->rate_control_algorithm = "minstrel_ht";
977 hw->sta_data_size = 0;
978 return ieee_hw_rate_init(hw);
982 * attach to the WL device.
984 * Attach to the WL device identified by vendor and device parameters.
985 * regs is a host accessible memory address pointing to WL device registers.
987 * brcms_attach is not defined as static because in the case where no bus
988 * is defined, wl_attach will never be called, and thus, gcc will issue
989 * a warning that this function is defined but not used if we declare
993 * is called in brcms_bcma_probe() context, therefore no locking required.
995 static struct brcms_info *brcms_attach(struct bcma_device *pdev)
997 struct brcms_info *wl = NULL;
999 struct ieee80211_hw *hw;
1002 unit = n_adapters_found;
1008 /* allocate private info */
1009 hw = bcma_get_drvdata(pdev);
1012 if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL))
1014 wl->wiphy = hw->wiphy;
1016 atomic_set(&wl->callbacks, 0);
1018 /* setup the bottom half handler */
1019 tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl);
1021 spin_lock_init(&wl->lock);
1022 spin_lock_init(&wl->isr_lock);
1025 if (brcms_request_fw(wl, pdev) < 0) {
1026 wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in "
1027 "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm");
1028 brcms_release_fw(wl);
1033 /* common load-time initialization */
1034 wl->wlc = brcms_c_attach((void *)wl, pdev, unit, false, &err);
1035 brcms_release_fw(wl);
1037 wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n",
1038 KBUILD_MODNAME, err);
1041 wl->pub = brcms_c_pub(wl->wlc);
1043 wl->pub->ieee_hw = hw;
1045 /* register our interrupt handler */
1046 if (request_irq(pdev->irq, brcms_isr,
1047 IRQF_SHARED, KBUILD_MODNAME, wl)) {
1048 wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit);
1051 wl->irq = pdev->irq;
1053 /* register module */
1054 brcms_c_module_register(wl->pub, "linux", wl, NULL);
1056 if (ieee_hw_init(hw)) {
1057 wiphy_err(wl->wiphy, "wl%d: %s: ieee_hw_init failed!\n", unit,
1062 brcms_c_regd_init(wl->wlc);
1064 memcpy(perm, &wl->pub->cur_etheraddr, ETH_ALEN);
1065 if (WARN_ON(!is_valid_ether_addr(perm)))
1067 SET_IEEE80211_PERM_ADDR(hw, perm);
1069 err = ieee80211_register_hw(hw);
1071 wiphy_err(wl->wiphy, "%s: ieee80211_register_hw failed, status"
1072 "%d\n", __func__, err);
1074 if (wl->pub->srom_ccode[0] &&
1075 regulatory_hint(wl->wiphy, wl->pub->srom_ccode))
1076 wiphy_err(wl->wiphy, "%s: regulatory hint failed\n", __func__);
1089 * determines if a device is a WL device, and if so, attaches it.
1091 * This function determines if a device pointed to by pdev is a WL device,
1092 * and if so, performs a brcms_attach() on it.
1094 * Perimeter lock is initialized in the course of this function.
1096 static int __devinit brcms_bcma_probe(struct bcma_device *pdev)
1098 struct brcms_info *wl;
1099 struct ieee80211_hw *hw;
1101 dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
1102 pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
1105 if ((pdev->id.manuf != BCMA_MANUF_BCM) ||
1106 (pdev->id.id != BCMA_CORE_80211))
1109 hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops);
1111 pr_err("%s: ieee80211_alloc_hw failed\n", __func__);
1115 SET_IEEE80211_DEV(hw, &pdev->dev);
1117 bcma_set_drvdata(pdev, hw);
1119 memset(hw->priv, 0, sizeof(*wl));
1121 wl = brcms_attach(pdev);
1123 pr_err("%s: brcms_attach failed!\n", __func__);
1129 static int brcms_suspend(struct bcma_device *pdev)
1131 struct brcms_info *wl;
1132 struct ieee80211_hw *hw;
1134 hw = bcma_get_drvdata(pdev);
1137 pr_err("%s: %s: no driver private struct!\n", KBUILD_MODNAME,
1142 /* only need to flag hw is down for proper resume */
1143 spin_lock_bh(&wl->lock);
1144 wl->pub->hw_up = false;
1145 spin_unlock_bh(&wl->lock);
1147 pr_debug("brcms_suspend ok\n");
1152 static int brcms_resume(struct bcma_device *pdev)
1154 pr_debug("brcms_resume ok\n");
1158 static struct bcma_driver brcms_bcma_driver = {
1159 .name = KBUILD_MODNAME,
1160 .probe = brcms_bcma_probe,
1161 .suspend = brcms_suspend,
1162 .resume = brcms_resume,
1163 .remove = __devexit_p(brcms_remove),
1164 .id_table = brcms_coreid_table,
1168 * This is the main entry point for the brcmsmac driver.
1170 * This function is scheduled upon module initialization and
1171 * does the driver registration, which result in brcms_bcma_probe()
1172 * call resulting in the driver bringup.
1174 static void brcms_driver_init(struct work_struct *work)
1178 error = bcma_driver_register(&brcms_bcma_driver);
1180 pr_err("%s: register returned %d\n", __func__, error);
1183 static DECLARE_WORK(brcms_driver_work, brcms_driver_init);
1185 static int __init brcms_module_init(void)
1188 if (msglevel != 0xdeadbeef)
1189 brcm_msg_level = msglevel;
1191 if (!schedule_work(&brcms_driver_work))
1198 * This function unloads the brcmsmac driver from the system.
1200 * This function unconditionally unloads the brcmsmac driver module from the
1204 static void __exit brcms_module_exit(void)
1206 cancel_work_sync(&brcms_driver_work);
1207 bcma_driver_unregister(&brcms_bcma_driver);
1210 module_init(brcms_module_init);
1211 module_exit(brcms_module_exit);
1214 * precondition: perimeter lock has been acquired
1216 void brcms_txflowcontrol(struct brcms_info *wl, struct brcms_if *wlif,
1217 bool state, int prio)
1219 wiphy_err(wl->wiphy, "Shouldn't be here %s\n", __func__);
1223 * precondition: perimeter lock has been acquired
1225 void brcms_init(struct brcms_info *wl)
1227 BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit);
1229 brcms_c_init(wl->wlc, wl->mute_tx);
1233 * precondition: perimeter lock has been acquired
1235 uint brcms_reset(struct brcms_info *wl)
1237 BCMMSG(wl->pub->ieee_hw->wiphy, "wl%d\n", wl->pub->unit);
1238 brcms_c_reset(wl->wlc);
1240 /* dpc will not be rescheduled */
1241 wl->resched = false;
1243 /* inform publicly that interface is down */
1244 wl->pub->up = false;
1249 void brcms_fatal_error(struct brcms_info *wl)
1251 wiphy_err(wl->wlc->wiphy, "wl%d: fatal error, reinitializing\n",
1252 wl->wlc->pub->unit);
1254 ieee80211_restart_hw(wl->pub->ieee_hw);
1258 * These are interrupt on/off entry points. Disable interrupts
1259 * during interrupt state transition.
1261 void brcms_intrson(struct brcms_info *wl)
1263 unsigned long flags;
1265 spin_lock_irqsave(&wl->isr_lock, flags);
1266 brcms_c_intrson(wl->wlc);
1267 spin_unlock_irqrestore(&wl->isr_lock, flags);
1270 u32 brcms_intrsoff(struct brcms_info *wl)
1272 unsigned long flags;
1275 spin_lock_irqsave(&wl->isr_lock, flags);
1276 status = brcms_c_intrsoff(wl->wlc);
1277 spin_unlock_irqrestore(&wl->isr_lock, flags);
1281 void brcms_intrsrestore(struct brcms_info *wl, u32 macintmask)
1283 unsigned long flags;
1285 spin_lock_irqsave(&wl->isr_lock, flags);
1286 brcms_c_intrsrestore(wl->wlc, macintmask);
1287 spin_unlock_irqrestore(&wl->isr_lock, flags);
1291 * precondition: perimeter lock has been acquired
1293 int brcms_up(struct brcms_info *wl)
1300 error = brcms_c_up(wl->wlc);
1306 * precondition: perimeter lock has been acquired
1308 void brcms_down(struct brcms_info *wl)
1310 uint callbacks, ret_val = 0;
1312 /* call common down function */
1313 ret_val = brcms_c_down(wl->wlc);
1314 callbacks = atomic_read(&wl->callbacks) - ret_val;
1316 /* wait for down callbacks to complete */
1317 spin_unlock_bh(&wl->lock);
1319 /* For HIGH_only driver, it's important to actually schedule other work,
1320 * not just spin wait since everything runs at schedule level
1322 SPINWAIT((atomic_read(&wl->callbacks) > callbacks), 100 * 1000);
1324 spin_lock_bh(&wl->lock);
1328 * precondition: perimeter lock is not acquired
1330 static void _brcms_timer(struct work_struct *work)
1332 struct brcms_timer *t = container_of(work, struct brcms_timer,
1335 spin_lock_bh(&t->wl->lock);
1339 atomic_inc(&t->wl->callbacks);
1340 ieee80211_queue_delayed_work(t->wl->pub->ieee_hw,
1342 msecs_to_jiffies(t->ms));
1350 atomic_dec(&t->wl->callbacks);
1352 spin_unlock_bh(&t->wl->lock);
1356 * Adds a timer to the list. Caller supplies a timer function.
1357 * Is called from wlc.
1359 * precondition: perimeter lock has been acquired
1361 struct brcms_timer *brcms_init_timer(struct brcms_info *wl,
1362 void (*fn) (void *arg),
1363 void *arg, const char *name)
1365 struct brcms_timer *t;
1367 t = kzalloc(sizeof(struct brcms_timer), GFP_ATOMIC);
1371 INIT_DELAYED_WORK(&t->dly_wrk, _brcms_timer);
1375 t->next = wl->timers;
1379 t->name = kmalloc(strlen(name) + 1, GFP_ATOMIC);
1381 strcpy(t->name, name);
1388 * adds only the kernel timer since it's going to be more accurate
1389 * as well as it's easier to make it periodic
1391 * precondition: perimeter lock has been acquired
1393 void brcms_add_timer(struct brcms_timer *t, uint ms, int periodic)
1395 struct ieee80211_hw *hw = t->wl->pub->ieee_hw;
1399 wiphy_err(hw->wiphy, "%s: Already set. Name: %s, per %d\n",
1400 __func__, t->name, periodic);
1403 t->periodic = (bool) periodic;
1406 atomic_inc(&t->wl->callbacks);
1408 ieee80211_queue_delayed_work(hw, &t->dly_wrk, msecs_to_jiffies(ms));
1412 * return true if timer successfully deleted, false if still pending
1414 * precondition: perimeter lock has been acquired
1416 bool brcms_del_timer(struct brcms_timer *t)
1420 if (!cancel_delayed_work(&t->dly_wrk))
1423 atomic_dec(&t->wl->callbacks);
1430 * precondition: perimeter lock has been acquired
1432 void brcms_free_timer(struct brcms_timer *t)
1434 struct brcms_info *wl = t->wl;
1435 struct brcms_timer *tmp;
1437 /* delete the timer in case it is active */
1440 if (wl->timers == t) {
1441 wl->timers = wl->timers->next;
1452 if (tmp->next == t) {
1453 tmp->next = t->next;
1466 * precondition: perimeter lock has been acquired
1468 int brcms_ucode_init_buf(struct brcms_info *wl, void **pbuf, u32 idx)
1472 struct firmware_hdr *hdr;
1473 for (i = 0; i < wl->fw.fw_cnt; i++) {
1474 hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data;
1475 for (entry = 0; entry < wl->fw.hdr_num_entries[i];
1477 u32 len = le32_to_cpu(hdr->len);
1478 if (le32_to_cpu(hdr->idx) == idx) {
1479 pdata = wl->fw.fw_bin[i]->data +
1480 le32_to_cpu(hdr->offset);
1481 *pbuf = kmemdup(pdata, len, GFP_ATOMIC);
1489 wiphy_err(wl->wiphy, "ERROR: ucode buf tag:%d can not be found!\n",
1497 * Precondition: Since this function is called in brcms_bcma_probe() context,
1498 * no locking is required.
1500 int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx)
1504 struct firmware_hdr *hdr;
1505 for (i = 0; i < wl->fw.fw_cnt; i++) {
1506 hdr = (struct firmware_hdr *)wl->fw.fw_hdr[i]->data;
1507 for (entry = 0; entry < wl->fw.hdr_num_entries[i];
1509 if (le32_to_cpu(hdr->idx) == idx) {
1510 pdata = wl->fw.fw_bin[i]->data +
1511 le32_to_cpu(hdr->offset);
1512 if (le32_to_cpu(hdr->len) != 4) {
1513 wiphy_err(wl->wiphy,
1514 "ERROR: fw hdr len\n");
1517 *n_bytes = le32_to_cpu(*((__le32 *) pdata));
1522 wiphy_err(wl->wiphy, "ERROR: ucode tag:%d can not be found!\n", idx);
1527 * precondition: can both be called locked and unlocked
1529 void brcms_ucode_free_buf(void *p)
1535 * checks validity of all firmware images loaded from user space
1537 * Precondition: Since this function is called in brcms_bcma_probe() context,
1538 * no locking is required.
1540 int brcms_check_firmwares(struct brcms_info *wl)
1545 const struct firmware *fw;
1546 const struct firmware *fw_hdr;
1547 struct firmware_hdr *ucode_hdr;
1548 for (i = 0; i < MAX_FW_IMAGES && rc == 0; i++) {
1549 fw = wl->fw.fw_bin[i];
1550 fw_hdr = wl->fw.fw_hdr[i];
1551 if (fw == NULL && fw_hdr == NULL) {
1553 } else if (fw == NULL || fw_hdr == NULL) {
1554 wiphy_err(wl->wiphy, "%s: invalid bin/hdr fw\n",
1557 } else if (fw_hdr->size % sizeof(struct firmware_hdr)) {
1558 wiphy_err(wl->wiphy, "%s: non integral fw hdr file "
1559 "size %zu/%zu\n", __func__, fw_hdr->size,
1560 sizeof(struct firmware_hdr));
1562 } else if (fw->size < MIN_FW_SIZE || fw->size > MAX_FW_SIZE) {
1563 wiphy_err(wl->wiphy, "%s: out of bounds fw file size "
1564 "%zu\n", __func__, fw->size);
1567 /* check if ucode section overruns firmware image */
1568 ucode_hdr = (struct firmware_hdr *)fw_hdr->data;
1569 for (entry = 0; entry < wl->fw.hdr_num_entries[i] &&
1570 !rc; entry++, ucode_hdr++) {
1571 if (le32_to_cpu(ucode_hdr->offset) +
1572 le32_to_cpu(ucode_hdr->len) >
1574 wiphy_err(wl->wiphy,
1575 "%s: conflicting bin/hdr\n",
1582 if (rc == 0 && wl->fw.fw_cnt != i) {
1583 wiphy_err(wl->wiphy, "%s: invalid fw_cnt=%d\n", __func__,
1591 * precondition: perimeter lock has been acquired
1593 bool brcms_rfkill_set_hw_state(struct brcms_info *wl)
1595 bool blocked = brcms_c_check_radio_disabled(wl->wlc);
1597 spin_unlock_bh(&wl->lock);
1598 wiphy_rfkill_set_hw_state(wl->pub->ieee_hw->wiphy, blocked);
1600 wiphy_rfkill_start_polling(wl->pub->ieee_hw->wiphy);
1601 spin_lock_bh(&wl->lock);
1606 * precondition: perimeter lock has been acquired
1608 void brcms_msleep(struct brcms_info *wl, uint ms)
1610 spin_unlock_bh(&wl->lock);
1612 spin_lock_bh(&wl->lock);