Commit 7d9e0b9a authored by Roland Vossen's avatar Roland Vossen Committed by Greg Kroah-Hartman

staging: brcm80211: macro cleanup in softmac main.c

Reported-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Reviewed-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarRoland Vossen <rvossen@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent be6d2b32
...@@ -167,23 +167,21 @@ ...@@ -167,23 +167,21 @@
#define BRCMS_HWRXOFF 38 /* chip rx buffer offset */ #define BRCMS_HWRXOFF 38 /* chip rx buffer offset */
/*
* driver maintains internal 'tick'(wlc->pub->now) which increments in 1s
* OS timer(soft watchdog) it is not a wall clock and won't increment when
* driver is in "down" state this low resolution driver tick can be used
* for maintenance tasks such as phy calibration and scb update
*/
#define BRCMS_WAR16165(wlc) (wlc->war16165)
/* Find basic rate for a given rate */ /* Find basic rate for a given rate */
#define BRCMS_BASIC_RATE(wlc, rspec) \ static u8 brcms_basic_rate(struct brcms_c_info *wlc, u32 rspec)
(IS_MCS(rspec) \ {
? (wlc)->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK].leg_ofdm] \ if (IS_MCS(rspec))
: (wlc)->band->basic_rate[rspec & RSPEC_RATE_MASK]) return wlc->band->basic_rate[mcs_table[rspec & RSPEC_RATE_MASK]
.leg_ofdm];
return wlc->band->basic_rate[rspec & RSPEC_RATE_MASK];
}
#define FRAMETYPE(r, mimoframe) \ static u16 frametype(u32 rspec, u8 mimoframe)
(IS_MCS(r) ? mimoframe : (IS_CCK(r) ? FT_CCK : FT_OFDM)) {
if (IS_MCS(rspec))
return mimoframe;
return IS_CCK(rspec) ? FT_CCK : FT_OFDM;
}
/* rfdisable delay timer 500 ms, runs of ALP clock */ /* rfdisable delay timer 500 ms, runs of ALP clock */
#define RFDISABLE_DEFAULT 10000000 #define RFDISABLE_DEFAULT 10000000
...@@ -240,11 +238,6 @@ ...@@ -240,11 +238,6 @@
#define FRAGNUM_MASK 0xF #define FRAGNUM_MASK 0xF
#define DMAREG(wlc_hw, direction, fifonum) \
((direction == DMA_TX) ? \
&(wlc_hw->regs->fifo64regs[fifonum].dmaxmt) : \
&(wlc_hw->regs->fifo64regs[fifonum].dmarcv))
#define APHY_SLOT_TIME 9 #define APHY_SLOT_TIME 9
#define BPHY_SLOT_TIME 20 #define BPHY_SLOT_TIME 20
...@@ -359,21 +352,11 @@ ...@@ -359,21 +352,11 @@
#define END_FOREACH_BSS() } #define END_FOREACH_BSS() }
/* currently the best mechanism for determining SIFS is the band in use */ /* currently the best mechanism for determining SIFS is the band in use */
#define SIFS(band) ((band)->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME : \ static u16 get_sifs(struct brcms_band *band)
BPHY_SIFS_TIME); {
return band->bandtype == BRCM_BAND_5G ? APHY_SIFS_TIME :
/* A fifo is full. Clear precedences related to that FIFO */ BPHY_SIFS_TIME;
#define BRCMS_TX_FIFO_CLEAR(wlc, fifo) \ }
((wlc)->tx_prec_map &= ~(wlc)->fifo2prec_map[fifo])
/* Fifo is NOT full. Enable precedences for that FIFO */
#define BRCMS_TX_FIFO_ENAB(wlc, fifo) \
((wlc)->tx_prec_map |= (wlc)->fifo2prec_map[fifo])
#define BRCMS_PORTOPEN(cfg) true
#define brcms_b_copyfrom_shm(wlc_hw, offset, buf, len) \
brcms_b_copyfrom_objmem(wlc_hw, offset, buf, len, OBJADDR_SHM_SEL)
/* /*
* Detect Card removed. * Detect Card removed.
...@@ -384,45 +367,35 @@ ...@@ -384,45 +367,35 @@
* If clocks are present, call the sb routine which will figure out if the * If clocks are present, call the sb routine which will figure out if the
* device is removed. * device is removed.
*/ */
#define DEVICEREMOVED(wlc) \ static bool brcms_deviceremoved(struct brcms_c_info *wlc)
((wlc->hw->clk) ? \ {
((R_REG(&wlc->hw->regs->maccontrol) & \ if (!wlc->hw->clk)
(MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN) : \ return ai_deviceremoved(wlc->hw->sih);
(ai_deviceremoved(wlc->hw->sih))) return (R_REG(&wlc->hw->regs->maccontrol) &
(MCTL_PSM_JMP_0 | MCTL_IHR_EN)) != MCTL_IHR_EN;
#define BRCMS_WME_RETRY_SHORT_GET(wlc, ac) \ }
GFIELD(wlc->wme_retries[ac], EDCF_SHORT)
#define BRCMS_WME_RETRY_SFB_GET(wlc, ac) \
GFIELD(wlc->wme_retries[ac], EDCF_SFB)
#define BRCMS_WME_RETRY_LONG_GET(wlc, ac) \
GFIELD(wlc->wme_retries[ac], EDCF_LONG)
#define BRCMS_WME_RETRY_LFB_GET(wlc, ac) \
GFIELD(wlc->wme_retries[ac], EDCF_LFB)
#define BRCMS_WME_RETRY_SHORT_SET(wlc, ac, val) \
(wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SHORT, val))
#define BRCMS_WME_RETRY_SFB_SET(wlc, ac, val) \
(wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_SFB, val))
#define BRCMS_WME_RETRY_LONG_SET(wlc, ac, val) \
(wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LONG, val))
#define BRCMS_WME_RETRY_LFB_SET(wlc, ac, val) \
(wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac], EDCF_LFB, val))
/* sum the individual fifo tx pending packet counts */ /* sum the individual fifo tx pending packet counts */
#define TXPKTPENDTOT(wlc) \ static s16 brcms_txpktpendtot(struct brcms_c_info *wlc)
((wlc)->core->txpktpend[0] + (wlc)->core->txpktpend[1] + \ {
(wlc)->core->txpktpend[2] + (wlc)->core->txpktpend[3]) return wlc->core->txpktpend[0] + wlc->core->txpktpend[1] +
#define TXPKTPENDGET(wlc, fifo) ((wlc)->core->txpktpend[(fifo)]) wlc->core->txpktpend[2] + wlc->core->txpktpend[3];
#define TXPKTPENDINC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] += (val)) }
#define TXPKTPENDDEC(wlc, fifo, val) ((wlc)->core->txpktpend[(fifo)] -= (val))
#define TXPKTPENDCLR(wlc, fifo) ((wlc)->core->txpktpend[(fifo)] = 0) static bool brcms_is_mband_unlocked(struct brcms_c_info *wlc)
{
return wlc->pub->_nbands > 1 && !wlc->bandlocked;
}
#define IS_MBAND_UNLOCKED(wlc) \ static int brcms_chspec_bw(u16 chanspec)
((wlc->pub->_nbands > 1) && !(wlc)->bandlocked) {
if (CHSPEC_IS40(chanspec))
return BRCMS_40_MHZ;
if (CHSPEC_IS20(chanspec))
return BRCMS_20_MHZ;
#define CHSPEC_WLC_BW(chanspec) (CHSPEC_IS40(chanspec) ? BRCMS_40_MHZ : \ return BRCMS_10_MHZ;
CHSPEC_IS20(chanspec) ? BRCMS_20_MHZ : \ }
BRCMS_10_MHZ)
/* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info) /* dup state between BMAC(struct brcms_hardware) and HIGH(struct brcms_c_info)
driver */ driver */
...@@ -973,7 +946,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded) ...@@ -973,7 +946,7 @@ bool brcms_c_dpc(struct brcms_c_info *wlc, bool bounded)
bool fatal = false; bool fatal = false;
struct wiphy *wiphy = wlc->wiphy; struct wiphy *wiphy = wlc->wiphy;
if (DEVICEREMOVED(wlc)) { if (brcms_deviceremoved(wlc)) {
wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit, wiphy_err(wiphy, "wl%d: %s: dead chip\n", wlc_hw->unit,
__func__); __func__);
brcms_down(wlc->wl); brcms_down(wlc->wl);
...@@ -1086,6 +1059,14 @@ brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init) ...@@ -1086,6 +1059,14 @@ brcms_c_mhfdef(struct brcms_c_info *wlc, u16 *mhfs, u16 mhf2_init)
} }
} }
static struct dma64regs *
dmareg(struct brcms_hardware *hw, uint direction, uint fifonum)
{
if (direction == DMA_TX)
return &(hw->regs->fifo64regs[fifonum].dmaxmt);
return &(hw->regs->fifo64regs[fifonum].dmarcv);
}
static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
{ {
uint i; uint i;
...@@ -1110,8 +1091,8 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) ...@@ -1110,8 +1091,8 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
* RX: RX_FIFO (RX data packets) * RX: RX_FIFO (RX data packets)
*/ */
wlc_hw->di[0] = dma_attach(name, wlc_hw->sih, wlc_hw->di[0] = dma_attach(name, wlc_hw->sih,
(wme ? DMAREG(wlc_hw, DMA_TX, 0) : (wme ? dmareg(wlc_hw, DMA_TX, 0) :
NULL), DMAREG(wlc_hw, DMA_RX, 0), NULL), dmareg(wlc_hw, DMA_RX, 0),
(wme ? NTXD : 0), NRXD, (wme ? NTXD : 0), NRXD,
RXBUFSZ, -1, NRXBUFPOST, RXBUFSZ, -1, NRXBUFPOST,
BRCMS_HWRXOFF, &brcm_msg_level); BRCMS_HWRXOFF, &brcm_msg_level);
...@@ -1124,7 +1105,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) ...@@ -1124,7 +1105,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
* RX: UNUSED * RX: UNUSED
*/ */
wlc_hw->di[1] = dma_attach(name, wlc_hw->sih, wlc_hw->di[1] = dma_attach(name, wlc_hw->sih,
DMAREG(wlc_hw, DMA_TX, 1), NULL, dmareg(wlc_hw, DMA_TX, 1), NULL,
NTXD, 0, 0, -1, 0, 0, NTXD, 0, 0, -1, 0, 0,
&brcm_msg_level); &brcm_msg_level);
dma_attach_err |= (NULL == wlc_hw->di[1]); dma_attach_err |= (NULL == wlc_hw->di[1]);
...@@ -1135,7 +1116,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) ...@@ -1135,7 +1116,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
* RX: UNUSED * RX: UNUSED
*/ */
wlc_hw->di[2] = dma_attach(name, wlc_hw->sih, wlc_hw->di[2] = dma_attach(name, wlc_hw->sih,
DMAREG(wlc_hw, DMA_TX, 2), NULL, dmareg(wlc_hw, DMA_TX, 2), NULL,
NTXD, 0, 0, -1, 0, 0, NTXD, 0, 0, -1, 0, 0,
&brcm_msg_level); &brcm_msg_level);
dma_attach_err |= (NULL == wlc_hw->di[2]); dma_attach_err |= (NULL == wlc_hw->di[2]);
...@@ -1145,7 +1126,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme) ...@@ -1145,7 +1126,7 @@ static bool brcms_b_attach_dmapio(struct brcms_c_info *wlc, uint j, bool wme)
* (legacy) TX_CTL_FIFO (TX control & mgmt packets) * (legacy) TX_CTL_FIFO (TX control & mgmt packets)
*/ */
wlc_hw->di[3] = dma_attach(name, wlc_hw->sih, wlc_hw->di[3] = dma_attach(name, wlc_hw->sih,
DMAREG(wlc_hw, DMA_TX, 3), dmareg(wlc_hw, DMA_TX, 3),
NULL, NTXD, 0, 0, -1, NULL, NTXD, 0, 0, -1,
0, 0, &brcm_msg_level); 0, 0, &brcm_msg_level);
dma_attach_err |= (NULL == wlc_hw->di[3]); dma_attach_err |= (NULL == wlc_hw->di[3]);
...@@ -2567,7 +2548,7 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags) ...@@ -2567,7 +2548,7 @@ static void brcms_b_mute(struct brcms_hardware *wlc_hw, bool on, u32 flags)
* Read and clear macintmask and macintstatus and intstatus registers. * Read and clear macintmask and macintstatus and intstatus registers.
* This routine should be called with interrupts off * This routine should be called with interrupts off
* Return: * Return:
* -1 if DEVICEREMOVED(wlc) evaluates to true; * -1 if brcms_deviceremoved(wlc) evaluates to true;
* 0 if the interrupt is not for us, or we are in some special cases; * 0 if the interrupt is not for us, or we are in some special cases;
* device interrupt status bits otherwise. * device interrupt status bits otherwise.
*/ */
...@@ -2584,10 +2565,10 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr) ...@@ -2584,10 +2565,10 @@ static inline u32 wlc_intstatus(struct brcms_c_info *wlc, bool in_isr)
macintstatus); macintstatus);
/* detect cardbus removed, in power down(suspend) and in reset */ /* detect cardbus removed, in power down(suspend) and in reset */
if (DEVICEREMOVED(wlc)) if (brcms_deviceremoved(wlc))
return -1; return -1;
/* DEVICEREMOVED succeeds even when the core is still resetting, /* brcms_deviceremoved() succeeds even when the core is still resetting,
* handle that case here. * handle that case here.
*/ */
if (macintstatus == 0xffffffff) if (macintstatus == 0xffffffff)
...@@ -2916,7 +2897,7 @@ void brcms_c_coredisable(struct brcms_hardware *wlc_hw) ...@@ -2916,7 +2897,7 @@ void brcms_c_coredisable(struct brcms_hardware *wlc_hw)
BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
dev_gone = DEVICEREMOVED(wlc_hw->wlc); dev_gone = brcms_deviceremoved(wlc_hw->wlc);
if (dev_gone) if (dev_gone)
return; return;
...@@ -2949,7 +2930,7 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc) ...@@ -2949,7 +2930,7 @@ static void brcms_c_flushqueues(struct brcms_c_info *wlc)
for (i = 0; i < NFIFO; i++) for (i = 0; i < NFIFO; i++)
if (wlc_hw->di[i]) { if (wlc_hw->di[i]) {
dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL); dma_txreclaim(wlc_hw->di[i], DMA_RANGE_ALL);
TXPKTPENDCLR(wlc, i); wlc->core->txpktpend[i] = 0;
BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i); BCMMSG(wlc->wiphy, "pktpend fifo %d clrd\n", i);
} }
...@@ -3131,7 +3112,7 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc) ...@@ -3131,7 +3112,7 @@ bool brcms_c_ps_allowed(struct brcms_c_info *wlc)
* disallow PS when one of the following * disallow PS when one of the following
* bsscfg specific conditions meets * bsscfg specific conditions meets
*/ */
if (!cfg->BSS || !BRCMS_PORTOPEN(cfg)) if (!cfg->BSS)
return false; return false;
if (!cfg->dtim_programmed) if (!cfg->dtim_programmed)
...@@ -3147,7 +3128,7 @@ static void brcms_b_reset(struct brcms_hardware *wlc_hw) ...@@ -3147,7 +3128,7 @@ static void brcms_b_reset(struct brcms_hardware *wlc_hw)
BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit); BCMMSG(wlc_hw->wlc->wiphy, "wl%d\n", wlc_hw->unit);
/* reset the core */ /* reset the core */
if (!DEVICEREMOVED(wlc_hw->wlc)) if (!brcms_deviceremoved(wlc_hw->wlc))
brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS); brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
/* purge the dma rings */ /* purge the dma rings */
...@@ -3724,7 +3705,7 @@ void brcms_c_init(struct brcms_c_info *wlc) ...@@ -3724,7 +3705,7 @@ void brcms_c_init(struct brcms_c_info *wlc)
* Initialize WME parameters; if they haven't been set by some other * Initialize WME parameters; if they haven't been set by some other
* mechanism (IOVar, etc) then read them from the hardware. * mechanism (IOVar, etc) then read them from the hardware.
*/ */
if (BRCMS_WME_RETRY_SHORT_GET(wlc, 0) == 0) { if (GFIELD(wlc->wme_retries[0], EDCF_SHORT) == 0) {
/* Uninitialized; read from HW */ /* Uninitialized; read from HW */
int ac; int ac;
...@@ -3987,16 +3968,14 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec) ...@@ -3987,16 +3968,14 @@ void brcms_c_set_chanspec(struct brcms_c_info *wlc, u16 chanspec)
brcms_c_set_phy_chanspec(wlc, chanspec); brcms_c_set_phy_chanspec(wlc, chanspec);
/* init antenna selection */ /* init antenna selection */
if (CHSPEC_WLC_BW(old_chanspec) != CHSPEC_WLC_BW(chanspec)) { if (brcms_chspec_bw(old_chanspec) != brcms_chspec_bw(chanspec)) {
brcms_c_antsel_init(wlc->asi); brcms_c_antsel_init(wlc->asi);
/* Fix the hardware rateset based on bw. /* Fix the hardware rateset based on bw.
* Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz * Mainly add MCS32 for 40Mhz, remove MCS 32 for 20Mhz
*/ */
brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset, brcms_c_rateset_bw_mcs_filter(&wlc->band->hw_rateset,
wlc->band-> wlc->band->mimo_cap_40 ? brcms_chspec_bw(chanspec) : 0);
mimo_cap_40 ? CHSPEC_WLC_BW(chanspec)
: 0);
} }
/* update some mac configuration since chanspec changed */ /* update some mac configuration since chanspec changed */
...@@ -4278,7 +4257,7 @@ static void brcms_c_radio_enable(struct brcms_c_info *wlc) ...@@ -4278,7 +4257,7 @@ static void brcms_c_radio_enable(struct brcms_c_info *wlc)
if (wlc->pub->up) if (wlc->pub->up)
return; return;
if (DEVICEREMOVED(wlc)) if (brcms_deviceremoved(wlc))
return; return;
brcms_up(wlc->wl); brcms_up(wlc->wl);
...@@ -4332,7 +4311,7 @@ static void brcms_c_radio_timer(void *arg) ...@@ -4332,7 +4311,7 @@ static void brcms_c_radio_timer(void *arg)
{ {
struct brcms_c_info *wlc = (struct brcms_c_info *) arg; struct brcms_c_info *wlc = (struct brcms_c_info *) arg;
if (DEVICEREMOVED(wlc)) { if (brcms_deviceremoved(wlc)) {
wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
__func__); __func__);
brcms_down(wlc->wl); brcms_down(wlc->wl);
...@@ -4380,7 +4359,7 @@ static void brcms_c_watchdog(void *arg) ...@@ -4380,7 +4359,7 @@ static void brcms_c_watchdog(void *arg)
if (!wlc->pub->up) if (!wlc->pub->up)
return; return;
if (DEVICEREMOVED(wlc)) { if (brcms_deviceremoved(wlc)) {
wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit, wiphy_err(wlc->wiphy, "wl%d: %s: dead chip\n", wlc->pub->unit,
__func__); __func__);
brcms_down(wlc->wl); brcms_down(wlc->wl);
...@@ -4564,8 +4543,6 @@ struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc) ...@@ -4564,8 +4543,6 @@ struct brcms_pub *brcms_c_pub(struct brcms_c_info *wlc)
return wlc->pub; return wlc->pub;
} }
#define CHIP_SUPPORTS_11N(wlc) 1
/* low level attach /* low level attach
* run backplane attach, init nvram * run backplane attach, init nvram
* run phy attach * run phy attach
...@@ -5011,7 +4988,7 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc) ...@@ -5011,7 +4988,7 @@ static void brcms_c_bss_default_init(struct brcms_c_info *wlc)
brcms_c_rateset_default(&bi->rateset, NULL, band->phytype, brcms_c_rateset_default(&bi->rateset, NULL, band->phytype,
band->bandtype, false, BRCMS_RATE_MASK_FULL, band->bandtype, false, BRCMS_RATE_MASK_FULL,
(bool) (wlc->pub->_n_enab & SUPPORT_11N), (bool) (wlc->pub->_n_enab & SUPPORT_11N),
CHSPEC_WLC_BW(chanspec), wlc->stf->txstreams); brcms_chspec_bw(chanspec), wlc->stf->txstreams);
if (wlc->pub->_n_enab & SUPPORT_11N) if (wlc->pub->_n_enab & SUPPORT_11N)
bi->flags |= BRCMS_BSS_HT; bi->flags |= BRCMS_BSS_HT;
...@@ -5202,7 +5179,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit, ...@@ -5202,7 +5179,7 @@ brcms_c_attach(struct brcms_info *wl, u16 vendor, u16 device, uint unit,
} }
/* init _n_enab supported mode */ /* init _n_enab supported mode */
if (BRCMS_PHY_11N_CAP(wlc->band) && CHIP_SUPPORTS_11N(wlc)) { if (BRCMS_PHY_11N_CAP(wlc->band)) {
if (n_disabled & WLFEATURE_DISABLE_11N) { if (n_disabled & WLFEATURE_DISABLE_11N) {
pub->_n_enab = OFF; pub->_n_enab = OFF;
brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER, brcms_c_protection_upd(wlc, BRCMS_PROT_N_USER,
...@@ -5649,7 +5626,7 @@ int brcms_c_up(struct brcms_c_info *wlc) ...@@ -5649,7 +5626,7 @@ int brcms_c_up(struct brcms_c_info *wlc)
BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit); BCMMSG(wlc->wiphy, "wl%d\n", wlc->pub->unit);
/* HW is turned off so don't try to access it */ /* HW is turned off so don't try to access it */
if (wlc->pub->hw_off || DEVICEREMOVED(wlc)) if (wlc->pub->hw_off || brcms_deviceremoved(wlc))
return -ENOMEDIUM; return -ENOMEDIUM;
if (!wlc->pub->hw_up) { if (!wlc->pub->hw_up) {
...@@ -5712,7 +5689,7 @@ int brcms_c_up(struct brcms_c_info *wlc) ...@@ -5712,7 +5689,7 @@ int brcms_c_up(struct brcms_c_info *wlc)
/* Set EDCF hostflags */ /* Set EDCF hostflags */
brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL); brcms_c_mhf(wlc, MHF1, MHF1_EDCF, MHF1_EDCF, BRCM_BAND_ALL);
if (BRCMS_WAR16165(wlc)) if (wlc->war16165)
brcms_c_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR, brcms_c_mhf(wlc, MHF2, MHF2_PCISLOWCLKWAR, MHF2_PCISLOWCLKWAR,
BRCM_BAND_ALL); BRCM_BAND_ALL);
...@@ -5760,7 +5737,7 @@ static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw) ...@@ -5760,7 +5737,7 @@ static int brcms_b_bmac_down_prep(struct brcms_hardware *wlc_hw)
if (!wlc_hw->up) if (!wlc_hw->up)
return callbacks; return callbacks;
dev_gone = DEVICEREMOVED(wlc_hw->wlc); dev_gone = brcms_deviceremoved(wlc_hw->wlc);
/* disable interrupts */ /* disable interrupts */
if (dev_gone) if (dev_gone)
...@@ -5791,7 +5768,7 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw) ...@@ -5791,7 +5768,7 @@ static int brcms_b_down_finish(struct brcms_hardware *wlc_hw)
wlc_hw->up = false; wlc_hw->up = false;
wlc_phy_hw_state_upd(wlc_hw->band->pi, false); wlc_phy_hw_state_upd(wlc_hw->band->pi, false);
dev_gone = DEVICEREMOVED(wlc_hw->wlc); dev_gone = brcms_deviceremoved(wlc_hw->wlc);
if (dev_gone) { if (dev_gone) {
wlc_hw->sbclk = false; wlc_hw->sbclk = false;
...@@ -5850,7 +5827,7 @@ uint brcms_c_down(struct brcms_c_info *wlc) ...@@ -5850,7 +5827,7 @@ uint brcms_c_down(struct brcms_c_info *wlc)
callbacks += brcms_b_bmac_down_prep(wlc->hw); callbacks += brcms_b_bmac_down_prep(wlc->hw);
dev_gone = DEVICEREMOVED(wlc); dev_gone = brcms_deviceremoved(wlc);
/* Call any registered down handlers */ /* Call any registered down handlers */
for (i = 0; i < BRCMS_MAXMODULES; i++) { for (i = 0; i < BRCMS_MAXMODULES; i++) {
...@@ -6099,7 +6076,7 @@ brcms_c_set_internal_rateset(struct brcms_c_info *wlc, ...@@ -6099,7 +6076,7 @@ brcms_c_set_internal_rateset(struct brcms_c_info *wlc,
goto good; goto good;
/* try the other band */ /* try the other band */
if (IS_MBAND_UNLOCKED(wlc)) { if (brcms_is_mband_unlocked(wlc)) {
bandunit = OTHERBANDUNIT(wlc); bandunit = OTHERBANDUNIT(wlc);
memcpy(&new, &rs, sizeof(struct brcms_c_rateset)); memcpy(&new, &rs, sizeof(struct brcms_c_rateset));
if (brcms_c_rate_hwrs_filter_sort_validate(&new, if (brcms_c_rate_hwrs_filter_sort_validate(&new,
...@@ -6147,7 +6124,7 @@ int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel) ...@@ -6147,7 +6124,7 @@ int brcms_c_set_channel(struct brcms_c_info *wlc, u16 channel)
return -EINVAL; return -EINVAL;
if (!wlc->pub->up && IS_MBAND_UNLOCKED(wlc)) { if (!wlc->pub->up && brcms_is_mband_unlocked(wlc)) {
if (wlc->band->bandunit != chspec_bandunit(chspec)) if (wlc->band->bandunit != chspec_bandunit(chspec))
wlc->bandinit_pending = true; wlc->bandinit_pending = true;
else else
...@@ -6180,8 +6157,10 @@ int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl) ...@@ -6180,8 +6157,10 @@ int brcms_c_set_rate_limit(struct brcms_c_info *wlc, u16 srl, u16 lrl)
brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL); brcms_b_retrylimit_upd(wlc->hw, wlc->SRL, wlc->LRL);
for (ac = 0; ac < AC_COUNT; ac++) { for (ac = 0; ac < AC_COUNT; ac++) {
BRCMS_WME_RETRY_SHORT_SET(wlc, ac, srl); wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac],
BRCMS_WME_RETRY_LONG_SET(wlc, ac, lrl); EDCF_SHORT, wlc->SRL);
wlc->wme_retries[ac] = SFIELD(wlc->wme_retries[ac],
EDCF_LONG, wlc->LRL);
} }
brcms_c_wme_retries_write(wlc); brcms_c_wme_retries_write(wlc);
...@@ -6400,8 +6379,8 @@ void brcms_c_statsupd(struct brcms_c_info *wlc) ...@@ -6400,8 +6379,8 @@ void brcms_c_statsupd(struct brcms_c_info *wlc)
#endif /* BCMDBG */ #endif /* BCMDBG */
/* Read mac stats from contiguous shared memory */ /* Read mac stats from contiguous shared memory */
brcms_b_copyfrom_shm(wlc->hw, M_UCODE_MACSTAT, brcms_b_copyfrom_objmem(wlc->hw, M_UCODE_MACSTAT, &macstats,
&macstats, sizeof(struct macstat)); sizeof(struct macstat), OBJADDR_SHM_SEL);
#ifdef BCMDBG #ifdef BCMDBG
/* check for rx fifo 0 overflow */ /* check for rx fifo 0 overflow */
...@@ -6719,7 +6698,7 @@ brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec, ...@@ -6719,7 +6698,7 @@ brcms_c_calc_ack_time(struct brcms_c_info *wlc, u32 rspec,
* is less than or equal to the rate of the immediately previous * is less than or equal to the rate of the immediately previous
* frame in the FES * frame in the FES
*/ */
rspec = BRCMS_BASIC_RATE(wlc, rspec); rspec = brcms_basic_rate(wlc, rspec);
/* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */ /* ACK frame len == 14 == 2(fc) + 2(dur) + 6(ra) + 4(fcs) */
dur = dur =
brcms_c_calc_frame_time(wlc, rspec, preamble_type, brcms_c_calc_frame_time(wlc, rspec, preamble_type,
...@@ -6747,7 +6726,7 @@ brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec, ...@@ -6747,7 +6726,7 @@ brcms_c_calc_ba_time(struct brcms_c_info *wlc, u32 rspec,
* is less than or equal to the rate of the immediately previous * is less than or equal to the rate of the immediately previous
* frame in the FES * frame in the FES
*/ */
rspec = BRCMS_BASIC_RATE(wlc, rspec); rspec = brcms_basic_rate(wlc, rspec);
/* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */ /* BA len == 32 == 16(ctl hdr) + 4(ba len) + 8(bitmap) + 4(fcs) */
return brcms_c_calc_frame_time(wlc, rspec, preamble_type, return brcms_c_calc_frame_time(wlc, rspec, preamble_type,
(DOT11_BA_LEN + DOT11_BA_BITMAP_LEN + (DOT11_BA_LEN + DOT11_BA_BITMAP_LEN +
...@@ -6770,7 +6749,7 @@ brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate, ...@@ -6770,7 +6749,7 @@ brcms_c_compute_frame_dur(struct brcms_c_info *wlc, u32 rate,
{ {
u16 dur, sifs; u16 dur, sifs;
sifs = SIFS(wlc->band); sifs = get_sifs(wlc->band);
dur = sifs; dur = sifs;
dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type); dur += (u16) brcms_c_calc_ack_time(wlc, rate, preamble_type);
...@@ -7140,7 +7119,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, ...@@ -7140,7 +7119,7 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
* Is the phy configured to use 40MHZ frames? If * Is the phy configured to use 40MHZ frames? If
* so then pick the desired txbw * so then pick the desired txbw
*/ */
if (CHSPEC_WLC_BW(wlc->chanspec) == BRCMS_40_MHZ) { if (brcms_chspec_bw(wlc->chanspec) == BRCMS_40_MHZ) {
/* default txbw is 20in40 SB */ /* default txbw is 20in40 SB */
mimo_ctlchbw = mimo_txbw = mimo_ctlchbw = mimo_txbw =
CHSPEC_SB_UPPER(wlc_phy_chanspec_get( CHSPEC_SB_UPPER(wlc_phy_chanspec_get(
...@@ -7458,15 +7437,15 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw, ...@@ -7458,15 +7437,15 @@ brcms_c_d11hdrs_mac80211(struct brcms_c_info *wlc, struct ieee80211_hw *hw,
txh->MainRates = cpu_to_le16(mainrates); txh->MainRates = cpu_to_le16(mainrates);
/* XtraFrameTypes */ /* XtraFrameTypes */
xfts = FRAMETYPE(rspec[1], wlc->mimoft); xfts = frametype(rspec[1], wlc->mimoft);
xfts |= (FRAMETYPE(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT); xfts |= (frametype(rts_rspec[0], wlc->mimoft) << XFTS_RTS_FT_SHIFT);
xfts |= (FRAMETYPE(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT); xfts |= (frametype(rts_rspec[1], wlc->mimoft) << XFTS_FBRRTS_FT_SHIFT);
xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) << xfts |= CHSPEC_CHANNEL(wlc_phy_chanspec_get(wlc->band->pi)) <<
XFTS_CHANNEL_SHIFT; XFTS_CHANNEL_SHIFT;
txh->XtraFrameTypes = cpu_to_le16(xfts); txh->XtraFrameTypes = cpu_to_le16(xfts);
/* PhyTxControlWord */ /* PhyTxControlWord */
phyctl = FRAMETYPE(rspec[0], wlc->mimoft); phyctl = frametype(rspec[0], wlc->mimoft);
if ((preamble_type[0] == BRCMS_SHORT_PREAMBLE) || if ((preamble_type[0] == BRCMS_SHORT_PREAMBLE) ||
(preamble_type[0] == BRCMS_GF_PREAMBLE)) { (preamble_type[0] == BRCMS_GF_PREAMBLE)) {
if (RSPEC2RATE(rspec[0]) != BRCM_RATE_1M) if (RSPEC2RATE(rspec[0]) != BRCM_RATE_1M)
...@@ -7707,7 +7686,7 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, ...@@ -7707,7 +7686,7 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p,
if (fifo == TX_BCMC_FIFO) if (fifo == TX_BCMC_FIFO)
frameid = le16_to_cpu(txh->TxFrameID); frameid = le16_to_cpu(txh->TxFrameID);
if (BRCMS_WAR16165(wlc)) if (wlc->war16165)
brcms_c_war16165(wlc, true); brcms_c_war16165(wlc, true);
...@@ -7716,9 +7695,9 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p, ...@@ -7716,9 +7695,9 @@ brcms_c_txfifo(struct brcms_c_info *wlc, uint fifo, struct sk_buff *p,
* used, this will be handled in brcms_b_txfifo() * used, this will be handled in brcms_b_txfifo()
*/ */
if (commit) { if (commit) {
TXPKTPENDINC(wlc, fifo, txpktpend); wlc->core->txpktpend[fifo] += txpktpend;
BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n", BCMMSG(wlc->wiphy, "pktpend inc %d to %d\n",
txpktpend, TXPKTPENDGET(wlc, fifo)); txpktpend, wlc->core->txpktpend[fifo]);
} }
/* Commit BCMC sequence number in the SHM frame ID location */ /* Commit BCMC sequence number in the SHM frame ID location */
...@@ -7867,7 +7846,7 @@ brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only, ...@@ -7867,7 +7846,7 @@ brcms_c_compute_rtscts_dur(struct brcms_c_info *wlc, bool cts_only,
{ {
u16 dur, sifs; u16 dur, sifs;
sifs = SIFS(wlc->band); sifs = get_sifs(wlc->band);
if (!cts_only) { if (!cts_only) {
/* RTS/CTS */ /* RTS/CTS */
...@@ -7955,19 +7934,19 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec, ...@@ -7955,19 +7934,19 @@ brcms_c_rspec_to_rts_rspec(struct brcms_c_info *wlc, u32 rspec,
rts_rspec = rspec; rts_rspec = rspec;
else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec)) else if (wlc->band->gmode && wlc->protection->_g && !IS_CCK(rspec))
/* Use 11Mbps as the g protection RTS target rate and fallback. /* Use 11Mbps as the g protection RTS target rate and fallback.
* Use the BRCMS_BASIC_RATE() lookup to find the best basic rate * Use the brcms_basic_rate() lookup to find the best basic rate
* under the target in case 11 Mbps is not Basic. * under the target in case 11 Mbps is not Basic.
* 6 and 9 Mbps are not usually selected by rate selection, but * 6 and 9 Mbps are not usually selected by rate selection, but
* even if the OFDM rate we are protecting is 6 or 9 Mbps, 11 * even if the OFDM rate we are protecting is 6 or 9 Mbps, 11
* is more robust. * is more robust.
*/ */
rts_rspec = BRCMS_BASIC_RATE(wlc, BRCM_RATE_11M); rts_rspec = brcms_basic_rate(wlc, BRCM_RATE_11M);
else else
/* calculate RTS rate and fallback rate based on the frame rate /* calculate RTS rate and fallback rate based on the frame rate
* RTS must be sent at a basic rate since it is a * RTS must be sent at a basic rate since it is a
* control frame, sec 9.6 of 802.11 spec * control frame, sec 9.6 of 802.11 spec
*/ */
rts_rspec = BRCMS_BASIC_RATE(wlc, rspec); rts_rspec = brcms_basic_rate(wlc, rspec);
if (BRCMS_PHY_11N_CAP(wlc->band)) { if (BRCMS_PHY_11N_CAP(wlc->band)) {
/* set rts txbw to correct side band */ /* set rts txbw to correct side band */
...@@ -8043,7 +8022,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) ...@@ -8043,7 +8022,7 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2)
} }
p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED); p = dma_getnexttxp(wlc->hw->di[queue], DMA_RANGE_TRANSMITTED);
if (BRCMS_WAR16165(wlc)) if (wlc->war16165)
brcms_c_war16165(wlc, false); brcms_c_war16165(wlc, false);
if (p == NULL) if (p == NULL)
goto fatal; goto fatal;
...@@ -8103,8 +8082,10 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) ...@@ -8103,8 +8082,10 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2)
fbl; fbl;
if (queue < AC_COUNT) { if (queue < AC_COUNT) {
sfbl = BRCMS_WME_RETRY_SFB_GET(wlc, wme_fifo2ac[queue]); sfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]],
lfbl = BRCMS_WME_RETRY_LFB_GET(wlc, wme_fifo2ac[queue]); EDCF_SFB);
lfbl = GFIELD(wlc->wme_retries[wme_fifo2ac[queue]],
EDCF_LFB);
} else { } else {
sfbl = wlc->SFBL; sfbl = wlc->SFBL;
lfbl = wlc->LFBL; lfbl = wlc->LFBL;
...@@ -8179,12 +8160,12 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2) ...@@ -8179,12 +8160,12 @@ brcms_c_dotxstatus(struct brcms_c_info *wlc, struct tx_status *txs, u32 frm_tx2)
void void
brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend) brcms_c_txfifo_complete(struct brcms_c_info *wlc, uint fifo, s8 txpktpend)
{ {
TXPKTPENDDEC(wlc, fifo, txpktpend); wlc->core->txpktpend[fifo] -= txpktpend;
BCMMSG(wlc->wiphy, "pktpend dec %d to %d\n", txpktpend, BCMMSG(wlc->wiphy, "pktpend dec %d to %d\n", txpktpend,
TXPKTPENDGET(wlc, fifo)); wlc->core->txpktpend[fifo]);
/* There is more room; mark precedences related to this FIFO sendable */ /* There is more room; mark precedences related to this FIFO sendable */
BRCMS_TX_FIFO_ENAB(wlc, fifo); wlc->tx_prec_map |= wlc->fifo2prec_map[fifo];
/* figure out which bsscfg is being worked on... */ /* figure out which bsscfg is being worked on... */
} }
...@@ -8774,10 +8755,10 @@ void brcms_c_set_ratetable(struct brcms_c_info *wlc) ...@@ -8774,10 +8755,10 @@ void brcms_c_set_ratetable(struct brcms_c_info *wlc)
for (i = 0; i < rs.count; i++) { for (i = 0; i < rs.count; i++) {
rate = rs.rates[i] & BRCMS_RATE_MASK; rate = rs.rates[i] & BRCMS_RATE_MASK;
/* for a given rate BRCMS_BASIC_RATE returns the rate at /* for a given rate brcms_basic_rate returns the rate at
* which a response ACK/CTS should be sent. * which a response ACK/CTS should be sent.
*/ */
basic_rate = BRCMS_BASIC_RATE(wlc, rate); basic_rate = brcms_basic_rate(wlc, rate);
if (basic_rate == 0) if (basic_rate == 0)
/* This should only happen if we are using a /* This should only happen if we are using a
* restricted rateset. * restricted rateset.
...@@ -8835,7 +8816,7 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len) ...@@ -8835,7 +8816,7 @@ void brcms_c_mod_prb_rsp_rate_table(struct brcms_c_info *wlc, uint frame_len)
u16 dur, sifs; u16 dur, sifs;
uint i; uint i;
sifs = SIFS(wlc->band); sifs = get_sifs(wlc->band);
rs_dflt = brcms_c_rateset_get_hwrs(wlc); rs_dflt = brcms_c_rateset_get_hwrs(wlc);
...@@ -9124,7 +9105,8 @@ int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop) ...@@ -9124,7 +9105,8 @@ int brcms_c_prep_pdu(struct brcms_c_info *wlc, struct sk_buff *pdu, uint *fifop)
/* return if insufficient dma resources */ /* return if insufficient dma resources */
if (*wlc->core->txavail[fifo] < MAX_DMA_SEGS) { if (*wlc->core->txavail[fifo] < MAX_DMA_SEGS) {
/* Mark precedences related to this FIFO, unsendable */ /* Mark precedences related to this FIFO, unsendable */
BRCMS_TX_FIFO_CLEAR(wlc, fifo); /* A fifo is full. Clear precedences related to that FIFO */
wlc->tx_prec_map &= ~(wlc->fifo2prec_map[fifo]);
return -EBUSY; return -EBUSY;
} }
return 0; return 0;
...@@ -9153,7 +9135,7 @@ void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs) ...@@ -9153,7 +9135,7 @@ void brcms_default_rateset(struct brcms_c_info *wlc, struct brcms_c_rateset *rs)
brcms_c_rateset_default(rs, NULL, wlc->band->phytype, brcms_c_rateset_default(rs, NULL, wlc->band->phytype,
wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL, wlc->band->bandtype, false, BRCMS_RATE_MASK_FULL,
(bool) (wlc->pub->_n_enab & SUPPORT_11N), (bool) (wlc->pub->_n_enab & SUPPORT_11N),
CHSPEC_WLC_BW(wlc->default_bss->chanspec), brcms_chspec_bw(wlc->default_bss->chanspec),
wlc->stf->txstreams); wlc->stf->txstreams);
} }
...@@ -9389,8 +9371,7 @@ void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop) ...@@ -9389,8 +9371,7 @@ void brcms_c_wait_for_tx_completion(struct brcms_c_info *wlc, bool drop)
brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL); brcmu_pktq_flush(&wlc->pkt_queue->q, false, NULL, NULL);
/* wait for queue and DMA fifos to run dry */ /* wait for queue and DMA fifos to run dry */
while (!pktq_empty(&wlc->pkt_queue->q) || while (!pktq_empty(&wlc->pkt_queue->q) || brcms_txpktpendtot(wlc) > 0)
TXPKTPENDTOT(wlc) > 0)
brcms_msleep(wlc->wl, 1); brcms_msleep(wlc->wl, 1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment