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
852 trace_brcms_txstatus(&wlc->hw->d11core->dev, txs->framelen, in brcms_c_dotxstatus()
863 brcms_dbg_tx(wlc->hw->d11core, "INTERMEDIATE but not AMPDU\n"); in brcms_c_dotxstatus()
870 brcms_err(wlc->hw->d11core, "queue %u >= NFIFO\n", queue); in brcms_c_dotxstatus()
874 dma = wlc->hw->di[queue]; in brcms_c_dotxstatus()
876 p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); in brcms_c_dotxstatus()
878 brcms_err(wlc->hw->d11core, "dma_getnexttxp returned null!\n"); in brcms_c_dotxstatus()
886 brcms_dbg_tx(wlc->hw->d11core, "phyerr 0x%x, rate 0x%x\n", in brcms_c_dotxstatus()
890 brcms_err(wlc->hw->d11core, "frameid != txh->TxFrameID\n"); in brcms_c_dotxstatus()
897 scb = &wlc->pri_scb; in brcms_c_dotxstatus()
900 brcms_c_ampdu_dotxstatus(wlc->ampdu, scb, p, txs); in brcms_c_dotxstatus()
909 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, sizeof(*txh)); in brcms_c_dotxstatus()
914 brcms_dbg_tx(wlc->hw->d11core, in brcms_c_dotxstatus()
917 CHSPEC_CHANNEL(wlc->default_bss->chanspec)); in brcms_c_dotxstatus()
929 brcms_err(wlc->hw->d11core, "Not last frame!\n"); in brcms_c_dotxstatus()
944 sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
946 lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]], in brcms_c_dotxstatus()
949 sfbl = wlc->SFBL; in brcms_c_dotxstatus()
950 lfbl = wlc->LFBL; in brcms_c_dotxstatus()
999 ieee80211_tx_status_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_dotxstatus()
1001 brcms_err(wlc->hw->d11core, in brcms_c_dotxstatus()
1011 trace_brcms_txdesc(&wlc->hw->d11core->dev, txh, in brcms_c_dotxstatus()
1019 ieee80211_queue_stopped(wlc->pub->ieee_hw, ac_queue)) in brcms_c_dotxstatus()
1020 ieee80211_wake_queue(wlc->pub->ieee_hw, ac_queue); in brcms_c_dotxstatus()
1066 *fatal = brcms_c_dotxstatus(wlc_hw->wlc, txs); in brcms_b_txstatus()
1075 static void brcms_c_tbtt(struct brcms_c_info *wlc) in brcms_c_tbtt() argument
1077 if (wlc->bsscfg->type == BRCMS_TYPE_ADHOC) in brcms_c_tbtt()
1082 wlc->qvalid |= MCMD_DIRFRMQVAL; in brcms_c_tbtt()
1087 brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) in brcms_c_mhfdef() argument
1089 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_mhfdef()
1113 static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) in brcms_b_attach_dmapio() argument
1121 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_attach_dmapio()
1135 wlc_hw->di[0] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1149 wlc_hw->di[1] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1159 wlc_hw->di[2] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1168 wlc_hw->di[3] = dma_attach(name, wlc, in brcms_b_attach_dmapio()
1191 brcms_c_mhfdef(wlc, wlc_hw->band->mhfs, pio_mhf2); in brcms_b_attach_dmapio()
1215 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_info_init() local
1218 wlc->defmacintmask = DEF_MACINTMASK; in brcms_b_info_init()
1239 DBGST_ASLEEP), wlc_hw->wlc->fastpwrup_dly); in brcms_b_wait_for_wake()
1605 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_upd_synthpu() local
1608 if (BRCMS_ISLCNPHY(wlc->band)) in brcms_b_upd_synthpu()
1610 else if (BRCMS_ISNPHY(wlc->band) && (NREV_GE(wlc->band->phyrev, 3))) in brcms_b_upd_synthpu()
1704 static void brcms_b_bsinit(struct brcms_c_info *wlc, u16 chanspec) in brcms_b_bsinit() argument
1706 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_bsinit()
1826 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_setband() local
1835 macintmask = brcms_c_setband_inact(wlc, bandunit); in brcms_b_setband()
1843 brcms_b_bsinit(wlc, chanspec); in brcms_b_setband()
1850 if (wlc->macintstatus) in brcms_b_setband()
1851 wlc->macintstatus = MI_DMAINT; in brcms_b_setband()
1854 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_setband()
1866 wiphy_err(wlc_hw->wlc->wiphy, "unsupported core rev %d\n", in brcms_c_isgoodchip()
2034 wlc_hw->wlc->macintstatus = 0; /* skip wl_dpc after down */ in brcms_b_corereset()
2074 wlc_hw->wlc->macintstatus = 0; in brcms_b_corereset()
2171 void brcms_c_start_station(struct brcms_c_info *wlc, u8 *addr) in brcms_c_start_station() argument
2173 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_station()
2174 wlc->bsscfg->type = BRCMS_TYPE_STATION; in brcms_c_start_station()
2177 void brcms_c_start_ap(struct brcms_c_info *wlc, u8 *addr, const u8 *bssid, in brcms_c_start_ap() argument
2180 brcms_c_set_ssid(wlc, ssid, ssid_len); in brcms_c_start_ap()
2182 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_ap()
2183 memcpy(wlc->bsscfg->BSSID, bssid, sizeof(wlc->bsscfg->BSSID)); in brcms_c_start_ap()
2184 wlc->bsscfg->type = BRCMS_TYPE_AP; in brcms_c_start_ap()
2186 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, MCTL_AP | MCTL_INFRA); in brcms_c_start_ap()
2189 void brcms_c_start_adhoc(struct brcms_c_info *wlc, u8 *addr) in brcms_c_start_adhoc() argument
2191 memcpy(wlc->pub->cur_etheraddr, addr, sizeof(wlc->pub->cur_etheraddr)); in brcms_c_start_adhoc()
2192 wlc->bsscfg->type = BRCMS_TYPE_ADHOC; in brcms_c_start_adhoc()
2194 brcms_b_mctrl(wlc->hw, MCTL_AP | MCTL_INFRA, 0); in brcms_c_start_adhoc()
2198 static void brcms_c_gpio_init(struct brcms_c_info *wlc) in brcms_c_gpio_init() argument
2200 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_gpio_init()
2281 struct brcms_c_info *wlc; in brcms_ucode_download() local
2282 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_ucode_download()
2284 wlc = wlc_hw->wlc; in brcms_ucode_download()
2325 return (u16) wlc_hw->wlc->stf->txant; in brcms_b_get_txant()
2392 brcms_fatal_error(wlc_hw->wlc->wl); /* big hammer */ in brcms_b_fifoerrors()
2401 void brcms_c_intrson(struct brcms_c_info *wlc) in brcms_c_intrson() argument
2403 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrson()
2404 wlc->macintmask = wlc->defmacintmask; in brcms_c_intrson()
2405 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrson()
2408 u32 brcms_c_intrsoff(struct brcms_c_info *wlc) in brcms_c_intrsoff() argument
2410 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsoff()
2416 macintmask = wlc->macintmask; /* isr can still happen */ in brcms_c_intrsoff()
2421 wlc->macintmask = 0; in brcms_c_intrsoff()
2424 return wlc->macintstatus ? 0 : macintmask; in brcms_c_intrsoff()
2427 void brcms_c_intrsrestore(struct brcms_c_info *wlc, u32 macintmask) in brcms_c_intrsrestore() argument
2429 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_intrsrestore()
2433 wlc->macintmask = macintmask; in brcms_c_intrsrestore()
2434 bcma_write32(wlc_hw->d11core, D11REGOFFS(macintmask), wlc->macintmask); in brcms_c_intrsrestore()
2463 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2468 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_tx_fifo_suspend()
2498 u8 *ethaddr = wlc_hw->wlc->pub->cur_etheraddr; in brcms_b_mute()
2529 brcms_c_mute(struct brcms_c_info *wlc, bool mute_tx) in brcms_c_mute() argument
2531 brcms_b_mute(wlc->hw, mute_tx); in brcms_c_mute()
2542 static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) in wlc_intstatus() argument
2544 struct brcms_hardware *wlc_hw = wlc->hw; in wlc_intstatus()
2550 mask = in_isr ? wlc->macintmask : wlc->defmacintmask; in wlc_intstatus()
2555 if (brcms_deviceremoved(wlc)) in wlc_intstatus()
2574 wlc->macintmask = 0; in wlc_intstatus()
2594 bool brcms_c_intrsupd(struct brcms_c_info *wlc) in brcms_c_intrsupd() argument
2599 macintstatus = wlc_intstatus(wlc, false); in brcms_c_intrsupd()
2606 wlc->macintstatus |= macintstatus; in brcms_c_intrsupd()
2617 bool brcms_c_isr(struct brcms_c_info *wlc) in brcms_c_isr() argument
2619 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_isr()
2622 if (!wlc_hw->up || !wlc->macintmask) in brcms_c_isr()
2626 macintstatus = wlc_intstatus(wlc, true); in brcms_c_isr()
2639 wlc->macintstatus = macintstatus; in brcms_c_isr()
2645 void brcms_c_suspend_mac_and_wait(struct brcms_c_info *wlc) in brcms_c_suspend_mac_and_wait() argument
2647 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_suspend_mac_and_wait()
2669 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2680 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2705 brcms_down(wlc->wl); in brcms_c_suspend_mac_and_wait()
2713 void brcms_c_enable_mac(struct brcms_c_info *wlc) in brcms_c_enable_mac() argument
2715 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_enable_mac()
2720 wlc->band->bandunit); in brcms_c_enable_mac()
2761 struct wiphy *wiphy = wlc_hw->wlc->wiphy; in brcms_b_validate_chip_access()
2877 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_c_coredisable()
2899 static void brcms_c_flushqueues(struct brcms_c_info *wlc) in brcms_c_flushqueues() argument
2901 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_flushqueues()
2909 ieee80211_wake_queue(wlc->pub->ieee_hw, in brcms_c_flushqueues()
3016 static void brcms_c_copyto_shm(struct brcms_c_info *wlc, uint offset, in brcms_c_copyto_shm() argument
3019 brcms_b_copyto_objmem(wlc->hw, offset, buf, len, OBJADDR_SHM_SEL); in brcms_c_copyto_shm()
3075 static bool brcms_c_ps_allowed(struct brcms_c_info *wlc) in brcms_c_ps_allowed() argument
3081 static void brcms_c_statsupd(struct brcms_c_info *wlc) in brcms_c_statsupd() argument
3092 if (!wlc->pub->up) in brcms_c_statsupd()
3095 macstats = wlc->core->macstat_snapshot; in brcms_c_statsupd()
3107 brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, macstats, in brcms_c_statsupd()
3114 brcms_err(wlc->hw->d11core, "wl%d: %u rx fifo 0 overflows!\n", in brcms_c_statsupd()
3115 wlc->pub->unit, delta); in brcms_c_statsupd()
3121 brcms_err(wlc->hw->d11core, in brcms_c_statsupd()
3123 wlc->pub->unit, delta, i); in brcms_c_statsupd()
3129 if (wlc->hw->di[i]) in brcms_c_statsupd()
3130 dma_counterreset(wlc->hw->di[i]); in brcms_c_statsupd()
3137 if (!brcms_deviceremoved(wlc_hw->wlc)) in brcms_b_reset()
3141 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_reset()
3144 void brcms_c_reset(struct brcms_c_info *wlc) in brcms_c_reset() argument
3146 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_reset()
3149 brcms_c_statsupd(wlc); in brcms_c_reset()
3152 memset(wlc->core->macstat_snapshot, 0, sizeof(struct macstat)); in brcms_c_reset()
3154 brcms_b_reset(wlc->hw); in brcms_c_reset()
3180 static void brcms_b_coreinit(struct brcms_c_info *wlc) in brcms_b_coreinit() argument
3182 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_coreinit()
3190 struct brcms_ucode *ucode = &wlc_hw->wlc->wl->ucode; in brcms_b_coreinit()
3215 brcms_c_gpio_init(wlc); in brcms_b_coreinit()
3312 wlc->fastpwrup_dly = ai_clkctl_fast_pwrup_delay(wlc_hw->sih); in brcms_b_coreinit()
3313 bcma_write16(core, D11REGOFFS(scc_fastpwrup_dly), wlc->fastpwrup_dly); in brcms_b_coreinit()
3357 struct brcms_c_info *wlc = wlc_hw->wlc; in brcms_b_init() local
3365 macintmask = brcms_intrsoff(wlc->wl); in brcms_b_init()
3375 brcms_b_coreinit(wlc); in brcms_b_init()
3378 brcms_b_bsinit(wlc, chanspec); in brcms_b_init()
3381 brcms_intrsrestore(wlc->wl, macintmask); in brcms_b_init()
3399 static void brcms_c_set_phy_chanspec(struct brcms_c_info *wlc, in brcms_c_set_phy_chanspec() argument
3403 wlc->chanspec = chanspec; in brcms_c_set_phy_chanspec()
3406 brcms_c_channel_set_chanspec(wlc->cmi, chanspec, BRCMS_TXPWR_MAX); in brcms_c_set_phy_chanspec()
3408 if (wlc->stf->ss_algosel_auto) in brcms_c_set_phy_chanspec()
3409 brcms_c_stf_ss_algo_channel_get(wlc, &wlc->stf->ss_algo_channel, in brcms_c_set_phy_chanspec()
3412 brcms_c_stf_ss_update(wlc, wlc->band); in brcms_c_set_phy_chanspec()
3416 brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) in brcms_default_rateset() argument
3418 brcms_c_rateset_default(rs, NULL, wlc->band->phytype, in brcms_default_rateset()
3419 wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, in brcms_default_rateset()
3420 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_default_rateset()
3421 brcms_chspec_bw(wlc->default_bss->chanspec), in brcms_default_rateset()
3422 wlc->stf->txstreams); in brcms_default_rateset()
3426 static void brcms_c_rate_lookup_init(struct brcms_c_info *wlc, in brcms_c_rate_lookup_init() argument
3433 u8 *br = wlc->band->basic_rate; in brcms_c_rate_lookup_init()
3451 brcms_err(wlc->hw->d11core, "brcms_c_rate_lookup_init: " in brcms_c_rate_lookup_init()
3474 for (i = 0; i < wlc->band->hw_rateset.count; i++) { in brcms_c_rate_lookup_init()
3475 rate = wlc->band->hw_rateset.rates[i]; in brcms_c_rate_lookup_init()
3520 static void brcms_c_bandinit_ordered(struct brcms_c_info *wlc, in brcms_c_bandinit_ordered() argument
3531 if (wlc->bandlocked || wlc->pub->_nbands == 1) { in brcms_c_bandinit_ordered()
3533 parkband = wlc->band->bandunit; in brcms_c_bandinit_ordered()
3545 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_bandinit_ordered()
3548 wlc->band = wlc->bandstate[j]; in brcms_c_bandinit_ordered()
3550 brcms_default_rateset(wlc, &default_rateset); in brcms_c_bandinit_ordered()
3553 brcms_c_rateset_filter(&default_rateset, &wlc->band->hw_rateset, in brcms_c_bandinit_ordered()
3555 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_bandinit_ordered()
3558 brcms_c_rate_lookup_init(wlc, &default_rateset); in brcms_c_bandinit_ordered()
3562 brcms_c_set_phy_chanspec(wlc, chanspec); in brcms_c_bandinit_ordered()
3569 void brcms_c_mac_promisc(struct brcms_c_info *wlc, uint filter_flags) in brcms_c_mac_promisc() argument
3573 wlc->filter_flags = filter_flags; in brcms_c_mac_promisc()
3587 brcms_b_mctrl(wlc->hw, in brcms_c_mac_promisc()
3597 static void brcms_c_ucode_mac_upd(struct brcms_c_info *wlc) in brcms_c_ucode_mac_upd() argument
3602 if (wlc->home_chanspec == wlc_phy_chanspec_get(wlc->band->pi)) { in brcms_c_ucode_mac_upd()
3603 if (wlc->pub->associated) { in brcms_c_ucode_mac_upd()
3613 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_ucode_mac_upd()
3614 brcms_b_write_shm(wlc->hw, in brcms_c_ucode_mac_upd()
3622 static void brcms_c_write_rate_shm(struct brcms_c_info *wlc, u8 rate, in brcms_c_write_rate_shm() argument
3648 basic_ptr = brcms_b_read_shm(wlc->hw, (dir_table + basic_index * 2)); in brcms_c_write_rate_shm()
3653 brcms_b_write_shm(wlc->hw, (basic_table + index * 2), basic_ptr); in brcms_c_write_rate_shm()
3657 brcms_c_rateset_get_hwrs(struct brcms_c_info *wlc) in brcms_c_rateset_get_hwrs() argument
3661 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rateset_get_hwrs()
3662 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_rateset_get_hwrs()
3666 } else if (wlc->band->gmode) in brcms_c_rateset_get_hwrs()
3674 static void brcms_c_set_ratetable(struct brcms_c_info *wlc) in brcms_c_set_ratetable() argument
3681 rs_dflt = brcms_c_rateset_get_hwrs(wlc); in brcms_c_set_ratetable()
3684 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_set_ratetable()
3693 basic_rate = brcms_basic_rate(wlc, rate); in brcms_c_set_ratetable()
3700 brcms_c_write_rate_shm(wlc, rate, basic_rate); in brcms_c_set_ratetable()
3705 static void brcms_c_bsinit(struct brcms_c_info *wlc) in brcms_c_bsinit() argument
3707 brcms_dbg_info(wlc->hw->d11core, "wl%d: bandunit %d\n", in brcms_c_bsinit()
3708 wlc->pub->unit, wlc->band->bandunit); in brcms_c_bsinit()
3711 brcms_c_set_ratetable(wlc); in brcms_c_bsinit()
3714 brcms_c_ucode_mac_upd(wlc); in brcms_c_bsinit()
3717 brcms_c_antsel_init(wlc->asi); in brcms_c_bsinit()
3723 brcms_c_duty_cycle_set(struct brcms_c_info *wlc, int duty_cycle, bool isOFDM, in brcms_c_duty_cycle_set() argument
3731 brcms_err(wlc->hw->d11core, in brcms_c_duty_cycle_set()
3733 wlc->pub->unit); in brcms_c_duty_cycle_set()
3740 brcms_b_write_shm(wlc->hw, offset, (u16) idle_busy_ratio_x_16); in brcms_c_duty_cycle_set()
3743 wlc->tx_duty_cycle_ofdm = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3745 wlc->tx_duty_cycle_cck = (u16) duty_cycle; in brcms_c_duty_cycle_set()
3751 static void brcms_c_set_ps_ctrl(struct brcms_c_info *wlc) in brcms_c_set_ps_ctrl() argument
3757 hps = brcms_c_ps_allowed(wlc); in brcms_c_set_ps_ctrl()
3759 brcms_dbg_mac80211(wlc->hw->d11core, "wl%d: hps %d\n", wlc->pub->unit, in brcms_c_set_ps_ctrl()
3762 v1 = bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_set_ps_ctrl()
3767 brcms_b_mctrl(wlc->hw, MCTL_WAKE | MCTL_HPS, v2); in brcms_c_set_ps_ctrl()
3772 brcms_b_wait_for_wake(wlc->hw); in brcms_c_set_ps_ctrl()
3782 struct brcms_c_info *wlc = bsscfg->wlc; in brcms_c_set_mac() local
3785 brcms_c_set_addrmatch(wlc, RCM_MAC_OFFSET, wlc->pub->cur_etheraddr); in brcms_c_set_mac()
3787 brcms_c_ampdu_macaddr_upd(wlc); in brcms_c_set_mac()
3798 brcms_c_set_addrmatch(bsscfg->wlc, RCM_BSSID_OFFSET, bsscfg->BSSID); in brcms_c_set_bssid()
3801 void brcms_c_set_ssid(struct brcms_c_info *wlc, u8 *ssid, size_t ssid_len) in brcms_c_set_ssid() argument
3803 u8 len = min_t(u8, sizeof(wlc->bsscfg->SSID), ssid_len); in brcms_c_set_ssid()
3804 memset(wlc->bsscfg->SSID, 0, sizeof(wlc->bsscfg->SSID)); in brcms_c_set_ssid()
3806 memcpy(wlc->bsscfg->SSID, ssid, len); in brcms_c_set_ssid()
3807 wlc->bsscfg->SSID_len = len; in brcms_c_set_ssid()
3815 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_set_shortslot()
3817 brcms_c_enable_mac(wlc_hw->wlc); in brcms_b_set_shortslot()
3825 static void brcms_c_switch_shortslot(struct brcms_c_info *wlc, bool shortslot) in brcms_c_switch_shortslot() argument
3828 if (wlc->shortslot_override != BRCMS_SHORTSLOT_AUTO) in brcms_c_switch_shortslot()
3829 shortslot = (wlc->shortslot_override == BRCMS_SHORTSLOT_ON); in brcms_c_switch_shortslot()
3831 if (wlc->shortslot == shortslot) in brcms_c_switch_shortslot()
3834 wlc->shortslot = shortslot; in brcms_c_switch_shortslot()
3836 brcms_b_set_shortslot(wlc->hw, shortslot); in brcms_c_switch_shortslot()
3839 static void brcms_c_set_home_chanspec(struct brcms_c_info *wlc, u16 chanspec) in brcms_c_set_home_chanspec() argument
3841 if (wlc->home_chanspec != chanspec) { in brcms_c_set_home_chanspec()
3842 wlc->home_chanspec = chanspec; in brcms_c_set_home_chanspec()
3844 if (wlc->pub->associated) in brcms_c_set_home_chanspec()
3845 wlc->bsscfg->current_bss->chanspec = chanspec; in brcms_c_set_home_chanspec()
3895 static void brcms_c_setband(struct brcms_c_info *wlc, in brcms_c_setband() argument
3898 wlc->band = wlc->bandstate[bandunit]; in brcms_c_setband()
3900 if (!wlc->pub->up) in brcms_c_setband()
3904 brcms_c_set_ps_ctrl(wlc); in brcms_c_setband()
3907 brcms_c_bsinit(wlc); in brcms_c_setband()
3910 static void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) in brcms_c_set_chanspec() argument
3914 u16 old_chanspec = wlc->chanspec; in brcms_c_set_chanspec()
3916 if (!brcms_c_valid_chanspec_db(wlc->cmi, chanspec)) { in brcms_c_set_chanspec()
3917 brcms_err(wlc->hw->d11core, "wl%d: %s: Bad channel %d\n", in brcms_c_set_chanspec()
3918 wlc->pub->unit, __func__, CHSPEC_CHANNEL(chanspec)); in brcms_c_set_chanspec()
3923 if (wlc->pub->_nbands > 1) { in brcms_c_set_chanspec()
3925 if (wlc->band->bandunit != bandunit || wlc->bandinit_pending) { in brcms_c_set_chanspec()
3927 if (wlc->bandlocked) { in brcms_c_set_chanspec()
3928 brcms_err(wlc->hw->d11core, in brcms_c_set_chanspec()
3930 wlc->pub->unit, __func__, in brcms_c_set_chanspec()
3942 brcms_c_setband(wlc, bandunit); in brcms_c_set_chanspec()
3947 brcms_c_set_phy_chanspec(wlc, chanspec); in brcms_c_set_chanspec()
3951 brcms_c_antsel_init(wlc->asi); in brcms_c_set_chanspec()
3956 brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, in brcms_c_set_chanspec()
3957 wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0); in brcms_c_set_chanspec()
3961 brcms_c_ucode_mac_upd(wlc); in brcms_c_set_chanspec()
3970 void brcms_c_beacon_phytxctl_txant_upd(struct brcms_c_info *wlc, in brcms_c_beacon_phytxctl_txant_upd() argument
3974 u16 phytxant = wlc->stf->phytxant; in brcms_c_beacon_phytxctl_txant_upd()
3978 if (BRCMS_PHY_11N_CAP(wlc->band)) in brcms_c_beacon_phytxctl_txant_upd()
3979 phytxant = brcms_c_stf_phytxchain_sel(wlc, bcn_rspec); in brcms_c_beacon_phytxctl_txant_upd()
3981 phyctl = brcms_b_read_shm(wlc->hw, M_BCN_PCTLWD); in brcms_c_beacon_phytxctl_txant_upd()
3983 brcms_b_write_shm(wlc->hw, M_BCN_PCTLWD, phyctl); in brcms_c_beacon_phytxctl_txant_upd()
3991 void brcms_c_protection_upd(struct brcms_c_info *wlc, uint idx, int val) in brcms_c_protection_upd() argument
3997 BCMMSG(wlc->wiphy, "idx %d, val %d\n", idx, val); in brcms_c_protection_upd()
4001 wlc->protection->_g = (bool) val; in brcms_c_protection_upd()
4004 wlc->protection->g_override = (s8) val; in brcms_c_protection_upd()
4007 wlc->protection->gmode_user = (u8) val; in brcms_c_protection_upd()
4010 wlc->protection->overlap = (s8) val; in brcms_c_protection_upd()
4013 wlc->protection->nmode_user = (s8) val; in brcms_c_protection_upd()
4016 wlc->protection->n_cfg = (s8) val; in brcms_c_protection_upd()
4019 wlc->protection->n_cfg_override = (s8) val; in brcms_c_protection_upd()
4022 wlc->protection->nongf = (bool) val; in brcms_c_protection_upd()
4025 wlc->protection->nongf_override = (s8) val; in brcms_c_protection_upd()
4028 wlc->protection->n_pam_override = (s8) val; in brcms_c_protection_upd()
4031 wlc->protection->n_obss = (bool) val; in brcms_c_protection_upd()
4040 static void brcms_c_ht_update_sgi_rx(struct brcms_c_info *wlc, int val) in brcms_c_ht_update_sgi_rx() argument
4042 if (wlc->pub->up) { in brcms_c_ht_update_sgi_rx()
4043 brcms_c_update_beacon(wlc); in brcms_c_ht_update_sgi_rx()
4044 brcms_c_update_probe_resp(wlc, true); in brcms_c_ht_update_sgi_rx()
4048 static void brcms_c_ht_update_ldpc(struct brcms_c_info *wlc, s8 val) in brcms_c_ht_update_ldpc() argument
4050 wlc->stf->ldpc = val; in brcms_c_ht_update_ldpc()
4052 if (wlc->pub->up) { in brcms_c_ht_update_ldpc()
4053 brcms_c_update_beacon(wlc); in brcms_c_ht_update_ldpc()
4054 brcms_c_update_probe_resp(wlc, true); in brcms_c_ht_update_ldpc()
4055 wlc_phy_ldpc_override_set(wlc->band->pi, (val ? true : false)); in brcms_c_ht_update_ldpc()
4059 void brcms_c_wme_setparams(struct brcms_c_info *wlc, u16 aci, in brcms_c_wme_setparams() argument
4068 if (!wlc->clk) { in brcms_c_wme_setparams()
4069 brcms_err(wlc->hw->d11core, "wl%d: %s : no-clock\n", in brcms_c_wme_setparams()
4070 wlc->pub->unit, __func__); in brcms_c_wme_setparams()
4078 wlc->edcf_txop[aci & 0x3] = acp_shm.txop = in brcms_c_wme_setparams()
4088 brcms_err(wlc->hw->d11core, "wl%d: edcf_setparams: bad " in brcms_c_wme_setparams()
4089 "aifs %d\n", wlc->pub->unit, acp_shm.aifs); in brcms_c_wme_setparams()
4095 bcma_read16(wlc->hw->d11core, D11REGOFFS(tsf_random)) & in brcms_c_wme_setparams()
4099 acp_shm.status = brcms_b_read_shm(wlc->hw, (M_EDCF_QINFO + in brcms_c_wme_setparams()
4108 brcms_b_write_shm(wlc->hw, in brcms_c_wme_setparams()
4115 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_wme_setparams()
4117 brcms_c_update_beacon(wlc); in brcms_c_wme_setparams()
4118 brcms_c_update_probe_resp(wlc, false); in brcms_c_wme_setparams()
4121 brcms_c_enable_mac(wlc); in brcms_c_wme_setparams()
4124 static void brcms_c_edcf_setparams(struct brcms_c_info *wlc, bool suspend) in brcms_c_edcf_setparams() argument
4150 brcms_c_wme_setparams(wlc, aci, &txq_pars, suspend); in brcms_c_edcf_setparams()
4154 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_edcf_setparams()
4155 brcms_c_enable_mac(wlc); in brcms_c_edcf_setparams()
4159 static void brcms_c_radio_monitor_start(struct brcms_c_info *wlc) in brcms_c_radio_monitor_start() argument
4162 if (wlc->radio_monitor) in brcms_c_radio_monitor_start()
4165 wlc->radio_monitor = true; in brcms_c_radio_monitor_start()
4166 brcms_b_pllreq(wlc->hw, true, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_start()
4167 brcms_add_timer(wlc->radio_timer, TIMER_INTERVAL_RADIOCHK, true); in brcms_c_radio_monitor_start()
4170 static bool brcms_c_radio_monitor_stop(struct brcms_c_info *wlc) in brcms_c_radio_monitor_stop() argument
4172 if (!wlc->radio_monitor) in brcms_c_radio_monitor_stop()
4175 wlc->radio_monitor = false; in brcms_c_radio_monitor_stop()
4176 brcms_b_pllreq(wlc->hw, false, BRCMS_PLLREQ_RADIO_MON); in brcms_c_radio_monitor_stop()
4177 return brcms_del_timer(wlc->radio_timer); in brcms_c_radio_monitor_stop()
4181 static void brcms_c_radio_hwdisable_upd(struct brcms_c_info *wlc) in brcms_c_radio_hwdisable_upd() argument
4183 if (wlc->pub->hw_off) in brcms_c_radio_hwdisable_upd()
4186 if (brcms_b_radio_read_hwdisabled(wlc->hw)) in brcms_c_radio_hwdisable_upd()
4187 mboolset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4189 mboolclr(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE); in brcms_c_radio_hwdisable_upd()
4193 bool brcms_c_check_radio_disabled(struct brcms_c_info *wlc) in brcms_c_check_radio_disabled() argument
4195 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_check_radio_disabled()
4197 return mboolisset(wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE) ? in brcms_c_check_radio_disabled()
4204 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; in brcms_c_radio_timer() local
4206 if (brcms_deviceremoved(wlc)) { in brcms_c_radio_timer()
4207 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_radio_timer()
4208 wlc->pub->unit, __func__); in brcms_c_radio_timer()
4209 brcms_down(wlc->wl); in brcms_c_radio_timer()
4213 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_radio_timer()
4217 static void brcms_b_watchdog(struct brcms_c_info *wlc) in brcms_b_watchdog() argument
4219 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_watchdog()
4231 dma_rxfill(wlc->hw->di[RX_FIFO]); in brcms_b_watchdog()
4237 static void brcms_c_watchdog(struct brcms_c_info *wlc) in brcms_c_watchdog() argument
4239 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_watchdog()
4241 if (!wlc->pub->up) in brcms_c_watchdog()
4244 if (brcms_deviceremoved(wlc)) { in brcms_c_watchdog()
4245 brcms_err(wlc->hw->d11core, "wl%d: %s: dead chip\n", in brcms_c_watchdog()
4246 wlc->pub->unit, __func__); in brcms_c_watchdog()
4247 brcms_down(wlc->wl); in brcms_c_watchdog()
4252 wlc->pub->now++; in brcms_c_watchdog()
4254 brcms_c_radio_hwdisable_upd(wlc); in brcms_c_watchdog()
4256 if (wlc->pub->radio_disabled) in brcms_c_watchdog()
4259 brcms_b_watchdog(wlc); in brcms_c_watchdog()
4265 if ((wlc->pub->now % SW_TIMER_MAC_STAT_UPD) == 0) in brcms_c_watchdog()
4266 brcms_c_statsupd(wlc); in brcms_c_watchdog()
4268 if (BRCMS_ISNPHY(wlc->band) && in brcms_c_watchdog()
4269 ((wlc->pub->now - wlc->tempsense_lasttime) >= in brcms_c_watchdog()
4271 wlc->tempsense_lasttime = wlc->pub->now; in brcms_c_watchdog()
4272 brcms_c_tempsense_upd(wlc); in brcms_c_watchdog()
4278 struct brcms_c_info *wlc = (struct brcms_c_info *) arg; in brcms_c_watchdog_by_timer() local
4280 brcms_c_watchdog(wlc); in brcms_c_watchdog_by_timer()
4283 static bool brcms_c_timers_init(struct brcms_c_info *wlc, int unit) in brcms_c_timers_init() argument
4285 wlc->wdtimer = brcms_init_timer(wlc->wl, brcms_c_watchdog_by_timer, in brcms_c_timers_init()
4286 wlc, "watchdog"); in brcms_c_timers_init()
4287 if (!wlc->wdtimer) { in brcms_c_timers_init()
4288 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for wdtimer " in brcms_c_timers_init()
4293 wlc->radio_timer = brcms_init_timer(wlc->wl, brcms_c_radio_timer, in brcms_c_timers_init()
4294 wlc, "radio"); in brcms_c_timers_init()
4295 if (!wlc->radio_timer) { in brcms_c_timers_init()
4296 wiphy_err(wlc->wiphy, "wl%d: wl_init_timer for radio_timer " in brcms_c_timers_init()
4311 static void brcms_c_info_init(struct brcms_c_info *wlc, int unit) in brcms_c_info_init() argument
4316 wlc->chanspec = ch20mhz_chspec(1); in brcms_c_info_init()
4319 wlc->shortslot = false; in brcms_c_info_init()
4320 wlc->shortslot_override = BRCMS_SHORTSLOT_AUTO; in brcms_c_info_init()
4322 brcms_c_protection_upd(wlc, BRCMS_PROT_G_OVR, BRCMS_PROTECTION_AUTO); in brcms_c_info_init()
4323 brcms_c_protection_upd(wlc, BRCMS_PROT_G_SPEC, false); in brcms_c_info_init()
4325 brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG_OVR, in brcms_c_info_init()
4327 brcms_c_protection_upd(wlc, BRCMS_PROT_N_CFG, BRCMS_N_PROTECTION_OFF); in brcms_c_info_init()
4328 brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF_OVR, in brcms_c_info_init()
4330 brcms_c_protection_upd(wlc, BRCMS_PROT_N_NONGF, false); in brcms_c_info_init()
4331 brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, AUTO); in brcms_c_info_init()
4333 brcms_c_protection_upd(wlc, BRCMS_PROT_OVERLAP, in brcms_c_info_init()
4337 wlc->include_legacy_erp = true; in brcms_c_info_init()
4339 wlc->stf->ant_rx_ovr = ANT_RX_DIV_DEF; in brcms_c_info_init()
4340 wlc->stf->txant = ANT_TX_DEF; in brcms_c_info_init()
4342 wlc->prb_resp_timeout = BRCMS_PRB_RESP_TIMEOUT; in brcms_c_info_init()
4344 wlc->usr_fragthresh = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4346 wlc->fragthresh[i] = DOT11_DEFAULT_FRAG_LEN; in brcms_c_info_init()
4347 wlc->RTSThresh = DOT11_DEFAULT_RTS_LEN; in brcms_c_info_init()
4350 wlc->SFBL = RETRY_SHORT_FB; in brcms_c_info_init()
4351 wlc->LFBL = RETRY_LONG_FB; in brcms_c_info_init()
4354 wlc->SRL = RETRY_SHORT_DEF; in brcms_c_info_init()
4355 wlc->LRL = RETRY_LONG_DEF; in brcms_c_info_init()
4358 wlc->pub->_ampdu = AMPDU_AGG_HOST; in brcms_c_info_init()
4361 static uint brcms_c_attach_module(struct brcms_c_info *wlc) in brcms_c_attach_module() argument
4365 unit = wlc->pub->unit; in brcms_c_attach_module()
4367 wlc->asi = brcms_c_antsel_attach(wlc); in brcms_c_attach_module()
4368 if (wlc->asi == NULL) { in brcms_c_attach_module()
4369 wiphy_err(wlc->wiphy, "wl%d: attach: antsel_attach " in brcms_c_attach_module()
4375 wlc->ampdu = brcms_c_ampdu_attach(wlc); in brcms_c_attach_module()
4376 if (wlc->ampdu == NULL) { in brcms_c_attach_module()
4377 wiphy_err(wlc->wiphy, "wl%d: attach: ampdu_attach " in brcms_c_attach_module()
4383 if ((brcms_c_stf_attach(wlc) != 0)) { in brcms_c_attach_module()
4384 wiphy_err(wlc->wiphy, "wl%d: attach: stf_attach " in brcms_c_attach_module()
4393 struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) in brcms_c_pub() argument
4395 return wlc->pub; in brcms_c_pub()
4404 static int brcms_b_attach(struct brcms_c_info *wlc, struct bcma_device *core, in brcms_b_attach() argument
4412 struct wiphy *wiphy = wlc->wiphy; in brcms_b_attach()
4427 wlc_hw = wlc->hw; in brcms_b_attach()
4428 wlc_hw->wlc = wlc; in brcms_b_attach()
4528 wlc->vendorid = wlc_hw->vendorid; in brcms_b_attach()
4529 wlc->deviceid = wlc_hw->deviceid; in brcms_b_attach()
4530 wlc->pub->sih = wlc_hw->sih; in brcms_b_attach()
4531 wlc->pub->corerev = wlc_hw->corerev; in brcms_b_attach()
4532 wlc->pub->sromrev = wlc_hw->sromrev; in brcms_b_attach()
4533 wlc->pub->boardrev = wlc_hw->boardrev; in brcms_b_attach()
4534 wlc->pub->boardflags = wlc_hw->boardflags; in brcms_b_attach()
4535 wlc->pub->boardflags2 = wlc_hw->boardflags2; in brcms_b_attach()
4536 wlc->pub->_nbands = wlc_hw->_nbands; in brcms_b_attach()
4538 wlc_hw->physhim = wlc_phy_shim_attach(wlc_hw, wlc->wl, wlc); in brcms_b_attach()
4581 wlc->band->bandunit = j; in brcms_b_attach()
4582 wlc->band->bandtype = j ? BRCM_BAND_5G : BRCM_BAND_2G; in brcms_b_attach()
4583 wlc->core->coreidx = core->core_index; in brcms_b_attach()
4600 wlc->wiphy); in brcms_b_attach()
4616 wlc->band->abgphy_encore = wlc_phy_get_encore(wlc_hw->band->pi); in brcms_b_attach()
4650 wlc->band->pi = wlc_hw->band->pi; in brcms_b_attach()
4651 wlc->band->phytype = wlc_hw->band->phytype; in brcms_b_attach()
4652 wlc->band->phyrev = wlc_hw->band->phyrev; in brcms_b_attach()
4653 wlc->band->radioid = wlc_hw->band->radioid; in brcms_b_attach()
4654 wlc->band->radiorev = wlc_hw->band->radiorev; in brcms_b_attach()
4656 wlc->band->phytype, wlc->band->phyrev, in brcms_b_attach()
4657 wlc->band->radioid, wlc->band->radiorev); in brcms_b_attach()
4662 if (!brcms_b_attach_dmapio(wlc, j, wme)) { in brcms_b_attach()
4710 static bool brcms_c_attach_stf_ant_init(struct brcms_c_info *wlc) in brcms_c_attach_stf_ant_init() argument
4715 struct ssb_sprom *sprom = &wlc->hw->d11core->bus->sprom; in brcms_c_attach_stf_ant_init()
4717 unit = wlc->pub->unit; in brcms_c_attach_stf_ant_init()
4718 bandtype = wlc->band->bandtype; in brcms_c_attach_stf_ant_init()
4727 wiphy_err(wlc->wiphy, "wl%d: %s: Invalid antennas available in" in brcms_c_attach_stf_ant_init()
4734 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_0; in brcms_c_attach_stf_ant_init()
4735 wlc->stf->txant = ANT_TX_FORCE_0; in brcms_c_attach_stf_ant_init()
4737 wlc->stf->ant_rx_ovr = ANT_RX_DIV_FORCE_1; in brcms_c_attach_stf_ant_init()
4738 wlc->stf->txant = ANT_TX_FORCE_1; in brcms_c_attach_stf_ant_init()
4744 wlc->band->antgain = sprom->antenna_gain.a1; in brcms_c_attach_stf_ant_init()
4746 wlc->band->antgain = sprom->antenna_gain.a0; in brcms_c_attach_stf_ant_init()
4751 static void brcms_c_bss_default_init(struct brcms_c_info *wlc) in brcms_c_bss_default_init() argument
4755 struct brcms_bss_info *bi = wlc->default_bss; in brcms_c_bss_default_init()
4765 wlc->home_chanspec = bi->chanspec = chanspec; in brcms_c_bss_default_init()
4768 band = wlc->band; in brcms_c_bss_default_init()
4769 if (wlc->pub->_nbands > 1 && in brcms_c_bss_default_init()
4771 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_bss_default_init()
4776 (bool) (wlc->pub->_n_enab & SUPPORT_11N), in brcms_c_bss_default_init()
4777 brcms_chspec_bw(chanspec), wlc->stf->txstreams); in brcms_c_bss_default_init()
4779 if (wlc->pub->_n_enab & SUPPORT_11N) in brcms_c_bss_default_init()
4783 static void brcms_c_update_mimo_band_bwcap(struct brcms_c_info *wlc, u8 bwcap) in brcms_c_update_mimo_band_bwcap() argument
4788 for (i = 0; i < wlc->pub->_nbands; i++) { in brcms_c_update_mimo_band_bwcap()
4789 band = wlc->bandstate[i]; in brcms_c_update_mimo_band_bwcap()
4805 static void brcms_c_timers_deinit(struct brcms_c_info *wlc) in brcms_c_timers_deinit() argument
4808 if (wlc->wdtimer) { in brcms_c_timers_deinit()
4809 brcms_free_timer(wlc->wdtimer); in brcms_c_timers_deinit()
4810 wlc->wdtimer = NULL; in brcms_c_timers_deinit()
4812 if (wlc->radio_timer) { in brcms_c_timers_deinit()
4813 brcms_free_timer(wlc->radio_timer); in brcms_c_timers_deinit()
4814 wlc->radio_timer = NULL; in brcms_c_timers_deinit()
4818 static void brcms_c_detach_module(struct brcms_c_info *wlc) in brcms_c_detach_module() argument
4820 if (wlc->asi) { in brcms_c_detach_module()
4821 brcms_c_antsel_detach(wlc->asi); in brcms_c_detach_module()
4822 wlc->asi = NULL; in brcms_c_detach_module()
4825 if (wlc->ampdu) { in brcms_c_detach_module()
4826 brcms_c_ampdu_detach(wlc->ampdu); in brcms_c_detach_module()
4827 wlc->ampdu = NULL; in brcms_c_detach_module()
4830 brcms_c_stf_detach(wlc); in brcms_c_detach_module()
4836 static void brcms_b_detach(struct brcms_c_info *wlc) in brcms_b_detach() argument
4840 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_b_detach()
4851 band = wlc_hw->bandstate[OTHERBANDUNIT(wlc)]; in brcms_b_detach()
4875 uint brcms_c_detach(struct brcms_c_info *wlc) in brcms_c_detach() argument
4879 if (wlc == NULL) in brcms_c_detach()
4882 brcms_b_detach(wlc); in brcms_c_detach()
4886 if (!brcms_c_radio_monitor_stop(wlc)) in brcms_c_detach()
4889 brcms_c_channel_mgr_detach(wlc->cmi); in brcms_c_detach()
4891 brcms_c_timers_deinit(wlc); in brcms_c_detach()
4893 brcms_c_detach_module(wlc); in brcms_c_detach()
4895 brcms_c_detach_mfree(wlc); in brcms_c_detach()
4900 static void brcms_c_ap_upd(struct brcms_c_info *wlc) in brcms_c_ap_upd() argument
4903 wlc->PLCPHdr_override = BRCMS_PLCP_SHORT; in brcms_c_ap_upd()
4909 if (wlc_hw->wlc->pub->hw_up) in brcms_b_hw_up()
4936 wlc_hw->wlc->pub->hw_up = true; in brcms_b_hw_up()
4993 brcms_intrson(wlc_hw->wlc->wl); in brcms_b_up_finish()
5001 static void brcms_c_wme_retries_write(struct brcms_c_info *wlc) in brcms_c_wme_retries_write() argument
5006 if (!wlc->clk) in brcms_c_wme_retries_write()
5010 brcms_b_write_shm(wlc->hw, M_AC_TXLMT_ADDR(ac), in brcms_c_wme_retries_write()
5011 wlc->wme_retries[ac]); in brcms_c_wme_retries_write()
5015 int brcms_c_up(struct brcms_c_info *wlc) in brcms_c_up() argument
5019 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_up()
5022 if (wlc->pub->hw_off || brcms_deviceremoved(wlc)) in brcms_c_up()
5025 if (!wlc->pub->hw_up) { in brcms_c_up()
5026 brcms_b_hw_up(wlc->hw); in brcms_c_up()
5027 wlc->pub->hw_up = true; in brcms_c_up()
5030 if ((wlc->pub->boardflags & BFL_FEM) in brcms_c_up()
5031 && (ai_get_chip_id(wlc->hw->sih) == BCMA_CHIP_ID_BCM4313)) { in brcms_c_up()
5032 if (wlc->pub->boardrev >= 0x1250 in brcms_c_up()
5033 && (wlc->pub->boardflags & BFL_FEM_BT)) in brcms_c_up()
5034 brcms_b_mhf(wlc->hw, MHF5, MHF5_4313_GPIOCTRL, in brcms_c_up()
5037 brcms_b_mhf(wlc->hw, MHF4, MHF4_EXTPA_ENABLE, in brcms_c_up()
5050 if (!wlc->pub->radio_disabled) { in brcms_c_up()
5051 int status = brcms_b_up_prep(wlc->hw); in brcms_c_up()
5054 (wlc->pub->radio_disabled, WL_RADIO_HW_DISABLE)) { in brcms_c_up()
5055 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_up()
5056 mboolset(wlc->pub->radio_disabled, in brcms_c_up()
5060 brcms_err(wlc->hw->d11core, in brcms_c_up()
5063 wlc->pub->unit); in brcms_c_up()
5068 if (wlc->pub->radio_disabled) { in brcms_c_up()
5069 brcms_c_radio_monitor_start(wlc); in brcms_c_up()
5074 wlc->clk = true; in brcms_c_up()
5076 brcms_c_radio_monitor_stop(wlc); in brcms_c_up()
5079 brcms_b_mhf(wlc->hw, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); in brcms_c_up()
5081 brcms_init(wlc->wl); in brcms_c_up()
5082 wlc->pub->up = true; in brcms_c_up()
5084 if (wlc->bandinit_pending) { in brcms_c_up()
5085 ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_up()
5086 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_up()
5087 brcms_c_set_chanspec(wlc, ch20mhz_chspec(ch->hw_value)); in brcms_c_up()
5088 wlc->bandinit_pending = false; in brcms_c_up()
5089 brcms_c_enable_mac(wlc); in brcms_c_up()
5092 brcms_b_up_finish(wlc->hw); in brcms_c_up()
5095 brcms_c_wme_retries_write(wlc); in brcms_c_up()
5098 brcms_add_timer(wlc->wdtimer, TIMER_INTERVAL_WATCHDOG, true); in brcms_c_up()
5099 wlc->WDarmed = true; in brcms_c_up()
5102 brcms_c_stf_phy_txant_upd(wlc); in brcms_c_up()
5104 brcms_c_ht_update_ldpc(wlc, wlc->stf->ldpc); in brcms_c_up()
5109 static uint brcms_c_down_del_timer(struct brcms_c_info *wlc) in brcms_c_down_del_timer() argument
5124 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_bmac_down_prep()
5128 wlc_hw->wlc->macintmask = 0; in brcms_b_bmac_down_prep()
5131 brcms_intrsoff(wlc_hw->wlc->wl); in brcms_b_bmac_down_prep()
5153 dev_gone = brcms_deviceremoved(wlc_hw->wlc); in brcms_b_down_finish()
5161 brcms_c_flushqueues(wlc_hw->wlc); in brcms_b_down_finish()
5168 brcms_c_suspend_mac_and_wait(wlc_hw->wlc); in brcms_b_down_finish()
5169 callbacks += brcms_reset(wlc_hw->wlc->wl); in brcms_b_down_finish()
5188 uint brcms_c_down(struct brcms_c_info *wlc) in brcms_c_down() argument
5195 brcms_dbg_info(wlc->hw->d11core, "wl%d\n", wlc->pub->unit); in brcms_c_down()
5198 if (wlc->going_down) { in brcms_c_down()
5199 brcms_err(wlc->hw->d11core, in brcms_c_down()
5201 wlc->pub->unit, __func__); in brcms_c_down()
5204 if (!wlc->pub->up) in brcms_c_down()
5207 wlc->going_down = true; in brcms_c_down()
5209 callbacks += brcms_b_bmac_down_prep(wlc->hw); in brcms_c_down()
5211 dev_gone = brcms_deviceremoved(wlc); in brcms_c_down()
5215 if (wlc->modulecb[i].down_fn) in brcms_c_down()
5217 wlc->modulecb[i].down_fn(wlc->modulecb[i].hdl); in brcms_c_down()
5221 if (wlc->WDarmed) { in brcms_c_down()
5222 if (!brcms_del_timer(wlc->wdtimer)) in brcms_c_down()
5224 wlc->WDarmed = false; in brcms_c_down()
5227 callbacks += brcms_c_down_del_timer(wlc); in brcms_c_down()
5229 wlc->pub->up = false; in brcms_c_down()
5231 wlc_phy_mute_upd(wlc->band->pi, false, PHY_MUTE_ALL); in brcms_c_down()
5233 callbacks += brcms_b_down_finish(wlc->hw); in brcms_c_down()
5236 wlc->clk = false; in brcms_c_down()
5238 wlc->going_down = false; in brcms_c_down()
5243 int brcms_c_set_gmode(struct brcms_c_info *wlc, u8 gmode, bool config) in brcms_c_set_gmode() argument
5257 if ((wlc->pub->_n_enab & SUPPORT_11N) && gmode == GMODE_LEGACY_B) in brcms_c_set_gmode()
5261 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_set_gmode()
5262 band = wlc->band; in brcms_c_set_gmode()
5263 else if ((wlc->pub->_nbands > 1) && in brcms_c_set_gmode()
5264 (wlc->bandstate[OTHERBANDUNIT(wlc)]->bandtype == BRCM_BAND_2G)) in brcms_c_set_gmode()
5265 band = wlc->bandstate[OTHERBANDUNIT(wlc)]; in brcms_c_set_gmode()
5271 brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, gmode); in brcms_c_set_gmode()
5301 brcms_err(wlc->hw->d11core, "wl%d: %s: invalid gmode %d\n", in brcms_c_set_gmode()
5302 wlc->pub->unit, __func__, gmode); in brcms_c_set_gmode()
5308 wlc->shortslot_override = shortslot; in brcms_c_set_gmode()
5324 wlc->default_bss->rateset.count = rs.count; in brcms_c_set_gmode()
5325 memcpy(wlc->default_bss->rateset.rates, rs.rates, in brcms_c_set_gmode()
5326 sizeof(wlc->default_bss->rateset.rates)); in brcms_c_set_gmode()
5331 int brcms_c_set_nmode(struct brcms_c_info *wlc) in brcms_c_set_nmode() argument
5336 if (wlc->stf->txstreams == WL_11N_3x3) in brcms_c_set_nmode()
5342 brcms_c_set_gmode(wlc, GMODE_AUTO, true); in brcms_c_set_nmode()
5344 wlc->pub->_n_enab = SUPPORT_HT; in brcms_c_set_nmode()
5346 wlc->pub->_n_enab = SUPPORT_11N; in brcms_c_set_nmode()
5347 wlc->default_bss->flags |= BRCMS_BSS_HT; in brcms_c_set_nmode()
5349 brcms_c_rateset_mcs_build(&wlc->default_bss->rateset, in brcms_c_set_nmode()
5350 wlc->stf->txstreams); in brcms_c_set_nmode()
5351 for (i = 0; i < wlc->pub->_nbands; i++) in brcms_c_set_nmode()
5352 memcpy(wlc->bandstate[i]->hw_rateset.mcs, in brcms_c_set_nmode()
5353 wlc->default_bss->rateset.mcs, MCSSET_LEN); in brcms_c_set_nmode()
5359 brcms_c_set_internal_rateset(struct brcms_c_info *wlc, in brcms_c_set_internal_rateset() argument
5372 bandunit = wlc->band->bandunit; in brcms_c_set_internal_rateset()
5375 (&new, &wlc->bandstate[bandunit]->hw_rateset, true, in brcms_c_set_internal_rateset()
5376 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5380 if (brcms_is_mband_unlocked(wlc)) { in brcms_c_set_internal_rateset()
5381 bandunit = OTHERBANDUNIT(wlc); in brcms_c_set_internal_rateset()
5384 &wlc-> in brcms_c_set_internal_rateset()
5387 wlc->stf->txstreams)) in brcms_c_set_internal_rateset()
5395 memcpy(&wlc->default_bss->rateset, &new, in brcms_c_set_internal_rateset()
5397 memcpy(&wlc->bandstate[bandunit]->defrateset, &new, in brcms_c_set_internal_rateset()
5402 static void brcms_c_ofdm_rateset_war(struct brcms_c_info *wlc) in brcms_c_ofdm_rateset_war() argument
5407 if (wlc->pub->associated) in brcms_c_ofdm_rateset_war()
5408 r = wlc->bsscfg->current_bss->rateset.rates[0]; in brcms_c_ofdm_rateset_war()
5410 r = wlc->default_bss->rateset.rates[0]; in brcms_c_ofdm_rateset_war()
5412 wlc_phy_ofdm_rateset_war(wlc->band->pi, war); in brcms_c_ofdm_rateset_war()
5415 int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) in brcms_c_set_channel() argument
5422 if (!brcms_c_valid_chanspec_db(wlc->cmi, chspec)) in brcms_c_set_channel()
5426 if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) { in brcms_c_set_channel()
5427 if (wlc->band->bandunit != chspec_bandunit(chspec)) in brcms_c_set_channel()
5428 wlc->bandinit_pending = true; in brcms_c_set_channel()
5430 wlc->bandinit_pending = false; in brcms_c_set_channel()
5433 wlc->default_bss->chanspec = chspec; in brcms_c_set_channel()
5436 if (wlc->pub->up && (wlc_phy_chanspec_get(wlc->band->pi) != chspec)) { in brcms_c_set_channel()
5437 brcms_c_set_home_chanspec(wlc, chspec); in brcms_c_set_channel()
5438 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_set_channel()
5439 brcms_c_set_chanspec(wlc, chspec); in brcms_c_set_channel()
5440 brcms_c_enable_mac(wlc); in brcms_c_set_channel()
5445 int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) in brcms_c_set_rate_limit() argument
5453 wlc->SRL = srl; in brcms_c_set_rate_limit()
5454 wlc->LRL = lrl; in brcms_c_set_rate_limit()
5456 brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); in brcms_c_set_rate_limit()
5459 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5460 EDCF_SHORT, wlc->SRL); in brcms_c_set_rate_limit()
5461 wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], in brcms_c_set_rate_limit()
5462 EDCF_LONG, wlc->LRL); in brcms_c_set_rate_limit()
5464 brcms_c_wme_retries_write(wlc); in brcms_c_set_rate_limit()
5469 void brcms_c_get_current_rateset(struct brcms_c_info *wlc, in brcms_c_get_current_rateset() argument
5474 if (wlc->pub->associated) in brcms_c_get_current_rateset()
5475 rs = &wlc->bsscfg->current_bss->rateset; in brcms_c_get_current_rateset()
5477 rs = &wlc->default_bss->rateset; in brcms_c_get_current_rateset()
5484 int brcms_c_set_rateset(struct brcms_c_info *wlc, struct brcm_rateset *rs) in brcms_c_set_rateset() argument
5499 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_set_rateset()
5501 if (wlc->pub->associated) in brcms_c_set_rateset()
5502 mcsset_bss = wlc->bsscfg->current_bss; in brcms_c_set_rateset()
5504 mcsset_bss = wlc->default_bss; in brcms_c_set_rateset()
5509 bcmerror = brcms_c_set_internal_rateset(wlc, &internal_rs); in brcms_c_set_rateset()
5511 brcms_c_ofdm_rateset_war(wlc); in brcms_c_set_rateset()
5516 static void brcms_c_time_lock(struct brcms_c_info *wlc) in brcms_c_time_lock() argument
5518 bcma_set32(wlc->hw->d11core, D11REGOFFS(maccontrol), MCTL_TBTTHOLD); in brcms_c_time_lock()
5520 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_lock()
5523 static void brcms_c_time_unlock(struct brcms_c_info *wlc) in brcms_c_time_unlock() argument
5525 bcma_mask32(wlc->hw->d11core, D11REGOFFS(maccontrol), ~MCTL_TBTTHOLD); in brcms_c_time_unlock()
5527 bcma_read32(wlc->hw->d11core, D11REGOFFS(maccontrol)); in brcms_c_time_unlock()
5530 int brcms_c_set_beacon_period(struct brcms_c_info *wlc, u16 period) in brcms_c_set_beacon_period() argument
5537 wlc->default_bss->beacon_period = period; in brcms_c_set_beacon_period()
5540 brcms_c_time_lock(wlc); in brcms_c_set_beacon_period()
5541 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfprep), in brcms_c_set_beacon_period()
5543 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_cfpstart), bcnint_us); in brcms_c_set_beacon_period()
5544 brcms_c_time_unlock(wlc); in brcms_c_set_beacon_period()
5549 u16 brcms_c_get_phy_type(struct brcms_c_info *wlc, int phyidx) in brcms_c_get_phy_type() argument
5551 return wlc->band->phytype; in brcms_c_get_phy_type()
5554 void brcms_c_set_shortslot_override(struct brcms_c_info *wlc, s8 sslot_override) in brcms_c_set_shortslot_override() argument
5556 wlc->shortslot_override = sslot_override; in brcms_c_set_shortslot_override()
5562 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_set_shortslot_override()
5565 if (wlc->pub->up && wlc->pub->associated) { in brcms_c_set_shortslot_override()
5567 } else if (wlc->pub->up) { in brcms_c_set_shortslot_override()
5569 brcms_c_switch_shortslot(wlc, false); in brcms_c_set_shortslot_override()
5573 if (wlc->shortslot_override == BRCMS_SHORTSLOT_AUTO) in brcms_c_set_shortslot_override()
5574 wlc->shortslot = false; in brcms_c_set_shortslot_override()
5576 wlc->shortslot = in brcms_c_set_shortslot_override()
5577 (wlc->shortslot_override == in brcms_c_set_shortslot_override()
5589 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_register() local
5594 if (wlc->modulecb[i].name[0] == '\0') { in brcms_c_module_register()
5595 strncpy(wlc->modulecb[i].name, name, in brcms_c_module_register()
5596 sizeof(wlc->modulecb[i].name) - 1); in brcms_c_module_register()
5597 wlc->modulecb[i].hdl = hdl; in brcms_c_module_register()
5598 wlc->modulecb[i].down_fn = d_fn; in brcms_c_module_register()
5610 struct brcms_c_info *wlc = (struct brcms_c_info *) pub->wlc; in brcms_c_module_unregister() local
5613 if (wlc == NULL) in brcms_c_module_unregister()
5617 if (!strcmp(wlc->modulecb[i].name, name) && in brcms_c_module_unregister()
5618 (wlc->modulecb[i].hdl == hdl)) { in brcms_c_module_unregister()
5619 memset(&wlc->modulecb[i], 0, sizeof(wlc->modulecb[i])); in brcms_c_module_unregister()
5705 bcmc_fid_generate(struct brcms_c_info *wlc, struct brcms_bss_cfg *bsscfg, in bcmc_fid_generate() argument
5713 (((wlc-> in bcmc_fid_generate()
5721 brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_ack_time() argument
5731 rspec = brcms_basic_rate(wlc, rspec); in brcms_c_calc_ack_time()
5734 brcms_c_calc_frame_time(wlc, rspec, preamble_type, in brcms_c_calc_ack_time()
5740 brcms_c_calc_cts_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_cts_time() argument
5743 return brcms_c_calc_ack_time(wlc, rspec, preamble_type); in brcms_c_calc_cts_time()
5747 brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, in brcms_c_calc_ba_time() argument
5755 rspec = brcms_basic_rate(wlc, rspec); in brcms_c_calc_ba_time()
5757 return brcms_c_calc_frame_time(wlc, rspec, preamble_type, in brcms_c_calc_ba_time()
5773 brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, in brcms_c_compute_frame_dur() argument
5778 sifs = get_sifs(wlc->band); in brcms_c_compute_frame_dur()
5781 dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type); in brcms_c_compute_frame_dur()
5789 (u16) brcms_c_calc_frame_time(wlc, rate, preamble_type, in brcms_c_compute_frame_dur()
5797 brcms_c_calc_frame_len(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_frame_len() argument
5808 if (wlc->band->bandtype == BRCM_BAND_2G) in brcms_c_calc_frame_len()
5842 static bool brcms_c_valid_rate(struct brcms_c_info *wlc, u32 rspec, int band, in brcms_c_valid_rate() argument
5848 if ((band == BRCM_BAND_AUTO) || (band == wlc->band->bandtype)) in brcms_c_valid_rate()
5849 hw_rateset = &wlc->band->hw_rateset; in brcms_c_valid_rate()
5850 else if (wlc->pub->_nbands > 1) in brcms_c_valid_rate()
5851 hw_rateset = &wlc->bandstate[OTHERBANDUNIT(wlc)]->hw_rateset; in brcms_c_valid_rate()
5869 brcms_err(wlc->hw->d11core, "wl%d: valid_rate: rate spec 0x%x " in brcms_c_valid_rate()
5870 "not in hw_rateset\n", wlc->pub->unit, rspec); in brcms_c_valid_rate()
5876 mac80211_wlc_set_nrate(struct brcms_c_info *wlc, struct brcms_band *cur_band, in mac80211_wlc_set_nrate() argument
5879 struct bcma_device *core = wlc->hw->d11core; in mac80211_wlc_set_nrate()
5893 if ((wlc->pub->_n_enab & SUPPORT_11N) && ismcs) { in mac80211_wlc_set_nrate()
5897 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5904 if (!CHSPEC_IS40(wlc->home_chanspec) || in mac80211_wlc_set_nrate()
5908 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5918 wlc->pub->unit, rate); in mac80211_wlc_set_nrate()
5927 (!BRCMS_STBC_CAP_PHY(wlc) in mac80211_wlc_set_nrate()
5930 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5938 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5946 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5952 wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5957 if ((stf != PHY_TXC1_MODE_SISO) && (wlc->stf->txstreams == 1)) { in mac80211_wlc_set_nrate()
5959 "request\n", wlc->pub->unit, __func__); in mac80211_wlc_set_nrate()
5984 && !brcms_c_valid_rate(wlc, rspec, cur_band->bandtype, true)) in mac80211_wlc_set_nrate()
5999 static void brcms_c_cck_plcp_set(struct brcms_c_info *wlc, int rate_500, in brcms_c_cck_plcp_set() argument
6027 brcms_err(wlc->hw->d11core, in brcms_c_cck_plcp_set()
6083 static void brcms_c_compute_cck_plcp(struct brcms_c_info *wlc, u32 rspec, in brcms_c_compute_cck_plcp() argument
6088 brcms_c_cck_plcp_set(wlc, rate, length, plcp); in brcms_c_compute_cck_plcp()
6092 brcms_c_compute_plcp(struct brcms_c_info *wlc, u32 rspec, in brcms_c_compute_plcp() argument
6100 brcms_c_compute_cck_plcp(wlc, rspec, length, plcp); in brcms_c_compute_plcp()
6115 brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, in brcms_c_compute_rtscts_dur() argument
6122 sifs = get_sifs(wlc->band); in brcms_c_compute_rtscts_dur()
6128 (u16) brcms_c_calc_cts_time(wlc, rts_rate, in brcms_c_compute_rtscts_dur()
6136 (u16) brcms_c_calc_frame_time(wlc, frame_rate, frame_preamble_type, in brcms_c_compute_rtscts_dur()
6140 (u16) brcms_c_calc_ba_time(wlc, frame_rate, in brcms_c_compute_rtscts_dur()
6144 (u16) brcms_c_calc_ack_time(wlc, frame_rate, in brcms_c_compute_rtscts_dur()
6149 static u16 brcms_c_phytxctl1_calc(struct brcms_c_info *wlc, u32 rspec) in brcms_c_phytxctl1_calc() argument
6154 if (BRCMS_ISLCNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6160 brcms_err(wlc->hw->d11core, "phytxctl1_calc: bw %d is " in brcms_c_phytxctl1_calc()
6173 } else if (is_cck_rate(rspec) && !BRCMS_ISLCNPHY(wlc->band) in brcms_c_phytxctl1_calc()
6174 && !BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_phytxctl1_calc()
6187 brcms_err(wlc->hw->d11core, "phytxctl1_calc: wrong " in brcms_c_phytxctl1_calc()
6209 brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, in brcms_c_d11hdrs_mac80211() argument
6267 brcms_err(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6269 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6270 frameid = bcmc_fid_generate(wlc, NULL, txh); in brcms_c_d11hdrs_mac80211()
6318 rspec[k] = mac80211_wlc_set_nrate(wlc, wlc->band, in brcms_c_d11hdrs_mac80211()
6345 brcms_c_antsel_antcfg_get(wlc->asi, false, in brcms_c_d11hdrs_mac80211()
6351 phyctl1_stf = wlc->stf->ss_opmode; in brcms_c_d11hdrs_mac80211()
6353 if (wlc->pub->_n_enab & SUPPORT_11N) { in brcms_c_d11hdrs_mac80211()
6368 && BRCMS_STF_SS_STBC_TX(wlc, scb)) { in brcms_c_d11hdrs_mac80211()
6385 if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) { in brcms_c_d11hdrs_mac80211()
6389 wlc->band->pi)) in brcms_c_d11hdrs_mac80211()
6399 } else if (wlc->mimo_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6400 mimo_txbw = wlc->mimo_40txbw; in brcms_c_d11hdrs_mac80211()
6405 if (wlc->ofdm_40txbw != AUTO) in brcms_c_d11hdrs_mac80211()
6406 mimo_txbw = wlc->ofdm_40txbw; in brcms_c_d11hdrs_mac80211()
6407 } else if (wlc->cck_40txbw != AUTO) { in brcms_c_d11hdrs_mac80211()
6408 mimo_txbw = wlc->cck_40txbw; in brcms_c_d11hdrs_mac80211()
6439 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6441 wlc->pub->unit, __func__); in brcms_c_d11hdrs_mac80211()
6470 if (BRCMS_ISNPHY(wlc->band) && is_ofdm_rate(rspec[k])) { in brcms_c_d11hdrs_mac80211()
6484 (phylen > wlc->RTSThresh) && !is_multicast_ether_addr(h->addr1)) in brcms_c_d11hdrs_mac80211()
6489 brcms_c_compute_plcp(wlc, rspec[0], phylen, plcp); in brcms_c_d11hdrs_mac80211()
6490 brcms_c_compute_plcp(wlc, rspec[1], phylen, plcp_fallback); in brcms_c_d11hdrs_mac80211()
6509 brcms_c_compute_frame_dur(wlc, rspec[0], preamble_type[0], in brcms_c_d11hdrs_mac80211()
6515 (u16) brcms_c_calc_frame_time(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6528 durid = brcms_c_compute_frame_dur(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6540 if (wlc->band->bandtype == BRCM_BAND_5G) in brcms_c_d11hdrs_mac80211()
6543 if (CHSPEC_IS40(wlc_phy_chanspec_get(wlc->band->pi))) in brcms_c_d11hdrs_mac80211()
6597 rts_rspec[k] = brcms_c_rspec_to_rts_rspec(wlc, rspec[k], in brcms_c_d11hdrs_mac80211()
6604 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6611 (wlc->PLCPHdr_override == BRCMS_PLCP_LONG))) { in brcms_c_d11hdrs_mac80211()
6631 brcms_c_compute_plcp(wlc, rts_rspec[0], rts_phylen, rts_plcp); in brcms_c_d11hdrs_mac80211()
6634 brcms_c_compute_plcp(wlc, rts_rspec[1], rts_phylen, in brcms_c_d11hdrs_mac80211()
6642 durid = brcms_c_compute_rtscts_dur(wlc, use_cts, rts_rspec[0], in brcms_c_d11hdrs_mac80211()
6647 durid = brcms_c_compute_rtscts_dur(wlc, use_cts, in brcms_c_d11hdrs_mac80211()
6684 brcm_c_ampdu_null_delim_cnt(wlc->ampdu, scb, rspec, phylen); in brcms_c_d11hdrs_mac80211()
6701 xfts = frametype(rspec[1], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6702 xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6703 xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); in brcms_c_d11hdrs_mac80211()
6704 xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << in brcms_c_d11hdrs_mac80211()
6709 phyctl = frametype(rspec[0], wlc->mimoft); in brcms_c_d11hdrs_mac80211()
6717 phyctl |= brcms_c_stf_d11hdrs_phyctl_txant(wlc, rspec[0]); in brcms_c_d11hdrs_mac80211()
6721 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_d11hdrs_mac80211()
6724 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[0]); in brcms_c_d11hdrs_mac80211()
6726 phyctl1 = brcms_c_phytxctl1_calc(wlc, rspec[1]); in brcms_c_d11hdrs_mac80211()
6730 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[0]); in brcms_c_d11hdrs_mac80211()
6732 phyctl1 = brcms_c_phytxctl1_calc(wlc, rts_rspec[1]); in brcms_c_d11hdrs_mac80211()
6744 brcms_c_calc_lsig_len(wlc, rspec[0], phylen); in brcms_c_d11hdrs_mac80211()
6751 brcms_c_calc_lsig_len(wlc, rspec[1], phylen); in brcms_c_d11hdrs_mac80211()
6757 if ((scb->flags & SCB_WMECAP) && qos && wlc->edcf_txop[ac]) { in brcms_c_d11hdrs_mac80211()
6763 brcms_c_calc_frame_time(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6769 brcms_c_calc_cts_time(wlc, rts_rspec[0], in brcms_c_d11hdrs_mac80211()
6772 brcms_c_calc_cts_time(wlc, rts_rspec[1], in brcms_c_d11hdrs_mac80211()
6785 brcms_c_compute_frame_dur(wlc, rspec[0], in brcms_c_d11hdrs_mac80211()
6789 brcms_c_calc_frame_time(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6793 brcms_c_compute_frame_dur(wlc, rspec[1], in brcms_c_d11hdrs_mac80211()
6809 if (wlc->edcf_txop[ac] >= (dur - frag_dur)) { in brcms_c_d11hdrs_mac80211()
6813 brcms_c_calc_frame_len(wlc, in brcms_c_d11hdrs_mac80211()
6815 (wlc->edcf_txop[ac] - in brcms_c_d11hdrs_mac80211()
6822 wlc->usr_fragthresh) in brcms_c_d11hdrs_mac80211()
6824 wlc->usr_fragthresh; in brcms_c_d11hdrs_mac80211()
6826 if (wlc->fragthresh[queue] != in brcms_c_d11hdrs_mac80211()
6828 wlc->fragthresh[queue] = in brcms_c_d11hdrs_mac80211()
6831 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6833 wlc->pub->unit, fifo_names[queue], in brcms_c_d11hdrs_mac80211()
6837 if (dur > wlc->edcf_txop[ac]) in brcms_c_d11hdrs_mac80211()
6838 brcms_warn(wlc->hw->d11core, in brcms_c_d11hdrs_mac80211()
6840 wlc->pub->unit, __func__, in brcms_c_d11hdrs_mac80211()
6842 phylen, wlc->fragthresh[queue], in brcms_c_d11hdrs_mac80211()
6843 dur, wlc->edcf_txop[ac]); in brcms_c_d11hdrs_mac80211()
6850 static int brcms_c_tx(struct brcms_c_info *wlc, struct sk_buff *skb) in brcms_c_tx() argument
6858 dma = wlc->hw->di[fifo]; in brcms_c_tx()
6871 brcms_warn(wlc->hw->d11core, in brcms_c_tx()
6873 WARN_ON(!ieee80211_queue_stopped(wlc->pub->ieee_hw, in brcms_c_tx()
6890 brcms_b_write_shm(wlc->hw, M_BCMC_FID, frameid); in brcms_c_tx()
6893 ret = brcms_c_txfifo(wlc, fifo, skb); in brcms_c_tx()
6904 bool brcms_c_sendpkt_mac80211(struct brcms_c_info *wlc, struct sk_buff *sdu, in brcms_c_sendpkt_mac80211() argument
6908 struct scb *scb = &wlc->pri_scb; in brcms_c_sendpkt_mac80211()
6911 brcms_c_d11hdrs_mac80211(wlc, hw, sdu, scb, 0, 1, fifo, 0); in brcms_c_sendpkt_mac80211()
6912 if (!brcms_c_tx(wlc, sdu)) in brcms_c_sendpkt_mac80211()
6921 brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p) in brcms_c_txfifo() argument
6923 struct dma_pub *dma = wlc->hw->di[fifo]; in brcms_c_txfifo()
6927 ret = dma_txfast(wlc, dma, p); in brcms_c_txfifo()
6929 wiphy_err(wlc->wiphy, "txfifo: fatal, toss frames !!!\n"); in brcms_c_txfifo()
6938 !ieee80211_queue_stopped(wlc->pub->ieee_hw, queue)) in brcms_c_txfifo()
6939 ieee80211_stop_queue(wlc->pub->ieee_hw, queue); in brcms_c_txfifo()
6945 brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, in brcms_c_rspec_to_rts_rspec() argument
6953 else if (wlc->band->gmode && wlc->protection->_g && !is_cck_rate(rspec)) in brcms_c_rspec_to_rts_rspec()
6961 rts_rspec = brcms_basic_rate(wlc, BRCM_RATE_11M); in brcms_c_rspec_to_rts_rspec()
6967 rts_rspec = brcms_basic_rate(wlc, rspec); in brcms_c_rspec_to_rts_rspec()
6969 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_rspec_to_rts_rspec()
6985 rts_rspec |= (wlc->stf->ss_opmode << RSPEC_STF_SHIFT); in brcms_c_rspec_to_rts_rspec()
6992 static void brcms_c_bcn_li_upd(struct brcms_c_info *wlc) in brcms_c_bcn_li_upd() argument
6995 if (wlc->bcn_li_dtim == 1) in brcms_c_bcn_li_upd()
6996 brcms_b_write_shm(wlc->hw, M_BCN_LI, 0); in brcms_c_bcn_li_upd()
6998 brcms_b_write_shm(wlc->hw, M_BCN_LI, in brcms_c_bcn_li_upd()
6999 (wlc->bcn_li_dtim << 8) | wlc->bcn_li_bcn); in brcms_c_bcn_li_upd()
7027 static u64 brcms_c_recover_tsf64(struct brcms_c_info *wlc, in brcms_c_recover_tsf64() argument
7033 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_recover_tsf64()
7052 prep_mac80211_status(struct brcms_c_info *wlc, struct d11rxhdr *rxh, in prep_mac80211_status() argument
7061 rx_status->mactime = brcms_c_recover_tsf64(wlc, rxh); in prep_mac80211_status()
7071 rx_status->signal = wlc_phy_rssi_compute(wlc->hw->band->pi, rxh); in prep_mac80211_status()
7125 brcms_err(wlc->hw->d11core, in prep_mac80211_status()
7144 brcms_err(wlc->hw->d11core, "%s: Unknown modulation\n", in prep_mac80211_status()
7154 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_PLCP_CRC\n", in prep_mac80211_status()
7159 brcms_err(wlc->hw->d11core, "%s: RX_FLAG_FAILED_FCS_CRC\n", in prep_mac80211_status()
7165 brcms_c_recvctl(struct brcms_c_info *wlc, struct d11rxhdr *rxh, in brcms_c_recvctl() argument
7173 prep_mac80211_status(wlc, rxh, p, &rx_status); in brcms_c_recvctl()
7181 if (wlc->hw->suspended_fifos) { in brcms_c_recvctl()
7184 brcms_b_mute(wlc->hw, false); in brcms_c_recvctl()
7188 ieee80211_rx_irqsafe(wlc->pub->ieee_hw, p); in brcms_c_recvctl()
7198 brcms_c_calc_lsig_len(struct brcms_c_info *wlc, u32 ratespec, in brcms_c_calc_lsig_len() argument
7240 brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) in brcms_c_mod_prb_rsp_rate_table() argument
7250 sifs = get_sifs(wlc->band); in brcms_c_mod_prb_rsp_rate_table()
7252 rs_dflt = brcms_c_rateset_get_hwrs(wlc); in brcms_c_mod_prb_rsp_rate_table()
7255 brcms_c_rateset_mcs_upd(&rs, wlc->stf->txstreams); in brcms_c_mod_prb_rsp_rate_table()
7264 entry_ptr = brcms_b_rate_shm_offset(wlc->hw, rate); in brcms_c_mod_prb_rsp_rate_table()
7267 brcms_c_compute_plcp(wlc, rate, frame_len, plcp); in brcms_c_mod_prb_rsp_rate_table()
7273 dur = (u16) brcms_c_calc_frame_time(wlc, rate, in brcms_c_mod_prb_rsp_rate_table()
7278 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS, in brcms_c_mod_prb_rsp_rate_table()
7280 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_PLCP_POS + 2, in brcms_c_mod_prb_rsp_rate_table()
7282 brcms_b_write_shm(wlc->hw, entry_ptr + M_RT_PRS_DUR_POS, dur); in brcms_c_mod_prb_rsp_rate_table()
7291 static void brcms_c_beacon_write(struct brcms_c_info *wlc, in brcms_c_beacon_write() argument
7297 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_beacon_write()
7298 struct ieee80211_hw *ieee_hw = brcms_c_pub(wlc)->ieee_hw; in brcms_c_beacon_write()
7304 wlc->bcn_rspec = ieee80211_get_tx_rate(ieee_hw, tx_info)->hw_value; in brcms_c_beacon_write()
7306 brcms_c_compute_plcp(wlc, wlc->bcn_rspec, in brcms_c_beacon_write()
7311 brcms_c_beacon_phytxctl_txant_upd(wlc, wlc->bcn_rspec); in brcms_c_beacon_write()
7341 static void brcms_c_update_beacon_hw(struct brcms_c_info *wlc, in brcms_c_update_beacon_hw() argument
7345 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_update_beacon_hw()
7358 if (wlc->beacon_template_virgin) { in brcms_c_update_beacon_hw()
7359 wlc->beacon_template_virgin = false; in brcms_c_update_beacon_hw()
7360 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true, in brcms_c_update_beacon_hw()
7371 wlc->defmacintmask |= MI_BCNTPL; in brcms_c_update_beacon_hw()
7376 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, true, in brcms_c_update_beacon_hw()
7383 brcms_c_beacon_write(wlc, beacon, tim_offset, dtim_period, in brcms_c_update_beacon_hw()
7395 void brcms_c_update_beacon(struct brcms_c_info *wlc) in brcms_c_update_beacon() argument
7397 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_beacon()
7399 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_beacon()
7402 wlc->defmacintmask &= ~MI_BCNTPL; in brcms_c_update_beacon()
7403 if (!wlc->beacon) in brcms_c_update_beacon()
7405 brcms_c_update_beacon_hw(wlc, wlc->beacon, in brcms_c_update_beacon()
7406 wlc->beacon_tim_offset, in brcms_c_update_beacon()
7407 wlc->beacon_dtim_period); in brcms_c_update_beacon()
7411 void brcms_c_set_new_beacon(struct brcms_c_info *wlc, struct sk_buff *beacon, in brcms_c_set_new_beacon() argument
7416 if (wlc->beacon) in brcms_c_set_new_beacon()
7417 dev_kfree_skb_any(wlc->beacon); in brcms_c_set_new_beacon()
7418 wlc->beacon = beacon; in brcms_c_set_new_beacon()
7421 skb_push(wlc->beacon, D11_PHY_HDR_LEN); in brcms_c_set_new_beacon()
7422 wlc->beacon_tim_offset = tim_offset; in brcms_c_set_new_beacon()
7423 wlc->beacon_dtim_period = dtim_period; in brcms_c_set_new_beacon()
7424 brcms_c_update_beacon(wlc); in brcms_c_set_new_beacon()
7427 void brcms_c_set_new_probe_resp(struct brcms_c_info *wlc, in brcms_c_set_new_probe_resp() argument
7432 if (wlc->probe_resp) in brcms_c_set_new_probe_resp()
7433 dev_kfree_skb_any(wlc->probe_resp); in brcms_c_set_new_probe_resp()
7434 wlc->probe_resp = probe_resp; in brcms_c_set_new_probe_resp()
7437 skb_push(wlc->probe_resp, D11_PHY_HDR_LEN); in brcms_c_set_new_probe_resp()
7438 brcms_c_update_probe_resp(wlc, false); in brcms_c_set_new_probe_resp()
7441 void brcms_c_enable_probe_resp(struct brcms_c_info *wlc, bool enable) in brcms_c_enable_probe_resp() argument
7447 wlc->prb_resp_timeout = enable ? BRCMS_PRB_RESP_TIMEOUT : 1; in brcms_c_enable_probe_resp()
7448 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_enable_probe_resp()
7454 brcms_c_shm_ssid_upd(struct brcms_c_info *wlc, struct brcms_bss_cfg *cfg) in brcms_c_shm_ssid_upd() argument
7464 brcms_c_copyto_shm(wlc, base, ssidbuf, IEEE80211_MAX_SSID_LEN); in brcms_c_shm_ssid_upd()
7465 brcms_b_write_shm(wlc->hw, M_SSIDLEN, (u16) cfg->SSID_len); in brcms_c_shm_ssid_upd()
7469 brcms_c_bss_update_probe_resp(struct brcms_c_info *wlc, in brcms_c_bss_update_probe_resp() argument
7479 brcms_c_suspend_mac_and_wait(wlc); in brcms_c_bss_update_probe_resp()
7482 brcms_b_write_template_ram(wlc->hw, T_PRS_TPL_BASE, in brcms_c_bss_update_probe_resp()
7486 brcms_b_write_shm(wlc->hw, M_PRB_RESP_FRM_LEN, (u16) len); in brcms_c_bss_update_probe_resp()
7489 brcms_c_shm_ssid_upd(wlc, cfg); in brcms_c_bss_update_probe_resp()
7497 brcms_c_mod_prb_rsp_rate_table(wlc, in brcms_c_bss_update_probe_resp()
7501 brcms_c_enable_mac(wlc); in brcms_c_bss_update_probe_resp()
7504 void brcms_c_update_probe_resp(struct brcms_c_info *wlc, bool suspend) in brcms_c_update_probe_resp() argument
7506 struct brcms_bss_cfg *bsscfg = wlc->bsscfg; in brcms_c_update_probe_resp()
7509 if (wlc->pub->up && (bsscfg->type == BRCMS_TYPE_AP || in brcms_c_update_probe_resp()
7511 if (!wlc->probe_resp) in brcms_c_update_probe_resp()
7513 brcms_c_bss_update_probe_resp(wlc, bsscfg, wlc->probe_resp, in brcms_c_update_probe_resp()
7530 brcms_c_set_addrmatch(struct brcms_c_info *wlc, int match_reg_offset, in brcms_c_set_addrmatch() argument
7533 brcms_b_set_addrmatch(wlc->hw, match_reg_offset, addr); in brcms_c_set_addrmatch()
7535 memcpy(wlc->bsscfg->BSSID, addr, ETH_ALEN); in brcms_c_set_addrmatch()
7541 void brcms_c_scan_start(struct brcms_c_info *wlc) in brcms_c_scan_start() argument
7543 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, true); in brcms_c_scan_start()
7546 void brcms_c_scan_stop(struct brcms_c_info *wlc) in brcms_c_scan_stop() argument
7548 wlc_phy_hold_upd(wlc->band->pi, PHY_HOLD_FOR_SCAN, false); in brcms_c_scan_stop()
7551 void brcms_c_associate_upd(struct brcms_c_info *wlc, bool state) in brcms_c_associate_upd() argument
7553 wlc->pub->associated = state; in brcms_c_associate_upd()
7574 int brcms_c_get_curband(struct brcms_c_info *wlc) in brcms_c_get_curband() argument
7576 return wlc->band->bandunit; in brcms_c_get_curband()
7579 bool brcms_c_tx_flush_completed(struct brcms_c_info *wlc) in brcms_c_tx_flush_completed() argument
7584 for (i = 0; i < ARRAY_SIZE(wlc->hw->di); i++) in brcms_c_tx_flush_completed()
7585 if (wlc->hw->di[i]) in brcms_c_tx_flush_completed()
7586 dma_kick_tx(wlc->hw->di[i]); in brcms_c_tx_flush_completed()
7588 return !brcms_txpktpendtot(wlc); in brcms_c_tx_flush_completed()
7591 void brcms_c_set_beacon_listen_interval(struct brcms_c_info *wlc, u8 interval) in brcms_c_set_beacon_listen_interval() argument
7593 wlc->bcn_li_bcn = interval; in brcms_c_set_beacon_listen_interval()
7594 if (wlc->pub->up) in brcms_c_set_beacon_listen_interval()
7595 brcms_c_bcn_li_upd(wlc); in brcms_c_set_beacon_listen_interval()
7598 u64 brcms_c_tsf_get(struct brcms_c_info *wlc) in brcms_c_tsf_get() argument
7603 brcms_b_read_tsf(wlc->hw, &tsf_l, &tsf_h); in brcms_c_tsf_get()
7612 void brcms_c_tsf_set(struct brcms_c_info *wlc, u64 tsf) in brcms_c_tsf_set() argument
7616 brcms_c_time_lock(wlc); in brcms_c_tsf_set()
7622 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerlow), tsf_l); in brcms_c_tsf_set()
7623 bcma_write32(wlc->hw->d11core, D11REGOFFS(tsf_timerhigh), tsf_h); in brcms_c_tsf_set()
7625 brcms_c_time_unlock(wlc); in brcms_c_tsf_set()
7628 int brcms_c_set_tx_power(struct brcms_c_info *wlc, int txpwr) in brcms_c_set_tx_power() argument
7634 return wlc_phy_txpower_set(wlc->band->pi, qdbm, false); in brcms_c_set_tx_power()
7637 int brcms_c_get_tx_power(struct brcms_c_info *wlc) in brcms_c_get_tx_power() argument
7642 wlc_phy_txpower_get(wlc->band->pi, &qdbm, &override); in brcms_c_get_tx_power()
7653 static void brcms_c_recv(struct brcms_c_info *wlc, struct sk_buff *p) in brcms_c_recv() argument
7669 brcms_err(wlc->hw->d11core, in brcms_c_recv()
7671 wlc->pub->unit, p->len); in brcms_c_recv()
7681 if (!(wlc->filter_flags & FIF_FCSFAIL)) in brcms_c_recv()
7694 brcms_c_recvctl(wlc, rxh, p); in brcms_c_recv()
7754 brcms_c_recv(wlc_hw->wlc, p); in brcms_b_recv()
7764 bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) in brcms_c_dpc() argument
7767 struct brcms_hardware *wlc_hw = wlc->hw; in brcms_c_dpc()
7770 if (brcms_deviceremoved(wlc)) { in brcms_c_dpc()
7773 brcms_down(wlc->wl); in brcms_c_dpc()
7778 macintstatus = wlc->macintstatus; in brcms_c_dpc()
7779 wlc->macintstatus = 0; in brcms_c_dpc()
7789 if (brcms_b_txstatus(wlc->hw, bounded, &fatal)) in brcms_c_dpc()
7790 wlc->macintstatus |= MI_TFS; in brcms_c_dpc()
7798 brcms_c_tbtt(wlc); in brcms_c_dpc()
7803 bcma_set32(core, D11REGOFFS(maccommand), wlc->qvalid); in brcms_c_dpc()
7804 wlc->qvalid = 0; in brcms_c_dpc()
7813 wlc->macintstatus |= MI_DMAINT; in brcms_c_dpc()
7826 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7836 brcms_rfkill_set_hw_state(wlc->wl); in brcms_c_dpc()
7841 brcms_c_update_beacon(wlc); in brcms_c_dpc()
7844 return wlc->macintstatus != 0; in brcms_c_dpc()
7847 brcms_fatal_error(wlc_hw->wlc->wl); in brcms_c_dpc()
7848 return wlc->macintstatus != 0; in brcms_c_dpc()
7851 void brcms_c_init(struct brcms_c_info *wlc, bool mute_tx) in brcms_c_init() argument
7853 struct bcma_device *core = wlc->hw->d11core; in brcms_c_init()
7854 struct ieee80211_channel *ch = wlc->pub->ieee_hw->conf.chandef.chan; in brcms_c_init()
7857 brcms_dbg_info(core, "wl%d\n", wlc->pub->unit); in brcms_c_init()
7861 brcms_b_init(wlc->hw, chanspec); in brcms_c_init()
7864 brcms_c_bcn_li_upd(wlc); in brcms_c_init()
7867 brcms_c_set_mac(wlc->bsscfg); in brcms_c_init()
7868 brcms_c_set_bssid(wlc->bsscfg); in brcms_c_init()
7871 if (wlc->pub->associated && wlc->pub->up) { in brcms_c_init()
7875 bi = wlc->bsscfg->current_bss->beacon_period << 10; in brcms_c_init()
7884 brcms_c_set_ps_ctrl(wlc); in brcms_c_init()
7887 brcms_c_bandinit_ordered(wlc, chanspec); in brcms_c_init()
7890 brcms_b_write_shm(wlc->hw, M_PRS_MAXTIME, wlc->prb_resp_timeout); in brcms_c_init()
7893 brcms_b_write_shm(wlc->hw, M_MBURST_TXOP, in brcms_c_init()
7894 (wlc-> in brcms_c_init()
7898 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_ofdm, true, true); in brcms_c_init()
7899 brcms_c_duty_cycle_set(wlc, wlc->tx_duty_cycle_cck, false, true); in brcms_c_init()
7905 brcms_c_ampdu_shm_upd(wlc->ampdu); in brcms_c_init()
7908 brcms_c_bsinit(wlc); in brcms_c_init()
7912 brcms_c_edcf_setparams(wlc, false); in brcms_c_init()
7915 if (wlc->ucode_rev == 0) { in brcms_c_init()
7919 rev = brcms_b_read_shm(wlc->hw, M_BOM_REV_MAJOR); in brcms_c_init()
7920 patch = brcms_b_read_shm(wlc->hw, M_BOM_REV_MINOR); in brcms_c_init()
7921 wlc->ucode_rev = (rev << NBITS(u16)) | patch; in brcms_c_init()
7922 snprintf(wlc->wiphy->fw_version, in brcms_c_init()
7923 sizeof(wlc->wiphy->fw_version), "%u.%u", rev, patch); in brcms_c_init()
7927 brcms_c_enable_mac(wlc); in brcms_c_init()
7931 brcms_b_mute(wlc->hw, true); in brcms_c_init()
7940 if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) { in brcms_c_init()
7945 wlc->wme_retries[ac] = in brcms_c_init()
7946 brcms_b_read_shm(wlc->hw, M_AC_TXLMT_ADDR(ac)); in brcms_c_init()
7957 struct brcms_c_info *wlc; in brcms_c_attach() local
7963 wlc = brcms_c_attach_malloc(unit, &err, 0); in brcms_c_attach()
7964 if (wlc == NULL) in brcms_c_attach()
7966 wlc->wiphy = wl->wiphy; in brcms_c_attach()
7967 pub = wlc->pub; in brcms_c_attach()
7970 wlc_info_dbg = wlc; in brcms_c_attach()
7973 wlc->band = wlc->bandstate[0]; in brcms_c_attach()
7974 wlc->core = wlc->corestate; in brcms_c_attach()
7975 wlc->wl = wl; in brcms_c_attach()
7978 wlc->bandinit_pending = false; in brcms_c_attach()
7979 wlc->beacon_template_virgin = true; in brcms_c_attach()
7982 brcms_c_info_init(wlc, unit); in brcms_c_attach()
7985 brcms_c_ap_upd(wlc); in brcms_c_attach()
7991 err = brcms_b_attach(wlc, core, unit, piomode); in brcms_c_attach()
7995 brcms_c_protection_upd(wlc, BRCMS_PROT_N_PAM_OVR, OFF); in brcms_c_attach()
7997 pub->phy_11ncapable = BRCMS_PHY_11N_CAP(wlc->band); in brcms_c_attach()
8000 wlc->tx_duty_cycle_ofdm = 0; in brcms_c_attach()
8001 wlc->tx_duty_cycle_cck = 0; in brcms_c_attach()
8003 brcms_c_stf_phy_chain_calc(wlc); in brcms_c_attach()
8006 if (BRCMS_ISNPHY(wlc->band) && (wlc->stf->txstreams == 1)) in brcms_c_attach()
8007 wlc->stf->txant = wlc->stf->hw_txchain - 1; in brcms_c_attach()
8010 wlc_phy_stf_chain_init(wlc->band->pi, wlc->stf->hw_txchain, in brcms_c_attach()
8011 wlc->stf->hw_rxchain); in brcms_c_attach()
8015 wlc->core->txavail[i] = wlc->hw->txavail[i]; in brcms_c_attach()
8017 memcpy(&wlc->perm_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
8018 memcpy(&pub->cur_etheraddr, &wlc->hw->etheraddr, ETH_ALEN); in brcms_c_attach()
8020 for (j = 0; j < wlc->pub->_nbands; j++) { in brcms_c_attach()
8021 wlc->band = wlc->bandstate[j]; in brcms_c_attach()
8023 if (!brcms_c_attach_stf_ant_init(wlc)) { in brcms_c_attach()
8029 wlc->band->CWmin = APHY_CWMIN; in brcms_c_attach()
8030 wlc->band->CWmax = PHY_CWMAX; in brcms_c_attach()
8033 if (wlc->band->bandtype == BRCM_BAND_2G) { in brcms_c_attach()
8034 wlc->band->gmode = GMODE_AUTO; in brcms_c_attach()
8035 brcms_c_protection_upd(wlc, BRCMS_PROT_G_USER, in brcms_c_attach()
8036 wlc->band->gmode); in brcms_c_attach()
8040 if (BRCMS_PHY_11N_CAP(wlc->band)) { in brcms_c_attach()
8042 brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, in brcms_c_attach()
8049 brcms_default_rateset(wlc, &wlc->band->defrateset); in brcms_c_attach()
8052 brcms_c_rateset_filter(&wlc->band->defrateset, in brcms_c_attach()
8053 &wlc->band->hw_rateset, false, in brcms_c_attach()
8055 (bool) (wlc->pub->_n_enab & SUPPORT_11N)); in brcms_c_attach()
8062 brcms_c_stf_phy_txant_upd(wlc); in brcms_c_attach()
8065 err = brcms_c_attach_module(wlc); in brcms_c_attach()
8069 if (!brcms_c_timers_init(wlc, unit)) { in brcms_c_attach()
8077 wlc->cmi = brcms_c_channel_mgr_attach(wlc); in brcms_c_attach()
8078 if (!wlc->cmi) { in brcms_c_attach()
8086 brcms_c_bss_default_init(wlc); in brcms_c_attach()
8092 wlc->bsscfg->wlc = wlc; in brcms_c_attach()
8094 wlc->mimoft = FT_HT; in brcms_c_attach()
8095 wlc->mimo_40txbw = AUTO; in brcms_c_attach()
8096 wlc->ofdm_40txbw = AUTO; in brcms_c_attach()
8097 wlc->cck_40txbw = AUTO; in brcms_c_attach()
8098 brcms_c_update_mimo_band_bwcap(wlc, BRCMS_N_BW_20IN2G_40IN5G); in brcms_c_attach()
8101 if (BRCMS_SGI_CAP_PHY(wlc)) { in brcms_c_attach()
8102 brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | in brcms_c_attach()
8104 } else if (BRCMS_ISSSLPNPHY(wlc->band)) { in brcms_c_attach()
8105 brcms_c_ht_update_sgi_rx(wlc, (BRCMS_N_SGI_20 | in brcms_c_attach()
8108 brcms_c_ht_update_sgi_rx(wlc, 0); in brcms_c_attach()
8111 brcms_b_antsel_set(wlc->hw, wlc->asi->antsel_avail); in brcms_c_attach()
8116 return wlc; in brcms_c_attach()
8121 if (wlc) in brcms_c_attach()
8122 brcms_c_detach(wlc); in brcms_c_attach()