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()
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()
583 return wlc; in brcms_c_attach_malloc()
586 brcms_c_detach_mfree(wlc); in brcms_c_attach_malloc()
615 static uint brcms_c_calc_frame_time(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_frame_time() argument
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()
718 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_c_ucode_bsinit()
794 wlc_hw->wlc->band = wlc_hw->wlc->bandstate[bandunit]; in brcms_c_setxband()
808 static u32 brcms_c_setband_inact(struct brcms_c_info *wlc, uint bandunit) in brcms_c_setband_inact() argument
810 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_setband_inact()
820 macintmask = brcms_intrsoff(wlc->wl); in brcms_c_setband_inact()
834 brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs) in brcms_c_dotxstatus() argument
850 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
861 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
868 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
872 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
874 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
876 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
883 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
887 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
894 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
897 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
906 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
911 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
914 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
923 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
938 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
940 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
943 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
944 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
990 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
992 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
1002 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1010 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1011 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1057 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1066 static void brcms_c_tbtt(struct brcms_c_info *wlc) in brcms_c_tbtt() argument
1068 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1073 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1078 brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) in brcms_c_mhfdef() argument
1080 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1104 static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) in brcms_b_attach_dmapio() argument
1112 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1126 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1140 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1150 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1159 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1182 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1206 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init() local
1209 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1230 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1596 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu() local
1599 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1601 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1695 static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) in brcms_b_bsinit() argument
1697 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1814 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband() local
1823 macintmask = brcms_c_setband_inact(wlc, bandunit); in brcms_b_setband()
1831 brcms_b_bsinit(wlc, chanspec); in brcms_b_setband()
1838 if (wlc->macintstatus) in brcms_b_setband()
1839 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1842 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1854 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
2022 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2062 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2159 void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr) in brcms_c_start_station() argument
2161 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2162 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2165 void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid, in brcms_c_start_ap() argument
2168 brcms_c_set_ssid(wlc, ssid, ssid_len); in brcms_c_start_ap()
2170 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2171 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2172 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2174 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2177 void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr) in brcms_c_start_adhoc() argument
2179 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2180 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2182 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2186 static void brcms_c_gpio_init(struct brcms_c_info *wlc) in brcms_c_gpio_init() argument
2188 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2269 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2310 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2377 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2386 void brcms_c_intrson(struct brcms_c_info *wlc) in brcms_c_intrson() argument
2388 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2389 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2390 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2393 u32 brcms_c_intrsoff(struct brcms_c_info *wlc) in brcms_c_intrsoff() argument
2395 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2401 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2406 wlc->macintmask = 0; in brcms_c_intrsoff()
2409 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2412 void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) in brcms_c_intrsrestore() argument
2414 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2418 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2419 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2448 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2453 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2483 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2514 brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) in brcms_c_mute() argument
2516 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2527 static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) in wlc_intstatus() argument
2529 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2535 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2540 if (brcms_deviceremoved(wlc)) in wlc_intstatus()
2559 wlc->macintmask = 0; in wlc_intstatus()
2579 bool brcms_c_intrsupd(struct brcms_c_info *wlc) in brcms_c_intrsupd() argument
2584 macintstatus = wlc_intstatus(wlc, false); in brcms_c_intrsupd()
2591 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2602 bool brcms_c_isr(struct brcms_c_info *wlc) in brcms_c_isr() argument
2604 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2607 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2611 macintstatus = wlc_intstatus(wlc, true); in brcms_c_isr()
2624 wlc->macintstatus = macintstatus; in brcms_c_isr()
2630 void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) in brcms_c_suspend_mac_and_wait() argument
2632 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2654 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2665 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2690 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2698 void brcms_c_enable_mac(struct brcms_c_info *wlc) in brcms_c_enable_mac() argument
2700 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2705 wlc->band->bandunit); in brcms_c_enable_mac()
2746 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2862 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2884 static void brcms_c_flushqueues(struct brcms_c_info *wlc) in brcms_c_flushqueues() argument
2886 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2894 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
3001 static void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, in brcms_c_copyto_shm() argument
3004 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3060 static bool brcms_c_ps_allowed(struct brcms_c_info *wlc) in brcms_c_ps_allowed() argument
3066 static void brcms_c_statsupd(struct brcms_c_info *wlc) in brcms_c_statsupd() argument
3077 if (!wlc->pub->up) in brcms_c_statsupd()
3080 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3092 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3099 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3100 wlc->pub->unit, delta); in brcms_c_statsupd()
3106 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3108 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3114 if (wlc->hw->di[i]) in brcms_c_statsupd()
3115 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3122 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3126 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3129 void brcms_c_reset(struct brcms_c_info *wlc) in brcms_c_reset() argument
3131 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3134 brcms_c_statsupd(wlc); in brcms_c_reset()
3137 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3139 brcms_b_reset(wlc->hw); in brcms_c_reset()
3165 static void brcms_b_coreinit(struct brcms_c_info *wlc) in brcms_b_coreinit() argument
3167 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3174 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3199 brcms_c_gpio_init(wlc); in brcms_b_coreinit()
3296 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3297 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3341 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init() local
3349 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3359 brcms_b_coreinit(wlc); in brcms_b_init()
3362 brcms_b_bsinit(wlc, chanspec); in brcms_b_init()
3365 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3383 static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, in brcms_c_set_phy_chanspec() argument
3387 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3390 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3392 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3393 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3396 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3400 brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) in brcms_default_rateset() argument
3402 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3403 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3404 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3405 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3406 wlc->stf->txstreams); in brcms_default_rateset()
3410 static void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, in brcms_c_rate_lookup_init() argument
3417 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3435 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3458 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3459 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3504 static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, in brcms_c_bandinit_ordered() argument
3515 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3517 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3529 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3532 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3534 brcms_default_rateset(wlc, &default_rateset); in brcms_c_bandinit_ordered()
3537 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3539 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3542 brcms_c_rate_lookup_init(wlc, &default_rateset); in brcms_c_bandinit_ordered()
3546 brcms_c_set_phy_chanspec(wlc, chanspec); in brcms_c_bandinit_ordered()
3553 void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags) in brcms_c_mac_promisc() argument
3557 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3571 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3581 static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) in brcms_c_ucode_mac_upd() argument
3586 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3587 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3597 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3598 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3606 static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, in brcms_c_write_rate_shm() argument
3632 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3637 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3641 brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) in brcms_c_rateset_get_hwrs() argument
3645 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3646 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3650 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3658 static void brcms_c_set_ratetable(struct brcms_c_info *wlc) in brcms_c_set_ratetable() argument
3665 rs_dflt = brcms_c_rateset_get_hwrs(wlc); in brcms_c_set_ratetable()
3668 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3677 basic_rate = brcms_basic_rate(wlc, rate); in brcms_c_set_ratetable()
3684 brcms_c_write_rate_shm(wlc, rate, basic_rate); in brcms_c_set_ratetable()
3689 static void brcms_c_bsinit(struct brcms_c_info *wlc) in brcms_c_bsinit() argument
3691 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3692 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3695 brcms_c_set_ratetable(wlc); in brcms_c_bsinit()
3698 brcms_c_ucode_mac_upd(wlc); in brcms_c_bsinit()
3701 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3707 brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, in brcms_c_duty_cycle_set() argument
3715 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3717 wlc->pub->unit); in brcms_c_duty_cycle_set()
3724 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3727 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3729 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3735 static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) in brcms_c_set_ps_ctrl() argument
3741 hps = brcms_c_ps_allowed(wlc); in brcms_c_set_ps_ctrl()
3743 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3746 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3751 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3756 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3765 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac() local
3768 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3770 brcms_c_ampdu_macaddr_upd(wlc); in brcms_c_set_mac()
3779 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3782 void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len) in brcms_c_set_ssid() argument
3784 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3785 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3787 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3788 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3796 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3798 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3806 static void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) in brcms_c_switch_shortslot() argument
3809 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3810 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3812 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3815 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3817 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3820 static void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) in brcms_c_set_home_chanspec() argument
3822 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3823 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3825 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3826 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3876 static void brcms_c_setband(struct brcms_c_info *wlc, in brcms_c_setband() argument
3879 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3881 if (!wlc->pub->up) in brcms_c_setband()
3885 brcms_c_set_ps_ctrl(wlc); in brcms_c_setband()
3888 brcms_c_bsinit(wlc); in brcms_c_setband()
3891 static void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) in brcms_c_set_chanspec() argument
3894 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3896 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3897 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3898 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3903 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3905 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3906 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3907 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3909 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3921 brcms_c_setband(wlc, bandunit); in brcms_c_set_chanspec()
3926 brcms_c_set_phy_chanspec(wlc, chanspec); in brcms_c_set_chanspec()
3930 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3935 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3936 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3940 brcms_c_ucode_mac_upd(wlc); in brcms_c_set_chanspec()
3949 void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, in brcms_c_beacon_phytxctl_txant_upd() argument
3953 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3957 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3958 phytxant = brcms_c_stf_phytxchain_sel(wlc, bcn_rspec); in brcms_c_beacon_phytxctl_txant_upd()
3960 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3962 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3970 void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) in brcms_c_protection_upd() argument
3976 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
3980 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
3983 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
3986 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
3989 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
3992 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
3995 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
3998 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
4001 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
4004 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
4007 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4010 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4019 static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val) in brcms_c_ht_update_sgi_rx() argument
4021 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4022 brcms_c_update_beacon(wlc); in brcms_c_ht_update_sgi_rx()
4023 brcms_c_update_probe_resp(wlc, true); in brcms_c_ht_update_sgi_rx()
4027 static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) in brcms_c_ht_update_ldpc() argument
4029 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4031 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4032 brcms_c_update_beacon(wlc); in brcms_c_ht_update_ldpc()
4033 brcms_c_update_probe_resp(wlc, true); in brcms_c_ht_update_ldpc()
4034 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4038 void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, in brcms_c_wme_setparams() argument
4047 if (!wlc->clk) { in brcms_c_wme_setparams()
4048 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4049 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4057 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4067 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4068 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4074 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4078 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4087 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4094 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_wme_setparams()
4096 brcms_c_update_beacon(wlc); in brcms_c_wme_setparams()
4097 brcms_c_update_probe_resp(wlc, false); in brcms_c_wme_setparams()
4100 brcms_c_enable_mac(wlc); in brcms_c_wme_setparams()
4103 static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) in brcms_c_edcf_setparams() argument
4129 brcms_c_wme_setparams(wlc, aci, &txq_pars, suspend); in brcms_c_edcf_setparams()
4133 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_edcf_setparams()
4134 brcms_c_enable_mac(wlc); in brcms_c_edcf_setparams()
4138 static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) in brcms_c_radio_monitor_start() argument
4141 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4144 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4145 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4146 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4149 static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) in brcms_c_radio_monitor_stop() argument
4151 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4154 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4155 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4156 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4160 static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) in brcms_c_radio_hwdisable_upd() argument
4162 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4165 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4166 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4168 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4172 bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) in brcms_c_check_radio_disabled() argument
4174 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_check_radio_disabled()
4176 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4183 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; in brcms_c_radio_timer() local
4185 if (brcms_deviceremoved(wlc)) { in brcms_c_radio_timer()
4186 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4187 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4188 brcms_down(wlc->wl); in brcms_c_radio_timer()
4192 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_radio_timer()
4196 static void brcms_b_watchdog(struct brcms_c_info *wlc) in brcms_b_watchdog() argument
4198 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4210 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4216 static void brcms_c_watchdog(struct brcms_c_info *wlc) in brcms_c_watchdog() argument
4218 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4220 if (!wlc->pub->up) in brcms_c_watchdog()
4223 if (brcms_deviceremoved(wlc)) { in brcms_c_watchdog()
4224 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4225 wlc->pub->unit, __func__); in brcms_c_watchdog()
4226 brcms_down(wlc->wl); in brcms_c_watchdog()
4231 wlc->pub->now++; in brcms_c_watchdog()
4233 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_watchdog()
4235 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4238 brcms_b_watchdog(wlc); in brcms_c_watchdog()
4244 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4245 brcms_c_statsupd(wlc); in brcms_c_watchdog()
4247 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4248 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4250 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4251 brcms_c_tempsense_upd(wlc); in brcms_c_watchdog()
4257 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; in brcms_c_watchdog_by_timer() local
4259 brcms_c_watchdog(wlc); in brcms_c_watchdog_by_timer()
4262 static bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit) in brcms_c_timers_init() argument
4264 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4265 wlc, "watchdog"); in brcms_c_timers_init()
4266 if (!wlc->wdtimer) { in brcms_c_timers_init()
4267 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4272 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4273 wlc, "radio"); in brcms_c_timers_init()
4274 if (!wlc->radio_timer) { in brcms_c_timers_init()
4275 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4290 static void brcms_c_info_init(struct brcms_c_info *wlc, int unit) in brcms_c_info_init() argument
4295 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4298 wlc->shortslot = false; in brcms_c_info_init()
4299 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4301 brcms_c_protection_upd(wlc, BRCMS_PROT_G_OVR, BRCMS_PROTECTION_AUTO); in brcms_c_info_init()
4302 brcms_c_protection_upd(wlc, BRCMS_PROT_G_SPEC, false); in brcms_c_info_init()
4304 brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG_OVR, in brcms_c_info_init()
4306 brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG, BRCMS_N_PROTECTION_OFF); in brcms_c_info_init()
4307 brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF_OVR, in brcms_c_info_init()
4309 brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF, false); in brcms_c_info_init()
4310 brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, AUTO); in brcms_c_info_init()
4312 brcms_c_protection_upd(wlc, BRCMS_PROT_OVERLAP, in brcms_c_info_init()
4316 wlc->include_legacy_erp = true; in brcms_c_info_init()
4318 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4319 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4321 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4323 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4325 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4326 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4329 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4330 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4333 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4334 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4337 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4340 static uint brcms_c_attach_module(struct brcms_c_info *wlc) in brcms_c_attach_module() argument
4344 unit = wlc->pub->unit; in brcms_c_attach_module()
4346 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4347 if (wlc->asi == NULL) { in brcms_c_attach_module()
4348 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4354 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4355 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4356 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4362 if ((brcms_c_stf_attach(wlc) != 0)) { in brcms_c_attach_module()
4363 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4372 struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) in brcms_c_pub() argument
4374 return wlc->pub; in brcms_c_pub()
4383 static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, in brcms_b_attach() argument
4391 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4406 wlc_hw = wlc->hw; in brcms_b_attach()
4407 wlc_hw->wlc = wlc; in brcms_b_attach()
4507 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4508 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4509 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4510 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4511 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4512 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4513 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4514 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4515 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4517 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4560 wlc->band->bandunit = j; in brcms_b_attach()
4561 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4562 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4579 wlc->wiphy); in brcms_b_attach()
4595 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4629 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4630 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4631 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4632 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4633 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4635 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4636 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4641 if (!brcms_b_attach_dmapio(wlc, j, wme)) { in brcms_b_attach()
4689 static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) in brcms_c_attach_stf_ant_init() argument
4694 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4696 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4697 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4706 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4713 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4714 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4716 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4717 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4723 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4725 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4730 static void brcms_c_bss_default_init(struct brcms_c_info *wlc) in brcms_c_bss_default_init() argument
4734 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4744 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4747 band = wlc->band; in brcms_c_bss_default_init()
4748 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4750 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4755 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4756 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4758 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4762 static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) in brcms_c_update_mimo_band_bwcap() argument
4767 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4768 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4784 static void brcms_c_timers_deinit(struct brcms_c_info *wlc) in brcms_c_timers_deinit() argument
4787 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4788 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4789 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4791 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4792 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4793 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4797 static void brcms_c_detach_module(struct brcms_c_info *wlc) in brcms_c_detach_module() argument
4799 if (wlc->asi) { in brcms_c_detach_module()
4800 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4801 wlc->asi = NULL; in brcms_c_detach_module()
4804 if (wlc->ampdu) { in brcms_c_detach_module()
4805 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4806 wlc->ampdu = NULL; in brcms_c_detach_module()
4809 brcms_c_stf_detach(wlc); in brcms_c_detach_module()
4815 static void brcms_b_detach(struct brcms_c_info *wlc) in brcms_b_detach() argument
4819 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4830 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4854 uint brcms_c_detach(struct brcms_c_info *wlc) in brcms_c_detach() argument
4858 if (wlc == NULL) in brcms_c_detach()
4861 brcms_b_detach(wlc); in brcms_c_detach()
4865 if (!brcms_c_radio_monitor_stop(wlc)) in brcms_c_detach()
4868 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4870 brcms_c_timers_deinit(wlc); in brcms_c_detach()
4872 brcms_c_detach_module(wlc); in brcms_c_detach()
4874 brcms_c_detach_mfree(wlc); in brcms_c_detach()
4879 static void brcms_c_ap_upd(struct brcms_c_info *wlc) in brcms_c_ap_upd() argument
4882 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4888 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4915 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4972 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
4980 static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) in brcms_c_wme_retries_write() argument
4985 if (!wlc->clk) in brcms_c_wme_retries_write()
4989 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
4990 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
4994 int brcms_c_up(struct brcms_c_info *wlc) in brcms_c_up() argument
4998 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
5001 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
5004 if (!wlc->pub->hw_up) { in brcms_c_up()
5005 brcms_b_hw_up(wlc->hw); in brcms_c_up()
5006 wlc->pub->hw_up = true; in brcms_c_up()
5009 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5010 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5011 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5012 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5013 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5016 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5029 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5030 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5033 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5034 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5035 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5039 brcms_err(wlc->hw->d11core, in brcms_c_up()
5042 wlc->pub->unit); in brcms_c_up()
5047 if (wlc->pub->radio_disabled) { in brcms_c_up()
5048 brcms_c_radio_monitor_start(wlc); in brcms_c_up()
5053 wlc->clk = true; in brcms_c_up()
5055 brcms_c_radio_monitor_stop(wlc); in brcms_c_up()
5058 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5060 brcms_init(wlc->wl); in brcms_c_up()
5061 wlc->pub->up = true; in brcms_c_up()
5063 if (wlc->bandinit_pending) { in brcms_c_up()
5064 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5065 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_up()
5066 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5067 wlc->bandinit_pending = false; in brcms_c_up()
5068 brcms_c_enable_mac(wlc); in brcms_c_up()
5071 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5074 brcms_c_wme_retries_write(wlc); in brcms_c_up()
5077 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5078 wlc->WDarmed = true; in brcms_c_up()
5081 brcms_c_stf_phy_txant_upd(wlc); in brcms_c_up()
5083 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5096 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5100 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5103 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5125 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5133 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5140 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5141 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5160 uint brcms_c_down(struct brcms_c_info *wlc) in brcms_c_down() argument
5166 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5169 if (wlc->going_down) { in brcms_c_down()
5170 brcms_err(wlc->hw->d11core, in brcms_c_down()
5172 wlc->pub->unit, __func__); in brcms_c_down()
5175 if (!wlc->pub->up) in brcms_c_down()
5178 wlc->going_down = true; in brcms_c_down()
5180 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5182 brcms_deviceremoved(wlc); in brcms_c_down()
5186 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5188 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5192 if (wlc->WDarmed) { in brcms_c_down()
5193 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5195 wlc->WDarmed = false; in brcms_c_down()
5198 wlc->pub->up = false; in brcms_c_down()
5200 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5202 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5205 wlc->clk = false; in brcms_c_down()
5207 wlc->going_down = false; in brcms_c_down()
5212 int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) in brcms_c_set_gmode() argument
5226 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5230 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5231 band = wlc->band; in brcms_c_set_gmode()
5232 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5233 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5234 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5240 brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); in brcms_c_set_gmode()
5270 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5271 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5277 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5293 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5294 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5295 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5300 int brcms_c_set_nmode(struct brcms_c_info *wlc) in brcms_c_set_nmode() argument
5305 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5311 brcms_c_set_gmode(wlc, GMODE_AUTO, true); in brcms_c_set_nmode()
5313 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5315 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5316 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5318 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5319 wlc->stf->txstreams); in brcms_c_set_nmode()
5320 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5321 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5322 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5328 brcms_c_set_internal_rateset(struct brcms_c_info *wlc, in brcms_c_set_internal_rateset() argument
5341 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5344 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5345 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5349 if (brcms_is_mband_unlocked(wlc)) { in brcms_c_set_internal_rateset()
5350 bandunit = OTHERBANDUNIT(wlc); in brcms_c_set_internal_rateset()
5353 &wlc-> in brcms_c_set_internal_rateset()
5356 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5364 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5366 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5371 static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) in brcms_c_ofdm_rateset_war() argument
5373 wlc_phy_ofdm_rateset_war(wlc->band->pi, false); in brcms_c_ofdm_rateset_war()
5376 int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) in brcms_c_set_channel() argument
5383 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5387 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5388 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5389 wlc->bandinit_pending = true; in brcms_c_set_channel()
5391 wlc->bandinit_pending = false; in brcms_c_set_channel()
5394 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5397 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5398 brcms_c_set_home_chanspec(wlc, chspec); in brcms_c_set_channel()
5399 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_set_channel()
5400 brcms_c_set_chanspec(wlc, chspec); in brcms_c_set_channel()
5401 brcms_c_enable_mac(wlc); in brcms_c_set_channel()
5406 int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) in brcms_c_set_rate_limit() argument
5414 wlc->SRL = srl; in brcms_c_set_rate_limit()
5415 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5417 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5420 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5421 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5422 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5423 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5425 brcms_c_wme_retries_write(wlc); in brcms_c_set_rate_limit()
5430 void brcms_c_get_current_rateset(struct brcms_c_info *wlc, in brcms_c_get_current_rateset() argument
5435 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5436 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5438 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5445 int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs) in brcms_c_set_rateset() argument
5460 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5462 if (wlc->pub->associated) in brcms_c_set_rateset()
5463 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5465 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5470 bcmerror = brcms_c_set_internal_rateset(wlc, &internal_rs); in brcms_c_set_rateset()
5472 brcms_c_ofdm_rateset_war(wlc); in brcms_c_set_rateset()
5477 static void brcms_c_time_lock(struct brcms_c_info *wlc) in brcms_c_time_lock() argument
5479 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5481 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5484 static void brcms_c_time_unlock(struct brcms_c_info *wlc) in brcms_c_time_unlock() argument
5486 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5488 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5491 int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period) in brcms_c_set_beacon_period() argument
5498 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5501 brcms_c_time_lock(wlc); in brcms_c_set_beacon_period()
5502 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5504 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5505 brcms_c_time_unlock(wlc); in brcms_c_set_beacon_period()
5510 u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx) in brcms_c_get_phy_type() argument
5512 return wlc->band->phytype; in brcms_c_get_phy_type()
5515 void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) in brcms_c_set_shortslot_override() argument
5517 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5523 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5526 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5528 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5530 brcms_c_switch_shortslot(wlc, false); in brcms_c_set_shortslot_override()
5534 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5535 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5537 wlc->shortslot = in brcms_c_set_shortslot_override()
5538 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5550 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register() local
5555 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5556 strncpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5557 sizeof(wlc->modulecb[i].name) - 1); in brcms_c_module_register()
5558 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5559 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5571 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister() local
5574 if (wlc == NULL) in brcms_c_module_unregister()
5578 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5579 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5580 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5666 bcmc_fid_generate(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg, in bcmc_fid_generate() argument
5674 (((wlc-> in bcmc_fid_generate()
5682 brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_ack_time() argument
5692 rspec = brcms_basic_rate(wlc, rspec); in brcms_c_calc_ack_time()
5695 brcms_c_calc_frame_time(wlc, rspec, preamble_type, in brcms_c_calc_ack_time()
5701 brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_cts_time() argument
5704 return brcms_c_calc_ack_time(wlc, rspec, preamble_type); in brcms_c_calc_cts_time()
5708 brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_ba_time() argument
5716 rspec = brcms_basic_rate(wlc, rspec); in brcms_c_calc_ba_time()
5718 return brcms_c_calc_frame_time(wlc, rspec, preamble_type, in brcms_c_calc_ba_time()
5734 brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, in brcms_c_compute_frame_dur() argument
5739 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5742 dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type); in brcms_c_compute_frame_dur()
5750 (u16) brcms_c_calc_frame_time(wlc, rate, preamble_type, in brcms_c_compute_frame_dur()
5758 brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_frame_len() argument
5769 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5803 static bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, in brcms_c_valid_rate() argument
5809 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5810 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5811 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5812 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5830 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5831 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5837 mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, in mac80211_wlc_set_nrate() argument
5840 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5853 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5857 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5863 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5867 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5876 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5885 (!BRCMS_STBC_CAP_PHY(wlc) in mac80211_wlc_set_nrate()
5888 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5895 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5902 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5907 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5911 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5913 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5937 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
5952 static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, in brcms_c_cck_plcp_set() argument
5980 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
6036 static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, in brcms_c_compute_cck_plcp() argument
6041 brcms_c_cck_plcp_set(wlc, rate, length, plcp); in brcms_c_compute_cck_plcp()
6045 brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, in brcms_c_compute_plcp() argument
6053 brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); in brcms_c_compute_plcp()
6068 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, in brcms_c_compute_rtscts_dur() argument
6075 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6081 (u16) brcms_c_calc_cts_time(wlc, rts_rate, in brcms_c_compute_rtscts_dur()
6089 (u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type, in brcms_c_compute_rtscts_dur()
6093 (u16) brcms_c_calc_ba_time(wlc, frame_rate, in brcms_c_compute_rtscts_dur()
6097 (u16) brcms_c_calc_ack_time(wlc, frame_rate, in brcms_c_compute_rtscts_dur()
6102 static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) in brcms_c_phytxctl1_calc() argument
6107 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6113 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6126 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6127 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6140 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6162 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, in brcms_c_d11hdrs_mac80211() argument
6219 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6221 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6222 frameid = bcmc_fid_generate(wlc, NULL, txh); in brcms_c_d11hdrs_mac80211()
6266 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6293 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6299 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6301 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6316 && BRCMS_STF_SS_STBC_TX(wlc, scb)) { in brcms_c_d11hdrs_mac80211()
6333 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6337 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6347 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6348 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6353 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6354 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6355 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6356 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6387 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6389 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6418 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6432 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6437 brcms_c_compute_plcp(wlc, rspec[0], phylen, plcp); in brcms_c_d11hdrs_mac80211()
6438 brcms_c_compute_plcp(wlc, rspec[1], phylen, plcp_fallback); in brcms_c_d11hdrs_mac80211()
6457 brcms_c_compute_frame_dur(wlc, rspec[0], preamble_type[0], in brcms_c_d11hdrs_mac80211()
6463 (u16) brcms_c_calc_frame_time(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6476 durid = brcms_c_compute_frame_dur(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6488 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6491 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6545 rts_rspec[k] = brcms_c_rspec_to_rts_rspec(wlc, rspec[k], in brcms_c_d11hdrs_mac80211()
6552 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6559 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6579 brcms_c_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp); in brcms_c_d11hdrs_mac80211()
6582 brcms_c_compute_plcp(wlc, rts_rspec[1], rts_phylen, in brcms_c_d11hdrs_mac80211()
6590 durid = brcms_c_compute_rtscts_dur(wlc, use_cts, rts_rspec[0], in brcms_c_d11hdrs_mac80211()
6595 durid = brcms_c_compute_rtscts_dur(wlc, use_cts, in brcms_c_d11hdrs_mac80211()
6632 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6649 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6650 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6651 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6652 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6657 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6665 phyctl |= brcms_c_stf_d11hdrs_phyctl_txant(wlc, rspec[0]); in brcms_c_d11hdrs_mac80211()
6669 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6672 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[0]); in brcms_c_d11hdrs_mac80211()
6674 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[1]); in brcms_c_d11hdrs_mac80211()
6678 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[0]); in brcms_c_d11hdrs_mac80211()
6680 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[1]); in brcms_c_d11hdrs_mac80211()
6692 brcms_c_calc_lsig_len(wlc, rspec[0], phylen); in brcms_c_d11hdrs_mac80211()
6699 brcms_c_calc_lsig_len(wlc, rspec[1], phylen); in brcms_c_d11hdrs_mac80211()
6705 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6711 brcms_c_calc_frame_time(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6717 brcms_c_calc_cts_time(wlc, rts_rspec[0], in brcms_c_d11hdrs_mac80211()
6720 brcms_c_calc_cts_time(wlc, rts_rspec[1], in brcms_c_d11hdrs_mac80211()
6733 brcms_c_compute_frame_dur(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6737 brcms_c_calc_frame_time(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6741 brcms_c_compute_frame_dur(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6757 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6761 brcms_c_calc_frame_len(wlc, in brcms_c_d11hdrs_mac80211()
6763 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6770 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6772 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6774 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6776 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6779 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6781 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6785 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6786 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6788 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6790 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6791 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6798 static int brcms_c_tx(struct brcms_c_info *wlc, struct sk_buff *skb) in brcms_c_tx() argument
6806 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6819 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6821 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6838 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6841 ret = brcms_c_txfifo(wlc, fifo, skb); in brcms_c_tx()
6852 bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, in brcms_c_sendpkt_mac80211() argument
6856 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6859 brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0); in brcms_c_sendpkt_mac80211()
6860 if (!brcms_c_tx(wlc, sdu)) in brcms_c_sendpkt_mac80211()
6869 brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p) in brcms_c_txfifo() argument
6871 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6875 ret = dma_txfast(wlc, dma, p); in brcms_c_txfifo()
6877 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6886 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6887 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6893 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, in brcms_c_rspec_to_rts_rspec() argument
6901 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6909 rts_rspec = brcms_basic_rate(wlc, BRCM_RATE_11M); in brcms_c_rspec_to_rts_rspec()
6915 rts_rspec = brcms_basic_rate(wlc, rspec); in brcms_c_rspec_to_rts_rspec()
6917 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6933 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
6940 static void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) in brcms_c_bcn_li_upd() argument
6943 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
6944 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
6946 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
6947 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
6975 static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, in brcms_c_recover_tsf64() argument
6981 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
7000 prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, in prep_mac80211_status() argument
7009 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7019 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7073 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7092 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7102 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7107 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7113 brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh, in brcms_c_recvctl() argument
7121 prep_mac80211_status(wlc, rxh, p, &rx_status); in brcms_c_recvctl()
7129 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7132 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7136 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7146 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_lsig_len() argument
7188 brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) in brcms_c_mod_prb_rsp_rate_table() argument
7198 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7200 rs_dflt = brcms_c_rateset_get_hwrs(wlc); in brcms_c_mod_prb_rsp_rate_table()
7203 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7212 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7215 brcms_c_compute_plcp(wlc, rate, frame_len, plcp); in brcms_c_mod_prb_rsp_rate_table()
7221 dur = (u16) brcms_c_calc_frame_time(wlc, rate, in brcms_c_mod_prb_rsp_rate_table()
7226 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7228 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7230 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7239 static void brcms_c_beacon_write(struct brcms_c_info *wlc, in brcms_c_beacon_write() argument
7245 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7246 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7252 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7254 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7259 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7289 static void brcms_c_update_beacon_hw(struct brcms_c_info *wlc, in brcms_c_update_beacon_hw() argument
7293 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7306 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7307 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7308 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true, in brcms_c_update_beacon_hw()
7319 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7324 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true, in brcms_c_update_beacon_hw()
7331 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, in brcms_c_update_beacon_hw()
7341 void brcms_c_update_beacon(struct brcms_c_info *wlc) in brcms_c_update_beacon() argument
7343 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7345 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7348 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7349 if (!wlc->beacon) in brcms_c_update_beacon()
7351 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7352 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7353 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7357 void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon, in brcms_c_set_new_beacon() argument
7362 if (wlc->beacon) in brcms_c_set_new_beacon()
7363 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7364 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7367 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7368 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7369 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7370 brcms_c_update_beacon(wlc); in brcms_c_set_new_beacon()
7373 void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc, in brcms_c_set_new_probe_resp() argument
7378 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7379 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7380 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7383 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7384 brcms_c_update_probe_resp(wlc, false); in brcms_c_set_new_probe_resp()
7387 void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable) in brcms_c_enable_probe_resp() argument
7393 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7394 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7400 brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) in brcms_c_shm_ssid_upd() argument
7410 brcms_c_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); in brcms_c_shm_ssid_upd()
7411 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7415 brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, in brcms_c_bss_update_probe_resp() argument
7425 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_bss_update_probe_resp()
7428 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7432 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7435 brcms_c_shm_ssid_upd(wlc, cfg); in brcms_c_bss_update_probe_resp()
7443 brcms_c_mod_prb_rsp_rate_table(wlc, in brcms_c_bss_update_probe_resp()
7447 brcms_c_enable_mac(wlc); in brcms_c_bss_update_probe_resp()
7450 void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) in brcms_c_update_probe_resp() argument
7452 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7455 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7457 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7459 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7476 brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, in brcms_c_set_addrmatch() argument
7479 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7481 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7487 void brcms_c_scan_start(struct brcms_c_info *wlc) in brcms_c_scan_start() argument
7489 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7492 void brcms_c_scan_stop(struct brcms_c_info *wlc) in brcms_c_scan_stop() argument
7494 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7497 void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state) in brcms_c_associate_upd() argument
7499 wlc->pub->associated = state; in brcms_c_associate_upd()
7520 int brcms_c_get_curband(struct brcms_c_info *wlc) in brcms_c_get_curband() argument
7522 return wlc->band->bandunit; in brcms_c_get_curband()
7525 bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc) in brcms_c_tx_flush_completed() argument
7530 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7531 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7532 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7534 return !brcms_txpktpendtot(wlc); in brcms_c_tx_flush_completed()
7537 void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval) in brcms_c_set_beacon_listen_interval() argument
7539 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7540 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7541 brcms_c_bcn_li_upd(wlc); in brcms_c_set_beacon_listen_interval()
7544 u64 brcms_c_tsf_get(struct brcms_c_info *wlc) in brcms_c_tsf_get() argument
7549 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7558 void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf) in brcms_c_tsf_set() argument
7562 brcms_c_time_lock(wlc); in brcms_c_tsf_set()
7568 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7569 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7571 brcms_c_time_unlock(wlc); in brcms_c_tsf_set()
7574 int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr) in brcms_c_set_tx_power() argument
7580 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7583 int brcms_c_get_tx_power(struct brcms_c_info *wlc) in brcms_c_get_tx_power() argument
7588 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7599 static void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) in brcms_c_recv() argument
7615 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7617 wlc->pub->unit, p->len); in brcms_c_recv()
7627 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7640 brcms_c_recvctl(wlc, rxh, p); in brcms_c_recv()
7700 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7710 bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) in brcms_c_dpc() argument
7713 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7716 if (brcms_deviceremoved(wlc)) { in brcms_c_dpc()
7719 brcms_down(wlc->wl); in brcms_c_dpc()
7724 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7725 wlc->macintstatus = 0; in brcms_c_dpc()
7735 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7736 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7744 brcms_c_tbtt(wlc); in brcms_c_dpc()
7749 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7750 wlc->qvalid = 0; in brcms_c_dpc()
7759 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7772 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7782 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7787 brcms_c_update_beacon(wlc); in brcms_c_dpc()
7790 return wlc->macintstatus != 0; in brcms_c_dpc()
7793 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7794 return wlc->macintstatus != 0; in brcms_c_dpc()
7797 void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) in brcms_c_init() argument
7799 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7800 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7803 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7807 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7810 brcms_c_bcn_li_upd(wlc); in brcms_c_init()
7813 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7814 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7817 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7821 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7830 brcms_c_set_ps_ctrl(wlc); in brcms_c_init()
7833 brcms_c_bandinit_ordered(wlc, chanspec); in brcms_c_init()
7836 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7839 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7840 (wlc-> in brcms_c_init()
7844 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7845 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7851 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7854 brcms_c_bsinit(wlc); in brcms_c_init()
7858 brcms_c_edcf_setparams(wlc, false); in brcms_c_init()
7861 if (wlc->ucode_rev == 0) { in brcms_c_init()
7865 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7866 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7867 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7868 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7869 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7873 brcms_c_enable_mac(wlc); in brcms_c_init()
7877 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7886 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7891 wlc->wme_retries[ac] = in brcms_c_init()
7892 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7903 struct brcms_c_info *wlc; in brcms_c_attach() local
7909 wlc = brcms_c_attach_malloc(unit, &err, 0); in brcms_c_attach()
7910 if (wlc == NULL) in brcms_c_attach()
7912 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7913 pub = wlc->pub; in brcms_c_attach()
7916 wlc_info_dbg = wlc; in brcms_c_attach()
7919 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7920 wlc->core = wlc->corestate; in brcms_c_attach()
7921 wlc->wl = wl; in brcms_c_attach()
7924 wlc->bandinit_pending = false; in brcms_c_attach()
7925 wlc->beacon_template_virgin = true; in brcms_c_attach()
7928 brcms_c_info_init(wlc, unit); in brcms_c_attach()
7931 brcms_c_ap_upd(wlc); in brcms_c_attach()
7937 err = brcms_b_attach(wlc, core, unit, piomode); in brcms_c_attach()
7941 brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, OFF); in brcms_c_attach()
7943 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
7946 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
7947 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
7949 brcms_c_stf_phy_chain_calc(wlc); in brcms_c_attach()
7952 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
7953 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
7956 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
7957 wlc->stf->hw_rxchain); in brcms_c_attach()
7961 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
7963 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7964 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
7966 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
7967 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
7969 if (!brcms_c_attach_stf_ant_init(wlc)) { in brcms_c_attach()
7975 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
7976 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
7979 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
7980 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
7981 brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, in brcms_c_attach()
7982 wlc->band->gmode); in brcms_c_attach()
7986 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
7988 brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, in brcms_c_attach()
7995 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
7998 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
7999 &wlc->band->hw_rateset, false, in brcms_c_attach()
8001 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
8008 brcms_c_stf_phy_txant_upd(wlc); in brcms_c_attach()
8011 err = brcms_c_attach_module(wlc); in brcms_c_attach()
8015 if (!brcms_c_timers_init(wlc, unit)) { in brcms_c_attach()
8023 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8024 if (!wlc->cmi) { in brcms_c_attach()
8032 brcms_c_bss_default_init(wlc); in brcms_c_attach()
8038 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8040 wlc->mimoft = FT_HT; in brcms_c_attach()
8041 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8042 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8043 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8044 brcms_c_update_mimo_band_bwcap(wlc, BRCMS_N_BW_20IN2G_40IN5G); in brcms_c_attach()
8047 if (BRCMS_SGI_CAP_PHY(wlc)) { in brcms_c_attach()
8048 brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | in brcms_c_attach()
8050 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8051 brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | in brcms_c_attach()
8054 brcms_c_ht_update_sgi_rx(wlc, 0); in brcms_c_attach()
8057 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8062 return wlc; in brcms_c_attach()
8067 if (wlc) in brcms_c_attach()
8068 brcms_c_detach(wlc); in brcms_c_attach()