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

staging: brcm80211: macro cleanup in softmac rate.h

Substituted/moved/deleted macro's.
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 2fc6af5b
...@@ -158,16 +158,16 @@ static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur) ...@@ -158,16 +158,16 @@ static void brcms_c_scb_ampdu_update_max_txlen(struct ampdu_info *ampdu, u8 dur)
for (mcs = 0; mcs < MCS_TABLE_SIZE; mcs++) { for (mcs = 0; mcs < MCS_TABLE_SIZE; mcs++) {
/* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */ /* rate is in Kbps; dur is in msec ==> len = (rate * dur) / 8 */
/* 20MHz, No SGI */ /* 20MHz, No SGI */
rate = MCS_RATE(mcs, false, false); rate = mcs_2_rate(mcs, false, false);
ampdu->max_txlen[mcs][0][0] = (rate * dur) >> 3; ampdu->max_txlen[mcs][0][0] = (rate * dur) >> 3;
/* 40 MHz, No SGI */ /* 40 MHz, No SGI */
rate = MCS_RATE(mcs, true, false); rate = mcs_2_rate(mcs, true, false);
ampdu->max_txlen[mcs][1][0] = (rate * dur) >> 3; ampdu->max_txlen[mcs][1][0] = (rate * dur) >> 3;
/* 20MHz, SGI */ /* 20MHz, SGI */
rate = MCS_RATE(mcs, false, true); rate = mcs_2_rate(mcs, false, true);
ampdu->max_txlen[mcs][0][1] = (rate * dur) >> 3; ampdu->max_txlen[mcs][0][1] = (rate * dur) >> 3;
/* 40 MHz, SGI */ /* 40 MHz, SGI */
rate = MCS_RATE(mcs, true, true); rate = mcs_2_rate(mcs, true, true);
ampdu->max_txlen[mcs][1][1] = (rate * dur) >> 3; ampdu->max_txlen[mcs][1][1] = (rate * dur) >> 3;
} }
} }
...@@ -330,7 +330,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) ...@@ -330,7 +330,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f)
/* note : we divide/multiply by 100 to avoid integer overflows */ /* note : we divide/multiply by 100 to avoid integer overflows */
max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS], max_mpdu = min_t(u8, fifo->mcs2ampdu_table[FFPLD_MAX_MCS],
AMPDU_NUM_MPDU_LEGACY); AMPDU_NUM_MPDU_LEGACY);
phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); phy_rate = mcs_2_rate(FFPLD_MAX_MCS, true, false);
dma_rate = dma_rate =
(((phy_rate / 100) * (((phy_rate / 100) *
(max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size)) (max_mpdu * FFPLD_MPDU_SIZE - fifo->ampdu_pld_size))
...@@ -341,7 +341,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) ...@@ -341,7 +341,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f)
dma_rate = dma_rate >> 7; dma_rate = dma_rate >> 7;
for (i = 0; i < FFPLD_MAX_MCS; i++) { for (i = 0; i < FFPLD_MAX_MCS; i++) {
/* shifting to keep it within integer range */ /* shifting to keep it within integer range */
phy_rate = MCS_RATE(i, true, false) >> 7; phy_rate = mcs_2_rate(i, true, false) >> 7;
if (phy_rate > dma_rate) { if (phy_rate > dma_rate) {
tmp = ((fifo->ampdu_pld_size * phy_rate) / tmp = ((fifo->ampdu_pld_size * phy_rate) /
((phy_rate - dma_rate) * FFPLD_MPDU_SIZE)) + 1; ((phy_rate - dma_rate) * FFPLD_MPDU_SIZE)) + 1;
...@@ -360,7 +360,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f) ...@@ -360,7 +360,7 @@ static void brcms_c_ffpld_calc_mcs2ampdu_table(struct ampdu_info *ampdu, int f)
static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid) static int brcms_c_ffpld_check_txfunfl(struct brcms_c_info *wlc, int fid)
{ {
struct ampdu_info *ampdu = wlc->ampdu; struct ampdu_info *ampdu = wlc->ampdu;
u32 phy_rate = MCS_RATE(FFPLD_MAX_MCS, true, false); u32 phy_rate = mcs_2_rate(FFPLD_MAX_MCS, true, false);
u32 txunfl_ratio; u32 txunfl_ratio;
u8 max_mpdu; u8 max_mpdu;
u32 current_ampdu_cnt = 0; u32 current_ampdu_cnt = 0;
...@@ -678,7 +678,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, ...@@ -678,7 +678,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi,
} }
is40 = (plcp0 & MIMO_PLCP_40MHZ) ? 1 : 0; is40 = (plcp0 & MIMO_PLCP_40MHZ) ? 1 : 0;
sgi = PLCP3_ISSGI(plcp3) ? 1 : 0; sgi = plcp3_issgi(plcp3) ? 1 : 0;
mcs = plcp0 & ~MIMO_PLCP_40MHZ; mcs = plcp0 & ~MIMO_PLCP_40MHZ;
max_ampdu_bytes = max_ampdu_bytes =
min(scb_ampdu->max_rx_ampdu_bytes, min(scb_ampdu->max_rx_ampdu_bytes,
...@@ -697,8 +697,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, ...@@ -697,8 +697,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi,
rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT); rspec |= (PHY_TXC1_BW_40MHZ << RSPEC_BW_SHIFT);
if (fbr_iscck) /* CCK */ if (fbr_iscck) /* CCK */
rspec_fallback = rspec_fallback = cck_rspec(cck_phy2mac_rate
CCK_RSPEC(CCK_PHY2MAC_RATE
(txh->FragPLCPFallback[0])); (txh->FragPLCPFallback[0]));
else { /* MIMO */ else { /* MIMO */
rspec_fallback = RSPEC_MIMORATE; rspec_fallback = RSPEC_MIMORATE;
...@@ -722,7 +721,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, ...@@ -722,7 +721,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi,
/* if (first mpdu for host agg) */ /* if (first mpdu for host agg) */
/* test whether to add more */ /* test whether to add more */
if ((MCS_RATE(mcs, true, false) >= f->dmaxferrate) && if ((mcs_2_rate(mcs, true, false) >= f->dmaxferrate) &&
(count == f->mcs2ampdu_table[mcs])) { (count == f->mcs2ampdu_table[mcs])) {
BCMMSG(wlc->wiphy, "wl%d: PR 37644: stopping" BCMMSG(wlc->wiphy, "wl%d: PR 37644: stopping"
" ampdu at %d for mcs %d\n", " ampdu at %d for mcs %d\n",
...@@ -816,7 +815,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi, ...@@ -816,7 +815,7 @@ brcms_c_sendampdu(struct ampdu_info *ampdu, struct brcms_txq_info *qi,
} }
/* set the preload length */ /* set the preload length */
if (MCS_RATE(mcs, true, false) >= f->dmaxferrate) { if (mcs_2_rate(mcs, true, false) >= f->dmaxferrate) {
dma_len = min(dma_len, f->ampdu_pld_size); dma_len = min(dma_len, f->ampdu_pld_size);
txh->PreloadSize = cpu_to_le16(dma_len); txh->PreloadSize = cpu_to_le16(dma_len);
} else } else
......
This diff is collapsed.
...@@ -353,12 +353,12 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) ...@@ -353,12 +353,12 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp)
switch (rxh->PhyRxStatus_0 & PRXS0_FT_MASK) { switch (rxh->PhyRxStatus_0 & PRXS0_FT_MASK) {
case PRXS0_CCK: case PRXS0_CCK:
rspec = rspec =
CCK_PHY2MAC_RATE( cck_phy2mac_rate(
((struct cck_phy_hdr *) plcp)->signal); ((struct cck_phy_hdr *) plcp)->signal);
break; break;
case PRXS0_OFDM: case PRXS0_OFDM:
rspec = rspec =
OFDM_PHY2MAC_RATE( ofdm_phy2mac_rate(
((struct ofdm_phy_hdr *) plcp)->rlpt[0]); ((struct ofdm_phy_hdr *) plcp)->rlpt[0]);
break; break;
case PRXS0_PREN: case PRXS0_PREN:
...@@ -375,14 +375,14 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp) ...@@ -375,14 +375,14 @@ u32 brcms_c_compute_rspec(struct d11rxhdr *rxh, u8 *plcp)
/* not supported, error condition */ /* not supported, error condition */
break; break;
} }
if (PLCP3_ISSGI(plcp[3])) if (plcp3_issgi(plcp[3]))
rspec |= RSPEC_SHORT_GI; rspec |= RSPEC_SHORT_GI;
} else } else
if ((phy_type == PHY_TYPE_A) || (rxh->PhyRxStatus_0 & PRXS0_OFDM)) if ((phy_type == PHY_TYPE_A) || (rxh->PhyRxStatus_0 & PRXS0_OFDM))
rspec = OFDM_PHY2MAC_RATE( rspec = ofdm_phy2mac_rate(
((struct ofdm_phy_hdr *) plcp)->rlpt[0]); ((struct ofdm_phy_hdr *) plcp)->rlpt[0]);
else else
rspec = CCK_PHY2MAC_RATE( rspec = cck_phy2mac_rate(
((struct cck_phy_hdr *) plcp)->signal); ((struct cck_phy_hdr *) plcp)->signal);
return rspec; return rspec;
...@@ -417,9 +417,11 @@ brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst, ...@@ -417,9 +417,11 @@ brcms_c_rateset_filter(struct brcms_c_rateset *src, struct brcms_c_rateset *dst,
r = src->rates[i]; r = src->rates[i];
if (basic_only && !(r & BRCMS_RATE_FLAG)) if (basic_only && !(r & BRCMS_RATE_FLAG))
continue; continue;
if (rates == BRCMS_RATES_CCK && IS_OFDM((r & BRCMS_RATE_MASK))) if (rates == BRCMS_RATES_CCK &&
is_ofdm_rate((r & BRCMS_RATE_MASK)))
continue; continue;
if (rates == BRCMS_RATES_OFDM && IS_CCK((r & BRCMS_RATE_MASK))) if (rates == BRCMS_RATES_OFDM &&
is_cck_rate((r & BRCMS_RATE_MASK)))
continue; continue;
dst->rates[count++] = r & xmask; dst->rates[count++] = r & xmask;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define _BRCM_RATE_H_ #define _BRCM_RATE_H_
#include "types.h" #include "types.h"
#include "d11.h"
extern const u8 rate_info[]; extern const u8 rate_info[];
extern const struct brcms_c_rateset cck_ofdm_mimo_rates; extern const struct brcms_c_rateset cck_ofdm_mimo_rates;
...@@ -48,33 +49,31 @@ struct brcms_mcs_info { ...@@ -48,33 +49,31 @@ struct brcms_mcs_info {
#define MCS_TABLE_SIZE 33 /* Number of mcs entries in the table */ #define MCS_TABLE_SIZE 33 /* Number of mcs entries in the table */
extern const struct brcms_mcs_info mcs_table[]; extern const struct brcms_mcs_info mcs_table[];
#define MCS_INVALID 0xFF
#define MCS_CR_MASK 0x07 /* Code Rate bit mask */
#define MCS_MOD_MASK 0x38 /* Modulation bit shift */
#define MCS_MOD_SHIFT 3 /* MOdulation bit shift */
#define MCS_TXS_MASK 0xc0 /* num tx streams - 1 bit mask */ #define MCS_TXS_MASK 0xc0 /* num tx streams - 1 bit mask */
#define MCS_TXS_SHIFT 6 /* num tx streams - 1 bit shift */ #define MCS_TXS_SHIFT 6 /* num tx streams - 1 bit shift */
#define MCS_CR(_mcs) (mcs_table[_mcs].tx_phy_ctl3 & MCS_CR_MASK)
#define MCS_MOD(_mcs) \ /* returns num tx streams - 1 */
((mcs_table[_mcs].tx_phy_ctl3 & MCS_MOD_MASK) >> MCS_MOD_SHIFT) static inline u8 mcs_2_txstreams(u8 mcs)
{
#define MCS_TXS(_mcs) \ return (mcs_table[mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT;
((mcs_table[_mcs].tx_phy_ctl3 & MCS_TXS_MASK) >> MCS_TXS_SHIFT) }
#define MCS_RATE(_mcs, _is40, _sgi) (_sgi ? \ static inline uint mcs_2_rate(u8 mcs, bool is40, bool sgi)
(_is40 ? mcs_table[_mcs].phy_rate_40_sgi : \ {
mcs_table[_mcs].phy_rate_20_sgi) : \ if (sgi) {
(_is40 ? mcs_table[_mcs].phy_rate_40 : mcs_table[_mcs].phy_rate_20)) if (is40)
return mcs_table[mcs].phy_rate_40_sgi;
#define VALID_MCS(_mcs) ((_mcs < MCS_TABLE_SIZE)) return mcs_table[mcs].phy_rate_20_sgi;
}
if (is40)
return mcs_table[mcs].phy_rate_40;
return mcs_table[mcs].phy_rate_20;
}
/* Macro to use the rate_info table */ /* Macro to use the rate_info table */
#define BRCMS_RATE_MASK_FULL 0xff /* Rate value mask with basic rate flag */ #define BRCMS_RATE_MASK_FULL 0xff /* Rate value mask with basic rate flag */
/* convert 500kbps to bps */
#define BRCMS_RATE_500K_TO_BPS(rate) ((rate) * 500000)
/* /*
* rate spec : holds rate and mode specific information required to generate a * rate spec : holds rate and mode specific information required to generate a
* tx frame. Legacy CCK and OFDM information is held in the same manner as was * tx frame. Legacy CCK and OFDM information is held in the same manner as was
...@@ -113,65 +112,104 @@ extern const struct brcms_mcs_info mcs_table[]; ...@@ -113,65 +112,104 @@ extern const struct brcms_mcs_info mcs_table[];
/* bit indicates override rate only */ /* bit indicates override rate only */
#define RSPEC_OVERRIDE_MCS_ONLY 0x40000000 #define RSPEC_OVERRIDE_MCS_ONLY 0x40000000
#define BRCMS_HTPHY 127 /* HT PHY Membership */ static inline bool rspec_active(u32 rspec)
{
#define RSPEC_ACTIVE(rspec) (rspec & (RSPEC_RATE_MASK | RSPEC_MIMORATE)) return rspec & (RSPEC_RATE_MASK | RSPEC_MIMORATE);
}
#define RSPEC2RATE(rspec) \
((rspec & RSPEC_MIMORATE) ? \ static inline u8 rspec_phytxbyte2(u32 rspec)
MCS_RATE((rspec & RSPEC_RATE_MASK), RSPEC_IS40MHZ(rspec), \ {
RSPEC_ISSGI(rspec)) : \ return (rspec & 0xff00) >> 8;
(rspec & RSPEC_RATE_MASK)) }
#define RSPEC_PHYTXBYTE2(rspec) ((rspec & 0xff00) >> 8) static inline u32 rspec_get_bw(u32 rspec)
{
#define RSPEC_GET_BW(rspec) ((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) return (rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT;
}
#define RSPEC_IS40MHZ(rspec) \
((((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ) || \ static inline bool rspec_issgi(u32 rspec)
(((rspec & RSPEC_BW_MASK) >> RSPEC_BW_SHIFT) == PHY_TXC1_BW_40MHZ_DUP)) {
return (rspec & RSPEC_SHORT_GI) == RSPEC_SHORT_GI;
#define RSPEC_ISSGI(rspec) ((rspec & RSPEC_SHORT_GI) == RSPEC_SHORT_GI) }
#define RSPEC_MIMOPLCP3(rspec) ((rspec & 0xf00000) >> 16)
#define PLCP3_ISSGI(plcp) (plcp & (RSPEC_SHORT_GI >> 16)) static inline bool rspec_is40mhz(u32 rspec)
#define RSPEC_STC(rspec) ((rspec & RSPEC_STC_MASK) >> RSPEC_STC_SHIFT) {
#define RSPEC_STF(rspec) ((rspec & RSPEC_STF_MASK) >> RSPEC_STF_SHIFT) u32 bw = rspec_get_bw(rspec);
#define PLCP3_ISSTBC(plcp) ((plcp & (RSPEC_STC_MASK) >> 16) == 0x10)
#define PLCP3_STC_MASK 0x30 return bw == PHY_TXC1_BW_40MHZ || bw == PHY_TXC1_BW_40MHZ_DUP;
#define PLCP3_STC_SHIFT 4 }
/* Rate info table; takes a legacy rate or u32 */ static inline uint rspec2rate(u32 rspec)
#define IS_MCS(r) (r & RSPEC_MIMORATE) {
if (rspec & RSPEC_MIMORATE)
#define IS_OFDM(r) (!IS_MCS(r) && (rate_info[(r) & RSPEC_RATE_MASK] & \ return mcs_2_rate(rspec & RSPEC_RATE_MASK, rspec_is40mhz(rspec),
BRCMS_RATE_FLAG)) rspec_issgi(rspec));
return rspec & RSPEC_RATE_MASK;
#define IS_CCK(r) (!IS_MCS(r) && ( \ }
((r) & BRCMS_RATE_MASK) == BRCM_RATE_1M || \
((r) & BRCMS_RATE_MASK) == BRCM_RATE_2M || \ static inline u8 rspec_mimoplcp3(u32 rspec)
((r) & BRCMS_RATE_MASK) == BRCM_RATE_5M5 || \ {
((r) & BRCMS_RATE_MASK) == BRCM_RATE_11M)) return (rspec & 0xf00000) >> 16;
}
#define IS_SINGLE_STREAM(mcs) \
(((mcs) <= HIGHEST_SINGLE_STREAM_MCS) || ((mcs) == 32)) static inline bool plcp3_issgi(u8 plcp)
{
#define CCK_RSPEC(cck) ((cck) & RSPEC_RATE_MASK) return (plcp & (RSPEC_SHORT_GI >> 16)) != 0;
}
#define OFDM_RSPEC(ofdm) (((ofdm) & RSPEC_RATE_MASK) |\
(PHY_TXC1_MODE_CDD << RSPEC_STF_SHIFT)) static inline uint rspec_stc(u32 rspec)
{
#define LEGACY_RSPEC(rate) \ return (rspec & RSPEC_STC_MASK) >> RSPEC_STC_SHIFT;
(IS_CCK(rate) ? CCK_RSPEC(rate) : OFDM_RSPEC(rate)) }
#define MCS_RSPEC(mcs) (((mcs) & RSPEC_RATE_MASK) | RSPEC_MIMORATE | \ static inline uint rspec_stf(u32 rspec)
(IS_SINGLE_STREAM(mcs) ? (PHY_TXC1_MODE_CDD << RSPEC_STF_SHIFT) : \ {
(PHY_TXC1_MODE_SDM << RSPEC_STF_SHIFT))) return (rspec & RSPEC_STF_MASK) >> RSPEC_STF_SHIFT;
}
static inline bool is_mcs_rate(u32 ratespec)
{
return (ratespec & RSPEC_MIMORATE) != 0;
}
static inline bool is_ofdm_rate(u32 ratespec)
{
return !is_mcs_rate(ratespec) &&
(rate_info[ratespec & RSPEC_RATE_MASK] & BRCMS_RATE_FLAG);
}
static inline bool is_cck_rate(u32 ratespec)
{
u32 rate = (ratespec & BRCMS_RATE_MASK);
return !is_mcs_rate(ratespec) && (
rate == BRCM_RATE_1M || rate == BRCM_RATE_2M ||
rate == BRCM_RATE_5M5 || rate == BRCM_RATE_11M);
}
static inline bool is_single_stream(u8 mcs)
{
return mcs <= HIGHEST_SINGLE_STREAM_MCS || mcs == 32;
}
static inline u8 cck_rspec(u8 cck)
{
return cck & RSPEC_RATE_MASK;
}
/* Convert encoded rate value in plcp header to numerical rates in 500 KHz /* Convert encoded rate value in plcp header to numerical rates in 500 KHz
* increments */ * increments */
extern const u8 ofdm_rate_lookup[]; extern const u8 ofdm_rate_lookup[];
#define OFDM_PHY2MAC_RATE(rlpt) (ofdm_rate_lookup[rlpt & 0x7])
#define CCK_PHY2MAC_RATE(signal) (signal/5) static inline u8 ofdm_phy2mac_rate(u8 rlpt)
{
return ofdm_rate_lookup[rlpt & 0x7];
}
static inline u8 cck_phy2mac_rate(u8 signal)
{
return signal/5;
}
/* Rates specified in brcms_c_rateset_filter() */ /* Rates specified in brcms_c_rateset_filter() */
#define BRCMS_RATES_CCK_OFDM 0 #define BRCMS_RATES_CCK_OFDM 0
......
...@@ -421,7 +421,7 @@ static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc, ...@@ -421,7 +421,7 @@ static u16 _brcms_c_stf_phytxchain_sel(struct brcms_c_info *wlc,
{ {
u16 phytxant = wlc->stf->phytxant; u16 phytxant = wlc->stf->phytxant;
if (RSPEC_STF(rspec) != PHY_TXC1_MODE_SISO) if (rspec_stf(rspec) != PHY_TXC1_MODE_SISO)
phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
else if (wlc->stf->txant == ANT_TX_DEF) else if (wlc->stf->txant == ANT_TX_DEF)
phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT; phytxant = wlc->stf->txchain << PHY_TXC_ANT_SHIFT;
......
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