Lines Matching +full:precondition +full:- +full:timeout

3  * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
50 /* n-mode support capability */
82 #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1)
123 #define BRCMS_TEMPSENSE_PERIOD 10 /* 10 second timeout */
133 /* Per-AC retry limit register definitions; uses defs.h bitfield macros */
167 #define BRCMS_PLCP_AUTO -1
172 #define BRCMS_PROTECTION_AUTO -1
199 /* MSC in use,indicates b0-6 holds an mcs */
361 return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK] in brcms_basic_rate()
363 return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK]; in brcms_basic_rate()
376 return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : in get_sifs()
384 * cause SB error if aphy is in reset on 4306B0-DB. Need a simple accessible
393 if (!wlc->hw->clk) in brcms_deviceremoved()
394 return ai_deviceremoved(wlc->hw->sih); in brcms_deviceremoved()
395 macctrl = bcma_read32(wlc->hw->d11core, in brcms_deviceremoved()
406 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_txpktpendtot()
407 if (wlc->hw->di[i]) in brcms_txpktpendtot()
408 pending += dma_txpending(wlc->hw->di[i]); in brcms_txpktpendtot()
414 return wlc->pub->_nbands > 1 && !wlc->bandlocked; in brcms_is_mband_unlocked()
432 kfree(cfg->current_bss); in brcms_c_bsscfg_mfree()
441 brcms_c_bsscfg_mfree(wlc->bsscfg); in brcms_c_detach_mfree()
442 kfree(wlc->pub); in brcms_c_detach_mfree()
443 kfree(wlc->modulecb); in brcms_c_detach_mfree()
444 kfree(wlc->default_bss); in brcms_c_detach_mfree()
445 kfree(wlc->protection); in brcms_c_detach_mfree()
446 kfree(wlc->stf); in brcms_c_detach_mfree()
447 kfree(wlc->bandstate[0]); in brcms_c_detach_mfree()
448 if (wlc->corestate) in brcms_c_detach_mfree()
449 kfree(wlc->corestate->macstat_snapshot); in brcms_c_detach_mfree()
450 kfree(wlc->corestate); in brcms_c_detach_mfree()
451 if (wlc->hw) in brcms_c_detach_mfree()
452 kfree(wlc->hw->bandstate[0]); in brcms_c_detach_mfree()
453 kfree(wlc->hw); in brcms_c_detach_mfree()
454 if (wlc->beacon) in brcms_c_detach_mfree()
455 dev_kfree_skb_any(wlc->beacon); in brcms_c_detach_mfree()
456 if (wlc->probe_resp) in brcms_c_detach_mfree()
457 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_detach_mfree()
470 cfg->current_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); in brcms_c_bsscfg_malloc()
471 if (cfg->current_bss == NULL) in brcms_c_bsscfg_malloc()
493 wlc->pub = kzalloc(sizeof(struct brcms_pub), GFP_ATOMIC); in brcms_c_attach_malloc()
494 if (wlc->pub == NULL) { in brcms_c_attach_malloc()
498 wlc->pub->wlc = wlc; in brcms_c_attach_malloc()
502 wlc->hw = kzalloc(sizeof(struct brcms_hardware), GFP_ATOMIC); in brcms_c_attach_malloc()
503 if (wlc->hw == NULL) { in brcms_c_attach_malloc()
507 wlc->hw->wlc = wlc; in brcms_c_attach_malloc()
509 wlc->hw->bandstate[0] = in brcms_c_attach_malloc()
511 if (wlc->hw->bandstate[0] == NULL) { in brcms_c_attach_malloc()
518 wlc->hw->bandstate[i] = (struct brcms_hw_band *) in brcms_c_attach_malloc()
519 ((unsigned long)wlc->hw->bandstate[0] + in brcms_c_attach_malloc()
523 wlc->modulecb = in brcms_c_attach_malloc()
526 if (wlc->modulecb == NULL) { in brcms_c_attach_malloc()
531 wlc->default_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); in brcms_c_attach_malloc()
532 if (wlc->default_bss == NULL) { in brcms_c_attach_malloc()
537 wlc->bsscfg = brcms_c_bsscfg_malloc(unit); in brcms_c_attach_malloc()
538 if (wlc->bsscfg == NULL) { in brcms_c_attach_malloc()
543 wlc->protection = kzalloc(sizeof(struct brcms_protection), in brcms_c_attach_malloc()
545 if (wlc->protection == NULL) { in brcms_c_attach_malloc()
550 wlc->stf = kzalloc(sizeof(struct brcms_stf), GFP_ATOMIC); in brcms_c_attach_malloc()
551 if (wlc->stf == NULL) { in brcms_c_attach_malloc()
556 wlc->bandstate[0] = in brcms_c_attach_malloc()
558 if (wlc->bandstate[0] == NULL) { in brcms_c_attach_malloc()
565 wlc->bandstate[i] = (struct brcms_band *) in brcms_c_attach_malloc()
566 ((unsigned long)wlc->bandstate[0] in brcms_c_attach_malloc()
570 wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); in brcms_c_attach_malloc()
571 if (wlc->corestate == NULL) { in brcms_c_attach_malloc()
576 wlc->corestate->macstat_snapshot = in brcms_c_attach_malloc()
578 if (wlc->corestate->macstat_snapshot == NULL) { in brcms_c_attach_malloc()
598 struct bcma_device *core = wlc_hw->d11core; in brcms_b_update_slot_timing()
622 brcms_err(wlc->hw->d11core, "wl%d: WAR: using rate of 1 mbps\n", in brcms_c_calc_frame_time()
623 wlc->pub->unit); in brcms_c_calc_frame_time()
650 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
662 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
671 dur = (mac_len + rate - 1) / rate; in brcms_c_calc_frame_time()
683 struct bcma_device *core = wlc_hw->d11core; in brcms_c_write_inits()
689 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_write_inits()
718 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_c_ucode_bsinit()
721 brcms_c_write_mhf(wlc_hw, wlc_hw->band->mhfs); in brcms_c_ucode_bsinit()
723 /* do band-specific ucode IHR, SHM, and SCR inits */ in brcms_c_ucode_bsinit()
724 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_c_ucode_bsinit()
725 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
726 brcms_c_write_inits(wlc_hw, ucode->d11n0bsinitvals16); in brcms_c_ucode_bsinit()
728 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
730 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
731 wlc_hw->corerev); in brcms_c_ucode_bsinit()
733 if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_c_ucode_bsinit()
734 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_c_ucode_bsinit()
736 ucode->d11lcn0bsinitvals24); in brcms_c_ucode_bsinit()
738 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
740 __func__, wlc_hw->unit, in brcms_c_ucode_bsinit()
741 wlc_hw->corerev); in brcms_c_ucode_bsinit()
743 brcms_err(wlc_hw->d11core, in brcms_c_ucode_bsinit()
745 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_c_ucode_bsinit()
752 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_ioctl()
760 brcms_dbg_info(wlc_hw->d11core, "wl%d: clk %d\n", wlc_hw->unit, clk); in brcms_b_core_phy_clk()
762 wlc_hw->phyclk = clk; in brcms_b_core_phy_clk()
782 /* low-level band switch utility routine */
785 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_setxband()
788 wlc_hw->band = wlc_hw->bandstate[bandunit]; in brcms_c_setxband()
792 * until we eliminate need for wlc->band refs in low level code in brcms_c_setxband()
794 wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; in brcms_c_setxband()
797 if (wlc_hw->sbclk && !wlc_hw->noreset) { in brcms_c_setxband()
810 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_setband_inact()
814 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_c_setband_inact()
815 macctrl = bcma_read32(wlc_hw->d11core, in brcms_c_setband_inact()
820 macintmask = brcms_intrsoff(wlc->wl); in brcms_c_setband_inact()
823 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_setband_inact()
850 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
851 txs->frameid, txs->status, txs->lasttxtime, in brcms_c_dotxstatus()
852 txs->sequence, txs->phyerr, txs->ackphyrxsh); in brcms_c_dotxstatus()
859 if (!(txs->status & TX_STATUS_AMPDU) in brcms_c_dotxstatus()
860 && (txs->status & TX_STATUS_INTERMEDIATE)) { in brcms_c_dotxstatus()
861 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
866 queue = txs->frameid & TXFID_QUEUE_MASK; in brcms_c_dotxstatus()
868 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
872 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
874 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
876 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
880 txh = (struct d11txh *) (p->data); in brcms_c_dotxstatus()
882 if (txs->phyerr) in brcms_c_dotxstatus()
883 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
884 txs->phyerr, txh->MainRates); in brcms_c_dotxstatus()
886 if (txs->frameid != le16_to_cpu(txh->TxFrameID)) { in brcms_c_dotxstatus()
887 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
893 if (tx_info->rate_driver_data[0]) in brcms_c_dotxstatus()
894 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
896 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { in brcms_c_dotxstatus()
897 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
906 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
908 supr_status = txs->status & TX_STATUS_SUPR_MASK; in brcms_c_dotxstatus()
910 unsigned xfts = le16_to_cpu(txh->XtraFrameTypes); in brcms_c_dotxstatus()
911 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
914 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
918 (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; in brcms_c_dotxstatus()
920 lastframe = !ieee80211_has_morefrags(h->frame_control); in brcms_c_dotxstatus()
923 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
938 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
940 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
943 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
944 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
947 txrate = tx_info->status.rates; in brcms_c_dotxstatus()
961 txrate[1].count = tx_frame_count - fbl; in brcms_c_dotxstatus()
970 * unused rates to be marked with idx = -1 in brcms_c_dotxstatus()
972 txrate[1].idx = -1; in brcms_c_dotxstatus()
978 txrate[i].idx = -1; in brcms_c_dotxstatus()
982 if (txs->status & TX_STATUS_ACK_RCV) in brcms_c_dotxstatus()
983 tx_info->flags |= IEEE80211_TX_STAT_ACK; in brcms_c_dotxstatus()
990 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
992 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
1002 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1009 if (dma->txavail > TX_HEADROOM && queue < TX_BCMC_FIFO && in brcms_c_dotxstatus()
1010 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1011 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1032 uint max_tx_num = bound ? TXSBND : -1; in brcms_b_txstatus()
1035 core = wlc_hw->d11core; in brcms_b_txstatus()
1041 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_b_txstatus()
1051 txs->status = s1 & TXS_STATUS_MASK; in brcms_b_txstatus()
1052 txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; in brcms_b_txstatus()
1053 txs->sequence = s2 & TXS_SEQ_MASK; in brcms_b_txstatus()
1054 txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; in brcms_b_txstatus()
1055 txs->lasttxtime = 0; in brcms_b_txstatus()
1057 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1068 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1073 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1080 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1087 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_c_mhfdef()
1090 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { in brcms_c_mhfdef()
1112 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1113 uint unit = wlc_hw->unit; in brcms_b_attach_dmapio()
1118 if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ in brcms_b_attach_dmapio()
1126 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1130 RXBUFSZ, -1, NRXBUFPOST, in brcms_b_attach_dmapio()
1132 dma_attach_err |= (NULL == wlc_hw->di[0]); in brcms_b_attach_dmapio()
1136 * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) in brcms_b_attach_dmapio()
1140 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1142 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1143 dma_attach_err |= (NULL == wlc_hw->di[1]); in brcms_b_attach_dmapio()
1150 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1152 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1153 dma_attach_err |= (NULL == wlc_hw->di[2]); in brcms_b_attach_dmapio()
1159 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1161 0, NTXD, 0, 0, -1, in brcms_b_attach_dmapio()
1163 dma_attach_err |= (NULL == wlc_hw->di[3]); in brcms_b_attach_dmapio()
1167 brcms_err(wlc_hw->d11core, in brcms_b_attach_dmapio()
1175 if (wlc_hw->di[i]) in brcms_b_attach_dmapio()
1176 wlc_hw->txavail[i] = in brcms_b_attach_dmapio()
1177 (uint *) dma_getvar(wlc_hw->di[i], in brcms_b_attach_dmapio()
1182 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1192 if (wlc_hw->di[j]) { in brcms_b_detach_dmapio()
1193 dma_detach(wlc_hw->di[j]); in brcms_b_detach_dmapio()
1194 wlc_hw->di[j] = NULL; in brcms_b_detach_dmapio()
1206 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init()
1209 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1212 wlc_hw->shortslot = false; in brcms_b_info_init()
1214 wlc_hw->SFBL = RETRY_SHORT_FB; in brcms_b_info_init()
1215 wlc_hw->LFBL = RETRY_LONG_FB; in brcms_b_info_init()
1218 wlc_hw->SRL = RETRY_SHORT_DEF; in brcms_b_info_init()
1219 wlc_hw->LRL = RETRY_LONG_DEF; in brcms_b_info_init()
1220 wlc_hw->chanspec = ch20mhz_chspec(1); in brcms_b_info_init()
1230 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1236 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) { in brcms_b_clkctl_clk()
1243 if (wlc_hw->clk) { in brcms_b_clkctl_clk()
1245 bcma_set32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1252 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1256 WARN_ON(!(bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1260 if ((ai_get_pmurev(wlc_hw->sih) == 0) && in brcms_b_clkctl_clk()
1261 (bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1265 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1270 bcma_mask32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1275 wlc_hw->forcefastclk = (mode == BCMA_CLKMODE_FAST); in brcms_b_clkctl_clk()
1282 wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); in brcms_b_clkctl_clk()
1285 if (wlc_hw->forcefastclk && wlc_hw->clk) in brcms_b_clkctl_clk()
1286 WARN_ON(!(bcma_aread32(wlc_hw->d11core, BCMA_IOST) & in brcms_b_clkctl_clk()
1295 * behavior. Older code set wlc->forcefastclk but only had the in brcms_b_clkctl_clk()
1299 if (wlc_hw->forcefastclk) in brcms_b_clkctl_clk()
1300 mboolset(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1303 mboolclr(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1309 * it has an optimization for no-change write
1311 * pre-CLK changes should use wlc_write_mhf to get around the optimization
1314 * bands values are: BRCM_BAND_AUTO <--- Current band only
1315 * BRCM_BAND_5G <--- 5G band only
1316 * BRCM_BAND_2G <--- 2G band only
1317 * BRCM_BAND_ALL <--- All bands
1339 band = wlc_hw->band; in brcms_b_mhf()
1342 band = wlc_hw->bandstate[BAND_5G_INDEX]; in brcms_b_mhf()
1345 band = wlc_hw->bandstate[BAND_2G_INDEX]; in brcms_b_mhf()
1352 save = band->mhfs[idx]; in brcms_b_mhf()
1353 band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1358 if (wlc_hw->clk && (band->mhfs[idx] != save) in brcms_b_mhf()
1359 && (band == wlc_hw->band)) in brcms_b_mhf()
1361 (u16) band->mhfs[idx]); in brcms_b_mhf()
1365 wlc_hw->bandstate[0]->mhfs[idx] = in brcms_b_mhf()
1366 (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1367 wlc_hw->bandstate[1]->mhfs[idx] = in brcms_b_mhf()
1368 (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1378 wlc_hw->maccontrol = 0; in brcms_c_mctrl_reset()
1379 wlc_hw->suspended_fifos = 0; in brcms_c_mctrl_reset()
1380 wlc_hw->wake_override = 0; in brcms_c_mctrl_reset()
1381 wlc_hw->mute_override = 0; in brcms_c_mctrl_reset()
1391 u32 maccontrol = wlc_hw->maccontrol; in brcms_c_mctrl_write()
1394 if (wlc_hw->wake_override) in brcms_c_mctrl_write()
1398 if (wlc_hw->mute_override) { in brcms_c_mctrl_write()
1403 bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), in brcms_c_mctrl_write()
1415 maccontrol = wlc_hw->maccontrol; in brcms_b_mctrl()
1423 wlc_hw->maccontrol = new_maccontrol; in brcms_b_mctrl()
1432 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { in brcms_c_ucode_wake_override_set()
1433 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1437 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1446 mboolclr(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_clear()
1448 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) in brcms_c_ucode_wake_override_clear()
1458 * STA 0 1 <--- This will ensure no beacons
1463 wlc_hw->mute_override = 1; in brcms_c_ucode_mute_override_set()
1468 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_set()
1477 if (wlc_hw->mute_override == 0) in brcms_c_ucode_mute_override_clear()
1480 wlc_hw->mute_override = 0; in brcms_c_ucode_mute_override_clear()
1485 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_clear()
1498 struct bcma_device *core = wlc_hw->d11core; in brcms_b_set_addrmatch()
1503 brcms_dbg_rx(core, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit); in brcms_b_set_addrmatch()
1521 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_template_ram()
1526 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_write_template_ram()
1550 len -= sizeof(u32); in brcms_b_write_template_ram()
1556 wlc_hw->band->CWmin = newmin; in brcms_b_set_cwmin()
1558 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmin()
1560 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmin()
1561 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); in brcms_b_set_cwmin()
1566 wlc_hw->band->CWmax = newmax; in brcms_b_set_cwmax()
1568 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmax()
1570 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmax()
1571 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); in brcms_b_set_cwmax()
1579 fastclk = wlc_hw->forcefastclk; in brcms_b_bw_set()
1583 wlc_phy_bw_state_set(wlc_hw->band->pi, bw); in brcms_b_bw_set()
1586 wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); in brcms_b_bw_set()
1596 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu()
1599 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1601 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1612 u16 phytxant = wlc_hw->bmac_phytxant; in brcms_c_ucode_txant_set()
1635 /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ in brcms_b_ofdm_ratetable_offset()
1655 * Direct-map Table in brcms_b_ofdm_ratetable_offset()
1671 if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_upd_ofdm_pctl1_table()
1686 pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); in brcms_upd_ofdm_pctl1_table()
1694 /* band-specific init */
1697 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1699 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_b_bsinit()
1700 wlc_hw->band->bandunit); in brcms_b_bsinit()
1704 wlc_phy_init(wlc_hw->band->pi, chanspec); in brcms_b_bsinit()
1709 * cwmin is band-specific, update hardware in brcms_b_bsinit()
1712 brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); in brcms_b_bsinit()
1713 brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); in brcms_b_bsinit()
1716 wlc_hw->band->bandtype == BRCM_BAND_5G ? in brcms_b_bsinit()
1717 true : wlc_hw->shortslot); in brcms_b_bsinit()
1720 brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); in brcms_b_bsinit()
1721 brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); in brcms_b_bsinit()
1735 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), in brcms_b_core_phypll_reset()
1738 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1741 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1744 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1755 if (!BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_phyclk_fgc()
1775 struct brcms_phy_pub *pih = wlc_hw->band->pi; in brcms_b_phy_reset()
1778 brcms_dbg_info(wlc_hw->d11core, "wl%d: reset phy\n", wlc_hw->unit); in brcms_b_phy_reset()
1783 phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); in brcms_b_phy_reset()
1786 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && in brcms_b_phy_reset()
1787 NREV_LE(wlc_hw->band->phyrev, 4)) { in brcms_b_phy_reset()
1814 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband()
1818 if (!bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_setband()
1819 bcma_core_enable(wlc_hw->d11core, 0); in brcms_b_setband()
1825 if (!wlc_hw->up) in brcms_b_setband()
1830 /* band-specific initializations */ in brcms_b_setband()
1836 * so brcms_c_dpc() will re-enable interrupts when done. in brcms_b_setband()
1838 if (wlc->macintstatus) in brcms_b_setband()
1839 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1842 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1845 WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & in brcms_b_setband()
1853 if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { in brcms_c_isgoodchip()
1854 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
1855 wlc_hw->corerev); in brcms_c_isgoodchip()
1865 uint boardrev = wlc_hw->boardrev; in brcms_c_validboardtype()
1874 if (ai_get_boardvendor(wlc_hw->sih) != PCI_VENDOR_ID_BROADCOM) in brcms_c_validboardtype()
1893 struct ssb_sprom *sprom = &wlc_hw->d11core->bus->sprom; in brcms_c_get_macaddr()
1896 if (!is_zero_ether_addr(sprom->il0mac)) { in brcms_c_get_macaddr()
1897 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1901 if (wlc_hw->_nbands > 1) in brcms_c_get_macaddr()
1902 memcpy(etheraddr, sprom->et1mac, ETH_ALEN); in brcms_c_get_macaddr()
1904 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1910 brcms_dbg_info(wlc_hw->d11core, "wl%d: want %d\n", wlc_hw->unit, want); in brcms_b_xtal()
1916 if (!want && wlc_hw->pllreq) in brcms_b_xtal()
1919 wlc_hw->sbclk = want; in brcms_b_xtal()
1920 if (!wlc_hw->sbclk) { in brcms_b_xtal()
1921 wlc_hw->clk = false; in brcms_b_xtal()
1922 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_xtal()
1923 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_xtal()
1938 xtal = wlc_hw->sbclk; in brcms_b_radio_read_hwdisabled()
1943 clk = wlc_hw->clk; in brcms_b_radio_read_hwdisabled()
1950 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_radio_read_hwdisabled()
1960 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_radio_read_hwdisabled()
1964 v = ((bcma_read32(wlc_hw->d11core, in brcms_b_radio_read_hwdisabled()
1969 bcma_core_disable(wlc_hw->d11core, 0); in brcms_b_radio_read_hwdisabled()
1979 struct dma_pub *di = wlc_hw->di[fifo]; in wlc_dma_rxreset()
1989 * one testing hack wlc_hw->noreset will bypass the d11/phy reset
1997 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); in brcms_b_corereset()
1999 brcms_dbg_info(wlc_hw->d11core, "wl%d: core reset\n", wlc_hw->unit); in brcms_b_corereset()
2002 fastclk = wlc_hw->forcefastclk; in brcms_b_corereset()
2007 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_corereset()
2009 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) in brcms_b_corereset()
2010 brcms_err(wlc_hw->d11core, "wl%d: %s: " in brcms_b_corereset()
2012 wlc_hw->unit, __func__, i); in brcms_b_corereset()
2014 if ((wlc_hw->di[RX_FIFO]) in brcms_b_corereset()
2016 brcms_err(wlc_hw->d11core, "wl%d: %s: dma_rxreset" in brcms_b_corereset()
2018 wlc_hw->unit, __func__, RX_FIFO); in brcms_b_corereset()
2021 if (wlc_hw->noreset) { in brcms_b_corereset()
2022 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2030 * band->pi is invalid. need to enable PHY CLK in brcms_b_corereset()
2032 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_corereset()
2038 * reg 0x1e0, which is cleared by the core_reset. have to re-request it. in brcms_b_corereset()
2045 wlc_hw->clk = false; in brcms_b_corereset()
2046 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_corereset()
2047 wlc_hw->clk = true; in brcms_b_corereset()
2048 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_corereset()
2049 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); in brcms_b_corereset()
2053 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) in brcms_b_corereset()
2062 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2074 struct bcma_device *core = wlc_hw->d11core; in brcms_b_corerev_fifofixup()
2086 txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2088 (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); in brcms_b_corerev_fifofixup()
2090 ((((txfifo_endblk - in brcms_b_corerev_fifofixup()
2101 txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2108 wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); in brcms_b_corerev_fifofixup()
2110 wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); in brcms_b_corerev_fifofixup()
2112 ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2115 ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2124 * For spuron2 - 126MHz -> 2^26/126 = 532610.0
2125 * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082
2126 * For spuron: 123MHz -> 2^26/123 = 545600.5
2127 * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341
2128 * For spur off: 120MHz -> 2^26/120 = 559240.5
2129 * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889
2134 struct bcma_device *core = wlc_hw->d11core; in brcms_b_switch_macfreq()
2136 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43224) || in brcms_b_switch_macfreq()
2137 (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) { in brcms_b_switch_macfreq()
2148 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_switch_macfreq()
2161 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2162 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2170 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2171 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2172 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2174 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2179 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2180 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2182 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2188 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2205 if (wlc_hw->antsel_type == ANTSEL_2x3) { in brcms_c_gpio_init()
2213 wlc_phy_antsel_init(wlc_hw->band->pi, false); in brcms_c_gpio_init()
2215 } else if (wlc_hw->antsel_type == ANTSEL_2x4) { in brcms_c_gpio_init()
2221 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), in brcms_c_gpio_init()
2223 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), in brcms_c_gpio_init()
2241 if (wlc_hw->boardflags & BFL_PACTRL) in brcms_c_gpio_init()
2245 bcma_chipco_gpio_control(&wlc_hw->d11core->bus->drv_cc, gm, gc); in brcms_c_gpio_init()
2251 struct bcma_device *core = wlc_hw->d11core; in brcms_ucode_write()
2255 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_ucode_write()
2269 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2271 if (wlc_hw->ucode_loaded) in brcms_ucode_download()
2274 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_ucode_download()
2275 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_ucode_download()
2276 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, in brcms_ucode_download()
2277 ucode->bcm43xx_16_mimosz); in brcms_ucode_download()
2278 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2280 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2282 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2283 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_ucode_download()
2284 if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_ucode_download()
2285 brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, in brcms_ucode_download()
2286 ucode->bcm43xx_24_lcnsz); in brcms_ucode_download()
2287 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2289 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2291 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2299 wlc_hw->bmac_phytxant = phytxant; in brcms_b_txant_set()
2302 if (!wlc_hw->up) in brcms_b_txant_set()
2310 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2315 wlc_hw->antsel_type = antsel_type; in brcms_b_antsel_type_set()
2318 wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); in brcms_b_antsel_type_set()
2326 struct bcma_device *core = wlc_hw->d11core; in brcms_b_fifoerrors()
2328 unit = wlc_hw->unit; in brcms_b_fifoerrors()
2331 /* read intstatus register and ignore any non-error bits */ in brcms_b_fifoerrors()
2377 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2388 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2389 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2390 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2395 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2398 if (!wlc_hw->clk) in brcms_c_intrsoff()
2401 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2403 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); in brcms_c_intrsoff()
2404 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); in brcms_c_intrsoff()
2406 wlc->macintmask = 0; in brcms_c_intrsoff()
2409 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2414 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2415 if (!wlc_hw->clk) in brcms_c_intrsrestore()
2418 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2419 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2431 if ((wlc_hw->suspended_fifos & fifo) == fifo) in brcms_b_tx_fifo_suspend()
2435 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_suspend()
2439 wlc_hw->suspended_fifos |= fifo; in brcms_b_tx_fifo_suspend()
2441 if (wlc_hw->di[tx_fifo]) { in brcms_b_tx_fifo_suspend()
2447 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2448 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2450 dma_txsuspend(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_suspend()
2452 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2453 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2465 if (wlc_hw->di[tx_fifo]) in brcms_b_tx_fifo_resume()
2466 dma_txresume(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_resume()
2469 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2472 wlc_hw->suspended_fifos &= ~(1 << tx_fifo); in brcms_b_tx_fifo_resume()
2473 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2479 /* precondition: requires the mac core to be enabled */
2483 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2505 wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); in brcms_b_mute()
2516 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2523 * -1 if brcms_deviceremoved(wlc) evaluates to true;
2529 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2530 struct bcma_device *core = wlc_hw->d11core; in wlc_intstatus()
2535 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2537 trace_brcms_macintstatus(&core->dev, in_isr, macintstatus, mask); in wlc_intstatus()
2541 return -1; in wlc_intstatus()
2559 wlc->macintmask = 0; in wlc_intstatus()
2564 /* MI_DMAINT is indication of non-zero intstatus */ in wlc_intstatus()
2577 /* Update wlc->macintstatus and wlc->intstatus[]. */
2591 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2597 * First-level interrupt processing.
2604 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2607 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2614 brcms_err(wlc_hw->d11core, in brcms_c_isr()
2624 wlc->macintstatus = macintstatus; in brcms_c_isr()
2632 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2633 struct bcma_device *core = wlc_hw->d11core; in brcms_c_suspend_mac_and_wait()
2636 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2637 wlc_hw->band->bandunit); in brcms_c_suspend_mac_and_wait()
2642 wlc_hw->mac_suspend_depth++; in brcms_c_suspend_mac_and_wait()
2643 if (wlc_hw->mac_suspend_depth > 1) in brcms_c_suspend_mac_and_wait()
2652 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2654 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2663 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2665 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2678 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); in brcms_c_suspend_mac_and_wait()
2680 "psm_brc 0x%04x\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2688 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2690 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2700 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2701 struct bcma_device *core = wlc_hw->d11core; in brcms_c_enable_mac()
2704 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_enable_mac()
2705 wlc->band->bandunit); in brcms_c_enable_mac()
2710 wlc_hw->mac_suspend_depth--; in brcms_c_enable_mac()
2711 if (wlc_hw->mac_suspend_depth > 0) in brcms_c_enable_mac()
2736 wlc_hw->hw_stf_ss_opmode = stf_mode; in brcms_b_band_stf_ss_set()
2738 if (wlc_hw->clk) in brcms_b_band_stf_ss_set()
2744 struct bcma_device *core = wlc_hw->d11core; in brcms_b_validate_chip_access()
2746 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2764 "expected 0xaa5555aa\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2777 "expected 0x55aaaa55\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2792 "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, in brcms_b_validate_chip_access()
2805 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_phypll_ctl()
2808 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_core_phypll_ctl()
2813 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_core_phypll_ctl()
2860 brcms_dbg_info(wlc_hw->d11core, "wl%d: disable core\n", wlc_hw->unit); in brcms_c_coredisable()
2862 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2867 if (wlc_hw->noreset) in brcms_c_coredisable()
2871 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2874 wlc_phy_anacore(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2879 wlc_hw->clk = false; in brcms_c_coredisable()
2880 bcma_core_disable(wlc_hw->d11core, 0); in brcms_c_coredisable()
2881 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_c_coredisable()
2886 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2891 if (wlc_hw->di[i]) { in brcms_c_flushqueues()
2892 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); in brcms_c_flushqueues()
2894 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
2900 dma_rxreclaim(wlc_hw->di[RX_FIFO]); in brcms_c_flushqueues()
2906 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_objmem()
2921 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_objmem()
3004 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3010 wlc_hw->SRL = SRL; in brcms_b_retrylimit_upd()
3011 wlc_hw->LRL = LRL; in brcms_b_retrylimit_upd()
3014 if (wlc_hw->up) { in brcms_b_retrylimit_upd()
3015 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3017 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3018 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_retrylimit_upd()
3019 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3021 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3022 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_retrylimit_upd()
3029 if (mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3032 mboolset(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3034 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3035 if (!wlc_hw->sbclk) in brcms_b_pllreq()
3039 if (!mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3042 mboolclr(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3044 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3045 if (wlc_hw->sbclk) in brcms_b_pllreq()
3053 wlc_hw->antsel_avail = antsel_avail; in brcms_b_antsel_set()
3077 if (!wlc->pub->up) in brcms_c_statsupd()
3080 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3084 rxf0ovfl = macstats->rxf0ovfl; in brcms_c_statsupd()
3088 txfunfl[i] = macstats->txfunfl[i]; in brcms_c_statsupd()
3092 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3097 delta = (u16)(macstats->rxf0ovfl - rxf0ovfl); in brcms_c_statsupd()
3099 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3100 wlc->pub->unit, delta); in brcms_c_statsupd()
3104 delta = macstats->txfunfl[i] - txfunfl[i]; in brcms_c_statsupd()
3106 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3108 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3114 if (wlc->hw->di[i]) in brcms_c_statsupd()
3115 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3122 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3126 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3131 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3137 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3139 brcms_b_reset(wlc->hw); in brcms_c_reset()
3147 scb->flags = SCB_WMECAP | SCB_HTCAP; in brcms_c_init_scb()
3149 scb->seqnum[i] = 0; in brcms_c_init_scb()
3150 scb->seqctl[i] = 0xFFFF; in brcms_c_init_scb()
3153 scb->seqctl_nonqos = 0xFFFF; in brcms_c_init_scb()
3154 scb->magic = SCB_MAGIC; in brcms_c_init_scb()
3167 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3168 struct bcma_device *core = wlc_hw->d11core; in brcms_b_coreinit()
3174 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3176 brcms_dbg_info(core, "wl%d: core init\n", wlc_hw->unit); in brcms_b_coreinit()
3188 bcma_write32(core, D11REGOFFS(macintstatus), -1); in brcms_b_coreinit()
3192 /* wait for ucode to self-suspend after auto-init */ in brcms_b_coreinit()
3196 brcms_err(core, "wl%d: wlc_coreinit: ucode did not self-" in brcms_b_coreinit()
3197 "suspend!\n", wlc_hw->unit); in brcms_b_coreinit()
3203 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_b_coreinit()
3204 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_coreinit()
3205 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); in brcms_b_coreinit()
3208 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3209 wlc_hw->corerev); in brcms_b_coreinit()
3210 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_b_coreinit()
3211 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_b_coreinit()
3212 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); in brcms_b_coreinit()
3215 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3216 wlc_hw->corerev); in brcms_b_coreinit()
3219 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_b_coreinit()
3228 if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { in brcms_b_coreinit()
3230 err = -1; in brcms_b_coreinit()
3233 if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { in brcms_b_coreinit()
3235 err = -1; in brcms_b_coreinit()
3240 if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { in brcms_b_coreinit()
3242 err = -1; in brcms_b_coreinit()
3244 if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { in brcms_b_coreinit()
3246 err = -1; in brcms_b_coreinit()
3251 if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { in brcms_b_coreinit()
3253 err = -1; in brcms_b_coreinit()
3255 if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { in brcms_b_coreinit()
3257 err = -1; in brcms_b_coreinit()
3262 wlc_hw->xmtfifo_sz[i], i); in brcms_b_coreinit()
3267 /* band-specific inits done by wlc_bsinit() */ in brcms_b_coreinit()
3296 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3297 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3300 brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); in brcms_b_coreinit()
3304 (u16) (wlc_hw->machwcap & 0xffff)); in brcms_b_coreinit()
3306 (u16) ((wlc_hw-> in brcms_b_coreinit()
3313 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_coreinit()
3317 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_coreinit()
3320 brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); in brcms_b_coreinit()
3321 brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); in brcms_b_coreinit()
3328 if (wlc_hw->di[i]) in brcms_b_coreinit()
3329 dma_txinit(wlc_hw->di[i]); in brcms_b_coreinit()
3333 dma_rxinit(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3334 dma_rxfill(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3341 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init()
3344 fastclk = wlc_hw->forcefastclk; in brcms_b_init()
3349 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3353 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_init()
3355 /* do one-time phy inits and calibration */ in brcms_b_init()
3356 wlc_phy_cal_init(wlc_hw->band->pi); in brcms_b_init()
3358 /* core-specific initialization */ in brcms_b_init()
3361 /* band-specific inits */ in brcms_b_init()
3365 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3370 mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); in brcms_b_init()
3376 wlc_hw->mac_suspend_depth = 1; in brcms_b_init()
3387 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3390 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3392 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3393 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3396 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3402 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3403 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3404 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3405 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3406 wlc->stf->txstreams); in brcms_default_rateset()
3409 /* derive wlc->band->basic_rate[] table from 'rateset' */
3417 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3426 for (i = 0; i < rateset->count; i++) { in brcms_c_rate_lookup_init()
3428 if (!(rateset->rates[i] & BRCMS_RATE_FLAG)) in brcms_c_rate_lookup_init()
3432 rate = (rateset->rates[i] & BRCMS_RATE_MASK); in brcms_c_rate_lookup_init()
3435 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3437 rateset->rates[i]); in brcms_c_rate_lookup_init()
3444 /* The rate lookup table now has non-zero entries for each in brcms_c_rate_lookup_init()
3451 * basic_rate = wlc->band->basic_rate[tx_rate] in brcms_c_rate_lookup_init()
3458 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3459 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3496 /* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ in brcms_c_rate_lookup_init()
3513 * power-cycled (hibernate). Figure out the right band to park on in brcms_c_bandinit_ordered()
3515 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3517 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3529 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3532 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3537 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3539 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3557 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3571 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3586 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3587 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3597 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3598 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3621 * for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_c_write_rate_shm()
3630 * Direct-map Table in brcms_c_write_rate_shm()
3632 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3634 /* Update the SHM BSS-basic-rate-set mapping table with the pointer in brcms_c_write_rate_shm()
3637 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3645 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3646 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3650 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3668 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3688 /* band-specific init */
3691 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3692 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3701 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3705 /* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */
3715 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3717 wlc->pub->unit); in brcms_c_duty_cycle_set()
3718 return -EINVAL; in brcms_c_duty_cycle_set()
3721 idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; in brcms_c_duty_cycle_set()
3724 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3727 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3729 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3743 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3746 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3751 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3756 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3765 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac()
3768 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3779 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3784 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3785 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3787 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3788 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3793 wlc_hw->shortslot = shortslot; in brcms_b_set_shortslot()
3795 if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { in brcms_b_set_shortslot()
3796 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3798 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3809 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3810 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3812 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3815 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3817 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3822 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3823 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3825 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3826 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3836 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: 0x%x\n", wlc_hw->unit, in brcms_b_set_chanspec()
3839 wlc_hw->chanspec = chanspec; in brcms_b_set_chanspec()
3842 if (wlc_hw->_nbands > 1) { in brcms_b_set_chanspec()
3844 if (wlc_hw->band->bandunit != bandunit) { in brcms_b_set_chanspec()
3848 if (wlc_hw->up) { in brcms_b_set_chanspec()
3849 wlc_phy_chanspec_radio_set(wlc_hw-> in brcms_b_set_chanspec()
3850 bandstate[bandunit]-> in brcms_b_set_chanspec()
3859 wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); in brcms_b_set_chanspec()
3861 if (!wlc_hw->up) { in brcms_b_set_chanspec()
3862 if (wlc_hw->clk) in brcms_b_set_chanspec()
3863 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, in brcms_b_set_chanspec()
3865 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3867 wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3868 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); in brcms_b_set_chanspec()
3879 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3881 if (!wlc->pub->up) in brcms_c_setband()
3887 /* band-specific initializations */ in brcms_c_setband()
3894 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3896 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3897 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3898 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3903 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3905 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3906 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3907 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3909 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3930 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3935 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3936 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3946 * ratespec CCK ant = wlc->stf->txant
3953 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3956 /* for non-siso rates or default setting, use the available chains */ in brcms_c_beacon_phytxctl_txant_upd()
3957 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3960 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3962 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3976 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
3980 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
3983 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
3986 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
3989 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
3992 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
3995 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
3998 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
4001 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
4004 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
4007 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4010 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4021 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4029 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4031 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4034 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4047 if (!wlc->clk) { in brcms_c_wme_setparams()
4048 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4049 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4055 acp_shm.txop = params->txop; in brcms_c_wme_setparams()
4057 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4059 acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); in brcms_c_wme_setparams()
4067 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4068 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4070 acp_shm.cwmin = params->cw_min; in brcms_c_wme_setparams()
4071 acp_shm.cwmax = params->cw_max; in brcms_c_wme_setparams()
4074 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4078 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4087 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4118 aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; in brcms_c_edcf_setparams()
4121 txq_pars.txop = edcf_acp->TXOP; in brcms_c_edcf_setparams()
4122 txq_pars.aifs = edcf_acp->ACI; in brcms_c_edcf_setparams()
4124 /* CWmin = 2^(ECWmin) - 1 */ in brcms_c_edcf_setparams()
4125 txq_pars.cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); in brcms_c_edcf_setparams()
4126 /* CWmax = 2^(ECWmax) - 1 */ in brcms_c_edcf_setparams()
4127 txq_pars.cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) in brcms_c_edcf_setparams()
4141 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4144 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4145 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4146 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4151 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4154 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4155 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4156 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4162 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4165 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4166 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4168 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4176 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4186 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4187 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4188 brcms_down(wlc->wl); in brcms_c_radio_timer()
4195 /* common low-level watchdog code */
4198 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4200 if (!wlc_hw->up) in brcms_b_watchdog()
4204 wlc_hw->now++; in brcms_b_watchdog()
4210 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4212 wlc_phy_watchdog(wlc_hw->band->pi); in brcms_b_watchdog()
4218 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4220 if (!wlc->pub->up) in brcms_c_watchdog()
4224 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4225 wlc->pub->unit, __func__); in brcms_c_watchdog()
4226 brcms_down(wlc->wl); in brcms_c_watchdog()
4231 wlc->pub->now++; in brcms_c_watchdog()
4235 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4242 * detect 16-bit counter wrap in brcms_c_watchdog()
4244 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4247 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4248 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4250 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4264 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4266 if (!wlc->wdtimer) { in brcms_c_timers_init()
4267 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4272 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4274 if (!wlc->radio_timer) { in brcms_c_timers_init()
4275 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4295 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4298 wlc->shortslot = false; in brcms_c_info_init()
4299 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4316 wlc->include_legacy_erp = true; in brcms_c_info_init()
4318 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4319 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4321 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4323 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4325 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4326 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4329 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4330 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4333 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4334 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4337 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4344 unit = wlc->pub->unit; in brcms_c_attach_module()
4346 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4347 if (wlc->asi == NULL) { in brcms_c_attach_module()
4348 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4354 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4355 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4356 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4363 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4374 return wlc->pub; in brcms_c_pub()
4391 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4392 struct pci_dev *pcidev = core->bus->host_pci; in brcms_b_attach()
4393 struct ssb_sprom *sprom = &core->bus->sprom; in brcms_b_attach()
4395 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) in brcms_b_attach()
4397 pcidev->vendor, in brcms_b_attach()
4398 pcidev->device); in brcms_b_attach()
4401 core->bus->boardinfo.vendor, in brcms_b_attach()
4402 core->bus->boardinfo.type); in brcms_b_attach()
4406 wlc_hw = wlc->hw; in brcms_b_attach()
4407 wlc_hw->wlc = wlc; in brcms_b_attach()
4408 wlc_hw->unit = unit; in brcms_b_attach()
4409 wlc_hw->band = wlc_hw->bandstate[0]; in brcms_b_attach()
4410 wlc_hw->_piomode = piomode; in brcms_b_attach()
4419 wlc_hw->sih = ai_attach(core->bus); in brcms_b_attach()
4420 if (wlc_hw->sih == NULL) { in brcms_b_attach()
4435 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) { in brcms_b_attach()
4436 wlc_hw->vendorid = pcidev->vendor; in brcms_b_attach()
4437 wlc_hw->deviceid = pcidev->device; in brcms_b_attach()
4439 wlc_hw->vendorid = core->bus->boardinfo.vendor; in brcms_b_attach()
4440 wlc_hw->deviceid = core->bus->boardinfo.type; in brcms_b_attach()
4443 wlc_hw->d11core = core; in brcms_b_attach()
4444 wlc_hw->corerev = core->id.rev; in brcms_b_attach()
4453 ai_clkctl_init(wlc_hw->sih); in brcms_b_attach()
4457 * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk in brcms_b_attach()
4472 j = sprom->board_rev; in brcms_b_attach()
4476 wlc_hw->boardrev = (u16) j; in brcms_b_attach()
4480 unit, ai_get_boardtype(wlc_hw->sih), in brcms_b_attach()
4481 wlc_hw->boardrev); in brcms_b_attach()
4485 wlc_hw->sromrev = sprom->revision; in brcms_b_attach()
4486 wlc_hw->boardflags = sprom->boardflags_lo + (sprom->boardflags_hi << 16); in brcms_b_attach()
4487 wlc_hw->boardflags2 = sprom->boardflags2_lo + (sprom->boardflags2_hi << 16); in brcms_b_attach()
4489 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_b_attach()
4493 if (wlc_hw->deviceid == BCM43224_D11N_ID || in brcms_b_attach()
4494 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1 || in brcms_b_attach()
4495 wlc_hw->deviceid == BCM43224_CHIP_ID) in brcms_b_attach()
4497 wlc_hw->_nbands = 2; in brcms_b_attach()
4499 wlc_hw->_nbands = 1; in brcms_b_attach()
4501 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) in brcms_b_attach()
4502 wlc_hw->_nbands = 1; in brcms_b_attach()
4507 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4508 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4509 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4510 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4511 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4512 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4513 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4514 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4515 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4517 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4519 if (wlc_hw->physhim == NULL) { in brcms_b_attach()
4527 sha_params.sih = wlc_hw->sih; in brcms_b_attach()
4528 sha_params.physhim = wlc_hw->physhim; in brcms_b_attach()
4530 sha_params.corerev = wlc_hw->corerev; in brcms_b_attach()
4531 sha_params.vid = wlc_hw->vendorid; in brcms_b_attach()
4532 sha_params.did = wlc_hw->deviceid; in brcms_b_attach()
4533 sha_params.chip = ai_get_chip_id(wlc_hw->sih); in brcms_b_attach()
4534 sha_params.chiprev = ai_get_chiprev(wlc_hw->sih); in brcms_b_attach()
4535 sha_params.chippkg = ai_get_chippkg(wlc_hw->sih); in brcms_b_attach()
4536 sha_params.sromrev = wlc_hw->sromrev; in brcms_b_attach()
4537 sha_params.boardtype = ai_get_boardtype(wlc_hw->sih); in brcms_b_attach()
4538 sha_params.boardrev = wlc_hw->boardrev; in brcms_b_attach()
4539 sha_params.boardflags = wlc_hw->boardflags; in brcms_b_attach()
4540 sha_params.boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4543 wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); in brcms_b_attach()
4544 if (!wlc_hw->phy_sh) { in brcms_b_attach()
4550 for (j = 0; j < wlc_hw->_nbands; j++) { in brcms_b_attach()
4558 wlc_hw->band->bandunit = j; in brcms_b_attach()
4559 wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4560 wlc->band->bandunit = j; in brcms_b_attach()
4561 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4562 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4564 wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); in brcms_b_attach()
4565 wlc_hw->machwcap_backup = wlc_hw->machwcap; in brcms_b_attach()
4568 WARN_ON(wlc_hw->corerev < XMTFIFOTBL_STARTREV || in brcms_b_attach()
4569 (wlc_hw->corerev - XMTFIFOTBL_STARTREV) > in brcms_b_attach()
4571 wlc_hw->xmtfifo_sz = in brcms_b_attach()
4572 xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; in brcms_b_attach()
4573 WARN_ON(!wlc_hw->xmtfifo_sz[0]); in brcms_b_attach()
4576 wlc_hw->band->pi = in brcms_b_attach()
4577 wlc_phy_attach(wlc_hw->phy_sh, core, in brcms_b_attach()
4578 wlc_hw->band->bandtype, in brcms_b_attach()
4579 wlc->wiphy); in brcms_b_attach()
4580 if (wlc_hw->band->pi == NULL) { in brcms_b_attach()
4587 wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); in brcms_b_attach()
4589 wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, in brcms_b_attach()
4590 &wlc_hw->band->phyrev, in brcms_b_attach()
4591 &wlc_hw->band->radioid, in brcms_b_attach()
4592 &wlc_hw->band->radiorev); in brcms_b_attach()
4593 wlc_hw->band->abgphy_encore = in brcms_b_attach()
4594 wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4595 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4596 wlc_hw->band->core_flags = in brcms_b_attach()
4597 wlc_phy_get_coreflags(wlc_hw->band->pi); in brcms_b_attach()
4600 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_b_attach()
4601 if (NCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4605 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_attach()
4606 if (LCNCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4614 wlc_hw->band->phytype, wlc_hw->band->phyrev); in brcms_b_attach()
4621 * BMAC_NOTE: wlc->band->pi should not be set below and should in brcms_b_attach()
4624 * wlc_hw->band->pi. Instead do the wlc->band->pi init below, in brcms_b_attach()
4625 * keeping wlc_hw->band->pi as well for incremental update of in brcms_b_attach()
4629 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4630 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4631 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4632 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4633 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4635 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4636 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4638 wlc_hw->band->CWmin = APHY_CWMIN; in brcms_b_attach()
4639 wlc_hw->band->CWmax = PHY_CWMAX; in brcms_b_attach()
4651 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_attach()
4661 * Beyond this point, wlc->sbclk == false and chip registers in brcms_b_attach()
4667 brcms_c_get_macaddr(wlc_hw, wlc_hw->etheraddr); in brcms_b_attach()
4669 if (is_broadcast_ether_addr(wlc_hw->etheraddr) || in brcms_b_attach()
4670 is_zero_ether_addr(wlc_hw->etheraddr)) { in brcms_b_attach()
4677 brcms_dbg_info(wlc_hw->d11core, "deviceid 0x%x nbands %d board 0x%x\n", in brcms_b_attach()
4678 wlc_hw->deviceid, wlc_hw->_nbands, in brcms_b_attach()
4679 ai_get_boardtype(wlc_hw->sih)); in brcms_b_attach()
4694 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4696 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4697 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4701 aa = sprom->ant_available_a; in brcms_c_attach_stf_ant_init()
4703 aa = sprom->ant_available_bg; in brcms_c_attach_stf_ant_init()
4706 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4713 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4714 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4716 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4717 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4723 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4725 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4734 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4738 bi->beacon_period = BEACON_INTERVAL_DEFAULT; in brcms_c_bss_default_init()
4744 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4747 band = wlc->band; in brcms_c_bss_default_init()
4748 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4749 band->bandunit != chspec_bandunit(chanspec)) in brcms_c_bss_default_init()
4750 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4753 brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, in brcms_c_bss_default_init()
4754 band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_c_bss_default_init()
4755 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4756 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4758 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4759 bi->flags |= BRCMS_BSS_HT; in brcms_c_bss_default_init()
4767 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4768 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4769 if (band->bandtype == BRCM_BAND_5G) { in brcms_c_update_mimo_band_bwcap()
4772 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4774 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4777 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4779 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4787 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4788 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4789 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4791 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4792 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4793 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4799 if (wlc->asi) { in brcms_c_detach_module()
4800 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4801 wlc->asi = NULL; in brcms_c_detach_module()
4804 if (wlc->ampdu) { in brcms_c_detach_module()
4805 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4806 wlc->ampdu = NULL; in brcms_c_detach_module()
4819 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4823 band = wlc_hw->band; in brcms_b_detach()
4824 for (i = 0; i < wlc_hw->_nbands; i++) { in brcms_b_detach()
4825 if (band->pi) { in brcms_b_detach()
4827 wlc_phy_detach(band->pi); in brcms_b_detach()
4828 band->pi = NULL; in brcms_b_detach()
4830 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4834 kfree(wlc_hw->phy_sh); in brcms_b_detach()
4836 wlc_phy_shim_detach(wlc_hw->physhim); in brcms_b_detach()
4838 if (wlc_hw->sih) { in brcms_b_detach()
4839 ai_detach(wlc_hw->sih); in brcms_b_detach()
4840 wlc_hw->sih = NULL; in brcms_b_detach()
4868 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4881 /* STA-BSS; short capable */ in brcms_c_ap_upd()
4882 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4888 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4891 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_hw_up()
4898 ai_clkctl_init(wlc_hw->sih); in brcms_b_hw_up()
4912 wlc_phy_por_inform(wlc_hw->band->pi); in brcms_b_hw_up()
4914 wlc_hw->ucode_loaded = false; in brcms_b_hw_up()
4915 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4917 if ((wlc_hw->boardflags & BFL_FEM) in brcms_b_hw_up()
4918 && (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_hw_up()
4920 (wlc_hw->boardrev >= 0x1250 in brcms_b_hw_up()
4921 && (wlc_hw->boardflags & BFL_FEM_BT))) in brcms_b_hw_up()
4922 ai_epa_4313war(wlc_hw->sih); in brcms_b_hw_up()
4928 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_up_prep()
4935 ai_clkctl_init(wlc_hw->sih); in brcms_b_up_prep()
4942 bcma_host_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core, in brcms_b_up_prep()
4952 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_up_prep()
4954 return -ENOMEDIUM; in brcms_b_up_prep()
4957 bcma_host_pci_up(wlc_hw->d11core->bus); in brcms_b_up_prep()
4967 wlc_hw->up = true; in brcms_b_up_finish()
4968 wlc_phy_hw_state_upd(wlc_hw->band->pi, true); in brcms_b_up_finish()
4972 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
4985 if (!wlc->clk) in brcms_c_wme_retries_write()
4989 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
4990 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
4998 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
5001 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
5002 return -ENOMEDIUM; in brcms_c_up()
5004 if (!wlc->pub->hw_up) { in brcms_c_up()
5005 brcms_b_hw_up(wlc->hw); in brcms_c_up()
5006 wlc->pub->hw_up = true; in brcms_c_up()
5009 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5010 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5011 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5012 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5013 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5016 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5027 * brcms_b_up_prep() returns either 0 or -BCME_RADIOOFF only in brcms_c_up()
5029 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5030 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5031 if (status == -ENOMEDIUM) { in brcms_c_up()
5033 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5034 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5035 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5037 if (bsscfg->type == BRCMS_TYPE_STATION || in brcms_c_up()
5038 bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_up()
5039 brcms_err(wlc->hw->d11core, in brcms_c_up()
5040 "wl%d: up: rfdisable -> " in brcms_c_up()
5042 wlc->pub->unit); in brcms_c_up()
5047 if (wlc->pub->radio_disabled) { in brcms_c_up()
5053 wlc->clk = true; in brcms_c_up()
5058 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5060 brcms_init(wlc->wl); in brcms_c_up()
5061 wlc->pub->up = true; in brcms_c_up()
5063 if (wlc->bandinit_pending) { in brcms_c_up()
5064 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5066 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5067 wlc->bandinit_pending = false; in brcms_c_up()
5071 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5077 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5078 wlc->WDarmed = true; in brcms_c_up()
5083 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5093 if (!wlc_hw->up) in brcms_b_bmac_down_prep()
5096 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5100 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5103 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5109 callbacks += wlc_phy_down(wlc_hw->band->pi); in brcms_b_bmac_down_prep()
5119 if (!wlc_hw->up) in brcms_b_down_finish()
5122 wlc_hw->up = false; in brcms_b_down_finish()
5123 wlc_phy_hw_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5125 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5128 wlc_hw->sbclk = false; in brcms_b_down_finish()
5129 wlc_hw->clk = false; in brcms_b_down_finish()
5130 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5133 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5137 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_down_finish()
5138 if (bcma_read32(wlc_hw->d11core, in brcms_b_down_finish()
5140 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5141 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5146 if (!wlc_hw->noreset) { in brcms_b_down_finish()
5147 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_down_finish()
5166 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5169 if (wlc->going_down) { in brcms_c_down()
5170 brcms_err(wlc->hw->d11core, in brcms_c_down()
5172 wlc->pub->unit, __func__); in brcms_c_down()
5175 if (!wlc->pub->up) in brcms_c_down()
5178 wlc->going_down = true; in brcms_c_down()
5180 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5186 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5188 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5192 if (wlc->WDarmed) { in brcms_c_down()
5193 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5195 wlc->WDarmed = false; in brcms_c_down()
5198 wlc->pub->up = false; in brcms_c_down()
5200 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5202 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5205 wlc->clk = false; in brcms_c_down()
5207 wlc->going_down = false; in brcms_c_down()
5218 /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ in brcms_c_set_gmode()
5223 /* if N-support is enabled, allow Gmode set as long as requested in brcms_c_set_gmode()
5226 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5227 return -ENOTSUPP; in brcms_c_set_gmode()
5230 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5231 band = wlc->band; in brcms_c_set_gmode()
5232 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5233 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5234 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5236 return -EINVAL; in brcms_c_set_gmode()
5270 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5271 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5272 return -ENOTSUPP; in brcms_c_set_gmode()
5275 band->gmode = gmode; in brcms_c_set_gmode()
5277 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5293 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5294 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5295 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5305 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5313 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5315 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5316 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5318 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5319 wlc->stf->txstreams); in brcms_c_set_nmode()
5320 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5321 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5322 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5338 return -EINVAL; in brcms_c_set_internal_rateset()
5341 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5344 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5345 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5353 &wlc-> in brcms_c_set_internal_rateset()
5354 bandstate[bandunit]-> in brcms_c_set_internal_rateset()
5356 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5360 return -EBADE; in brcms_c_set_internal_rateset()
5364 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5366 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5373 wlc_phy_ofdm_rateset_war(wlc->band->pi, false); in brcms_c_ofdm_rateset_war()
5381 return -EINVAL; in brcms_c_set_channel()
5383 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5384 return -EINVAL; in brcms_c_set_channel()
5387 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5388 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5389 wlc->bandinit_pending = true; in brcms_c_set_channel()
5391 wlc->bandinit_pending = false; in brcms_c_set_channel()
5394 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5397 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5412 return -EINVAL; in brcms_c_set_rate_limit()
5414 wlc->SRL = srl; in brcms_c_set_rate_limit()
5415 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5417 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5420 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5421 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5422 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5423 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5435 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5436 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5438 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5441 currs->count = rs->count; in brcms_c_get_current_rateset()
5442 memcpy(&currs->rates, &rs->rates, rs->count); in brcms_c_get_current_rateset()
5450 if (rs->count > BRCMS_NUMRATES) in brcms_c_set_rateset()
5451 return -ENOBUFS; in brcms_c_set_rateset()
5456 internal_rs.count = rs->count; in brcms_c_set_rateset()
5457 memcpy(&internal_rs.rates, &rs->rates, internal_rs.count); in brcms_c_set_rateset()
5460 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5462 if (wlc->pub->associated) in brcms_c_set_rateset()
5463 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5465 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5466 memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], in brcms_c_set_rateset()
5479 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5481 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5486 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5488 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5496 return -EINVAL; in brcms_c_set_beacon_period()
5498 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5502 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5504 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5512 return wlc->band->phytype; in brcms_c_get_phy_type()
5517 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5523 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5526 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5528 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5534 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5535 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5537 wlc->shortslot = in brcms_c_set_shortslot_override()
5538 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5550 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register()
5555 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5556 strncpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5557 sizeof(wlc->modulecb[i].name) - 1); in brcms_c_module_register()
5558 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5559 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5564 return -ENOSR; in brcms_c_module_register()
5571 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister()
5575 return -ENODATA; in brcms_c_module_unregister()
5578 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5579 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5580 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5586 return -ENODATA; in brcms_c_module_unregister()
5591 struct pci_dev *pcidev = core->bus->host_pci; in brcms_c_chipmatch_pci()
5592 u16 vendor = pcidev->vendor; in brcms_c_chipmatch_pci()
5593 u16 device = pcidev->device; in brcms_c_chipmatch_pci()
5615 struct bcma_chipinfo *chipinfo = &core->bus->chipinfo; in brcms_c_chipmatch_soc()
5617 if (chipinfo->id == BCMA_CHIP_ID_BCM4716) in brcms_c_chipmatch_soc()
5620 pr_err("unknown chip id %04x\n", chipinfo->id); in brcms_c_chipmatch_soc()
5626 switch (core->bus->hosttype) { in brcms_c_chipmatch()
5632 pr_err("unknown host type: %i\n", core->bus->hosttype); in brcms_c_chipmatch()
5648 /* for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_b_rate_shm_offset()
5655 * Direct-map Table in brcms_b_rate_shm_offset()
5671 frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK | in bcmc_fid_generate()
5674 (((wlc-> in bcmc_fid_generate()
5739 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5767 dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); in brcms_c_calc_frame_len()
5769 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5770 dur -= DOT11_OFDM_SIGNAL_EXTENSION; in brcms_c_calc_frame_len()
5776 ((nsyms * kNdps) - in brcms_c_calc_frame_len()
5779 dur -= APHY_PREAMBLE_TIME; in brcms_c_calc_frame_len()
5780 dur -= APHY_SIGNAL_TIME; in brcms_c_calc_frame_len()
5785 ((nsyms * Ndps) - in brcms_c_calc_frame_len()
5789 dur -= BPHY_PLCP_SHORT_TIME; in brcms_c_calc_frame_len()
5791 dur -= BPHY_PLCP_TIME; in brcms_c_calc_frame_len()
5809 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5810 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5811 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5812 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5822 return isset(hw_rateset->mcs, (rspec & RSPEC_RATE_MASK)); in brcms_c_valid_rate()
5825 for (i = 0; i < hw_rateset->count; i++) in brcms_c_valid_rate()
5826 if (hw_rateset->rates[i] == rspec2rate(rspec)) in brcms_c_valid_rate()
5830 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5831 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5840 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5853 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5857 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5863 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5867 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5876 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5881 * MCS 0-7 may use SISO, CDD, and for in mac80211_wlc_set_nrate()
5888 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5895 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5899 if ((cur_band->bandtype != BRCM_BAND_2G) in mac80211_wlc_set_nrate()
5902 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5907 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5910 /* make sure multiple antennae are available for non-siso rates */ in mac80211_wlc_set_nrate()
5911 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5913 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5937 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
5967 if ((length << 4) - (usec * 11) > 0) in brcms_c_cck_plcp_set()
5972 if ((length << 3) - (usec * 11) > 0) { in brcms_c_cck_plcp_set()
5974 if ((usec * 11) - (length << 3) >= 8) in brcms_c_cck_plcp_set()
5980 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
6022 * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb in brcms_c_compute_ofdm_plcp()
6060 * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK
6062 * cts cts-to-self or rts/cts
6075 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6084 /* CTS-TO-SELF */ in brcms_c_compute_rtscts_dur()
6107 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6113 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6122 /* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ in brcms_c_phytxctl1_calc()
6126 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6127 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6139 if (phycfg == -1) { in brcms_c_phytxctl1_calc()
6140 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6198 h = (struct ieee80211_hdr *)(p->data); in brcms_c_d11hdrs_mac80211()
6199 qos = ieee80211_is_data_qos(h->frame_control); in brcms_c_d11hdrs_mac80211()
6202 len = p->len; in brcms_c_d11hdrs_mac80211()
6216 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { in brcms_c_d11hdrs_mac80211()
6217 /* non-AP STA should never use BCMC queue */ in brcms_c_d11hdrs_mac80211()
6219 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6221 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6225 if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in brcms_c_d11hdrs_mac80211()
6226 scb->seqnum[p->priority]++; in brcms_c_d11hdrs_mac80211()
6229 seq = le16_to_cpu(h->seq_ctrl) & FRAGNUM_MASK; in brcms_c_d11hdrs_mac80211()
6230 seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); in brcms_c_d11hdrs_mac80211()
6231 h->seq_ctrl = cpu_to_le16(seq); in brcms_c_d11hdrs_mac80211()
6240 if (ieee80211_is_beacon(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6243 txrate[0] = tx_info->control.rates; in brcms_c_d11hdrs_mac80211()
6250 if (txrate[1]->idx < 0) in brcms_c_d11hdrs_mac80211()
6253 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6254 is_mcs = txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; in brcms_c_d11hdrs_mac80211()
6256 if ((txrate[k]->idx >= 0) in brcms_c_d11hdrs_mac80211()
6257 && (txrate[k]->idx < in brcms_c_d11hdrs_mac80211()
6258 hw->wiphy->bands[tx_info->band]->n_bitrates)) { in brcms_c_d11hdrs_mac80211()
6260 hw->wiphy->bands[tx_info->band]-> in brcms_c_d11hdrs_mac80211()
6261 bitrates[txrate[k]->idx].hw_value; in brcms_c_d11hdrs_mac80211()
6266 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6267 NRATE_MCS_INUSE | txrate[k]->idx); in brcms_c_d11hdrs_mac80211()
6276 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6279 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6291 if (!is_multicast_ether_addr(h->addr1)) { in brcms_c_d11hdrs_mac80211()
6293 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6299 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6301 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6302 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6333 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6337 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6347 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6348 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6350 else if (scb->flags & SCB_IS40) in brcms_c_d11hdrs_mac80211()
6353 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6354 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6355 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6356 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6382 if (txrate[k]->flags & IEEE80211_TX_RC_GREEN_FIELD) in brcms_c_d11hdrs_mac80211()
6385 if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) in brcms_c_d11hdrs_mac80211()
6387 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6389 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6407 && (tx_info->control.rates[0]. in brcms_c_d11hdrs_mac80211()
6412 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6418 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6426 txrate[0]->count = 0; in brcms_c_d11hdrs_mac80211()
6427 txrate[1]->count = 0; in brcms_c_d11hdrs_mac80211()
6430 if ((ieee80211_is_data(h->frame_control) || in brcms_c_d11hdrs_mac80211()
6431 ieee80211_is_mgmt(h->frame_control)) && in brcms_c_d11hdrs_mac80211()
6432 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6439 memcpy(&txh->FragPLCPFallback, in brcms_c_d11hdrs_mac80211()
6440 plcp_fallback, sizeof(txh->FragPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6444 txh->FragPLCPFallback[4] = phylen & 0xff; in brcms_c_d11hdrs_mac80211()
6445 txh->FragPLCPFallback[5] = (phylen & 0xff00) >> 8; in brcms_c_d11hdrs_mac80211()
6448 /* MIMO-RATE: need validation ?? */ in brcms_c_d11hdrs_mac80211()
6454 if (!ieee80211_is_pspoll(h->frame_control) && in brcms_c_d11hdrs_mac80211()
6455 !is_multicast_ether_addr(h->addr1) && !use_rifs) { in brcms_c_d11hdrs_mac80211()
6459 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6467 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6471 if (ieee80211_is_pspoll(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6472 txh->FragDurFallback = h->duration_id; in brcms_c_d11hdrs_mac80211()
6473 else if (is_multicast_ether_addr(h->addr1) || use_rifs) in brcms_c_d11hdrs_mac80211()
6474 txh->FragDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6478 txh->FragDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6481 /* (4) MAC-HDR: MacTxControlLow */ in brcms_c_d11hdrs_mac80211()
6485 if (!is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6488 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6491 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6498 txh->MacTxControlLow = cpu_to_le16(mcl); in brcms_c_d11hdrs_mac80211()
6511 memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16)); in brcms_c_d11hdrs_mac80211()
6512 txh->TxFesTimeNormal = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6514 txh->TxFesTimeFallback = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6517 memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6520 txh->TxFrameID = cpu_to_le16(frameid); in brcms_c_d11hdrs_mac80211()
6526 txh->TxStatus = cpu_to_le16(status); in brcms_c_d11hdrs_mac80211()
6532 txh->MaxNMpdus = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6533 txh->MaxABytes_MRT = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6534 txh->MaxABytes_FBR = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6535 txh->MinMBytes = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6552 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6559 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6566 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS); in brcms_c_d11hdrs_mac80211()
6568 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS); in brcms_c_d11hdrs_mac80211()
6569 txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME); in brcms_c_d11hdrs_mac80211()
6573 rts_plcp = txh->RTSPhyHeader; in brcms_c_d11hdrs_mac80211()
6584 memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback, in brcms_c_d11hdrs_mac80211()
6585 sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6588 rts = (struct ieee80211_rts *)&txh->rts_frame; in brcms_c_d11hdrs_mac80211()
6593 rts->duration = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6599 txh->RTSDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6602 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6605 memcpy(&rts->ra, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6607 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6610 memcpy(&rts->ra, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6611 memcpy(&rts->ta, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6623 memset(txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN); in brcms_c_d11hdrs_mac80211()
6624 memset(&txh->rts_frame, 0, sizeof(struct ieee80211_rts)); in brcms_c_d11hdrs_mac80211()
6625 memset(txh->RTSPLCPFallback, 0, sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6626 txh->RTSDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6631 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && is_mcs_rate(rspec)) in brcms_c_d11hdrs_mac80211()
6632 txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = in brcms_c_d11hdrs_mac80211()
6633 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6641 txh->MacTxControlHigh = cpu_to_le16(mch); in brcms_c_d11hdrs_mac80211()
6647 txh->MainRates = cpu_to_le16(mainrates); in brcms_c_d11hdrs_mac80211()
6650 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6651 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6652 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6653 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6655 txh->XtraFrameTypes = cpu_to_le16(xfts); in brcms_c_d11hdrs_mac80211()
6658 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6667 txh->PhyTxControlWord = cpu_to_le16(phyctl); in brcms_c_d11hdrs_mac80211()
6670 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6674 txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6676 txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6680 txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6682 txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6687 * is going to be set, fill in non-zero MModeLen and/or in brcms_c_d11hdrs_mac80211()
6694 txh->MModeLen = cpu_to_le16(mmodelen); in brcms_c_d11hdrs_mac80211()
6701 txh->MModeFbrLen = cpu_to_le16(mmodefbrlen); in brcms_c_d11hdrs_mac80211()
6706 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6710 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU) && frag == 0) { in brcms_c_d11hdrs_mac80211()
6716 /* 1 RTS or CTS-to-self frame */ in brcms_c_d11hdrs_mac80211()
6724 dur += le16_to_cpu(rts->duration); in brcms_c_d11hdrs_mac80211()
6726 le16_to_cpu(txh->RTSDurFallback); in brcms_c_d11hdrs_mac80211()
6746 txh->TxFesTimeNormal = cpu_to_le16((u16) dur); in brcms_c_d11hdrs_mac80211()
6751 txh->TxFesTimeFallback = in brcms_c_d11hdrs_mac80211()
6758 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6764 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6765 (dur - frag_dur))); in brcms_c_d11hdrs_mac80211()
6771 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6773 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6775 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6777 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6780 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6782 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6786 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6787 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6789 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6791 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6792 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6802 int fifo, ret = -ENOSPC; in brcms_c_tx()
6807 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6808 txh = (struct d11txh *)(skb->data); in brcms_c_tx()
6810 if (dma->txavail == 0) { in brcms_c_tx()
6820 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6822 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6824 return -ENOSPC; in brcms_c_tx()
6831 frameid = le16_to_cpu(txh->TxFrameID); in brcms_c_tx()
6839 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6857 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6872 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6878 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6886 if (dma->txavail <= TX_HEADROOM && fifo < TX_BCMC_FIFO && in brcms_c_txfifo()
6887 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6888 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6902 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6918 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6934 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
6944 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
6945 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
6947 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
6948 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
6955 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_tsf()
6969 * |<---------- tsf_h ----------->||<--- tsf_l -->||<-RxTSFTime ->|
6982 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
6985 rx_tsf_0_15 = rxh->RxTSFTime; in brcms_c_recover_tsf64()
6992 rx_tsf_16_31 -= 1; in brcms_c_recover_tsf64()
6994 tsf_h -= 1; in brcms_c_recover_tsf64()
7010 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7011 rx_status->flag |= RX_FLAG_MACTIME_START; in prep_mac80211_status()
7013 channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); in prep_mac80211_status()
7015 rx_status->band = in prep_mac80211_status()
7017 rx_status->freq = in prep_mac80211_status()
7018 ieee80211_channel_to_frequency(channel, rx_status->band); in prep_mac80211_status()
7020 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7024 rx_status->antenna = in prep_mac80211_status()
7025 (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; in prep_mac80211_status()
7027 plcp = p->data; in prep_mac80211_status()
7031 rx_status->rate_idx = rspec & RSPEC_RATE_MASK; in prep_mac80211_status()
7032 rx_status->encoding = RX_ENC_HT; in prep_mac80211_status()
7034 rx_status->bw = RATE_INFO_BW_40; in prep_mac80211_status()
7038 rx_status->rate_idx = 0; in prep_mac80211_status()
7041 rx_status->rate_idx = 1; in prep_mac80211_status()
7044 rx_status->rate_idx = 2; in prep_mac80211_status()
7047 rx_status->rate_idx = 3; in prep_mac80211_status()
7050 rx_status->rate_idx = 4; in prep_mac80211_status()
7053 rx_status->rate_idx = 5; in prep_mac80211_status()
7056 rx_status->rate_idx = 6; in prep_mac80211_status()
7059 rx_status->rate_idx = 7; in prep_mac80211_status()
7062 rx_status->rate_idx = 8; in prep_mac80211_status()
7065 rx_status->rate_idx = 9; in prep_mac80211_status()
7068 rx_status->rate_idx = 10; in prep_mac80211_status()
7071 rx_status->rate_idx = 11; in prep_mac80211_status()
7074 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7083 if (rx_status->band == NL80211_BAND_5GHZ) in prep_mac80211_status()
7084 rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; in prep_mac80211_status()
7088 if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) in prep_mac80211_status()
7089 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7091 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7093 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7099 rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in prep_mac80211_status()
7101 if (rxh->RxStatus1 & RXS_DECERR) { in prep_mac80211_status()
7102 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; in prep_mac80211_status()
7103 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7106 if (rxh->RxStatus1 & RXS_FCSERR) { in prep_mac80211_status()
7107 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; in prep_mac80211_status()
7108 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7125 len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN; in brcms_c_recvctl()
7130 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7131 hdr = (struct ieee80211_hdr *)p->data; in brcms_c_recvctl()
7132 if (ieee80211_is_beacon(hdr->frame_control)) in brcms_c_recvctl()
7133 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7137 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7140 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
7144 * len = 3(nsyms + nstream + 3) - 3
7176 /* (+3) account for HT-SIG(2) and HT-STF(1) */ in brcms_c_calc_lsig_len()
7180 * (-3) excluding service bits and tail bits in brcms_c_calc_lsig_len()
7182 len = (3 * nsyms) - 3; in brcms_c_calc_lsig_len()
7199 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7204 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7213 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7227 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7229 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7231 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7246 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7247 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7252 len = min_t(size_t, beacon->len, BCN_TMPL_LEN); in brcms_c_beacon_write()
7253 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7255 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7256 len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data); in brcms_c_beacon_write()
7260 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7265 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7273 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7294 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7295 struct bcma_device *core = wlc_hw->d11core; in brcms_c_update_beacon_hw()
7307 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7308 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7320 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7344 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7346 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7347 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_beacon()
7349 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7350 if (!wlc->beacon) in brcms_c_update_beacon()
7352 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7353 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7354 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7363 if (wlc->beacon) in brcms_c_set_new_beacon()
7364 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7365 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7368 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7369 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7370 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7379 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7380 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7381 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7384 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7391 * prevent ucode from sending probe responses by setting the timeout in brcms_c_enable_probe_resp()
7394 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7395 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7403 u8 *ssidptr = cfg->SSID; in brcms_c_shm_ssid_upd()
7409 memcpy(ssidbuf, ssidptr, cfg->SSID_len); in brcms_c_shm_ssid_upd()
7412 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7423 len = min_t(size_t, probe_resp->len, BCN_TMPL_LEN); in brcms_c_bss_update_probe_resp()
7429 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7430 (len + 3) & ~3, probe_resp->data); in brcms_c_bss_update_probe_resp()
7432 /* write the length of the probe response frame (+PLCP/-FCS) */ in brcms_c_bss_update_probe_resp()
7433 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7445 (u16)len + FCS_LEN - D11_PHY_HDR_LEN); in brcms_c_bss_update_probe_resp()
7453 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7456 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7457 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_probe_resp()
7458 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7460 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7469 return -EINVAL; in brcms_b_xmtfifo_sz_get()
7471 *blocks = wlc_hw->xmtfifo_sz[fifo]; in brcms_b_xmtfifo_sz_get()
7480 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7482 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7490 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7495 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7500 wlc->pub->associated = state; in brcms_c_associate_upd()
7515 dmah = hw->di[i]; in brcms_c_inval_dma_pkts()
7523 return wlc->band->bandunit; in brcms_c_get_curband()
7531 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7532 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7533 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7540 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7541 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7550 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7569 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7570 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7581 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7589 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7608 rxh = (struct d11rxhdr *) (p->data); in brcms_c_recv()
7613 /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ in brcms_c_recv()
7614 if (rxh->RxStatus1 & RXS_PBPRES) { in brcms_c_recv()
7615 if (p->len < 2) { in brcms_c_recv()
7616 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7618 wlc->pub->unit, p->len); in brcms_c_recv()
7624 h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN); in brcms_c_recv()
7625 len = p->len; in brcms_c_recv()
7627 if (rxh->RxStatus1 & RXS_FCSERR) { in brcms_c_recv()
7628 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7633 if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) in brcms_c_recv()
7636 /* not supporting A-MSDU */ in brcms_c_recv()
7637 is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; in brcms_c_recv()
7661 uint bound_limit = bound ? RXBND : -1; in brcms_b_recv()
7672 morepending = dma_rx(wlc_hw->di[fifo], &recv_frames); in brcms_b_recv()
7677 dma_rxfill(wlc_hw->di[fifo]); in brcms_b_recv()
7685 rxh_le = (struct d11rxhdr_le *)p->data; in brcms_b_recv()
7686 rxh = (struct d11rxhdr *)p->data; in brcms_b_recv()
7689 rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); in brcms_b_recv()
7690 rxh->PhyRxStatus_0 = le16_to_cpu(rxh_le->PhyRxStatus_0); in brcms_b_recv()
7691 rxh->PhyRxStatus_1 = le16_to_cpu(rxh_le->PhyRxStatus_1); in brcms_b_recv()
7692 rxh->PhyRxStatus_2 = le16_to_cpu(rxh_le->PhyRxStatus_2); in brcms_b_recv()
7693 rxh->PhyRxStatus_3 = le16_to_cpu(rxh_le->PhyRxStatus_3); in brcms_b_recv()
7694 rxh->PhyRxStatus_4 = le16_to_cpu(rxh_le->PhyRxStatus_4); in brcms_b_recv()
7695 rxh->PhyRxStatus_5 = le16_to_cpu(rxh_le->PhyRxStatus_5); in brcms_b_recv()
7696 rxh->RxStatus1 = le16_to_cpu(rxh_le->RxStatus1); in brcms_b_recv()
7697 rxh->RxStatus2 = le16_to_cpu(rxh_le->RxStatus2); in brcms_b_recv()
7698 rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); in brcms_b_recv()
7699 rxh->RxChan = le16_to_cpu(rxh_le->RxChan); in brcms_b_recv()
7701 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7707 /* second-level interrupt processing
7708 * Return true if another dpc needs to be re-scheduled. false otherwise.
7714 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7715 struct bcma_device *core = wlc_hw->d11core; in brcms_c_dpc()
7718 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_dpc()
7720 brcms_down(wlc->wl); in brcms_c_dpc()
7725 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7726 wlc->macintstatus = 0; in brcms_c_dpc()
7729 wlc_hw->unit, macintstatus); in brcms_c_dpc()
7731 WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ in brcms_c_dpc()
7736 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7737 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7750 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7751 wlc->qvalid = 0; in brcms_c_dpc()
7760 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7764 wlc_phy_noise_sample_intr(wlc_hw->band->pi); in brcms_c_dpc()
7768 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); in brcms_c_dpc()
7771 __func__, ai_get_chip_id(wlc_hw->sih), in brcms_c_dpc()
7772 ai_get_chiprev(wlc_hw->sih)); in brcms_c_dpc()
7773 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7776 /* gptimer timeout */ in brcms_c_dpc()
7782 " RF Disable Input\n", wlc_hw->unit); in brcms_c_dpc()
7783 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7790 /* it isn't done and needs to be resched if macintstatus is non-zero */ in brcms_c_dpc()
7791 return wlc->macintstatus != 0; in brcms_c_dpc()
7794 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7795 return wlc->macintstatus != 0; in brcms_c_dpc()
7800 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7801 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7804 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7806 chanspec = ch20mhz_chspec(ch->hw_value); in brcms_c_init()
7808 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7814 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7815 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7818 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7822 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7836 /* init probe response timeout */ in brcms_c_init()
7837 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7840 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7841 (wlc-> in brcms_c_init()
7845 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7846 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7852 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7854 /* band-specific inits */ in brcms_c_init()
7862 if (wlc->ucode_rev == 0) { in brcms_c_init()
7866 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7867 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7868 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7869 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7870 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7878 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7887 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7892 wlc->wme_retries[ac] = in brcms_c_init()
7893 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7913 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7914 pub = wlc->pub; in brcms_c_attach()
7920 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7921 wlc->core = wlc->corestate; in brcms_c_attach()
7922 wlc->wl = wl; in brcms_c_attach()
7923 pub->unit = unit; in brcms_c_attach()
7924 pub->_piomode = piomode; in brcms_c_attach()
7925 wlc->bandinit_pending = false; in brcms_c_attach()
7926 wlc->beacon_template_virgin = true; in brcms_c_attach()
7944 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
7947 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
7948 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
7953 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
7954 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
7957 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
7958 wlc->stf->hw_rxchain); in brcms_c_attach()
7962 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
7964 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7965 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7967 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
7968 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
7976 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
7977 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
7980 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
7981 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
7983 wlc->band->gmode); in brcms_c_attach()
7987 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
7988 pub->_n_enab = SUPPORT_11N; in brcms_c_attach()
7990 ((pub->_n_enab == in brcms_c_attach()
7995 /* init per-band default rateset, depend on band->gmode */ in brcms_c_attach()
7996 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
7999 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
8000 &wlc->band->hw_rateset, false, in brcms_c_attach()
8002 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
8007 * wlc->stf->txant/txchain/ant_rx_ovr change in brcms_c_attach()
8017 wiphy_err(wl->wiphy, "wl%d: %s: init_timer failed\n", unit, in brcms_c_attach()
8024 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8025 if (!wlc->cmi) { in brcms_c_attach()
8026 wiphy_err(wl->wiphy, "wl%d: %s: channel_mgr_attach failed" in brcms_c_attach()
8032 /* init default when all parameters are ready, i.e. ->rateset */ in brcms_c_attach()
8039 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8041 wlc->mimoft = FT_HT; in brcms_c_attach()
8042 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8043 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8044 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8051 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8058 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8066 wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n", in brcms_c_attach()