Lines Matching refs:wlc
358 static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec) in brcms_basic_rate() argument
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()
389 static bool brcms_deviceremoved(struct brcms_c_info *wlc) in brcms_deviceremoved() argument
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()
401 static int brcms_txpktpendtot(struct brcms_c_info *wlc) in brcms_txpktpendtot() argument
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()
412 static bool brcms_is_mband_unlocked(struct brcms_c_info *wlc) in brcms_is_mband_unlocked() argument
414 return wlc->pub->_nbands > 1 && !wlc->bandlocked; in brcms_is_mband_unlocked()
436 static void brcms_c_detach_mfree(struct brcms_c_info *wlc) in brcms_c_detach_mfree() argument
438 if (wlc == NULL) in brcms_c_detach_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()
459 kfree(wlc); in brcms_c_detach_mfree()
484 struct brcms_c_info *wlc; in brcms_c_attach_malloc() local
486 wlc = kzalloc(sizeof(struct brcms_c_info), GFP_ATOMIC); in brcms_c_attach_malloc()
487 if (wlc == NULL) { in brcms_c_attach_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()
525 if (wlc->modulecb == NULL) { in brcms_c_attach_malloc()
530 wlc->default_bss = kzalloc(sizeof(struct brcms_bss_info), GFP_ATOMIC); in brcms_c_attach_malloc()
531 if (wlc->default_bss == NULL) { in brcms_c_attach_malloc()
536 wlc->bsscfg = brcms_c_bsscfg_malloc(unit); in brcms_c_attach_malloc()
537 if (wlc->bsscfg == NULL) { in brcms_c_attach_malloc()
542 wlc->protection = kzalloc(sizeof(struct brcms_protection), in brcms_c_attach_malloc()
544 if (wlc->protection == NULL) { in brcms_c_attach_malloc()
549 wlc->stf = kzalloc(sizeof(struct brcms_stf), GFP_ATOMIC); in brcms_c_attach_malloc()
550 if (wlc->stf == NULL) { in brcms_c_attach_malloc()
555 wlc->bandstate[0] = in brcms_c_attach_malloc()
557 if (wlc->bandstate[0] == NULL) { in brcms_c_attach_malloc()
564 wlc->bandstate[i] = (struct brcms_band *) in brcms_c_attach_malloc()
565 ((unsigned long)wlc->bandstate[0] in brcms_c_attach_malloc()
569 wlc->corestate = kzalloc(sizeof(struct brcms_core), GFP_ATOMIC); in brcms_c_attach_malloc()
570 if (wlc->corestate == NULL) { in brcms_c_attach_malloc()
575 wlc->corestate->macstat_snapshot = in brcms_c_attach_malloc()
577 if (wlc->corestate->macstat_snapshot == NULL) { in brcms_c_attach_malloc()
582 return wlc; in brcms_c_attach_malloc()
585 brcms_c_detach_mfree(wlc); in brcms_c_attach_malloc()
614 static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_frame_time() argument
621 brcms_err(wlc->hw->d11core, "wl%d: WAR: using rate of 1 mbps\n", in brcms_c_calc_frame_time()
622 wlc->pub->unit); in brcms_c_calc_frame_time()
649 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
661 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_time()
717 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_c_ucode_bsinit()
793 wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; in brcms_c_setxband()
807 static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit) in brcms_c_setband_inact() argument
809 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_setband_inact()
819 macintmask = brcms_intrsoff(wlc->wl); in brcms_c_setband_inact()
833 brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) in brcms_c_dotxstatus() argument
851 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
862 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
869 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
873 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
875 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
877 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
885 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
889 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
896 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
899 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
908 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
913 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
916 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
928 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
943 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
945 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
948 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
949 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
998 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
1000 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
1010 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1018 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1019 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1065 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1074 static void brcms_c_tbtt(struct brcms_c_info *wlc) in brcms_c_tbtt() argument
1076 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1081 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1086 brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) in brcms_c_mhfdef() argument
1088 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1112 static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) in brcms_b_attach_dmapio() argument
1120 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1134 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1148 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1158 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1167 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1190 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1214 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init() local
1217 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1238 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1604 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu() local
1607 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1609 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1703 static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) in brcms_b_bsinit() argument
1705 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1825 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband() local
1834 macintmask = brcms_c_setband_inact(wlc, bandunit); in brcms_b_setband()
1842 brcms_b_bsinit(wlc, chanspec); in brcms_b_setband()
1849 if (wlc->macintstatus) in brcms_b_setband()
1850 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1853 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1865 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
2033 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2073 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2170 void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr) in brcms_c_start_station() argument
2172 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2173 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2176 void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid, in brcms_c_start_ap() argument
2179 brcms_c_set_ssid(wlc, ssid, ssid_len); in brcms_c_start_ap()
2181 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2182 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2183 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2185 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2188 void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr) in brcms_c_start_adhoc() argument
2190 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2191 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2193 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2197 static void brcms_c_gpio_init(struct brcms_c_info *wlc) in brcms_c_gpio_init() argument
2199 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2280 struct brcms_c_info *wlc; in brcms_ucode_download() local
2281 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2283 wlc = wlc_hw->wlc; in brcms_ucode_download()
2324 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2391 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2400 void brcms_c_intrson(struct brcms_c_info *wlc) in brcms_c_intrson() argument
2402 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2403 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2404 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2407 u32 brcms_c_intrsoff(struct brcms_c_info *wlc) in brcms_c_intrsoff() argument
2409 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2415 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2420 wlc->macintmask = 0; in brcms_c_intrsoff()
2423 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2426 void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) in brcms_c_intrsrestore() argument
2428 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2432 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2433 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2462 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2467 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2497 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2528 brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) in brcms_c_mute() argument
2530 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2541 static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) in wlc_intstatus() argument
2543 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2549 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2554 if (brcms_deviceremoved(wlc)) in wlc_intstatus()
2573 wlc->macintmask = 0; in wlc_intstatus()
2593 bool brcms_c_intrsupd(struct brcms_c_info *wlc) in brcms_c_intrsupd() argument
2598 macintstatus = wlc_intstatus(wlc, false); in brcms_c_intrsupd()
2605 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2616 bool brcms_c_isr(struct brcms_c_info *wlc) in brcms_c_isr() argument
2618 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2621 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2625 macintstatus = wlc_intstatus(wlc, true); in brcms_c_isr()
2638 wlc->macintstatus = macintstatus; in brcms_c_isr()
2644 void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) in brcms_c_suspend_mac_and_wait() argument
2646 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2668 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2679 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2704 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2712 void brcms_c_enable_mac(struct brcms_c_info *wlc) in brcms_c_enable_mac() argument
2714 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2719 wlc->band->bandunit); in brcms_c_enable_mac()
2760 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2876 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2898 static void brcms_c_flushqueues(struct brcms_c_info *wlc) in brcms_c_flushqueues() argument
2900 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2908 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
3015 static void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, in brcms_c_copyto_shm() argument
3018 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3074 static bool brcms_c_ps_allowed(struct brcms_c_info *wlc) in brcms_c_ps_allowed() argument
3080 static void brcms_c_statsupd(struct brcms_c_info *wlc) in brcms_c_statsupd() argument
3091 if (!wlc->pub->up) in brcms_c_statsupd()
3094 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3106 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3113 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3114 wlc->pub->unit, delta); in brcms_c_statsupd()
3120 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3122 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3128 if (wlc->hw->di[i]) in brcms_c_statsupd()
3129 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3136 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3140 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3143 void brcms_c_reset(struct brcms_c_info *wlc) in brcms_c_reset() argument
3145 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3148 brcms_c_statsupd(wlc); in brcms_c_reset()
3151 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3153 brcms_b_reset(wlc->hw); in brcms_c_reset()
3179 static void brcms_b_coreinit(struct brcms_c_info *wlc) in brcms_b_coreinit() argument
3181 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3189 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3214 brcms_c_gpio_init(wlc); in brcms_b_coreinit()
3311 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3312 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3356 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init() local
3364 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3374 brcms_b_coreinit(wlc); in brcms_b_init()
3377 brcms_b_bsinit(wlc, chanspec); in brcms_b_init()
3380 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3398 static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, in brcms_c_set_phy_chanspec() argument
3402 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3405 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3407 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3408 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3411 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3415 brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) in brcms_default_rateset() argument
3417 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3418 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3419 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3420 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3421 wlc->stf->txstreams); in brcms_default_rateset()
3425 static void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, in brcms_c_rate_lookup_init() argument
3432 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3450 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3473 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3474 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3519 static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, in brcms_c_bandinit_ordered() argument
3530 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3532 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3544 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3547 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3549 brcms_default_rateset(wlc, &default_rateset); in brcms_c_bandinit_ordered()
3552 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3554 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3557 brcms_c_rate_lookup_init(wlc, &default_rateset); in brcms_c_bandinit_ordered()
3561 brcms_c_set_phy_chanspec(wlc, chanspec); in brcms_c_bandinit_ordered()
3568 void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags) in brcms_c_mac_promisc() argument
3572 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3586 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3596 static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) in brcms_c_ucode_mac_upd() argument
3601 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3602 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3612 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3613 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3621 static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, in brcms_c_write_rate_shm() argument
3647 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3652 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3656 brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) in brcms_c_rateset_get_hwrs() argument
3660 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3661 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3665 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3673 static void brcms_c_set_ratetable(struct brcms_c_info *wlc) in brcms_c_set_ratetable() argument
3680 rs_dflt = brcms_c_rateset_get_hwrs(wlc); in brcms_c_set_ratetable()
3683 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3692 basic_rate = brcms_basic_rate(wlc, rate); in brcms_c_set_ratetable()
3699 brcms_c_write_rate_shm(wlc, rate, basic_rate); in brcms_c_set_ratetable()
3704 static void brcms_c_bsinit(struct brcms_c_info *wlc) in brcms_c_bsinit() argument
3706 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3707 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3710 brcms_c_set_ratetable(wlc); in brcms_c_bsinit()
3713 brcms_c_ucode_mac_upd(wlc); in brcms_c_bsinit()
3716 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3722 brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, in brcms_c_duty_cycle_set() argument
3730 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3732 wlc->pub->unit); in brcms_c_duty_cycle_set()
3739 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3742 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3744 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3750 static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) in brcms_c_set_ps_ctrl() argument
3756 hps = brcms_c_ps_allowed(wlc); in brcms_c_set_ps_ctrl()
3758 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3761 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3766 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3771 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3781 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac() local
3784 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3786 brcms_c_ampdu_macaddr_upd(wlc); in brcms_c_set_mac()
3797 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3800 void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len) in brcms_c_set_ssid() argument
3802 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3803 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3805 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3806 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3814 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3816 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3824 static void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) in brcms_c_switch_shortslot() argument
3827 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3828 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3830 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3833 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3835 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3838 static void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) in brcms_c_set_home_chanspec() argument
3840 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3841 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3843 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3844 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3894 static void brcms_c_setband(struct brcms_c_info *wlc, in brcms_c_setband() argument
3897 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3899 if (!wlc->pub->up) in brcms_c_setband()
3903 brcms_c_set_ps_ctrl(wlc); in brcms_c_setband()
3906 brcms_c_bsinit(wlc); in brcms_c_setband()
3909 static void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) in brcms_c_set_chanspec() argument
3913 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3915 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3916 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3917 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3922 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3924 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3926 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3927 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3929 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3941 brcms_c_setband(wlc, bandunit); in brcms_c_set_chanspec()
3946 brcms_c_set_phy_chanspec(wlc, chanspec); in brcms_c_set_chanspec()
3950 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3955 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3956 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3960 brcms_c_ucode_mac_upd(wlc); in brcms_c_set_chanspec()
3969 void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, in brcms_c_beacon_phytxctl_txant_upd() argument
3973 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3977 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3978 phytxant = brcms_c_stf_phytxchain_sel(wlc, bcn_rspec); in brcms_c_beacon_phytxctl_txant_upd()
3980 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3982 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3990 void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) in brcms_c_protection_upd() argument
3996 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
4000 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
4003 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
4006 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
4009 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
4012 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
4015 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
4018 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
4021 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
4024 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
4027 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4030 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4039 static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val) in brcms_c_ht_update_sgi_rx() argument
4041 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4042 brcms_c_update_beacon(wlc); in brcms_c_ht_update_sgi_rx()
4043 brcms_c_update_probe_resp(wlc, true); in brcms_c_ht_update_sgi_rx()
4047 static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) in brcms_c_ht_update_ldpc() argument
4049 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4051 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4052 brcms_c_update_beacon(wlc); in brcms_c_ht_update_ldpc()
4053 brcms_c_update_probe_resp(wlc, true); in brcms_c_ht_update_ldpc()
4054 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4058 void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, in brcms_c_wme_setparams() argument
4067 if (!wlc->clk) { in brcms_c_wme_setparams()
4068 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4069 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4077 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4087 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4088 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4094 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4098 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4107 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4114 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_wme_setparams()
4116 brcms_c_update_beacon(wlc); in brcms_c_wme_setparams()
4117 brcms_c_update_probe_resp(wlc, false); in brcms_c_wme_setparams()
4120 brcms_c_enable_mac(wlc); in brcms_c_wme_setparams()
4123 static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) in brcms_c_edcf_setparams() argument
4149 brcms_c_wme_setparams(wlc, aci, &txq_pars, suspend); in brcms_c_edcf_setparams()
4153 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_edcf_setparams()
4154 brcms_c_enable_mac(wlc); in brcms_c_edcf_setparams()
4158 static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) in brcms_c_radio_monitor_start() argument
4161 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4164 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4165 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4166 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4169 static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) in brcms_c_radio_monitor_stop() argument
4171 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4174 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4175 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4176 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4180 static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) in brcms_c_radio_hwdisable_upd() argument
4182 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4185 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4186 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4188 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4192 bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) in brcms_c_check_radio_disabled() argument
4194 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_check_radio_disabled()
4196 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4203 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; in brcms_c_radio_timer() local
4205 if (brcms_deviceremoved(wlc)) { in brcms_c_radio_timer()
4206 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4207 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4208 brcms_down(wlc->wl); in brcms_c_radio_timer()
4212 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_radio_timer()
4216 static void brcms_b_watchdog(struct brcms_c_info *wlc) in brcms_b_watchdog() argument
4218 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4230 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4236 static void brcms_c_watchdog(struct brcms_c_info *wlc) in brcms_c_watchdog() argument
4238 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4240 if (!wlc->pub->up) in brcms_c_watchdog()
4243 if (brcms_deviceremoved(wlc)) { in brcms_c_watchdog()
4244 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4245 wlc->pub->unit, __func__); in brcms_c_watchdog()
4246 brcms_down(wlc->wl); in brcms_c_watchdog()
4251 wlc->pub->now++; in brcms_c_watchdog()
4253 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_watchdog()
4255 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4258 brcms_b_watchdog(wlc); in brcms_c_watchdog()
4264 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4265 brcms_c_statsupd(wlc); in brcms_c_watchdog()
4267 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4268 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4270 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4271 brcms_c_tempsense_upd(wlc); in brcms_c_watchdog()
4277 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; in brcms_c_watchdog_by_timer() local
4279 brcms_c_watchdog(wlc); in brcms_c_watchdog_by_timer()
4282 static bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit) in brcms_c_timers_init() argument
4284 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4285 wlc, "watchdog"); in brcms_c_timers_init()
4286 if (!wlc->wdtimer) { in brcms_c_timers_init()
4287 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4292 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4293 wlc, "radio"); in brcms_c_timers_init()
4294 if (!wlc->radio_timer) { in brcms_c_timers_init()
4295 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4310 static void brcms_c_info_init(struct brcms_c_info *wlc, int unit) in brcms_c_info_init() argument
4315 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4318 wlc->shortslot = false; in brcms_c_info_init()
4319 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4321 brcms_c_protection_upd(wlc, BRCMS_PROT_G_OVR, BRCMS_PROTECTION_AUTO); in brcms_c_info_init()
4322 brcms_c_protection_upd(wlc, BRCMS_PROT_G_SPEC, false); in brcms_c_info_init()
4324 brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG_OVR, in brcms_c_info_init()
4326 brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG, BRCMS_N_PROTECTION_OFF); in brcms_c_info_init()
4327 brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF_OVR, in brcms_c_info_init()
4329 brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF, false); in brcms_c_info_init()
4330 brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, AUTO); in brcms_c_info_init()
4332 brcms_c_protection_upd(wlc, BRCMS_PROT_OVERLAP, in brcms_c_info_init()
4336 wlc->include_legacy_erp = true; in brcms_c_info_init()
4338 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4339 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4341 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4343 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4345 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4346 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4349 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4350 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4353 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4354 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4357 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4360 static uint brcms_c_attach_module(struct brcms_c_info *wlc) in brcms_c_attach_module() argument
4364 unit = wlc->pub->unit; in brcms_c_attach_module()
4366 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4367 if (wlc->asi == NULL) { in brcms_c_attach_module()
4368 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4374 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4375 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4376 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4382 if ((brcms_c_stf_attach(wlc) != 0)) { in brcms_c_attach_module()
4383 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4392 struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) in brcms_c_pub() argument
4394 return wlc->pub; in brcms_c_pub()
4403 static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, in brcms_b_attach() argument
4411 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4426 wlc_hw = wlc->hw; in brcms_b_attach()
4427 wlc_hw->wlc = wlc; in brcms_b_attach()
4527 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4528 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4529 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4530 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4531 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4532 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4533 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4534 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4535 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4537 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4580 wlc->band->bandunit = j; in brcms_b_attach()
4581 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4582 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4599 wlc->wiphy); in brcms_b_attach()
4615 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4649 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4650 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4651 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4652 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4653 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4655 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4656 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4661 if (!brcms_b_attach_dmapio(wlc, j, wme)) { in brcms_b_attach()
4709 static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) in brcms_c_attach_stf_ant_init() argument
4714 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4716 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4717 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4726 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4733 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4734 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4736 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4737 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4743 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4745 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4750 static void brcms_c_bss_default_init(struct brcms_c_info *wlc) in brcms_c_bss_default_init() argument
4754 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4764 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4767 band = wlc->band; in brcms_c_bss_default_init()
4768 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4770 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4775 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4776 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4778 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4782 static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) in brcms_c_update_mimo_band_bwcap() argument
4787 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4788 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4804 static void brcms_c_timers_deinit(struct brcms_c_info *wlc) in brcms_c_timers_deinit() argument
4807 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4808 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4809 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4811 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4812 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4813 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4817 static void brcms_c_detach_module(struct brcms_c_info *wlc) in brcms_c_detach_module() argument
4819 if (wlc->asi) { in brcms_c_detach_module()
4820 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4821 wlc->asi = NULL; in brcms_c_detach_module()
4824 if (wlc->ampdu) { in brcms_c_detach_module()
4825 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4826 wlc->ampdu = NULL; in brcms_c_detach_module()
4829 brcms_c_stf_detach(wlc); in brcms_c_detach_module()
4835 static void brcms_b_detach(struct brcms_c_info *wlc) in brcms_b_detach() argument
4839 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4850 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4874 uint brcms_c_detach(struct brcms_c_info *wlc) in brcms_c_detach() argument
4878 if (wlc == NULL) in brcms_c_detach()
4881 brcms_b_detach(wlc); in brcms_c_detach()
4885 if (!brcms_c_radio_monitor_stop(wlc)) in brcms_c_detach()
4888 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4890 brcms_c_timers_deinit(wlc); in brcms_c_detach()
4892 brcms_c_detach_module(wlc); in brcms_c_detach()
4894 brcms_c_detach_mfree(wlc); in brcms_c_detach()
4899 static void brcms_c_ap_upd(struct brcms_c_info *wlc) in brcms_c_ap_upd() argument
4902 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4908 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4935 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4992 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
5000 static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) in brcms_c_wme_retries_write() argument
5005 if (!wlc->clk) in brcms_c_wme_retries_write()
5009 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
5010 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
5014 int brcms_c_up(struct brcms_c_info *wlc) in brcms_c_up() argument
5018 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
5021 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
5024 if (!wlc->pub->hw_up) { in brcms_c_up()
5025 brcms_b_hw_up(wlc->hw); in brcms_c_up()
5026 wlc->pub->hw_up = true; in brcms_c_up()
5029 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5030 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5031 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5032 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5033 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5036 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5049 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5050 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5053 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5054 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5055 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5059 brcms_err(wlc->hw->d11core, in brcms_c_up()
5062 wlc->pub->unit); in brcms_c_up()
5067 if (wlc->pub->radio_disabled) { in brcms_c_up()
5068 brcms_c_radio_monitor_start(wlc); in brcms_c_up()
5073 wlc->clk = true; in brcms_c_up()
5075 brcms_c_radio_monitor_stop(wlc); in brcms_c_up()
5078 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5080 brcms_init(wlc->wl); in brcms_c_up()
5081 wlc->pub->up = true; in brcms_c_up()
5083 if (wlc->bandinit_pending) { in brcms_c_up()
5084 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5085 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_up()
5086 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5087 wlc->bandinit_pending = false; in brcms_c_up()
5088 brcms_c_enable_mac(wlc); in brcms_c_up()
5091 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5094 brcms_c_wme_retries_write(wlc); in brcms_c_up()
5097 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5098 wlc->WDarmed = true; in brcms_c_up()
5101 brcms_c_stf_phy_txant_upd(wlc); in brcms_c_up()
5103 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5108 static uint brcms_c_down_del_timer(struct brcms_c_info *wlc) in brcms_c_down_del_timer() argument
5123 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5127 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5130 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5152 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5160 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5167 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5168 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5187 uint brcms_c_down(struct brcms_c_info *wlc) in brcms_c_down() argument
5194 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5197 if (wlc->going_down) { in brcms_c_down()
5198 brcms_err(wlc->hw->d11core, in brcms_c_down()
5200 wlc->pub->unit, __func__); in brcms_c_down()
5203 if (!wlc->pub->up) in brcms_c_down()
5206 wlc->going_down = true; in brcms_c_down()
5208 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5210 dev_gone = brcms_deviceremoved(wlc); in brcms_c_down()
5214 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5216 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5220 if (wlc->WDarmed) { in brcms_c_down()
5221 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5223 wlc->WDarmed = false; in brcms_c_down()
5226 callbacks += brcms_c_down_del_timer(wlc); in brcms_c_down()
5228 wlc->pub->up = false; in brcms_c_down()
5230 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5232 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5235 wlc->clk = false; in brcms_c_down()
5237 wlc->going_down = false; in brcms_c_down()
5242 int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) in brcms_c_set_gmode() argument
5264 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5268 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5269 band = wlc->band; in brcms_c_set_gmode()
5270 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5271 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5272 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5278 brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); in brcms_c_set_gmode()
5313 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5314 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5320 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5336 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5337 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5338 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5343 int brcms_c_set_nmode(struct brcms_c_info *wlc) in brcms_c_set_nmode() argument
5348 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5354 brcms_c_set_gmode(wlc, GMODE_AUTO, true); in brcms_c_set_nmode()
5356 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5358 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5359 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5361 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5362 wlc->stf->txstreams); in brcms_c_set_nmode()
5363 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5364 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5365 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5371 brcms_c_set_internal_rateset(struct brcms_c_info *wlc, in brcms_c_set_internal_rateset() argument
5384 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5387 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5388 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5392 if (brcms_is_mband_unlocked(wlc)) { in brcms_c_set_internal_rateset()
5393 bandunit = OTHERBANDUNIT(wlc); in brcms_c_set_internal_rateset()
5396 &wlc-> in brcms_c_set_internal_rateset()
5399 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5407 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5409 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5414 static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) in brcms_c_ofdm_rateset_war() argument
5419 if (wlc->pub->associated) in brcms_c_ofdm_rateset_war()
5420 r = wlc->bsscfg->current_bss->rateset.rates[0]; in brcms_c_ofdm_rateset_war()
5422 r = wlc->default_bss->rateset.rates[0]; in brcms_c_ofdm_rateset_war()
5424 wlc_phy_ofdm_rateset_war(wlc->band->pi, war); in brcms_c_ofdm_rateset_war()
5427 int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) in brcms_c_set_channel() argument
5434 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5438 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5439 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5440 wlc->bandinit_pending = true; in brcms_c_set_channel()
5442 wlc->bandinit_pending = false; in brcms_c_set_channel()
5445 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5448 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5449 brcms_c_set_home_chanspec(wlc, chspec); in brcms_c_set_channel()
5450 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_set_channel()
5451 brcms_c_set_chanspec(wlc, chspec); in brcms_c_set_channel()
5452 brcms_c_enable_mac(wlc); in brcms_c_set_channel()
5457 int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) in brcms_c_set_rate_limit() argument
5465 wlc->SRL = srl; in brcms_c_set_rate_limit()
5466 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5468 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5471 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5472 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5473 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5474 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5476 brcms_c_wme_retries_write(wlc); in brcms_c_set_rate_limit()
5481 void brcms_c_get_current_rateset(struct brcms_c_info *wlc, in brcms_c_get_current_rateset() argument
5486 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5487 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5489 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5496 int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs) in brcms_c_set_rateset() argument
5511 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5513 if (wlc->pub->associated) in brcms_c_set_rateset()
5514 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5516 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5521 bcmerror = brcms_c_set_internal_rateset(wlc, &internal_rs); in brcms_c_set_rateset()
5523 brcms_c_ofdm_rateset_war(wlc); in brcms_c_set_rateset()
5528 static void brcms_c_time_lock(struct brcms_c_info *wlc) in brcms_c_time_lock() argument
5530 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5532 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5535 static void brcms_c_time_unlock(struct brcms_c_info *wlc) in brcms_c_time_unlock() argument
5537 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5539 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5542 int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period) in brcms_c_set_beacon_period() argument
5549 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5552 brcms_c_time_lock(wlc); in brcms_c_set_beacon_period()
5553 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5555 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5556 brcms_c_time_unlock(wlc); in brcms_c_set_beacon_period()
5561 u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx) in brcms_c_get_phy_type() argument
5563 return wlc->band->phytype; in brcms_c_get_phy_type()
5566 void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) in brcms_c_set_shortslot_override() argument
5568 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5574 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5577 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5579 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5581 brcms_c_switch_shortslot(wlc, false); in brcms_c_set_shortslot_override()
5585 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5586 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5588 wlc->shortslot = in brcms_c_set_shortslot_override()
5589 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5601 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register() local
5606 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5607 strncpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5608 sizeof(wlc->modulecb[i].name) - 1); in brcms_c_module_register()
5609 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5610 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5622 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister() local
5625 if (wlc == NULL) in brcms_c_module_unregister()
5629 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5630 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5631 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5717 bcmc_fid_generate(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg, in bcmc_fid_generate() argument
5725 (((wlc-> in bcmc_fid_generate()
5733 brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_ack_time() argument
5743 rspec = brcms_basic_rate(wlc, rspec); in brcms_c_calc_ack_time()
5746 brcms_c_calc_frame_time(wlc, rspec, preamble_type, in brcms_c_calc_ack_time()
5752 brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_cts_time() argument
5755 return brcms_c_calc_ack_time(wlc, rspec, preamble_type); in brcms_c_calc_cts_time()
5759 brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_ba_time() argument
5767 rspec = brcms_basic_rate(wlc, rspec); in brcms_c_calc_ba_time()
5769 return brcms_c_calc_frame_time(wlc, rspec, preamble_type, in brcms_c_calc_ba_time()
5785 brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, in brcms_c_compute_frame_dur() argument
5790 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5793 dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type); in brcms_c_compute_frame_dur()
5801 (u16) brcms_c_calc_frame_time(wlc, rate, preamble_type, in brcms_c_compute_frame_dur()
5809 brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_frame_len() argument
5820 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5854 static bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, in brcms_c_valid_rate() argument
5860 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5861 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5862 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5863 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5881 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5882 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5888 mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, in mac80211_wlc_set_nrate() argument
5891 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5905 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5909 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5916 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5920 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5930 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5939 (!BRCMS_STBC_CAP_PHY(wlc) in mac80211_wlc_set_nrate()
5942 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5950 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5958 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5964 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5969 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5971 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5996 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
6011 static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, in brcms_c_cck_plcp_set() argument
6039 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
6095 static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, in brcms_c_compute_cck_plcp() argument
6100 brcms_c_cck_plcp_set(wlc, rate, length, plcp); in brcms_c_compute_cck_plcp()
6104 brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, in brcms_c_compute_plcp() argument
6112 brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); in brcms_c_compute_plcp()
6127 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, in brcms_c_compute_rtscts_dur() argument
6134 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6140 (u16) brcms_c_calc_cts_time(wlc, rts_rate, in brcms_c_compute_rtscts_dur()
6148 (u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type, in brcms_c_compute_rtscts_dur()
6152 (u16) brcms_c_calc_ba_time(wlc, frame_rate, in brcms_c_compute_rtscts_dur()
6156 (u16) brcms_c_calc_ack_time(wlc, frame_rate, in brcms_c_compute_rtscts_dur()
6161 static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) in brcms_c_phytxctl1_calc() argument
6166 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6172 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6185 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6186 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6199 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6221 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, in brcms_c_d11hdrs_mac80211() argument
6279 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6281 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6282 frameid = bcmc_fid_generate(wlc, NULL, txh); in brcms_c_d11hdrs_mac80211()
6330 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6357 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6363 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6365 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6380 && BRCMS_STF_SS_STBC_TX(wlc, scb)) { in brcms_c_d11hdrs_mac80211()
6397 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6401 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6411 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6412 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6417 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6418 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6419 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6420 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6451 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6453 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6482 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6496 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6501 brcms_c_compute_plcp(wlc, rspec[0], phylen, plcp); in brcms_c_d11hdrs_mac80211()
6502 brcms_c_compute_plcp(wlc, rspec[1], phylen, plcp_fallback); in brcms_c_d11hdrs_mac80211()
6521 brcms_c_compute_frame_dur(wlc, rspec[0], preamble_type[0], in brcms_c_d11hdrs_mac80211()
6527 (u16) brcms_c_calc_frame_time(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6540 durid = brcms_c_compute_frame_dur(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6552 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6555 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6609 rts_rspec[k] = brcms_c_rspec_to_rts_rspec(wlc, rspec[k], in brcms_c_d11hdrs_mac80211()
6616 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6623 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6643 brcms_c_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp); in brcms_c_d11hdrs_mac80211()
6646 brcms_c_compute_plcp(wlc, rts_rspec[1], rts_phylen, in brcms_c_d11hdrs_mac80211()
6654 durid = brcms_c_compute_rtscts_dur(wlc, use_cts, rts_rspec[0], in brcms_c_d11hdrs_mac80211()
6659 durid = brcms_c_compute_rtscts_dur(wlc, use_cts, in brcms_c_d11hdrs_mac80211()
6696 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6713 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6714 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6715 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6716 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6721 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6729 phyctl |= brcms_c_stf_d11hdrs_phyctl_txant(wlc, rspec[0]); in brcms_c_d11hdrs_mac80211()
6733 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6736 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[0]); in brcms_c_d11hdrs_mac80211()
6738 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[1]); in brcms_c_d11hdrs_mac80211()
6742 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[0]); in brcms_c_d11hdrs_mac80211()
6744 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[1]); in brcms_c_d11hdrs_mac80211()
6756 brcms_c_calc_lsig_len(wlc, rspec[0], phylen); in brcms_c_d11hdrs_mac80211()
6763 brcms_c_calc_lsig_len(wlc, rspec[1], phylen); in brcms_c_d11hdrs_mac80211()
6769 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6775 brcms_c_calc_frame_time(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6781 brcms_c_calc_cts_time(wlc, rts_rspec[0], in brcms_c_d11hdrs_mac80211()
6784 brcms_c_calc_cts_time(wlc, rts_rspec[1], in brcms_c_d11hdrs_mac80211()
6797 brcms_c_compute_frame_dur(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6801 brcms_c_calc_frame_time(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6805 brcms_c_compute_frame_dur(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6821 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6825 brcms_c_calc_frame_len(wlc, in brcms_c_d11hdrs_mac80211()
6827 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6834 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6836 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6838 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6840 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6843 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6845 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6849 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6850 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6852 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6854 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6855 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6862 static int brcms_c_tx(struct brcms_c_info *wlc, struct sk_buff *skb) in brcms_c_tx() argument
6870 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6883 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6885 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6902 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6905 ret = brcms_c_txfifo(wlc, fifo, skb); in brcms_c_tx()
6916 bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, in brcms_c_sendpkt_mac80211() argument
6920 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6923 brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0); in brcms_c_sendpkt_mac80211()
6924 if (!brcms_c_tx(wlc, sdu)) in brcms_c_sendpkt_mac80211()
6933 brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p) in brcms_c_txfifo() argument
6935 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6939 ret = dma_txfast(wlc, dma, p); in brcms_c_txfifo()
6941 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6950 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6951 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6957 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, in brcms_c_rspec_to_rts_rspec() argument
6965 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6973 rts_rspec = brcms_basic_rate(wlc, BRCM_RATE_11M); in brcms_c_rspec_to_rts_rspec()
6979 rts_rspec = brcms_basic_rate(wlc, rspec); in brcms_c_rspec_to_rts_rspec()
6981 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6997 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
7004 static void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) in brcms_c_bcn_li_upd() argument
7007 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
7008 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
7010 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
7011 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
7039 static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, in brcms_c_recover_tsf64() argument
7045 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
7064 prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, in prep_mac80211_status() argument
7073 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7083 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7137 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7156 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7166 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7171 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7177 brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh, in brcms_c_recvctl() argument
7185 prep_mac80211_status(wlc, rxh, p, &rx_status); in brcms_c_recvctl()
7193 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7196 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7200 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7210 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_lsig_len() argument
7252 brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) in brcms_c_mod_prb_rsp_rate_table() argument
7262 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7264 rs_dflt = brcms_c_rateset_get_hwrs(wlc); in brcms_c_mod_prb_rsp_rate_table()
7267 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7276 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7279 brcms_c_compute_plcp(wlc, rate, frame_len, plcp); in brcms_c_mod_prb_rsp_rate_table()
7285 dur = (u16) brcms_c_calc_frame_time(wlc, rate, in brcms_c_mod_prb_rsp_rate_table()
7290 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7292 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7294 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7303 static void brcms_c_beacon_write(struct brcms_c_info *wlc, in brcms_c_beacon_write() argument
7309 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7310 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7316 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7318 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7323 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7353 static void brcms_c_update_beacon_hw(struct brcms_c_info *wlc, in brcms_c_update_beacon_hw() argument
7357 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7370 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7371 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7372 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true, in brcms_c_update_beacon_hw()
7383 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7388 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true, in brcms_c_update_beacon_hw()
7395 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, in brcms_c_update_beacon_hw()
7407 void brcms_c_update_beacon(struct brcms_c_info *wlc) in brcms_c_update_beacon() argument
7409 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7411 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7414 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7415 if (!wlc->beacon) in brcms_c_update_beacon()
7417 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7418 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7419 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7423 void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon, in brcms_c_set_new_beacon() argument
7428 if (wlc->beacon) in brcms_c_set_new_beacon()
7429 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7430 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7433 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7434 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7435 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7436 brcms_c_update_beacon(wlc); in brcms_c_set_new_beacon()
7439 void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc, in brcms_c_set_new_probe_resp() argument
7444 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7445 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7446 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7449 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7450 brcms_c_update_probe_resp(wlc, false); in brcms_c_set_new_probe_resp()
7453 void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable) in brcms_c_enable_probe_resp() argument
7459 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7460 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7466 brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) in brcms_c_shm_ssid_upd() argument
7476 brcms_c_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); in brcms_c_shm_ssid_upd()
7477 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7481 brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, in brcms_c_bss_update_probe_resp() argument
7491 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_bss_update_probe_resp()
7494 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7498 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7501 brcms_c_shm_ssid_upd(wlc, cfg); in brcms_c_bss_update_probe_resp()
7509 brcms_c_mod_prb_rsp_rate_table(wlc, in brcms_c_bss_update_probe_resp()
7513 brcms_c_enable_mac(wlc); in brcms_c_bss_update_probe_resp()
7516 void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) in brcms_c_update_probe_resp() argument
7518 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7521 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7523 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7525 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7542 brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, in brcms_c_set_addrmatch() argument
7545 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7547 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7553 void brcms_c_scan_start(struct brcms_c_info *wlc) in brcms_c_scan_start() argument
7555 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7558 void brcms_c_scan_stop(struct brcms_c_info *wlc) in brcms_c_scan_stop() argument
7560 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7563 void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state) in brcms_c_associate_upd() argument
7565 wlc->pub->associated = state; in brcms_c_associate_upd()
7586 int brcms_c_get_curband(struct brcms_c_info *wlc) in brcms_c_get_curband() argument
7588 return wlc->band->bandunit; in brcms_c_get_curband()
7591 bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc) in brcms_c_tx_flush_completed() argument
7596 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7597 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7598 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7600 return !brcms_txpktpendtot(wlc); in brcms_c_tx_flush_completed()
7603 void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval) in brcms_c_set_beacon_listen_interval() argument
7605 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7606 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7607 brcms_c_bcn_li_upd(wlc); in brcms_c_set_beacon_listen_interval()
7610 u64 brcms_c_tsf_get(struct brcms_c_info *wlc) in brcms_c_tsf_get() argument
7615 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7624 void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf) in brcms_c_tsf_set() argument
7628 brcms_c_time_lock(wlc); in brcms_c_tsf_set()
7634 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7635 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7637 brcms_c_time_unlock(wlc); in brcms_c_tsf_set()
7640 int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr) in brcms_c_set_tx_power() argument
7646 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7649 int brcms_c_get_tx_power(struct brcms_c_info *wlc) in brcms_c_get_tx_power() argument
7654 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7665 static void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) in brcms_c_recv() argument
7681 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7683 wlc->pub->unit, p->len); in brcms_c_recv()
7693 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7706 brcms_c_recvctl(wlc, rxh, p); in brcms_c_recv()
7766 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7776 bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) in brcms_c_dpc() argument
7779 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7782 if (brcms_deviceremoved(wlc)) { in brcms_c_dpc()
7785 brcms_down(wlc->wl); in brcms_c_dpc()
7790 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7791 wlc->macintstatus = 0; in brcms_c_dpc()
7801 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7802 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7810 brcms_c_tbtt(wlc); in brcms_c_dpc()
7815 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7816 wlc->qvalid = 0; in brcms_c_dpc()
7825 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7838 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7848 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7853 brcms_c_update_beacon(wlc); in brcms_c_dpc()
7856 return wlc->macintstatus != 0; in brcms_c_dpc()
7859 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7860 return wlc->macintstatus != 0; in brcms_c_dpc()
7863 void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) in brcms_c_init() argument
7865 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7866 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7869 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7873 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7876 brcms_c_bcn_li_upd(wlc); in brcms_c_init()
7879 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7880 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7883 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7887 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7896 brcms_c_set_ps_ctrl(wlc); in brcms_c_init()
7899 brcms_c_bandinit_ordered(wlc, chanspec); in brcms_c_init()
7902 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7905 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7906 (wlc-> in brcms_c_init()
7910 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7911 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7917 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7920 brcms_c_bsinit(wlc); in brcms_c_init()
7924 brcms_c_edcf_setparams(wlc, false); in brcms_c_init()
7927 if (wlc->ucode_rev == 0) { in brcms_c_init()
7931 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7932 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7933 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7934 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7935 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7939 brcms_c_enable_mac(wlc); in brcms_c_init()
7943 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7952 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7957 wlc->wme_retries[ac] = in brcms_c_init()
7958 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7969 struct brcms_c_info *wlc; in brcms_c_attach() local
7975 wlc = brcms_c_attach_malloc(unit, &err, 0); in brcms_c_attach()
7976 if (wlc == NULL) in brcms_c_attach()
7978 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7979 pub = wlc->pub; in brcms_c_attach()
7982 wlc_info_dbg = wlc; in brcms_c_attach()
7985 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7986 wlc->core = wlc->corestate; in brcms_c_attach()
7987 wlc->wl = wl; in brcms_c_attach()
7990 wlc->bandinit_pending = false; in brcms_c_attach()
7991 wlc->beacon_template_virgin = true; in brcms_c_attach()
7994 brcms_c_info_init(wlc, unit); in brcms_c_attach()
7997 brcms_c_ap_upd(wlc); in brcms_c_attach()
8003 err = brcms_b_attach(wlc, core, unit, piomode); in brcms_c_attach()
8007 brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, OFF); in brcms_c_attach()
8009 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
8012 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
8013 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
8015 brcms_c_stf_phy_chain_calc(wlc); in brcms_c_attach()
8018 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
8019 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
8022 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
8023 wlc->stf->hw_rxchain); in brcms_c_attach()
8027 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
8029 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
8030 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
8032 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
8033 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
8035 if (!brcms_c_attach_stf_ant_init(wlc)) { in brcms_c_attach()
8041 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
8042 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
8045 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
8046 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
8047 brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, in brcms_c_attach()
8048 wlc->band->gmode); in brcms_c_attach()
8052 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
8054 brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, in brcms_c_attach()
8061 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
8064 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
8065 &wlc->band->hw_rateset, false, in brcms_c_attach()
8067 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
8074 brcms_c_stf_phy_txant_upd(wlc); in brcms_c_attach()
8077 err = brcms_c_attach_module(wlc); in brcms_c_attach()
8081 if (!brcms_c_timers_init(wlc, unit)) { in brcms_c_attach()
8089 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8090 if (!wlc->cmi) { in brcms_c_attach()
8098 brcms_c_bss_default_init(wlc); in brcms_c_attach()
8104 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8106 wlc->mimoft = FT_HT; in brcms_c_attach()
8107 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8108 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8109 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8110 brcms_c_update_mimo_band_bwcap(wlc, BRCMS_N_BW_20IN2G_40IN5G); in brcms_c_attach()
8113 if (BRCMS_SGI_CAP_PHY(wlc)) { in brcms_c_attach()
8114 brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | in brcms_c_attach()
8116 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8117 brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | in brcms_c_attach()
8120 brcms_c_ht_update_sgi_rx(wlc, 0); in brcms_c_attach()
8123 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8128 return wlc; in brcms_c_attach()
8133 if (wlc) in brcms_c_attach()
8134 brcms_c_detach(wlc); in brcms_c_attach()