Lines Matching +full:in +full:- +full:band

3  * Copyright (c) 2013 Hauke Mehrtens <hauke@hauke-m.de>
7 * copyright notice and this permission notice appear in all copies.
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
14 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
42 /* watchdog timer, in unit of ms */
44 /* radio monitor timer, in unit of ms */
47 /* beacon interval, in unit of 1024TU */
50 /* n-mode support capability */
82 #define EDCF_ECW2CW(exp) ((1 << (exp)) - 1)
125 /* synthpu_dly times in us */
133 /* Per-AC retry limit register definitions; uses defs.h bitfield macros */
167 #define BRCMS_PLCP_AUTO -1
172 #define BRCMS_PROTECTION_AUTO -1
189 /* values for band specific 40MHz capabilities */
199 /* MSC in use,indicates b0-6 holds an mcs */
211 #define NRATE_LDPC_CODING 0x00400000 /* adv coding in use */
221 /* # of entries in Tx FIFO */
223 /* Max # of entries in Rx FIFO based on 4kb page size */
226 /* Amount of headroom to leave in Tx FIFO */
232 /* max # frames to process in brcms_c_recv() */
234 /* max # tx status to process in wlc_txstatus() */
244 * The following table lists the buffer memory allocated to xmt fifos in HW.
245 * the size is in units of 256bytes(one block), total size is HW dependent
248 * This is documented in twiki under the topic UcodeTxFifo. Please ensure
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()
373 /* currently the best mechanism for determining SIFS is the band in use */
374 static u16 get_sifs(struct brcms_band *band) in get_sifs() argument
376 return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : in get_sifs()
383 * is in reset it breaks CF address mechanism. Accessing gphy phyversion will
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()
613 * time in usec unit
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()
666 * calc # bits * 2 so factor of 2 in rate (1/2 mbps) 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()
729 "%s: wl%d: unsupported phy in corerev %d\n", 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()
739 "%s: wl%d: unsupported phy in core rev %d\n", 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()
807 /* switch to new band but leave it inactive */
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()
852 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
853 txs->frameid, txs->status, txs->lasttxtime, in brcms_c_dotxstatus()
854 txs->sequence, txs->phyerr, txs->ackphyrxsh); in brcms_c_dotxstatus()
861 if (!(txs->status & TX_STATUS_AMPDU) in brcms_c_dotxstatus()
862 && (txs->status & TX_STATUS_INTERMEDIATE)) { in brcms_c_dotxstatus()
863 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
868 queue = txs->frameid & TXFID_QUEUE_MASK; in brcms_c_dotxstatus()
870 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
874 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
876 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
878 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
882 txh = (struct d11txh *) (p->data); in brcms_c_dotxstatus()
883 mcl = le16_to_cpu(txh->MacTxControlLow); in brcms_c_dotxstatus()
885 if (txs->phyerr) in brcms_c_dotxstatus()
886 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
887 txs->phyerr, txh->MainRates); in brcms_c_dotxstatus()
889 if (txs->frameid != le16_to_cpu(txh->TxFrameID)) { in brcms_c_dotxstatus()
890 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
896 if (tx_info->rate_driver_data[0]) in brcms_c_dotxstatus()
897 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
899 if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { in brcms_c_dotxstatus()
900 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
909 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
911 supr_status = txs->status & TX_STATUS_SUPR_MASK; in brcms_c_dotxstatus()
913 unsigned xfts = le16_to_cpu(txh->XtraFrameTypes); in brcms_c_dotxstatus()
914 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
917 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
920 tx_rts = le16_to_cpu(txh->MacTxControlLow) & TXC_SENDRTS; in brcms_c_dotxstatus()
922 (txs->status & TX_STATUS_FRM_RTX_MASK) >> TX_STATUS_FRM_RTX_SHIFT; in brcms_c_dotxstatus()
924 (txs->status & TX_STATUS_RTS_RTX_MASK) >> TX_STATUS_RTS_RTX_SHIFT; in brcms_c_dotxstatus()
926 lastframe = !ieee80211_has_morefrags(h->frame_control); in brcms_c_dotxstatus()
929 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
944 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
946 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
949 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
950 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
953 txrate = tx_info->status.rates; in brcms_c_dotxstatus()
967 txrate[1].count = tx_frame_count - fbl; in brcms_c_dotxstatus()
976 * unused rates to be marked with idx = -1 in brcms_c_dotxstatus()
978 txrate[1].idx = -1; in brcms_c_dotxstatus()
984 txrate[i].idx = -1; in brcms_c_dotxstatus()
988 if (txs->status & TX_STATUS_ACK_RCV) in brcms_c_dotxstatus()
989 tx_info->flags |= IEEE80211_TX_STAT_ACK; in brcms_c_dotxstatus()
992 totlen = p->len; in brcms_c_dotxstatus()
999 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
1001 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
1011 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1018 if (dma->txavail > TX_HEADROOM && queue < TX_BCMC_FIFO && in brcms_c_dotxstatus()
1019 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1020 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1027 /* process tx completion events in BMAC
1041 uint max_tx_num = bound ? TXSBND : -1; in brcms_b_txstatus()
1044 core = wlc_hw->d11core; in brcms_b_txstatus()
1050 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_b_txstatus()
1060 txs->status = s1 & TXS_STATUS_MASK; in brcms_b_txstatus()
1061 txs->frameid = (s1 & TXS_FID_MASK) >> TXS_FID_SHIFT; in brcms_b_txstatus()
1062 txs->sequence = s2 & TXS_SEQ_MASK; in brcms_b_txstatus()
1063 txs->phyerr = (s2 & TXS_PTX_MASK) >> TXS_PTX_SHIFT; in brcms_b_txstatus()
1064 txs->lasttxtime = 0; in brcms_b_txstatus()
1066 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1077 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1082 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1089 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1096 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_c_mhfdef()
1099 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_LT(wlc_hw->band->phyrev, 2)) { in brcms_c_mhfdef()
1118 * ucode host flag 2 needed for pio mode, independent of band and fifo in brcms_b_attach_dmapio()
1121 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1122 uint unit = wlc_hw->unit; in brcms_b_attach_dmapio()
1127 if (wlc_hw->di[0] == NULL) { /* Init FIFOs */ in brcms_b_attach_dmapio()
1135 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1139 RXBUFSZ, -1, NRXBUFPOST, in brcms_b_attach_dmapio()
1141 dma_attach_err |= (NULL == wlc_hw->di[0]); in brcms_b_attach_dmapio()
1145 * TX: TX_AC_BE_FIFO (TX AC Best-Effort data packets) in brcms_b_attach_dmapio()
1149 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1151 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1152 dma_attach_err |= (NULL == wlc_hw->di[1]); in brcms_b_attach_dmapio()
1159 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1161 NTXD, 0, 0, -1, 0, 0); in brcms_b_attach_dmapio()
1162 dma_attach_err |= (NULL == wlc_hw->di[2]); in brcms_b_attach_dmapio()
1168 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1170 0, NTXD, 0, 0, -1, in brcms_b_attach_dmapio()
1172 dma_attach_err |= (NULL == wlc_hw->di[3]); in brcms_b_attach_dmapio()
1176 brcms_err(wlc_hw->d11core, in brcms_b_attach_dmapio()
1184 if (wlc_hw->di[i]) in brcms_b_attach_dmapio()
1185 wlc_hw->txavail[i] = in brcms_b_attach_dmapio()
1186 (uint *) dma_getvar(wlc_hw->di[i], in brcms_b_attach_dmapio()
1191 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1201 if (wlc_hw->di[j]) { in brcms_b_detach_dmapio()
1202 dma_detach(wlc_hw->di[j]); in brcms_b_detach_dmapio()
1203 wlc_hw->di[j] = NULL; in brcms_b_detach_dmapio()
1210 * may get overrides later in this function
1215 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init()
1218 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1221 wlc_hw->shortslot = false; in brcms_b_info_init()
1223 wlc_hw->SFBL = RETRY_SHORT_FB; in brcms_b_info_init()
1224 wlc_hw->LFBL = RETRY_LONG_FB; in brcms_b_info_init()
1227 wlc_hw->SRL = RETRY_SHORT_DEF; in brcms_b_info_init()
1228 wlc_hw->LRL = RETRY_LONG_DEF; in brcms_b_info_init()
1229 wlc_hw->chanspec = ch20mhz_chspec(1); in brcms_b_info_init()
1239 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1245 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) { in brcms_b_clkctl_clk()
1252 if (wlc_hw->clk) { in brcms_b_clkctl_clk()
1254 bcma_set32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1261 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1265 WARN_ON(!(bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1269 if ((ai_get_pmurev(wlc_hw->sih) == 0) && in brcms_b_clkctl_clk()
1270 (bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1274 ((bcma_read32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1279 bcma_mask32(wlc_hw->d11core, in brcms_b_clkctl_clk()
1284 wlc_hw->forcefastclk = (mode == BCMA_CLKMODE_FAST); in brcms_b_clkctl_clk()
1291 wlc_hw->forcefastclk = ai_clkctl_cc(wlc_hw->sih, mode); in brcms_b_clkctl_clk()
1293 /* check fast clock is available (if core is not in reset) */ in brcms_b_clkctl_clk()
1294 if (wlc_hw->forcefastclk && wlc_hw->clk) in brcms_b_clkctl_clk()
1295 WARN_ON(!(bcma_aread32(wlc_hw->d11core, BCMA_IOST) & in brcms_b_clkctl_clk()
1302 * current forcefastclk state. Only setting bit in wake_override in brcms_b_clkctl_clk()
1304 * behavior. Older code set wlc->forcefastclk but only had the in brcms_b_clkctl_clk()
1308 if (wlc_hw->forcefastclk) in brcms_b_clkctl_clk()
1309 mboolset(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1312 mboolclr(wlc_hw->wake_override, in brcms_b_clkctl_clk()
1318 * it has an optimization for no-change write
1320 * pre-CLK changes should use wlc_write_mhf to get around the optimization
1323 * bands values are: BRCM_BAND_AUTO <--- Current band only
1324 * BRCM_BAND_5G <--- 5G band only
1325 * BRCM_BAND_2G <--- 2G band only
1326 * BRCM_BAND_ALL <--- All bands
1337 struct brcms_hw_band *band; in brcms_b_mhf() local
1343 /* Current band only or all bands, in brcms_b_mhf()
1344 * then set the band to current band in brcms_b_mhf()
1348 band = wlc_hw->band; in brcms_b_mhf()
1351 band = wlc_hw->bandstate[BAND_5G_INDEX]; in brcms_b_mhf()
1354 band = wlc_hw->bandstate[BAND_2G_INDEX]; in brcms_b_mhf()
1357 band = NULL; /* error condition */ in brcms_b_mhf()
1360 if (band) { in brcms_b_mhf()
1361 save = band->mhfs[idx]; in brcms_b_mhf()
1362 band->mhfs[idx] = (band->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1365 * changed band is the current band in brcms_b_mhf()
1367 if (wlc_hw->clk && (band->mhfs[idx] != save) in brcms_b_mhf()
1368 && (band == wlc_hw->band)) in brcms_b_mhf()
1370 (u16) band->mhfs[idx]); in brcms_b_mhf()
1374 wlc_hw->bandstate[0]->mhfs[idx] = in brcms_b_mhf()
1375 (wlc_hw->bandstate[0]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1376 wlc_hw->bandstate[1]->mhfs[idx] = in brcms_b_mhf()
1377 (wlc_hw->bandstate[1]->mhfs[idx] & ~mask) | val; in brcms_b_mhf()
1387 wlc_hw->maccontrol = 0; in brcms_c_mctrl_reset()
1388 wlc_hw->suspended_fifos = 0; in brcms_c_mctrl_reset()
1389 wlc_hw->wake_override = 0; in brcms_c_mctrl_reset()
1390 wlc_hw->mute_override = 0; in brcms_c_mctrl_reset()
1400 u32 maccontrol = wlc_hw->maccontrol; in brcms_c_mctrl_write()
1402 /* OR in the wake bit if overridden */ in brcms_c_mctrl_write()
1403 if (wlc_hw->wake_override) in brcms_c_mctrl_write()
1407 if (wlc_hw->mute_override) { in brcms_c_mctrl_write()
1412 bcma_write32(wlc_hw->d11core, D11REGOFFS(maccontrol), in brcms_c_mctrl_write()
1424 maccontrol = wlc_hw->maccontrol; in brcms_b_mctrl()
1432 wlc_hw->maccontrol = new_maccontrol; in brcms_b_mctrl()
1441 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) { in brcms_c_ucode_wake_override_set()
1442 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1446 mboolset(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_set()
1455 mboolclr(wlc_hw->wake_override, override_bit); in brcms_c_ucode_wake_override_clear()
1457 if (wlc_hw->wake_override || (wlc_hw->maccontrol & MCTL_WAKE)) in brcms_c_ucode_wake_override_clear()
1467 * STA 0 1 <--- This will ensure no beacons
1472 wlc_hw->mute_override = 1; in brcms_c_ucode_mute_override_set()
1477 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_set()
1486 if (wlc_hw->mute_override == 0) in brcms_c_ucode_mute_override_clear()
1489 wlc_hw->mute_override = 0; in brcms_c_ucode_mute_override_clear()
1494 if ((wlc_hw->maccontrol & (MCTL_AP | MCTL_INFRA)) == MCTL_INFRA) in brcms_c_ucode_mute_override_clear()
1501 * Write a MAC address to the given match reg offset in the RXE match engine.
1507 struct bcma_device *core = wlc_hw->d11core; in brcms_b_set_addrmatch()
1512 brcms_dbg_rx(core, "wl%d: brcms_b_set_addrmatch\n", wlc_hw->unit); in brcms_b_set_addrmatch()
1530 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_template_ram()
1535 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_write_template_ram()
1539 /* if MCTL_BIGEND bit set in mac control register, in brcms_b_write_template_ram()
1540 * the chip swaps data in fifo, as well as data in in brcms_b_write_template_ram()
1559 len -= sizeof(u32); in brcms_b_write_template_ram()
1565 wlc_hw->band->CWmin = newmin; in brcms_b_set_cwmin()
1567 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmin()
1569 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmin()
1570 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmin); in brcms_b_set_cwmin()
1575 wlc_hw->band->CWmax = newmax; in brcms_b_set_cwmax()
1577 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_set_cwmax()
1579 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_set_cwmax()
1580 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), newmax); in brcms_b_set_cwmax()
1588 fastclk = wlc_hw->forcefastclk; in brcms_b_bw_set()
1592 wlc_phy_bw_state_set(wlc_hw->band->pi, bw); in brcms_b_bw_set()
1595 wlc_phy_init(wlc_hw->band->pi, wlc_phy_chanspec_get(wlc_hw->band->pi)); in brcms_b_bw_set()
1605 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu()
1608 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1610 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1621 u16 phytxant = wlc_hw->bmac_phytxant; in brcms_c_ucode_txant_set()
1644 /* OFDM RATE sub-field of PLCP SIGNAL field, per 802.11 sec 17.3.4.1 */ in brcms_b_ofdm_ratetable_offset()
1663 /* Find the SHM pointer to the rate table entry by looking in the in brcms_b_ofdm_ratetable_offset()
1664 * Direct-map Table in brcms_b_ofdm_ratetable_offset()
1680 if (!BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_upd_ofdm_pctl1_table()
1695 pctl1 |= (wlc_hw->hw_stf_ss_opmode << PHY_TXC1_MODE_SHIFT); in brcms_upd_ofdm_pctl1_table()
1703 /* band-specific init */
1706 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1708 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_b_bsinit()
1709 wlc_hw->band->bandunit); in brcms_b_bsinit()
1713 wlc_phy_init(wlc_hw->band->pi, chanspec); in brcms_b_bsinit()
1718 * cwmin is band-specific, update hardware in brcms_b_bsinit()
1719 * with value for current band in brcms_b_bsinit()
1721 brcms_b_set_cwmin(wlc_hw, wlc_hw->band->CWmin); in brcms_b_bsinit()
1722 brcms_b_set_cwmax(wlc_hw, wlc_hw->band->CWmax); in brcms_b_bsinit()
1725 wlc_hw->band->bandtype == BRCM_BAND_5G ? in brcms_b_bsinit()
1726 true : wlc_hw->shortslot); in brcms_b_bsinit()
1729 brcms_b_write_shm(wlc_hw, M_PHYTYPE, (u16) wlc_hw->band->phytype); in brcms_b_bsinit()
1730 brcms_b_write_shm(wlc_hw, M_PHYVER, (u16) wlc_hw->band->phyrev); in brcms_b_bsinit()
1744 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_addr), in brcms_b_core_phypll_reset()
1747 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1750 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1753 ai_cc_reg(wlc_hw->sih, offsetof(struct chipcregs, chipcontrol_data), in brcms_b_core_phypll_reset()
1764 if (!BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_phyclk_fgc()
1784 struct brcms_phy_pub *pih = wlc_hw->band->pi; in brcms_b_phy_reset()
1788 brcms_dbg_info(wlc_hw->d11core, "wl%d: reset phy\n", wlc_hw->unit); in brcms_b_phy_reset()
1793 phy_bw_clkbits = wlc_phy_clk_bwbits(wlc_hw->band->pi); in brcms_b_phy_reset()
1796 if (BRCMS_ISNPHY(wlc_hw->band) && NREV_GE(wlc_hw->band->phyrev, 3) && in brcms_b_phy_reset()
1797 NREV_LE(wlc_hw->band->phyrev, 4)) { in brcms_b_phy_reset()
1823 /* switch to and initialize new band */
1826 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband()
1830 if (!bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_setband()
1831 bcma_core_enable(wlc_hw->d11core, 0); in brcms_b_setband()
1837 if (!wlc_hw->up) in brcms_b_setband()
1842 /* band-specific initializations */ in brcms_b_setband()
1848 * so brcms_c_dpc() will re-enable interrupts when done. in brcms_b_setband()
1850 if (wlc->macintstatus) in brcms_b_setband()
1851 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1854 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1857 WARN_ON((bcma_read32(wlc_hw->d11core, D11REGOFFS(maccontrol)) & in brcms_b_setband()
1865 if (!CONF_HAS(D11CONF, wlc_hw->corerev)) { in brcms_c_isgoodchip()
1866 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
1867 wlc_hw->corerev); in brcms_c_isgoodchip()
1877 uint boardrev = wlc_hw->boardrev; in brcms_c_validboardtype()
1886 if (ai_get_boardvendor(wlc_hw->sih) != PCI_VENDOR_ID_BROADCOM) in brcms_c_validboardtype()
1905 struct ssb_sprom *sprom = &wlc_hw->d11core->bus->sprom; in brcms_c_get_macaddr()
1908 if (!is_zero_ether_addr(sprom->il0mac)) { in brcms_c_get_macaddr()
1909 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1913 if (wlc_hw->_nbands > 1) in brcms_c_get_macaddr()
1914 memcpy(etheraddr, sprom->et1mac, ETH_ALEN); in brcms_c_get_macaddr()
1916 memcpy(etheraddr, sprom->il0mac, ETH_ALEN); in brcms_c_get_macaddr()
1922 brcms_dbg_info(wlc_hw->d11core, "wl%d: want %d\n", wlc_hw->unit, want); in brcms_b_xtal()
1928 if (!want && wlc_hw->pllreq) in brcms_b_xtal()
1931 wlc_hw->sbclk = want; in brcms_b_xtal()
1932 if (!wlc_hw->sbclk) { in brcms_b_xtal()
1933 wlc_hw->clk = false; in brcms_b_xtal()
1934 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_xtal()
1935 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_xtal()
1950 xtal = wlc_hw->sbclk; in brcms_b_radio_read_hwdisabled()
1955 clk = wlc_hw->clk; in brcms_b_radio_read_hwdisabled()
1962 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_radio_read_hwdisabled()
1972 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_radio_read_hwdisabled()
1976 v = ((bcma_read32(wlc_hw->d11core, in brcms_b_radio_read_hwdisabled()
1981 bcma_core_disable(wlc_hw->d11core, 0); in brcms_b_radio_read_hwdisabled()
1991 struct dma_pub *di = wlc_hw->di[fifo]; in wlc_dma_rxreset()
2001 * one testing hack wlc_hw->noreset will bypass the d11/phy reset
2009 flags = (wlc_hw->band->pi ? wlc_hw->band->core_flags : 0); in brcms_b_corereset()
2011 brcms_dbg_info(wlc_hw->d11core, "wl%d: core reset\n", wlc_hw->unit); in brcms_b_corereset()
2014 fastclk = wlc_hw->forcefastclk; in brcms_b_corereset()
2019 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_corereset()
2021 if ((wlc_hw->di[i]) && (!dma_txreset(wlc_hw->di[i]))) in brcms_b_corereset()
2022 brcms_err(wlc_hw->d11core, "wl%d: %s: " in brcms_b_corereset()
2024 wlc_hw->unit, __func__, i); in brcms_b_corereset()
2026 if ((wlc_hw->di[RX_FIFO]) in brcms_b_corereset()
2028 brcms_err(wlc_hw->d11core, "wl%d: %s: dma_rxreset" in brcms_b_corereset()
2030 wlc_hw->unit, __func__, RX_FIFO); in brcms_b_corereset()
2033 if (wlc_hw->noreset) { in brcms_b_corereset()
2034 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2042 * band->pi is invalid. need to enable PHY CLK in brcms_b_corereset()
2044 if (D11REV_GE(wlc_hw->corerev, 18)) in brcms_b_corereset()
2049 * In chips with PMU, the fastclk request goes through d11 core in brcms_b_corereset()
2050 * reg 0x1e0, which is cleared by the core_reset. have to re-request it. in brcms_b_corereset()
2057 wlc_hw->clk = false; in brcms_b_corereset()
2058 bcma_core_enable(wlc_hw->d11core, flags); in brcms_b_corereset()
2059 wlc_hw->clk = true; in brcms_b_corereset()
2060 if (wlc_hw->band && wlc_hw->band->pi) in brcms_b_corereset()
2061 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, true); in brcms_b_corereset()
2065 if (ai_get_cccaps(wlc_hw->sih) & CC_CAP_PMU) in brcms_b_corereset()
2074 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2086 struct bcma_device *core = wlc_hw->d11core; in brcms_b_corerev_fifofixup()
2098 txfifo_endblk = txfifo_startblk + wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2100 (((txfifo_endblk - 1) & 0xff) << TXFIFO_FIFOTOP_SHIFT); in brcms_b_corerev_fifofixup()
2102 ((((txfifo_endblk - in brcms_b_corerev_fifofixup()
2113 txfifo_startblk += wlc_hw->xmtfifo_sz[fifo_nu]; in brcms_b_corerev_fifofixup()
2116 * need to propagate to shm location to be in sync since ucode/hw won't in brcms_b_corerev_fifofixup()
2120 wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]); in brcms_b_corerev_fifofixup()
2122 wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]); in brcms_b_corerev_fifofixup()
2124 ((wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2127 ((wlc_hw->xmtfifo_sz[TX_ATIM_FIFO] << 8) | wlc_hw-> in brcms_b_corerev_fifofixup()
2136 * For spuron2 - 126MHz -> 2^26/126 = 532610.0
2137 * - 532610 = 0x82082 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x2082
2138 * For spuron: 123MHz -> 2^26/123 = 545600.5
2139 * - 545601 = 0x85341 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x5341
2140 * For spur off: 120MHz -> 2^26/120 = 559240.5
2141 * - 559241 = 0x88889 => tsf_clk_frac_h = 0x8, tsf_clk_frac_l = 0x8889
2146 struct bcma_device *core = wlc_hw->d11core; in brcms_b_switch_macfreq()
2148 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43224) || in brcms_b_switch_macfreq()
2149 (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) { in brcms_b_switch_macfreq()
2160 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_switch_macfreq()
2173 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2174 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2182 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2183 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2184 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2186 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2191 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2192 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2194 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2200 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2217 if (wlc_hw->antsel_type == ANTSEL_2x3) { in brcms_c_gpio_init()
2225 wlc_phy_antsel_init(wlc_hw->band->pi, false); in brcms_c_gpio_init()
2227 } else if (wlc_hw->antsel_type == ANTSEL_2x4) { in brcms_c_gpio_init()
2233 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_oe), in brcms_c_gpio_init()
2235 bcma_set16(wlc_hw->d11core, D11REGOFFS(psm_gpio_out), in brcms_c_gpio_init()
2253 if (wlc_hw->boardflags & BFL_PACTRL) in brcms_c_gpio_init()
2257 bcma_chipco_gpio_control(&wlc_hw->d11core->bus->drv_cc, gm, gc); in brcms_c_gpio_init()
2263 struct bcma_device *core = wlc_hw->d11core; in brcms_ucode_write()
2267 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_ucode_write()
2282 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2284 wlc = wlc_hw->wlc; in brcms_ucode_download()
2286 if (wlc_hw->ucode_loaded) in brcms_ucode_download()
2289 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_ucode_download()
2290 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_ucode_download()
2291 brcms_ucode_write(wlc_hw, ucode->bcm43xx_16_mimo, in brcms_ucode_download()
2292 ucode->bcm43xx_16_mimosz); in brcms_ucode_download()
2293 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2295 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2296 "%s: wl%d: unsupported phy in corerev %d\n", in brcms_ucode_download()
2297 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2298 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_ucode_download()
2299 if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_ucode_download()
2300 brcms_ucode_write(wlc_hw, ucode->bcm43xx_24_lcn, in brcms_ucode_download()
2301 ucode->bcm43xx_24_lcnsz); in brcms_ucode_download()
2302 wlc_hw->ucode_loaded = true; in brcms_ucode_download()
2304 brcms_err(wlc_hw->d11core, in brcms_ucode_download()
2305 "%s: wl%d: unsupported phy in corerev %d\n", in brcms_ucode_download()
2306 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_ucode_download()
2314 wlc_hw->bmac_phytxant = phytxant; in brcms_b_txant_set()
2317 if (!wlc_hw->up) in brcms_b_txant_set()
2325 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2330 wlc_hw->antsel_type = antsel_type; in brcms_b_antsel_type_set()
2333 wlc_phy_antsel_type_set(wlc_hw->band->pi, antsel_type); in brcms_b_antsel_type_set()
2341 struct bcma_device *core = wlc_hw->d11core; in brcms_b_fifoerrors()
2343 unit = wlc_hw->unit; in brcms_b_fifoerrors()
2346 /* read intstatus register and ignore any non-error bits */ in brcms_b_fifoerrors()
2392 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2403 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2404 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2405 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2410 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2413 if (!wlc_hw->clk) in brcms_c_intrsoff()
2416 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2418 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), 0); in brcms_c_intrsoff()
2419 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(macintmask)); in brcms_c_intrsoff()
2421 wlc->macintmask = 0; in brcms_c_intrsoff()
2424 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2429 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2430 if (!wlc_hw->clk) in brcms_c_intrsrestore()
2433 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2434 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2446 if ((wlc_hw->suspended_fifos & fifo) == fifo) in brcms_b_tx_fifo_suspend()
2450 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_suspend()
2454 wlc_hw->suspended_fifos |= fifo; in brcms_b_tx_fifo_suspend()
2456 if (wlc_hw->di[tx_fifo]) { in brcms_b_tx_fifo_suspend()
2458 * Suspending AMPDU transmissions in the middle can cause in brcms_b_tx_fifo_suspend()
2459 * underflow which may result in mismatch between ucode and in brcms_b_tx_fifo_suspend()
2462 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2463 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2465 dma_txsuspend(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_suspend()
2467 if (BRCMS_PHY_11N_CAP(wlc_hw->band)) in brcms_b_tx_fifo_suspend()
2468 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2475 /* BMAC_NOTE: BRCMS_TX_FIFO_ENAB is done in brcms_c_dpc() for DMA case in brcms_b_tx_fifo_resume()
2480 if (wlc_hw->di[tx_fifo]) in brcms_b_tx_fifo_resume()
2481 dma_txresume(wlc_hw->di[tx_fifo]); in brcms_b_tx_fifo_resume()
2484 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2487 wlc_hw->suspended_fifos &= ~(1 << tx_fifo); in brcms_b_tx_fifo_resume()
2488 if (wlc_hw->suspended_fifos == 0) in brcms_b_tx_fifo_resume()
2498 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2520 wlc_phy_mute_upd(wlc_hw->band->pi, mute_tx, 0); in brcms_b_mute()
2531 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2538 * -1 if brcms_deviceremoved(wlc) evaluates to true;
2539 * 0 if the interrupt is not for us, or we are in some special cases;
2544 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2545 struct bcma_device *core = wlc_hw->d11core; in wlc_intstatus()
2550 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2552 trace_brcms_macintstatus(&core->dev, in_isr, macintstatus, mask); in wlc_intstatus()
2554 /* detect cardbus removed, in power down(suspend) and in reset */ in wlc_intstatus()
2556 return -1; in wlc_intstatus()
2574 wlc->macintmask = 0; in wlc_intstatus()
2579 /* MI_DMAINT is indication of non-zero intstatus */ in wlc_intstatus()
2582 * only fifo interrupt enabled is I_RI in in wlc_intstatus()
2592 /* Update wlc->macintstatus and wlc->intstatus[]. */
2605 /* update interrupt status in software */ in brcms_c_intrsupd()
2606 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2612 * First-level interrupt processing.
2619 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2622 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2629 brcms_err(wlc_hw->d11core, in brcms_c_isr()
2630 "DEVICEREMOVED detected in the ISR code path\n"); in brcms_c_isr()
2639 wlc->macintstatus = macintstatus; in brcms_c_isr()
2647 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2648 struct bcma_device *core = wlc_hw->d11core; in brcms_c_suspend_mac_and_wait()
2651 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2652 wlc_hw->band->bandunit); in brcms_c_suspend_mac_and_wait()
2657 wlc_hw->mac_suspend_depth++; in brcms_c_suspend_mac_and_wait()
2658 if (wlc_hw->mac_suspend_depth > 1) in brcms_c_suspend_mac_and_wait()
2667 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2669 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2678 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2680 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2693 wlc_hw->unit, BRCMS_MAX_MAC_SUSPEND); in brcms_c_suspend_mac_and_wait()
2695 "psm_brc 0x%04x\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2703 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_suspend_mac_and_wait()
2705 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2715 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2716 struct bcma_device *core = wlc_hw->d11core; in brcms_c_enable_mac()
2719 brcms_dbg_mac80211(core, "wl%d: bandunit %d\n", wlc_hw->unit, in brcms_c_enable_mac()
2720 wlc->band->bandunit); in brcms_c_enable_mac()
2725 wlc_hw->mac_suspend_depth--; in brcms_c_enable_mac()
2726 if (wlc_hw->mac_suspend_depth > 0) in brcms_c_enable_mac()
2751 wlc_hw->hw_stf_ss_opmode = stf_mode; in brcms_b_band_stf_ss_set()
2753 if (wlc_hw->clk) in brcms_b_band_stf_ss_set()
2759 struct bcma_device *core = wlc_hw->d11core; in brcms_b_validate_chip_access()
2761 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2779 "expected 0xaa5555aa\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2792 "expected 0x55aaaa55\n", wlc_hw->unit, val); in brcms_b_validate_chip_access()
2807 "0x%x, expected 0x%x or 0x%x\n", wlc_hw->unit, w, in brcms_b_validate_chip_access()
2820 struct bcma_device *core = wlc_hw->d11core; in brcms_b_core_phypll_ctl()
2823 brcms_dbg_info(core, "wl%d\n", wlc_hw->unit); in brcms_b_core_phypll_ctl()
2828 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_core_phypll_ctl()
2875 brcms_dbg_info(wlc_hw->d11core, "wl%d: disable core\n", wlc_hw->unit); in brcms_c_coredisable()
2877 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2882 if (wlc_hw->noreset) in brcms_c_coredisable()
2886 wlc_phy_switch_radio(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2889 wlc_phy_anacore(wlc_hw->band->pi, OFF); in brcms_c_coredisable()
2894 wlc_hw->clk = false; in brcms_c_coredisable()
2895 bcma_core_disable(wlc_hw->d11core, 0); in brcms_c_coredisable()
2896 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_c_coredisable()
2901 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2906 if (wlc_hw->di[i]) { in brcms_c_flushqueues()
2907 dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); in brcms_c_flushqueues()
2909 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
2915 dma_rxreclaim(wlc_hw->di[RX_FIFO]); in brcms_c_flushqueues()
2921 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_objmem()
2936 struct bcma_device *core = wlc_hw->d11core; in brcms_b_write_objmem()
3019 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3025 wlc_hw->SRL = SRL; in brcms_b_retrylimit_upd()
3026 wlc_hw->LRL = LRL; in brcms_b_retrylimit_upd()
3029 if (wlc_hw->up) { in brcms_b_retrylimit_upd()
3030 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3032 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3033 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_retrylimit_upd()
3034 bcma_write32(wlc_hw->d11core, D11REGOFFS(objaddr), in brcms_b_retrylimit_upd()
3036 (void)bcma_read32(wlc_hw->d11core, D11REGOFFS(objaddr)); in brcms_b_retrylimit_upd()
3037 bcma_write32(wlc_hw->d11core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_retrylimit_upd()
3044 if (mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3047 mboolset(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3049 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3050 if (!wlc_hw->sbclk) in brcms_b_pllreq()
3054 if (!mboolisset(wlc_hw->pllreq, req_bit)) in brcms_b_pllreq()
3057 mboolclr(wlc_hw->pllreq, req_bit); in brcms_b_pllreq()
3059 if (mboolisset(wlc_hw->pllreq, BRCMS_PLLREQ_FLIP)) { in brcms_b_pllreq()
3060 if (wlc_hw->sbclk) in brcms_b_pllreq()
3068 wlc_hw->antsel_avail = antsel_avail; in brcms_b_antsel_set()
3072 * conditions under which the PM bit should be set in outgoing frames
3092 if (!wlc->pub->up) in brcms_c_statsupd()
3095 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3099 rxf0ovfl = macstats->rxf0ovfl; in brcms_c_statsupd()
3103 txfunfl[i] = macstats->txfunfl[i]; in brcms_c_statsupd()
3107 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3112 delta = (u16)(macstats->rxf0ovfl - rxf0ovfl); in brcms_c_statsupd()
3114 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3115 wlc->pub->unit, delta); in brcms_c_statsupd()
3119 delta = macstats->txfunfl[i] - txfunfl[i]; in brcms_c_statsupd()
3121 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3123 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3129 if (wlc->hw->di[i]) in brcms_c_statsupd()
3130 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3137 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3141 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3146 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3152 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3154 brcms_b_reset(wlc->hw); in brcms_c_reset()
3162 scb->flags = SCB_WMECAP | SCB_HTCAP; in brcms_c_init_scb()
3164 scb->seqnum[i] = 0; in brcms_c_init_scb()
3165 scb->seqctl[i] = 0xFFFF; in brcms_c_init_scb()
3168 scb->seqctl_nonqos = 0xFFFF; in brcms_c_init_scb()
3169 scb->magic = SCB_MAGIC; in brcms_c_init_scb()
3182 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3183 struct bcma_device *core = wlc_hw->d11core; in brcms_b_coreinit()
3190 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3192 brcms_dbg_info(core, "wl%d: core init\n", wlc_hw->unit); in brcms_b_coreinit()
3204 bcma_write32(core, D11REGOFFS(macintstatus), -1); in brcms_b_coreinit()
3208 /* wait for ucode to self-suspend after auto-init */ in brcms_b_coreinit()
3212 brcms_err(core, "wl%d: wlc_coreinit: ucode did not self-" in brcms_b_coreinit()
3213 "suspend!\n", wlc_hw->unit); in brcms_b_coreinit()
3219 if (D11REV_IS(wlc_hw->corerev, 17) || D11REV_IS(wlc_hw->corerev, 23)) { in brcms_b_coreinit()
3220 if (BRCMS_ISNPHY(wlc_hw->band)) in brcms_b_coreinit()
3221 brcms_c_write_inits(wlc_hw, ucode->d11n0initvals16); in brcms_b_coreinit()
3223 brcms_err(core, "%s: wl%d: unsupported phy in corerev" in brcms_b_coreinit()
3224 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3225 wlc_hw->corerev); in brcms_b_coreinit()
3226 } else if (D11REV_IS(wlc_hw->corerev, 24)) { in brcms_b_coreinit()
3227 if (BRCMS_ISLCNPHY(wlc_hw->band)) in brcms_b_coreinit()
3228 brcms_c_write_inits(wlc_hw, ucode->d11lcn0initvals24); in brcms_b_coreinit()
3230 brcms_err(core, "%s: wl%d: unsupported phy in corerev" in brcms_b_coreinit()
3231 " %d\n", __func__, wlc_hw->unit, in brcms_b_coreinit()
3232 wlc_hw->corerev); in brcms_b_coreinit()
3235 __func__, wlc_hw->unit, wlc_hw->corerev); in brcms_b_coreinit()
3244 if (buf[TX_AC_BE_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BE_FIFO]) { in brcms_b_coreinit()
3246 err = -1; in brcms_b_coreinit()
3249 if (buf[TX_AC_VI_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VI_FIFO]) { in brcms_b_coreinit()
3251 err = -1; in brcms_b_coreinit()
3256 if (buf[TX_AC_BK_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_BK_FIFO]) { in brcms_b_coreinit()
3258 err = -1; in brcms_b_coreinit()
3260 if (buf[TX_AC_VO_FIFO] != wlc_hw->xmtfifo_sz[TX_AC_VO_FIFO]) { in brcms_b_coreinit()
3262 err = -1; in brcms_b_coreinit()
3267 if (buf[TX_BCMC_FIFO] != wlc_hw->xmtfifo_sz[TX_BCMC_FIFO]) { in brcms_b_coreinit()
3269 err = -1; in brcms_b_coreinit()
3271 if (buf[TX_ATIM_FIFO] != wlc_hw->xmtfifo_sz[TX_ATIM_FIFO]) { in brcms_b_coreinit()
3273 err = -1; in brcms_b_coreinit()
3278 wlc_hw->xmtfifo_sz[i], i); in brcms_b_coreinit()
3283 /* band-specific inits done by wlc_bsinit() */ in brcms_b_coreinit()
3312 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3313 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3316 brcms_b_write_shm(wlc_hw, M_MACHW_VER, (u16) wlc_hw->corerev); in brcms_b_coreinit()
3320 (u16) (wlc_hw->machwcap & 0xffff)); in brcms_b_coreinit()
3322 (u16) ((wlc_hw-> in brcms_b_coreinit()
3329 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->SRL); in brcms_b_coreinit()
3333 bcma_write32(core, D11REGOFFS(objdata), wlc_hw->LRL); in brcms_b_coreinit()
3336 brcms_b_write_shm(wlc_hw, M_SFRMTXCNTFBRTHSD, wlc_hw->SFBL); in brcms_b_coreinit()
3337 brcms_b_write_shm(wlc_hw, M_LFRMTXCNTFBRTHSD, wlc_hw->LFBL); in brcms_b_coreinit()
3344 if (wlc_hw->di[i]) in brcms_b_coreinit()
3345 dma_txinit(wlc_hw->di[i]); in brcms_b_coreinit()
3349 dma_rxinit(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3350 dma_rxfill(wlc_hw->di[RX_FIFO]); in brcms_b_coreinit()
3357 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init()
3360 fastclk = wlc_hw->forcefastclk; in brcms_b_init()
3365 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3367 /* set up the specified band and chanspec */ in brcms_b_init()
3369 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_init()
3371 /* do one-time phy inits and calibration */ in brcms_b_init()
3372 wlc_phy_cal_init(wlc_hw->band->pi); in brcms_b_init()
3374 /* core-specific initialization */ in brcms_b_init()
3377 /* band-specific inits */ in brcms_b_init()
3381 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3386 mboolset(wlc_hw->wake_override, BRCMS_WAKE_OVERRIDE_MACSUSPEND); in brcms_b_init()
3392 wlc_hw->mac_suspend_depth = 1; in brcms_b_init()
3403 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3406 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3408 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3409 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3412 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3418 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3419 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3420 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3421 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3422 wlc->stf->txstreams); in brcms_default_rateset()
3425 /* derive wlc->band->basic_rate[] table from 'rateset' */
3433 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3436 /* incoming rates are in 500kbps units as in 802.11 Supported Rates */ in brcms_c_rate_lookup_init()
3439 /* For each basic rate in the rates list, make an entry in the in brcms_c_rate_lookup_init()
3442 for (i = 0; i < rateset->count; i++) { in brcms_c_rate_lookup_init()
3444 if (!(rateset->rates[i] & BRCMS_RATE_FLAG)) in brcms_c_rate_lookup_init()
3448 rate = (rateset->rates[i] & BRCMS_RATE_MASK); in brcms_c_rate_lookup_init()
3451 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3452 "invalid rate 0x%X in rate set\n", in brcms_c_rate_lookup_init()
3453 rateset->rates[i]); in brcms_c_rate_lookup_init()
3460 /* The rate lookup table now has non-zero entries for each in brcms_c_rate_lookup_init()
3467 * basic_rate = wlc->band->basic_rate[tx_rate] in brcms_c_rate_lookup_init()
3471 * to high, filling in holes in the lookup table in brcms_c_rate_lookup_init()
3474 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3475 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3491 * best basic rate less than this rate and fill in in brcms_c_rate_lookup_init()
3492 * the hole in the table in brcms_c_rate_lookup_init()
3502 * In 11g and 11a, the OFDM mandatory rates in brcms_c_rate_lookup_init()
3512 /* In 11b, all CCK rates are mandatory 1 - 11 Mbps */ in brcms_c_rate_lookup_init()
3529 * power-cycled (hibernate). Figure out the right band to park on in brcms_c_bandinit_ordered()
3531 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3532 /* updated in brcms_c_bandlock() */ in brcms_c_bandinit_ordered()
3533 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3536 /* park on the band of the specified chanspec */ in brcms_c_bandinit_ordered()
3544 /* make each band operational, software state init */ in brcms_c_bandinit_ordered()
3545 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3548 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3552 /* fill in hw_rate */ in brcms_c_bandinit_ordered()
3553 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3555 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3573 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3587 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3602 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3603 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3606 * in ucode inits. I think that the ucode inits set in brcms_c_ucode_mac_upd()
3608 * beacon. This should not be done in the inits. If in brcms_c_ucode_mac_upd()
3613 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3614 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3637 * for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_c_write_rate_shm()
3645 /* Find the SHM pointer to the ACK rate entry by looking in the in brcms_c_write_rate_shm()
3646 * Direct-map Table in brcms_c_write_rate_shm()
3648 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3650 /* Update the SHM BSS-basic-rate-set mapping table with the pointer in brcms_c_write_rate_shm()
3653 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3661 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3662 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3666 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3684 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3704 /* band-specific init */
3707 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3708 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3713 /* update some band specific mac configuration */ in brcms_c_bsinit()
3717 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3721 /* formula: IDLE_BUSY_RATIO_X_16 = (100-duty_cycle)/duty_cycle*16 */
3731 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3733 wlc->pub->unit); in brcms_c_duty_cycle_set()
3734 return -EINVAL; in brcms_c_duty_cycle_set()
3737 idle_busy_ratio_x_16 = (100 - duty_cycle) * 16 / duty_cycle; in brcms_c_duty_cycle_set()
3740 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3743 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3745 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3759 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3762 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3767 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3772 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3782 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac()
3785 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3792 /* Write the BSS config's BSSID address to core (set_bssid in d11procs.tcl).
3797 /* we need to update BSSID in RXE match registers */ in brcms_c_set_bssid()
3798 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3803 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3804 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3806 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3807 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3812 wlc_hw->shortslot = shortslot; in brcms_b_set_shortslot()
3814 if (wlc_hw->band->bandtype == BRCM_BAND_2G && wlc_hw->up) { in brcms_b_set_shortslot()
3815 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3817 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3828 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3829 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3831 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3834 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3836 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3841 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3842 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3844 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3845 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3855 brcms_dbg_mac80211(wlc_hw->d11core, "wl%d: 0x%x\n", wlc_hw->unit, in brcms_b_set_chanspec()
3858 wlc_hw->chanspec = chanspec; in brcms_b_set_chanspec()
3861 if (wlc_hw->_nbands > 1) { in brcms_b_set_chanspec()
3863 if (wlc_hw->band->bandunit != bandunit) { in brcms_b_set_chanspec()
3865 * use light band switch if not up yet in brcms_b_set_chanspec()
3867 if (wlc_hw->up) { in brcms_b_set_chanspec()
3868 wlc_phy_chanspec_radio_set(wlc_hw-> in brcms_b_set_chanspec()
3869 bandstate[bandunit]-> in brcms_b_set_chanspec()
3878 wlc_phy_initcal_enable(wlc_hw->band->pi, !mute_tx); in brcms_b_set_chanspec()
3880 if (!wlc_hw->up) { in brcms_b_set_chanspec()
3881 if (wlc_hw->clk) in brcms_b_set_chanspec()
3882 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, in brcms_b_set_chanspec()
3884 wlc_phy_chanspec_radio_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3886 wlc_phy_chanspec_set(wlc_hw->band->pi, chanspec); in brcms_b_set_chanspec()
3887 wlc_phy_txpower_limit_set(wlc_hw->band->pi, txpwr, chanspec); in brcms_b_set_chanspec()
3894 /* switch to and initialize new band */
3898 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3900 if (!wlc->pub->up) in brcms_c_setband()
3906 /* band-specific initializations */ in brcms_c_setband()
3914 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3916 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3917 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3918 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3923 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3925 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3927 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3928 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3929 "wl%d: %s: chspec %d band is locked!\n", in brcms_c_set_chanspec()
3930 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3939 * band, or the following brcms_b_set_chanspec() may in brcms_c_set_chanspec()
3951 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3956 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3957 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3967 * ratespec CCK ant = wlc->stf->txant
3974 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3977 /* for non-siso rates or default setting, use the available chains */ in brcms_c_beacon_phytxctl_txant_upd()
3978 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3981 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3983 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3989 * in periodic function
3997 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
4001 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
4004 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
4007 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
4010 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
4013 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
4016 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
4019 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
4022 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
4025 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
4028 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4031 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4042 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4050 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4052 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4055 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4068 if (!wlc->clk) { in brcms_c_wme_setparams()
4069 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4070 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4075 /* fill in shm ac params struct */ in brcms_c_wme_setparams()
4076 acp_shm.txop = params->txop; in brcms_c_wme_setparams()
4078 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4080 acp_shm.aifs = (params->aifs & EDCF_AIFSN_MASK); in brcms_c_wme_setparams()
4088 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4089 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4091 acp_shm.cwmin = params->cw_min; in brcms_c_wme_setparams()
4092 acp_shm.cwmax = params->cw_max; in brcms_c_wme_setparams()
4095 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4099 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4105 /* Fill in shm acparam table */ in brcms_c_wme_setparams()
4108 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4139 aci = (edcf_acp->ACI & EDCF_ACI_MASK) >> EDCF_ACI_SHIFT; in brcms_c_edcf_setparams()
4141 /* fill in shm ac params struct */ in brcms_c_edcf_setparams()
4142 txq_pars.txop = edcf_acp->TXOP; in brcms_c_edcf_setparams()
4143 txq_pars.aifs = edcf_acp->ACI; in brcms_c_edcf_setparams()
4145 /* CWmin = 2^(ECWmin) - 1 */ in brcms_c_edcf_setparams()
4146 txq_pars.cw_min = EDCF_ECW2CW(edcf_acp->ECW & EDCF_ECWMIN_MASK); in brcms_c_edcf_setparams()
4147 /* CWmax = 2^(ECWmax) - 1 */ in brcms_c_edcf_setparams()
4148 txq_pars.cw_max = EDCF_ECW2CW((edcf_acp->ECW & EDCF_ECWMAX_MASK) in brcms_c_edcf_setparams()
4162 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4165 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4166 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4167 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4172 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4175 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4176 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4177 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4183 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4186 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4187 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4189 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4197 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4207 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4208 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4209 brcms_down(wlc->wl); in brcms_c_radio_timer()
4216 /* common low-level watchdog code */
4219 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4221 if (!wlc_hw->up) in brcms_b_watchdog()
4225 wlc_hw->now++; in brcms_b_watchdog()
4231 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4233 wlc_phy_watchdog(wlc_hw->band->pi); in brcms_b_watchdog()
4239 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4241 if (!wlc->pub->up) in brcms_c_watchdog()
4245 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4246 wlc->pub->unit, __func__); in brcms_c_watchdog()
4247 brcms_down(wlc->wl); in brcms_c_watchdog()
4252 wlc->pub->now++; in brcms_c_watchdog()
4256 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4263 * detect 16-bit counter wrap in brcms_c_watchdog()
4265 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4268 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4269 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4271 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4285 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4287 if (!wlc->wdtimer) { in brcms_c_timers_init()
4288 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4293 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4295 if (!wlc->radio_timer) { in brcms_c_timers_init()
4296 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4309 * may get overrides later in this function
4316 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4319 wlc->shortslot = false; in brcms_c_info_init()
4320 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4337 wlc->include_legacy_erp = true; in brcms_c_info_init()
4339 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4340 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4342 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4344 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4346 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4347 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4350 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4351 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4354 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4355 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4358 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4365 unit = wlc->pub->unit; in brcms_c_attach_module()
4367 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4368 if (wlc->asi == NULL) { in brcms_c_attach_module()
4369 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4375 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4376 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4377 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4384 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4395 return wlc->pub; in brcms_c_pub()
4401 * initialize software state for each core and band
4402 * put the whole chip in reset(driver down state), no clock
4412 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4413 struct pci_dev *pcidev = core->bus->host_pci; in brcms_b_attach()
4414 struct ssb_sprom *sprom = &core->bus->sprom; in brcms_b_attach()
4416 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) in brcms_b_attach()
4418 pcidev->vendor, in brcms_b_attach()
4419 pcidev->device); in brcms_b_attach()
4422 core->bus->boardinfo.vendor, in brcms_b_attach()
4423 core->bus->boardinfo.type); in brcms_b_attach()
4427 wlc_hw = wlc->hw; in brcms_b_attach()
4428 wlc_hw->wlc = wlc; in brcms_b_attach()
4429 wlc_hw->unit = unit; in brcms_b_attach()
4430 wlc_hw->band = wlc_hw->bandstate[0]; in brcms_b_attach()
4431 wlc_hw->_piomode = piomode; in brcms_b_attach()
4440 wlc_hw->sih = ai_attach(core->bus); in brcms_b_attach()
4441 if (wlc_hw->sih == NULL) { in brcms_b_attach()
4456 if (core->bus->hosttype == BCMA_HOSTTYPE_PCI) { in brcms_b_attach()
4457 wlc_hw->vendorid = pcidev->vendor; in brcms_b_attach()
4458 wlc_hw->deviceid = pcidev->device; in brcms_b_attach()
4460 wlc_hw->vendorid = core->bus->boardinfo.vendor; in brcms_b_attach()
4461 wlc_hw->deviceid = core->bus->boardinfo.type; in brcms_b_attach()
4464 wlc_hw->d11core = core; in brcms_b_attach()
4465 wlc_hw->corerev = core->id.rev; in brcms_b_attach()
4474 ai_clkctl_init(wlc_hw->sih); in brcms_b_attach()
4478 * For PMU chips, the first wlc_clkctl_clk is no-op since core-clk in brcms_b_attach()
4493 j = sprom->board_rev; in brcms_b_attach()
4497 wlc_hw->boardrev = (u16) j; in brcms_b_attach()
4501 unit, ai_get_boardtype(wlc_hw->sih), in brcms_b_attach()
4502 wlc_hw->boardrev); in brcms_b_attach()
4506 wlc_hw->sromrev = sprom->revision; in brcms_b_attach()
4507 wlc_hw->boardflags = sprom->boardflags_lo + (sprom->boardflags_hi << 16); in brcms_b_attach()
4508 wlc_hw->boardflags2 = sprom->boardflags2_lo + (sprom->boardflags2_hi << 16); in brcms_b_attach()
4510 if (wlc_hw->boardflags & BFL_NOPLLDOWN) in brcms_b_attach()
4514 if (wlc_hw->deviceid == BCM43224_D11N_ID || in brcms_b_attach()
4515 wlc_hw->deviceid == BCM43224_D11N_ID_VEN1 || in brcms_b_attach()
4516 wlc_hw->deviceid == BCM43224_CHIP_ID) in brcms_b_attach()
4518 wlc_hw->_nbands = 2; in brcms_b_attach()
4520 wlc_hw->_nbands = 1; in brcms_b_attach()
4522 if ((ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM43225)) in brcms_b_attach()
4523 wlc_hw->_nbands = 1; in brcms_b_attach()
4528 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4529 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4530 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4531 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4532 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4533 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4534 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4535 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4536 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4538 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4540 if (wlc_hw->physhim == NULL) { in brcms_b_attach()
4547 /* pass all the parameters to wlc_phy_shared_attach in one struct */ in brcms_b_attach()
4548 sha_params.sih = wlc_hw->sih; in brcms_b_attach()
4549 sha_params.physhim = wlc_hw->physhim; in brcms_b_attach()
4551 sha_params.corerev = wlc_hw->corerev; in brcms_b_attach()
4552 sha_params.vid = wlc_hw->vendorid; in brcms_b_attach()
4553 sha_params.did = wlc_hw->deviceid; in brcms_b_attach()
4554 sha_params.chip = ai_get_chip_id(wlc_hw->sih); in brcms_b_attach()
4555 sha_params.chiprev = ai_get_chiprev(wlc_hw->sih); in brcms_b_attach()
4556 sha_params.chippkg = ai_get_chippkg(wlc_hw->sih); in brcms_b_attach()
4557 sha_params.sromrev = wlc_hw->sromrev; in brcms_b_attach()
4558 sha_params.boardtype = ai_get_boardtype(wlc_hw->sih); in brcms_b_attach()
4559 sha_params.boardrev = wlc_hw->boardrev; in brcms_b_attach()
4560 sha_params.boardflags = wlc_hw->boardflags; in brcms_b_attach()
4561 sha_params.boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4564 wlc_hw->phy_sh = wlc_phy_shared_attach(&sha_params); in brcms_b_attach()
4565 if (!wlc_hw->phy_sh) { in brcms_b_attach()
4570 /* initialize software state for each core and band */ in brcms_b_attach()
4571 for (j = 0; j < wlc_hw->_nbands; j++) { in brcms_b_attach()
4579 wlc_hw->band->bandunit = j; in brcms_b_attach()
4580 wlc_hw->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4581 wlc->band->bandunit = j; in brcms_b_attach()
4582 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4583 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4585 wlc_hw->machwcap = bcma_read32(core, D11REGOFFS(machwcap)); in brcms_b_attach()
4586 wlc_hw->machwcap_backup = wlc_hw->machwcap; in brcms_b_attach()
4589 WARN_ON(wlc_hw->corerev < XMTFIFOTBL_STARTREV || in brcms_b_attach()
4590 (wlc_hw->corerev - XMTFIFOTBL_STARTREV) > in brcms_b_attach()
4592 wlc_hw->xmtfifo_sz = in brcms_b_attach()
4593 xmtfifo_sz[(wlc_hw->corerev - XMTFIFOTBL_STARTREV)]; in brcms_b_attach()
4594 WARN_ON(!wlc_hw->xmtfifo_sz[0]); in brcms_b_attach()
4596 /* Get a phy for this band */ in brcms_b_attach()
4597 wlc_hw->band->pi = in brcms_b_attach()
4598 wlc_phy_attach(wlc_hw->phy_sh, core, in brcms_b_attach()
4599 wlc_hw->band->bandtype, in brcms_b_attach()
4600 wlc->wiphy); in brcms_b_attach()
4601 if (wlc_hw->band->pi == NULL) { in brcms_b_attach()
4608 wlc_phy_machwcap_set(wlc_hw->band->pi, wlc_hw->machwcap); in brcms_b_attach()
4610 wlc_phy_get_phyversion(wlc_hw->band->pi, &wlc_hw->band->phytype, in brcms_b_attach()
4611 &wlc_hw->band->phyrev, in brcms_b_attach()
4612 &wlc_hw->band->radioid, in brcms_b_attach()
4613 &wlc_hw->band->radiorev); in brcms_b_attach()
4614 wlc_hw->band->abgphy_encore = in brcms_b_attach()
4615 wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4616 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4617 wlc_hw->band->core_flags = in brcms_b_attach()
4618 wlc_phy_get_coreflags(wlc_hw->band->pi); in brcms_b_attach()
4621 if (BRCMS_ISNPHY(wlc_hw->band)) { in brcms_b_attach()
4622 if (NCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4626 } else if (BRCMS_ISLCNPHY(wlc_hw->band)) { in brcms_b_attach()
4627 if (LCNCONF_HAS(wlc_hw->band->phyrev)) in brcms_b_attach()
4635 wlc_hw->band->phytype, wlc_hw->band->phyrev); in brcms_b_attach()
4642 * BMAC_NOTE: wlc->band->pi should not be set below and should in brcms_b_attach()
4643 * be done in the high level attach. However we can not make in brcms_b_attach()
4645 * wlc_hw->band->pi. Instead do the wlc->band->pi init below, in brcms_b_attach()
4646 * keeping wlc_hw->band->pi as well for incremental update of in brcms_b_attach()
4650 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4651 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4652 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4653 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4654 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4656 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4657 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4659 wlc_hw->band->CWmin = APHY_CWMIN; in brcms_b_attach()
4660 wlc_hw->band->CWmax = PHY_CWMAX; in brcms_b_attach()
4672 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_attach()
4678 * The hardware is in the DOWN state at this point. D11 core in brcms_b_attach()
4679 * or cores are in reset with clocks off, and the board PLLs in brcms_b_attach()
4682 * Beyond this point, wlc->sbclk == false and chip registers in brcms_b_attach()
4688 brcms_c_get_macaddr(wlc_hw, wlc_hw->etheraddr); in brcms_b_attach()
4690 if (is_broadcast_ether_addr(wlc_hw->etheraddr) || in brcms_b_attach()
4691 is_zero_ether_addr(wlc_hw->etheraddr)) { in brcms_b_attach()
4698 brcms_dbg_info(wlc_hw->d11core, "deviceid 0x%x nbands %d board 0x%x\n", in brcms_b_attach()
4699 wlc_hw->deviceid, wlc_hw->_nbands, in brcms_b_attach()
4700 ai_get_boardtype(wlc_hw->sih)); in brcms_b_attach()
4715 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4717 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4718 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4722 aa = sprom->ant_available_a; in brcms_c_attach_stf_ant_init()
4724 aa = sprom->ant_available_bg; in brcms_c_attach_stf_ant_init()
4727 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4734 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4735 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4737 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4738 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4744 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4746 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4754 struct brcms_band *band; in brcms_c_bss_default_init() local
4755 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4759 bi->beacon_period = BEACON_INTERVAL_DEFAULT; in brcms_c_bss_default_init()
4765 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4767 /* find the band of our default channel */ in brcms_c_bss_default_init()
4768 band = wlc->band; in brcms_c_bss_default_init()
4769 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4770 band->bandunit != chspec_bandunit(chanspec)) in brcms_c_bss_default_init()
4771 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4773 /* init bss rates to the band specific default rate set */ in brcms_c_bss_default_init()
4774 brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, in brcms_c_bss_default_init()
4775 band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_c_bss_default_init()
4776 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4777 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4779 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4780 bi->flags |= BRCMS_BSS_HT; in brcms_c_bss_default_init()
4786 struct brcms_band *band; in brcms_c_update_mimo_band_bwcap() local
4788 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4789 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4790 if (band->bandtype == BRCM_BAND_5G) { in brcms_c_update_mimo_band_bwcap()
4793 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4795 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4798 band->mimo_cap_40 = true; in brcms_c_update_mimo_band_bwcap()
4800 band->mimo_cap_40 = false; in brcms_c_update_mimo_band_bwcap()
4808 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4809 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4810 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4812 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4813 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4814 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4820 if (wlc->asi) { in brcms_c_detach_module()
4821 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4822 wlc->asi = NULL; in brcms_c_detach_module()
4825 if (wlc->ampdu) { in brcms_c_detach_module()
4826 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4827 wlc->ampdu = NULL; in brcms_c_detach_module()
4839 struct brcms_hw_band *band; in brcms_b_detach() local
4840 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4844 band = wlc_hw->band; in brcms_b_detach()
4845 for (i = 0; i < wlc_hw->_nbands; i++) { in brcms_b_detach()
4846 if (band->pi) { in brcms_b_detach()
4847 /* Detach this band's phy */ in brcms_b_detach()
4848 wlc_phy_detach(band->pi); in brcms_b_detach()
4849 band->pi = NULL; in brcms_b_detach()
4851 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4855 kfree(wlc_hw->phy_sh); in brcms_b_detach()
4857 wlc_phy_shim_detach(wlc_hw->physhim); in brcms_b_detach()
4859 if (wlc_hw->sih) { in brcms_b_detach()
4860 ai_detach(wlc_hw->sih); in brcms_b_detach()
4861 wlc_hw->sih = NULL; in brcms_b_detach()
4869 * It can NOT touch hardware registers since the d11core may be in reset and
4889 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4902 /* STA-BSS; short capable */ in brcms_c_ap_upd()
4903 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4909 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4912 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_hw_up()
4919 ai_clkctl_init(wlc_hw->sih); in brcms_b_hw_up()
4933 wlc_phy_por_inform(wlc_hw->band->pi); in brcms_b_hw_up()
4935 wlc_hw->ucode_loaded = false; in brcms_b_hw_up()
4936 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4938 if ((wlc_hw->boardflags & BFL_FEM) in brcms_b_hw_up()
4939 && (ai_get_chip_id(wlc_hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_b_hw_up()
4941 (wlc_hw->boardrev >= 0x1250 in brcms_b_hw_up()
4942 && (wlc_hw->boardflags & BFL_FEM_BT))) in brcms_b_hw_up()
4943 ai_epa_4313war(wlc_hw->sih); in brcms_b_hw_up()
4949 brcms_dbg_info(wlc_hw->d11core, "wl%d\n", wlc_hw->unit); in brcms_b_up_prep()
4956 ai_clkctl_init(wlc_hw->sih); in brcms_b_up_prep()
4960 * Configure pci/pcmcia here instead of in brcms_c_attach() in brcms_b_up_prep()
4963 bcma_host_pci_irq_ctl(wlc_hw->d11core->bus, wlc_hw->d11core, in brcms_b_up_prep()
4969 * bring the driver up in this case. in brcms_b_up_prep()
4972 /* put SB PCI in down state again */ in brcms_b_up_prep()
4973 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_up_prep()
4975 return -ENOMEDIUM; in brcms_b_up_prep()
4978 bcma_host_pci_up(wlc_hw->d11core->bus); in brcms_b_up_prep()
4988 wlc_hw->up = true; in brcms_b_up_finish()
4989 wlc_phy_hw_state_upd(wlc_hw->band->pi, true); in brcms_b_up_finish()
4993 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
5006 if (!wlc->clk) in brcms_c_wme_retries_write()
5010 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
5011 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
5019 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
5022 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
5023 return -ENOMEDIUM; in brcms_c_up()
5025 if (!wlc->pub->hw_up) { in brcms_c_up()
5026 brcms_b_hw_up(wlc->hw); in brcms_c_up()
5027 wlc->pub->hw_up = true; in brcms_c_up()
5030 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5031 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5032 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5033 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5034 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5037 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5044 * the driver up in this case. If radio is disabled, abort up, lower in brcms_c_up()
5048 * brcms_b_up_prep() returns either 0 or -BCME_RADIOOFF only in brcms_c_up()
5050 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5051 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5052 if (status == -ENOMEDIUM) { in brcms_c_up()
5054 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5055 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5056 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5058 if (bsscfg->type == BRCMS_TYPE_STATION || in brcms_c_up()
5059 bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_up()
5060 brcms_err(wlc->hw->d11core, in brcms_c_up()
5061 "wl%d: up: rfdisable -> " in brcms_c_up()
5063 wlc->pub->unit); in brcms_c_up()
5068 if (wlc->pub->radio_disabled) { in brcms_c_up()
5074 wlc->clk = true; in brcms_c_up()
5079 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5081 brcms_init(wlc->wl); in brcms_c_up()
5082 wlc->pub->up = true; in brcms_c_up()
5084 if (wlc->bandinit_pending) { in brcms_c_up()
5085 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5087 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5088 wlc->bandinit_pending = false; in brcms_c_up()
5092 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5098 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5099 wlc->WDarmed = true; in brcms_c_up()
5103 /* ensure LDPC config is in sync */ in brcms_c_up()
5104 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5121 if (!wlc_hw->up) in brcms_b_bmac_down_prep()
5124 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5128 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5131 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5137 callbacks += wlc_phy_down(wlc_hw->band->pi); in brcms_b_bmac_down_prep()
5147 if (!wlc_hw->up) in brcms_b_down_finish()
5150 wlc_hw->up = false; in brcms_b_down_finish()
5151 wlc_phy_hw_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5153 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5156 wlc_hw->sbclk = false; in brcms_b_down_finish()
5157 wlc_hw->clk = false; in brcms_b_down_finish()
5158 wlc_phy_hw_clk_state_upd(wlc_hw->band->pi, false); in brcms_b_down_finish()
5161 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5165 if (bcma_core_is_enabled(wlc_hw->d11core)) { in brcms_b_down_finish()
5166 if (bcma_read32(wlc_hw->d11core, in brcms_b_down_finish()
5168 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5169 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5174 if (!wlc_hw->noreset) { in brcms_b_down_finish()
5175 bcma_host_pci_down(wlc_hw->d11core->bus); in brcms_b_down_finish()
5195 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5197 /* check if we are already in the going down path */ in brcms_c_down()
5198 if (wlc->going_down) { in brcms_c_down()
5199 brcms_err(wlc->hw->d11core, in brcms_c_down()
5201 wlc->pub->unit, __func__); in brcms_c_down()
5204 if (!wlc->pub->up) in brcms_c_down()
5207 wlc->going_down = true; in brcms_c_down()
5209 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5215 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5217 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5221 if (wlc->WDarmed) { in brcms_c_down()
5222 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5224 wlc->WDarmed = false; in brcms_c_down()
5229 wlc->pub->up = false; in brcms_c_down()
5231 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5233 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5236 wlc->clk = false; in brcms_c_down()
5238 wlc->going_down = false; in brcms_c_down()
5249 /* Advertise and use shortslot (-1/0/1 Auto/Off/On) */ in brcms_c_set_gmode()
5252 struct brcms_band *band; in brcms_c_set_gmode() local
5254 /* if N-support is enabled, allow Gmode set as long as requested in brcms_c_set_gmode()
5257 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5258 return -ENOTSUPP; in brcms_c_set_gmode()
5260 /* verify that we are dealing with 2G band and grab the band pointer */ in brcms_c_set_gmode()
5261 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5262 band = wlc->band; in brcms_c_set_gmode()
5263 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5264 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5265 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5267 return -EINVAL; in brcms_c_set_gmode()
5301 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5302 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5303 return -ENOTSUPP; in brcms_c_set_gmode()
5306 band->gmode = gmode; in brcms_c_set_gmode()
5308 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5324 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5325 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5326 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5336 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5344 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5346 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5347 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5349 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5350 wlc->stf->txstreams); in brcms_c_set_nmode()
5351 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5352 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5353 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5369 return -EINVAL; in brcms_c_set_internal_rateset()
5371 /* try the current band */ in brcms_c_set_internal_rateset()
5372 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5375 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5376 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5379 /* try the other band */ in brcms_c_set_internal_rateset()
5384 &wlc-> in brcms_c_set_internal_rateset()
5385 bandstate[bandunit]-> in brcms_c_set_internal_rateset()
5387 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5391 return -EBADE; in brcms_c_set_internal_rateset()
5395 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5397 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5407 if (wlc->pub->associated) in brcms_c_ofdm_rateset_war()
5408 r = wlc->bsscfg->current_bss->rateset.rates[0]; in brcms_c_ofdm_rateset_war()
5410 r = wlc->default_bss->rateset.rates[0]; in brcms_c_ofdm_rateset_war()
5412 wlc_phy_ofdm_rateset_war(wlc->band->pi, war); in brcms_c_ofdm_rateset_war()
5420 return -EINVAL; in brcms_c_set_channel()
5422 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5423 return -EINVAL; in brcms_c_set_channel()
5426 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5427 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5428 wlc->bandinit_pending = true; in brcms_c_set_channel()
5430 wlc->bandinit_pending = false; in brcms_c_set_channel()
5433 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5436 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5451 return -EINVAL; in brcms_c_set_rate_limit()
5453 wlc->SRL = srl; in brcms_c_set_rate_limit()
5454 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5456 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5459 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5460 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5461 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5462 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5474 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5475 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5477 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5480 currs->count = rs->count; in brcms_c_get_current_rateset()
5481 memcpy(&currs->rates, &rs->rates, rs->count); in brcms_c_get_current_rateset()
5489 if (rs->count > BRCMS_NUMRATES) in brcms_c_set_rateset()
5490 return -ENOBUFS; in brcms_c_set_rateset()
5495 internal_rs.count = rs->count; in brcms_c_set_rateset()
5496 memcpy(&internal_rs.rates, &rs->rates, internal_rs.count); in brcms_c_set_rateset()
5498 /* merge rateset coming in with the current mcsset */ in brcms_c_set_rateset()
5499 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5501 if (wlc->pub->associated) in brcms_c_set_rateset()
5502 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5504 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5505 memcpy(internal_rs.mcs, &mcsset_bss->rateset.mcs[0], in brcms_c_set_rateset()
5518 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5520 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5525 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5527 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5535 return -EINVAL; in brcms_c_set_beacon_period()
5537 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5541 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5543 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5551 return wlc->band->phytype; in brcms_c_get_phy_type()
5556 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5560 * currently on the 5G band in brcms_c_set_shortslot_override()
5562 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5565 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5567 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5573 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5574 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5576 wlc->shortslot = in brcms_c_set_shortslot_override()
5577 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5589 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register()
5594 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5595 strncpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5596 sizeof(wlc->modulecb[i].name) - 1); in brcms_c_module_register()
5597 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5598 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5603 return -ENOSR; in brcms_c_module_register()
5610 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister()
5614 return -ENODATA; in brcms_c_module_unregister()
5617 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5618 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5619 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5625 return -ENODATA; in brcms_c_module_unregister()
5630 struct pci_dev *pcidev = core->bus->host_pci; in brcms_c_chipmatch_pci()
5631 u16 vendor = pcidev->vendor; in brcms_c_chipmatch_pci()
5632 u16 device = pcidev->device; in brcms_c_chipmatch_pci()
5654 struct bcma_chipinfo *chipinfo = &core->bus->chipinfo; in brcms_c_chipmatch_soc()
5656 if (chipinfo->id == BCMA_CHIP_ID_BCM4716) in brcms_c_chipmatch_soc()
5659 pr_err("unknown chip id %04x\n", chipinfo->id); in brcms_c_chipmatch_soc()
5665 switch (core->bus->hosttype) { in brcms_c_chipmatch()
5671 pr_err("unknown host type: %i\n", core->bus->hosttype); in brcms_c_chipmatch()
5687 /* for a given rate, the LS-nibble of the PLCP SIGNAL field is in brcms_b_rate_shm_offset()
5693 /* Find the SHM pointer to the rate table entry by looking in the in brcms_b_rate_shm_offset()
5694 * Direct-map Table in brcms_b_rate_shm_offset()
5710 frameid = le16_to_cpu(txh->TxFrameID) & ~(TXFID_SEQ_MASK | in bcmc_fid_generate()
5713 (((wlc-> in bcmc_fid_generate()
5727 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that in brcms_c_calc_ack_time()
5729 * frame in the FES in brcms_c_calc_ack_time()
5751 * Spec 9.6: ack rate is the highest rate in BSSBasicRateSet that in brcms_c_calc_ba_time()
5753 * frame in the FES in brcms_c_calc_ba_time()
5768 * rate MPDU rate in unit of 500kbps
5769 * next_frag_len next MPDU length in bytes
5778 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5806 dur -= PREN_PREAMBLE + (tot_streams * PREN_PREAMBLE_EXT); in brcms_c_calc_frame_len()
5808 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5809 dur -= DOT11_OFDM_SIGNAL_EXTENSION; in brcms_c_calc_frame_len()
5815 ((nsyms * kNdps) - in brcms_c_calc_frame_len()
5818 dur -= APHY_PREAMBLE_TIME; in brcms_c_calc_frame_len()
5819 dur -= APHY_SIGNAL_TIME; in brcms_c_calc_frame_len()
5824 ((nsyms * Ndps) - in brcms_c_calc_frame_len()
5828 dur -= BPHY_PLCP_SHORT_TIME; in brcms_c_calc_frame_len()
5830 dur -= BPHY_PLCP_TIME; in brcms_c_calc_frame_len()
5832 /* divide out factor of 2 in rate (1/2 mbps) */ in brcms_c_calc_frame_len()
5839 * Return true if the specified rate is supported by the specified band.
5840 * BRCM_BAND_AUTO indicates the current band.
5842 static bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, in brcms_c_valid_rate() argument
5848 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5849 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5850 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5851 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5853 /* other band specified and we are a single band device */ in brcms_c_valid_rate()
5861 return isset(hw_rateset->mcs, (rspec & RSPEC_RATE_MASK)); in brcms_c_valid_rate()
5864 for (i = 0; i < hw_rateset->count; i++) in brcms_c_valid_rate()
5865 if (hw_rateset->rates[i] == rspec2rate(rspec)) in brcms_c_valid_rate()
5869 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5870 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5879 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5893 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5897 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5898 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5904 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5908 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5909 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5918 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5923 * MCS 0-7 may use SISO, CDD, and for in mac80211_wlc_set_nrate()
5930 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5931 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5938 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5939 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5943 if ((cur_band->bandtype != BRCM_BAND_2G) in mac80211_wlc_set_nrate()
5946 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5947 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5952 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5953 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5956 /* make sure multiple antennae are available for non-siso rates */ in mac80211_wlc_set_nrate()
5957 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5959 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5960 bcmerror = -EINVAL; in mac80211_wlc_set_nrate()
5984 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
5994 * Rate is given in the driver standard multiple of 500 kbps.
6014 if ((length << 4) - (usec * 11) > 0) in brcms_c_cck_plcp_set()
6019 if ((length << 3) - (usec * 11) > 0) { in brcms_c_cck_plcp_set()
6021 if ((usec * 11) - (length << 3) >= 8) in brcms_c_cck_plcp_set()
6027 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
6046 /* Rate: 802.11 rate code, length: PSDU length in octets */
6060 /* Rate: 802.11 rate code, length: PSDU length in octets */
6069 * encode rate per 802.11a-1999 sec 17.3.4.1, with lsb in brcms_c_compute_ofdm_plcp()
6082 /* Rate: 802.11 rate code, length: PSDU length in octets */
6107 * DUR for CTS-TO-SELF w/ frame = 2 SIFS + next frame time + 1 ACK
6109 * cts cts-to-self or rts/cts
6110 * rts_rate rts or cts rate in unit of 500kbps
6111 * rate next MPDU rate in unit of 500kbps
6112 * frame_len next MPDU frame length in bytes
6122 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6131 /* CTS-TO-SELF */ in brcms_c_compute_rtscts_dur()
6154 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6160 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6169 /* bw, stf, coding-type is part of rspec_phytxbyte2 returns */ in brcms_c_phytxctl1_calc()
6173 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6174 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6176 * In CCK mode LPPHY overloads OFDM Modulation bits with CCK in brcms_c_phytxctl1_calc()
6186 if (phycfg == -1) { in brcms_c_phytxctl1_calc()
6187 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6246 h = (struct ieee80211_hdr *)(p->data); in brcms_c_d11hdrs_mac80211()
6247 qos = ieee80211_is_data_qos(h->frame_control); in brcms_c_d11hdrs_mac80211()
6249 /* compute length of frame in bytes for use in PLCP computations */ in brcms_c_d11hdrs_mac80211()
6250 len = p->len; in brcms_c_d11hdrs_mac80211()
6264 if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { in brcms_c_d11hdrs_mac80211()
6265 /* non-AP STA should never use BCMC queue */ in brcms_c_d11hdrs_mac80211()
6267 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6269 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6273 if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) in brcms_c_d11hdrs_mac80211()
6274 scb->seqnum[p->priority]++; in brcms_c_d11hdrs_mac80211()
6277 seq = le16_to_cpu(h->seq_ctrl) & FRAGNUM_MASK; in brcms_c_d11hdrs_mac80211()
6278 seq |= (scb->seqnum[p->priority] << SEQNUM_SHIFT); in brcms_c_d11hdrs_mac80211()
6279 h->seq_ctrl = cpu_to_le16(seq); in brcms_c_d11hdrs_mac80211()
6287 /* set the ignpmq bit for all pkts tx'd in PS mode and for beacons */ in brcms_c_d11hdrs_mac80211()
6288 if (ieee80211_is_beacon(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6291 txrate[0] = tx_info->control.rates; in brcms_c_d11hdrs_mac80211()
6298 if (txrate[1]->idx < 0) in brcms_c_d11hdrs_mac80211()
6301 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6302 is_mcs = txrate[k]->flags & IEEE80211_TX_RC_MCS ? true : false; in brcms_c_d11hdrs_mac80211()
6304 if ((txrate[k]->idx >= 0) in brcms_c_d11hdrs_mac80211()
6305 && (txrate[k]->idx < in brcms_c_d11hdrs_mac80211()
6306 hw->wiphy->bands[tx_info->band]->n_bitrates)) { in brcms_c_d11hdrs_mac80211()
6308 hw->wiphy->bands[tx_info->band]-> in brcms_c_d11hdrs_mac80211()
6309 bitrates[txrate[k]->idx].hw_value; in brcms_c_d11hdrs_mac80211()
6311 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6318 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6319 NRATE_MCS_INUSE | txrate[k]->idx); in brcms_c_d11hdrs_mac80211()
6328 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6331 txrate[k]-> in brcms_c_d11hdrs_mac80211()
6343 if (!is_multicast_ether_addr(h->addr1)) { in brcms_c_d11hdrs_mac80211()
6345 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6351 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6353 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6354 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6385 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6389 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6399 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6400 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6402 else if (scb->flags & SCB_IS40) in brcms_c_d11hdrs_mac80211()
6405 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6406 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6407 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6408 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6434 if (txrate[k]->flags & IEEE80211_TX_RC_GREEN_FIELD) in brcms_c_d11hdrs_mac80211()
6437 if ((txrate[k]->flags & IEEE80211_TX_RC_MCS) in brcms_c_d11hdrs_mac80211()
6439 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6441 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6459 && (tx_info->control.rates[0]. in brcms_c_d11hdrs_mac80211()
6464 for (k = 0; k < hw->max_rates; k++) { in brcms_c_d11hdrs_mac80211()
6470 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6478 txrate[0]->count = 0; in brcms_c_d11hdrs_mac80211()
6479 txrate[1]->count = 0; in brcms_c_d11hdrs_mac80211()
6482 if ((ieee80211_is_data(h->frame_control) || in brcms_c_d11hdrs_mac80211()
6483 ieee80211_is_mgmt(h->frame_control)) && in brcms_c_d11hdrs_mac80211()
6484 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6491 memcpy(&txh->FragPLCPFallback, in brcms_c_d11hdrs_mac80211()
6492 plcp_fallback, sizeof(txh->FragPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6494 /* Length field now put in CCK FBR CRC field */ in brcms_c_d11hdrs_mac80211()
6496 txh->FragPLCPFallback[4] = phylen & 0xff; in brcms_c_d11hdrs_mac80211()
6497 txh->FragPLCPFallback[5] = (phylen & 0xff00) >> 8; in brcms_c_d11hdrs_mac80211()
6500 /* MIMO-RATE: need validation ?? */ in brcms_c_d11hdrs_mac80211()
6506 if (!ieee80211_is_pspoll(h->frame_control) && in brcms_c_d11hdrs_mac80211()
6507 !is_multicast_ether_addr(h->addr1) && !use_rifs) { in brcms_c_d11hdrs_mac80211()
6511 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6519 h->duration_id = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6523 if (ieee80211_is_pspoll(h->frame_control)) in brcms_c_d11hdrs_mac80211()
6524 txh->FragDurFallback = h->duration_id; in brcms_c_d11hdrs_mac80211()
6525 else if (is_multicast_ether_addr(h->addr1) || use_rifs) in brcms_c_d11hdrs_mac80211()
6526 txh->FragDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6530 txh->FragDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6533 /* (4) MAC-HDR: MacTxControlLow */ in brcms_c_d11hdrs_mac80211()
6537 if (!is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6540 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6543 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6550 txh->MacTxControlLow = cpu_to_le16(mcl); in brcms_c_d11hdrs_mac80211()
6563 memcpy(&txh->MacFrameControl, &h->frame_control, sizeof(u16)); in brcms_c_d11hdrs_mac80211()
6564 txh->TxFesTimeNormal = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6566 txh->TxFesTimeFallback = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6569 memcpy(&txh->TxFrameRA, &h->addr1, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6572 txh->TxFrameID = cpu_to_le16(frameid); in brcms_c_d11hdrs_mac80211()
6578 txh->TxStatus = cpu_to_le16(status); in brcms_c_d11hdrs_mac80211()
6582 * the END of previous structure so that it's compatible in driver. in brcms_c_d11hdrs_mac80211()
6584 txh->MaxNMpdus = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6585 txh->MaxABytes_MRT = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6586 txh->MaxABytes_FBR = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6587 txh->MinMBytes = cpu_to_le16(0); in brcms_c_d11hdrs_mac80211()
6604 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6611 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6618 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDCTS); in brcms_c_d11hdrs_mac80211()
6620 txh->MacTxControlLow |= cpu_to_le16(TXC_SENDRTS); in brcms_c_d11hdrs_mac80211()
6621 txh->MacTxControlLow |= cpu_to_le16(TXC_LONGFRAME); in brcms_c_d11hdrs_mac80211()
6625 rts_plcp = txh->RTSPhyHeader; in brcms_c_d11hdrs_mac80211()
6636 memcpy(&txh->RTSPLCPFallback, rts_plcp_fallback, in brcms_c_d11hdrs_mac80211()
6637 sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6640 rts = (struct ieee80211_rts *)&txh->rts_frame; in brcms_c_d11hdrs_mac80211()
6645 rts->duration = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6651 txh->RTSDurFallback = cpu_to_le16(durid); in brcms_c_d11hdrs_mac80211()
6654 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6657 memcpy(&rts->ra, &h->addr2, ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6659 rts->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL | in brcms_c_d11hdrs_mac80211()
6662 memcpy(&rts->ra, &h->addr1, 2 * ETH_ALEN); in brcms_c_d11hdrs_mac80211()
6674 memset(txh->RTSPhyHeader, 0, D11_PHY_HDR_LEN); in brcms_c_d11hdrs_mac80211()
6675 memset(&txh->rts_frame, 0, sizeof(struct ieee80211_rts)); in brcms_c_d11hdrs_mac80211()
6676 memset(txh->RTSPLCPFallback, 0, sizeof(txh->RTSPLCPFallback)); in brcms_c_d11hdrs_mac80211()
6677 txh->RTSDurFallback = 0; in brcms_c_d11hdrs_mac80211()
6682 if ((tx_info->flags & IEEE80211_TX_CTL_AMPDU) && is_mcs_rate(rspec)) in brcms_c_d11hdrs_mac80211()
6683 txh->RTSPLCPFallback[AMPDU_FBR_NULL_DELIM] = in brcms_c_d11hdrs_mac80211()
6684 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6692 txh->MacTxControlHigh = cpu_to_le16(mch); in brcms_c_d11hdrs_mac80211()
6698 txh->MainRates = cpu_to_le16(mainrates); in brcms_c_d11hdrs_mac80211()
6701 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6702 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6703 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6704 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6706 txh->XtraFrameTypes = cpu_to_le16(xfts); in brcms_c_d11hdrs_mac80211()
6709 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6718 txh->PhyTxControlWord = cpu_to_le16(phyctl); in brcms_c_d11hdrs_mac80211()
6721 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6725 txh->PhyTxControlWord_1 = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6727 txh->PhyTxControlWord_1_Fbr = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6731 txh->PhyTxControlWord_1_Rts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6733 txh->PhyTxControlWord_1_FbrRts = cpu_to_le16(phyctl1); in brcms_c_d11hdrs_mac80211()
6738 * is going to be set, fill in non-zero MModeLen and/or in brcms_c_d11hdrs_mac80211()
6745 txh->MModeLen = cpu_to_le16(mmodelen); in brcms_c_d11hdrs_mac80211()
6752 txh->MModeFbrLen = cpu_to_le16(mmodefbrlen); in brcms_c_d11hdrs_mac80211()
6757 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6761 if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU) && frag == 0) { in brcms_c_d11hdrs_mac80211()
6767 /* 1 RTS or CTS-to-self frame */ in brcms_c_d11hdrs_mac80211()
6775 dur += le16_to_cpu(rts->duration); in brcms_c_d11hdrs_mac80211()
6777 le16_to_cpu(txh->RTSDurFallback); in brcms_c_d11hdrs_mac80211()
6797 txh->TxFesTimeNormal = cpu_to_le16((u16) dur); in brcms_c_d11hdrs_mac80211()
6802 txh->TxFesTimeFallback = in brcms_c_d11hdrs_mac80211()
6809 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6815 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6816 (dur - frag_dur))); in brcms_c_d11hdrs_mac80211()
6822 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6824 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6826 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6828 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6831 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6833 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6837 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6838 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6840 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6842 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6843 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6853 int fifo, ret = -ENOSPC; in brcms_c_tx()
6858 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6859 txh = (struct d11txh *)(skb->data); in brcms_c_tx()
6861 if (dma->txavail == 0) { in brcms_c_tx()
6868 * in the tx ring and the tx queue isn't stopped then in brcms_c_tx()
6871 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6872 "Received frame for tx with no space in DMA ring\n"); in brcms_c_tx()
6873 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6875 return -ENOSPC; in brcms_c_tx()
6882 frameid = le16_to_cpu(txh->TxFrameID); in brcms_c_tx()
6884 /* Commit BCMC sequence number in the SHM frame ID location */ in brcms_c_tx()
6890 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6908 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6923 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6929 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6937 if (dma->txavail <= TX_HEADROOM && fifo < TX_BCMC_FIFO && in brcms_c_txfifo()
6938 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6939 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6953 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6956 * under the target in case 11 Mbps is not Basic. in brcms_c_rspec_to_rts_rspec()
6969 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6970 /* set rts txbw to correct side band */ in brcms_c_rspec_to_rts_rspec()
6985 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
6991 /* Update beacon listen interval in shared memory */
6995 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
6996 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
6998 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
6999 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
7006 struct bcma_device *core = wlc_hw->d11core; in brcms_b_read_tsf()
7014 * recover 64bit TSF value from the 16bit TSF value in the rx header
7015 * given the assumption that the TSF passed in header is within 65ms
7020 * |<---------- tsf_h ----------->||<--- tsf_l -->||<-RxTSFTime ->|
7023 * tsf_l is filled in by brcms_b_recv, which is done earlier in the
7033 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
7036 rx_tsf_0_15 = rxh->RxTSFTime; in brcms_c_recover_tsf64()
7043 rx_tsf_16_31 -= 1; in brcms_c_recover_tsf64()
7045 tsf_h -= 1; in brcms_c_recover_tsf64()
7060 /* fill in TSF and flag its presence */ in prep_mac80211_status()
7061 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7062 rx_status->flag |= RX_FLAG_MACTIME_START; in prep_mac80211_status()
7064 channel = BRCMS_CHAN_CHANNEL(rxh->RxChan); in prep_mac80211_status()
7066 rx_status->band = in prep_mac80211_status()
7068 rx_status->freq = in prep_mac80211_status()
7069 ieee80211_channel_to_frequency(channel, rx_status->band); in prep_mac80211_status()
7071 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7075 rx_status->antenna = in prep_mac80211_status()
7076 (rxh->PhyRxStatus_0 & PRXS0_RXANT_UPSUBBAND) ? 1 : 0; in prep_mac80211_status()
7078 plcp = p->data; in prep_mac80211_status()
7082 rx_status->rate_idx = rspec & RSPEC_RATE_MASK; in prep_mac80211_status()
7083 rx_status->encoding = RX_ENC_HT; in prep_mac80211_status()
7085 rx_status->bw = RATE_INFO_BW_40; in prep_mac80211_status()
7089 rx_status->rate_idx = 0; in prep_mac80211_status()
7092 rx_status->rate_idx = 1; in prep_mac80211_status()
7095 rx_status->rate_idx = 2; in prep_mac80211_status()
7098 rx_status->rate_idx = 3; in prep_mac80211_status()
7101 rx_status->rate_idx = 4; in prep_mac80211_status()
7104 rx_status->rate_idx = 5; in prep_mac80211_status()
7107 rx_status->rate_idx = 6; in prep_mac80211_status()
7110 rx_status->rate_idx = 7; in prep_mac80211_status()
7113 rx_status->rate_idx = 8; in prep_mac80211_status()
7116 rx_status->rate_idx = 9; in prep_mac80211_status()
7119 rx_status->rate_idx = 10; in prep_mac80211_status()
7122 rx_status->rate_idx = 11; in prep_mac80211_status()
7125 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7132 * of brcms_band_5GHz_nphy (in mac80211_if.c). in prep_mac80211_status()
7134 if (rx_status->band == NL80211_BAND_5GHZ) in prep_mac80211_status()
7135 rx_status->rate_idx -= BRCMS_LEGACY_5G_RATE_OFFSET; in prep_mac80211_status()
7139 if (rxh->PhyRxStatus_0 & PRXS0_SHORTH) in prep_mac80211_status()
7140 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7142 rx_status->enc_flags |= RX_ENC_FLAG_SHORTPRE; in prep_mac80211_status()
7144 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7150 rx_status->enc_flags |= RX_ENC_FLAG_SHORT_GI; in prep_mac80211_status()
7152 if (rxh->RxStatus1 & RXS_DECERR) { in prep_mac80211_status()
7153 rx_status->flag |= RX_FLAG_FAILED_PLCP_CRC; in prep_mac80211_status()
7154 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7157 if (rxh->RxStatus1 & RXS_FCSERR) { in prep_mac80211_status()
7158 rx_status->flag |= RX_FLAG_FAILED_FCS_CRC; in prep_mac80211_status()
7159 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7176 len_mpdu = p->len - D11_PHY_HDR_LEN - FCS_LEN; in brcms_c_recvctl()
7181 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7182 hdr = (struct ieee80211_hdr *)p->data; in brcms_c_recvctl()
7183 if (ieee80211_is_beacon(hdr->frame_control)) in brcms_c_recvctl()
7184 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7188 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7191 /* calculate frame duration for Mixed-mode L-SIG spoofing, return
7192 * number of bytes goes in the length field
7195 * len = 3(nsyms + nstream + 3) - 3
7227 /* (+3) account for HT-SIG(2) and HT-STF(1) */ in brcms_c_calc_lsig_len()
7231 * (-3) excluding service bits and tail bits in brcms_c_calc_lsig_len()
7233 len = (3 * nsyms) - 3; in brcms_c_calc_lsig_len()
7250 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7255 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7264 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7278 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7280 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7282 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7297 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7298 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7303 len = min_t(size_t, beacon->len, BCN_TMPL_LEN); in brcms_c_beacon_write()
7304 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7306 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7307 len + FCS_LEN - D11_PHY_HDR_LEN, beacon->data); in brcms_c_beacon_write()
7311 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7316 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7324 (len + 3) & ~3, beacon->data); in brcms_c_beacon_write()
7345 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7346 struct bcma_device *core = wlc_hw->d11core; in brcms_c_update_beacon_hw()
7351 /* Check if both templates are in use, if so sched. an interrupt in brcms_c_update_beacon_hw()
7358 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7359 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7371 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7397 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7399 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7400 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_beacon()
7402 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7403 if (!wlc->beacon) in brcms_c_update_beacon()
7405 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7406 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7407 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7416 if (wlc->beacon) in brcms_c_set_new_beacon()
7417 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7418 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7421 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7422 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7423 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7432 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7433 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7434 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7437 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7445 * to 1, it can not send it in that time frame. in brcms_c_enable_probe_resp()
7447 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7448 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7456 u8 *ssidptr = cfg->SSID; in brcms_c_shm_ssid_upd()
7462 memcpy(ssidbuf, ssidptr, cfg->SSID_len); in brcms_c_shm_ssid_upd()
7465 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7476 len = min_t(size_t, probe_resp->len, BCN_TMPL_LEN); in brcms_c_bss_update_probe_resp()
7482 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7483 (len + 3) & ~3, probe_resp->data); in brcms_c_bss_update_probe_resp()
7485 /* write the length of the probe response frame (+PLCP/-FCS) */ in brcms_c_bss_update_probe_resp()
7486 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7498 (u16)len + FCS_LEN - D11_PHY_HDR_LEN); in brcms_c_bss_update_probe_resp()
7506 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7509 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7510 bsscfg->type == BRCMS_TYPE_ADHOC)) { in brcms_c_update_probe_resp()
7511 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7513 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7522 return -EINVAL; in brcms_b_xmtfifo_sz_get()
7524 *blocks = wlc_hw->xmtfifo_sz[fifo]; in brcms_b_xmtfifo_sz_get()
7533 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7535 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7539 * Flag 'scan in progress' to withhold dynamic phy calibration
7543 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7548 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7553 wlc->pub->associated = state; in brcms_c_associate_upd()
7558 * AMPDU traffic, packets pending in hardware have to be invalidated so that
7568 dmah = hw->di[i]; in brcms_c_inval_dma_pkts()
7576 return wlc->band->bandunit; in brcms_c_get_curband()
7584 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7585 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7586 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7593 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7594 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7603 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7622 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7623 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7634 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7642 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7661 rxh = (struct d11rxhdr *) (p->data); in brcms_c_recv()
7666 /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU subframes */ in brcms_c_recv()
7667 if (rxh->RxStatus1 & RXS_PBPRES) { in brcms_c_recv()
7668 if (p->len < 2) { in brcms_c_recv()
7669 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7671 wlc->pub->unit, p->len); in brcms_c_recv()
7677 h = (struct ieee80211_hdr *)(p->data + D11_PHY_HDR_LEN); in brcms_c_recv()
7678 len = p->len; in brcms_c_recv()
7680 if (rxh->RxStatus1 & RXS_FCSERR) { in brcms_c_recv()
7681 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7686 if (len < D11_PHY_HDR_LEN + sizeof(h->frame_control)) in brcms_c_recv()
7689 /* not supporting A-MSDU */ in brcms_c_recv()
7690 is_amsdu = rxh->RxStatus2 & RXS_AMSDU_MASK; in brcms_c_recv()
7714 uint bound_limit = bound ? RXBND : -1; in brcms_b_recv()
7725 morepending = dma_rx(wlc_hw->di[fifo], &recv_frames); in brcms_b_recv()
7730 dma_rxfill(wlc_hw->di[fifo]); in brcms_b_recv()
7738 rxh_le = (struct d11rxhdr_le *)p->data; in brcms_b_recv()
7739 rxh = (struct d11rxhdr *)p->data; in brcms_b_recv()
7742 rxh->RxFrameSize = le16_to_cpu(rxh_le->RxFrameSize); in brcms_b_recv()
7743 rxh->PhyRxStatus_0 = le16_to_cpu(rxh_le->PhyRxStatus_0); in brcms_b_recv()
7744 rxh->PhyRxStatus_1 = le16_to_cpu(rxh_le->PhyRxStatus_1); in brcms_b_recv()
7745 rxh->PhyRxStatus_2 = le16_to_cpu(rxh_le->PhyRxStatus_2); in brcms_b_recv()
7746 rxh->PhyRxStatus_3 = le16_to_cpu(rxh_le->PhyRxStatus_3); in brcms_b_recv()
7747 rxh->PhyRxStatus_4 = le16_to_cpu(rxh_le->PhyRxStatus_4); in brcms_b_recv()
7748 rxh->PhyRxStatus_5 = le16_to_cpu(rxh_le->PhyRxStatus_5); in brcms_b_recv()
7749 rxh->RxStatus1 = le16_to_cpu(rxh_le->RxStatus1); in brcms_b_recv()
7750 rxh->RxStatus2 = le16_to_cpu(rxh_le->RxStatus2); in brcms_b_recv()
7751 rxh->RxTSFTime = le16_to_cpu(rxh_le->RxTSFTime); in brcms_b_recv()
7752 rxh->RxChan = le16_to_cpu(rxh_le->RxChan); in brcms_b_recv()
7754 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7760 /* second-level interrupt processing
7761 * Return true if another dpc needs to be re-scheduled. false otherwise.
7767 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7768 struct bcma_device *core = wlc_hw->d11core; in brcms_c_dpc()
7771 brcms_err(core, "wl%d: %s: dead chip\n", wlc_hw->unit, in brcms_c_dpc()
7773 brcms_down(wlc->wl); in brcms_c_dpc()
7778 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7779 wlc->macintstatus = 0; in brcms_c_dpc()
7782 wlc_hw->unit, macintstatus); in brcms_c_dpc()
7784 WARN_ON(macintstatus & MI_PRQ); /* PRQ Interrupt in non-MBSS */ in brcms_c_dpc()
7789 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7790 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7803 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7804 wlc->qvalid = 0; in brcms_c_dpc()
7813 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7817 wlc_phy_noise_sample_intr(wlc_hw->band->pi); in brcms_c_dpc()
7821 "(seconds). Resetting.\n", wlc_hw->unit, wlc_hw->now); in brcms_c_dpc()
7824 __func__, ai_get_chip_id(wlc_hw->sih), in brcms_c_dpc()
7825 ai_get_chiprev(wlc_hw->sih)); in brcms_c_dpc()
7826 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7835 " RF Disable Input\n", wlc_hw->unit); in brcms_c_dpc()
7836 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7843 /* it isn't done and needs to be resched if macintstatus is non-zero */ in brcms_c_dpc()
7844 return wlc->macintstatus != 0; in brcms_c_dpc()
7847 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7848 return wlc->macintstatus != 0; in brcms_c_dpc()
7853 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7854 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7857 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7859 chanspec = ch20mhz_chspec(ch->hw_value); in brcms_c_init()
7861 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7867 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7868 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7871 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7875 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7890 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7893 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7894 (wlc-> in brcms_c_init()
7898 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7899 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7905 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7907 /* band-specific inits */ in brcms_c_init()
7915 if (wlc->ucode_rev == 0) { in brcms_c_init()
7919 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7920 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7921 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7922 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7923 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7931 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7940 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7945 wlc->wme_retries[ac] = in brcms_c_init()
7946 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7966 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7967 pub = wlc->pub; in brcms_c_attach()
7973 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7974 wlc->core = wlc->corestate; in brcms_c_attach()
7975 wlc->wl = wl; in brcms_c_attach()
7976 pub->unit = unit; in brcms_c_attach()
7977 pub->_piomode = piomode; in brcms_c_attach()
7978 wlc->bandinit_pending = false; in brcms_c_attach()
7979 wlc->beacon_template_virgin = true; in brcms_c_attach()
7989 * inside, no more in rest of the attach) in brcms_c_attach()
7997 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
8000 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
8001 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
8006 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
8007 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
8010 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
8011 wlc->stf->hw_rxchain); in brcms_c_attach()
8015 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
8017 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
8018 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
8020 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
8021 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
8029 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
8030 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
8033 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
8034 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
8036 wlc->band->gmode); in brcms_c_attach()
8040 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
8041 pub->_n_enab = SUPPORT_11N; in brcms_c_attach()
8043 ((pub->_n_enab == in brcms_c_attach()
8048 /* init per-band default rateset, depend on band->gmode */ in brcms_c_attach()
8049 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
8051 /* fill in hw_rateset */ in brcms_c_attach()
8052 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
8053 &wlc->band->hw_rateset, false, in brcms_c_attach()
8055 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
8060 * wlc->stf->txant/txchain/ant_rx_ovr change in brcms_c_attach()
8070 wiphy_err(wl->wiphy, "wl%d: %s: init_timer failed\n", unit, in brcms_c_attach()
8077 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8078 if (!wlc->cmi) { in brcms_c_attach()
8079 wiphy_err(wl->wiphy, "wl%d: %s: channel_mgr_attach failed" in brcms_c_attach()
8085 /* init default when all parameters are ready, i.e. ->rateset */ in brcms_c_attach()
8092 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8094 wlc->mimoft = FT_HT; in brcms_c_attach()
8095 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8096 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8097 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8104 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8111 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8119 wiphy_err(wl->wiphy, "wl%d: %s: failed with err %d\n", in brcms_c_attach()