17 #define __UNDEF_NO_VERSION__
18 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 #include <linux/sched.h>
24 #include <linux/module.h>
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), \
83 static int n_adapters_found;
102 static int msglevel = 0xdeadbeef;
213 .channels = brcms_2ghz_chantable,
214 .n_channels =
ARRAY_SIZE(brcms_2ghz_chantable),
215 .bitrates = legacy_ratetable,
221 .ht_supported =
true,
226 .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
234 .channels = brcms_5ghz_nphy_chantable,
235 .n_channels =
ARRAY_SIZE(brcms_5ghz_nphy_chantable),
242 .ht_supported =
true,
247 .rx_mask = {0xff, 0xff, 0, 0, 0, 0, 0, 0, 0, 0},
258 for (i = 0; i < rs->
count; i++) {
259 if (rate != (rs->
rates[i] & 0x7f))
277 spin_lock_bh(&wl->
lock);
286 spin_unlock_bh(&wl->
lock);
296 spin_lock_bh(&wl->
lock);
298 spin_unlock_bh(&wl->
lock);
302 spin_lock_bh(&wl->
lock);
313 spin_unlock_bh(&wl->
lock);
331 spin_lock_bh(&wl->
lock);
333 spin_unlock_bh(&wl->
lock);
336 "wl: brcms_ops_stop: chipmatch failed\n");
341 spin_lock_bh(&wl->
lock);
343 spin_unlock_bh(&wl->
lock);
354 " STA for now\n", __func__, vif->
type);
377 spin_lock_bh(&wl->
lock);
383 wiphy_dbg(wiphy,
"%s: change monitor mode: %s\n",
387 wiphy_err(wiphy,
"%s: change power-save mode: %s (implement)\n",
394 wiphy_err(wiphy,
"%s: Error setting power_level\n",
400 wiphy_err(wiphy,
"%s: Power level req != actual, %d %d"
418 spin_unlock_bh(&wl->
lock);
428 struct wiphy *wiphy = hw->
wiphy;
434 wiphy_err(wiphy,
"%s: %s: %sassociated\n", KBUILD_MODNAME,
435 __func__, info->
assoc ?
"" :
"dis");
436 spin_lock_bh(&wl->
lock);
438 spin_unlock_bh(&wl->
lock);
448 spin_lock_bh(&wl->
lock);
450 spin_unlock_bh(&wl->
lock);
457 spin_lock_bh(&wl->
lock);
464 spin_unlock_bh(&wl->
lock);
474 spin_lock_bh(&wl->
lock);
476 spin_unlock_bh(&wl->
lock);
482 rate = (bi->
bitrates[
i].bitrate << 1) / 10;
485 brcms_set_basic_rate(&rs, rate, br_mask & 1);
490 spin_lock_bh(&wl->
lock);
492 spin_unlock_bh(&wl->
lock);
494 wiphy_err(wiphy,
"changing basic rates failed: %d\n",
499 spin_lock_bh(&wl->
lock);
501 spin_unlock_bh(&wl->
lock);
505 spin_lock_bh(&wl->
lock);
507 spin_unlock_bh(&wl->
lock);
511 wiphy_err(wiphy,
"%s: beacon changed\n", __func__);
515 wiphy_err(wiphy,
"%s: Beacon enabled: %s\n", __func__,
521 wiphy_err(wiphy,
"%s: cqm change: threshold %d, hys %d "
528 wiphy_err(wiphy,
"%s: IBSS joined: %s (implement)\n", __func__,
534 wiphy_err(wiphy,
"%s: arp filtering: enabled %s, count %d"
544 wiphy_err(wiphy,
"%s: qos enabled: %s (implement)\n", __func__,
545 info->
qos ?
"true" :
"false");
552 unsigned int changed_flags,
553 unsigned int *total_flags,
u64 multicast)
556 struct wiphy *wiphy = hw->
wiphy;
562 wiphy_dbg(wiphy,
"FIF_PROMISC_IN_BSS\n");
574 wiphy_dbg(wiphy,
"FIF_BCN_PRBRESP_PROMISC\n");
576 spin_lock_bh(&wl->
lock);
578 spin_unlock_bh(&wl->
lock);
582 static void brcms_ops_sw_scan_start(
struct ieee80211_hw *hw)
585 spin_lock_bh(&wl->
lock);
587 spin_unlock_bh(&wl->
lock);
591 static void brcms_ops_sw_scan_complete(
struct ieee80211_hw *hw)
594 spin_lock_bh(&wl->
lock);
596 spin_unlock_bh(&wl->
lock);
606 spin_lock_bh(&wl->
lock);
608 spin_unlock_bh(&wl->
lock);
623 wl->
pub->global_ampdu->scb =
scb;
624 wl->
pub->global_ampdu->max_pdu = 16;
652 spin_lock_bh(&wl->
lock);
654 spin_unlock_bh(&wl->
lock);
664 spin_lock_bh(&wl->
lock);
666 spin_unlock_bh(&wl->
lock);
676 spin_lock_bh(&wl->
lock);
679 sta->
ht_cap.ampdu_factor)) - 1);
680 spin_unlock_bh(&wl->
lock);
691 static void brcms_ops_rfkill_poll(
struct ieee80211_hw *hw)
696 spin_lock_bh(&wl->
lock);
698 spin_unlock_bh(&wl->
lock);
703 static void brcms_ops_flush(
struct ieee80211_hw *hw,
bool drop)
707 no_printk(
"%s: drop = %s\n", __func__, drop ?
"true" :
"false");
710 spin_lock_bh(&wl->
lock);
712 spin_unlock_bh(&wl->
lock);
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,
739 spin_lock_bh(&wl->
lock);
748 spin_unlock_irqrestore(&wl->
isr_lock, flags);
760 tasklet_schedule(&wl->
tasklet);
766 spin_unlock_bh(&wl->
lock);
782 if (brcms_firmwares[i] ==
NULL)
784 sprintf(fw_name,
"%s-%d.fw", brcms_firmwares[i],
789 KBUILD_MODNAME, fw_name);
792 sprintf(fw_name,
"%s_hdr-%d.fw", brcms_firmwares[i],
797 KBUILD_MODNAME, fw_name);
800 wl->
fw.hdr_num_entries[
i] =
811 static void brcms_release_fw(
struct brcms_info *wl)
859 for (t = wl->
timers; t; t = next) {
885 bcma_set_drvdata(pdev,
NULL);
906 tasklet_schedule(&wl->
tasklet);
932 *band = brcms_band_2GHz_nphy_template;
935 band->
ht_cap.mcs.rx_mask[1] = 0;
944 if (wl->
pub->_nbands > 1) {
948 *band = brcms_band_5GHz_nphy_template;
978 return ieee_hw_rate_init(hw);
1002 unit = n_adapters_found;
1009 hw = bcma_get_drvdata(pdev);
1025 if (brcms_request_fw(wl, pdev) < 0) {
1027 "%s\n", KBUILD_MODNAME,
"/lib/firmware/brcm");
1028 brcms_release_fw(wl);
1035 brcms_release_fw(wl);
1038 KBUILD_MODNAME, err);
1043 wl->
pub->ieee_hw =
hw;
1056 if (ieee_hw_init(hw)) {
1065 if (
WARN_ON(!is_valid_ether_addr(perm)))
1067 SET_IEEE80211_PERM_ADDR(hw, perm);
1072 "%d\n", __func__, err);
1074 if (wl->
pub->srom_ccode[0] &&
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,
1111 pr_err(
"%s: ieee80211_alloc_hw failed\n", __func__);
1115 SET_IEEE80211_DEV(hw, &pdev->
dev);
1117 bcma_set_drvdata(pdev, hw);
1121 wl = brcms_attach(pdev);
1123 pr_err(
"%s: brcms_attach failed!\n", __func__);
1129 static int brcms_suspend(
struct bcma_device *pdev)
1134 hw = bcma_get_drvdata(pdev);
1137 pr_err(
"%s: %s: no driver private struct!\n", KBUILD_MODNAME,
1143 spin_lock_bh(&wl->
lock);
1144 wl->
pub->hw_up =
false;
1145 spin_unlock_bh(&wl->
lock);
1159 .name = KBUILD_MODNAME,
1160 .probe = brcms_bcma_probe,
1161 .suspend = brcms_suspend,
1162 .resume = brcms_resume,
1164 .id_table = brcms_coreid_table,
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)
1204 static void __exit brcms_module_exit(
void)
1227 BCMMSG(wl->
pub->ieee_hw->wiphy,
"wl%d\n", wl->
pub->unit);
1237 BCMMSG(wl->
pub->ieee_hw->wiphy,
"wl%d\n", wl->
pub->unit);
1244 wl->
pub->up =
false;
1251 wiphy_err(wl->
wlc->wiphy,
"wl%d: fatal error, reinitializing\n",
1252 wl->
wlc->pub->unit);
1263 unsigned long flags;
1267 spin_unlock_irqrestore(&wl->
isr_lock, flags);
1272 unsigned long flags;
1277 spin_unlock_irqrestore(&wl->
isr_lock, flags);
1283 unsigned long flags;
1287 spin_unlock_irqrestore(&wl->
isr_lock, flags);
1310 uint callbacks, ret_val = 0;
1317 spin_unlock_bh(&wl->
lock);
1324 spin_lock_bh(&wl->
lock);
1330 static void _brcms_timer(
struct work_struct *work)
1335 spin_lock_bh(&t->
wl->lock);
1352 spin_unlock_bh(&t->
wl->lock);
1362 void (*
fn) (
void *
arg),
1363 void *arg,
const char *
name)
1400 __func__, t->name, periodic);
1452 if (tmp->
next == t) {
1473 for (i = 0; i < wl->
fw.fw_cnt; i++) {
1475 for (entry = 0; entry < wl->
fw.hdr_num_entries[
i];
1479 pdata = wl->
fw.fw_bin[
i]->data +
1489 wiphy_err(wl->
wiphy,
"ERROR: ucode buf tag:%d can not be found!\n",
1505 for (i = 0; i < wl->
fw.fw_cnt; i++) {
1507 for (entry = 0; entry < wl->
fw.hdr_num_entries[
i];
1510 pdata = wl->
fw.fw_bin[
i]->data +
1514 "ERROR: fw hdr len\n");
1522 wiphy_err(wl->
wiphy,
"ERROR: ucode tag:%d can not be found!\n", idx);
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) {
1559 "size %zu/%zu\n", __func__, fw_hdr->
size,
1564 "%zu\n", __func__, fw->
size);
1569 for (entry = 0; entry < wl->
fw.hdr_num_entries[
i] &&
1570 !
rc; entry++, ucode_hdr++) {
1575 "%s: conflicting bin/hdr\n",
1582 if (rc == 0 && wl->
fw.fw_cnt != i) {
1597 spin_unlock_bh(&wl->
lock);
1601 spin_lock_bh(&wl->
lock);
1610 spin_unlock_bh(&wl->
lock);
1612 spin_lock_bh(&wl->
lock);