rtwn(4): some initial preparations for (basic) VHT support.
Rename RTWN_RIDX_MCS to RTWN_RIDX_HT_MCS before adding 802.11ac MCS rate indexes (they have different offset). No functional change intended.
This commit is contained in:
parent
aed9aaaa76
commit
0cc18edf18
@ -36,7 +36,7 @@
|
||||
#define RTWN_RIDX_OFDM36 9
|
||||
#define RTWN_RIDX_OFDM48 10
|
||||
#define RTWN_RIDX_OFDM54 11
|
||||
#define RTWN_RIDX_MCS(i) (12 + (i))
|
||||
#define RTWN_RIDX_HT_MCS(i) (12 + (i))
|
||||
|
||||
#define RTWN_RIDX_COUNT 28
|
||||
#define RTWN_RIDX_UNKNOWN (uint8_t)-1
|
||||
@ -82,10 +82,10 @@ rtwn_ctl_mcsrate(const struct ieee80211_rate_table *rt, uint8_t ridx)
|
||||
uint8_t cix, rate;
|
||||
|
||||
/* Check if we are using MCS rate. */
|
||||
KASSERT(ridx >= RTWN_RIDX_MCS(0) && ridx != RTWN_RIDX_UNKNOWN,
|
||||
KASSERT(ridx >= RTWN_RIDX_HT_MCS(0) && ridx != RTWN_RIDX_UNKNOWN,
|
||||
("bad mcs rate index %d", ridx));
|
||||
|
||||
rate = (ridx - RTWN_RIDX_MCS(0)) | IEEE80211_RATE_MCS;
|
||||
rate = (ridx - RTWN_RIDX_HT_MCS(0)) | IEEE80211_RATE_MCS;
|
||||
cix = rt->info[rt->rateCodeToIndex[rate]].ctlRateIndex;
|
||||
KASSERT(cix != (uint8_t)-1, ("rate %d (%d) has no info", rate, ridx));
|
||||
return rt->info[cix].dot11Rate;
|
||||
|
@ -88,7 +88,7 @@ rtwn_get_rates(struct rtwn_softc *sc, const struct ieee80211_rateset *rs,
|
||||
if ((rs_ht->rs_rates[i] & 0x7f) > 0xf)
|
||||
continue;
|
||||
/* 11n rates start at index 12 */
|
||||
ridx = RTWN_RIDX_MCS((rs_ht->rs_rates[i]) & 0xf);
|
||||
ridx = RTWN_RIDX_HT_MCS((rs_ht->rs_rates[i]) & 0xf);
|
||||
rates |= (1 << ridx);
|
||||
|
||||
/* Guard against the rate table being oddly ordered */
|
||||
|
@ -101,7 +101,7 @@ r88e_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
|
||||
/* XXX net80211 regulatory */
|
||||
|
||||
max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1);
|
||||
max_mcs = RTWN_RIDX_HT_MCS(sc->ntxchains * 8 - 1);
|
||||
KASSERT(max_mcs <= RTWN_RIDX_COUNT, ("increase ridx limit\n"));
|
||||
|
||||
memset(power, 0, max_mcs * sizeof(power[0]));
|
||||
@ -121,7 +121,7 @@ r88e_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
power[ridx] = ofdmpow;
|
||||
|
||||
bw20pow = htpow + rt->bw20_tx_pwr_diff;
|
||||
for (ridx = RTWN_RIDX_MCS(0); ridx <= max_mcs; ridx++)
|
||||
for (ridx = RTWN_RIDX_HT_MCS(0); ridx <= max_mcs; ridx++)
|
||||
power[ridx] = bw20pow;
|
||||
|
||||
/* Apply max limit. */
|
||||
|
@ -99,7 +99,7 @@ r92c_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
|
||||
/* XXX net80211 regulatory */
|
||||
|
||||
max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1);
|
||||
max_mcs = RTWN_RIDX_HT_MCS(sc->ntxchains * 8 - 1);
|
||||
KASSERT(max_mcs <= RTWN_RIDX_COUNT, ("increase ridx limit\n"));
|
||||
|
||||
memset(power, 0, max_mcs * sizeof(power[0]));
|
||||
@ -146,7 +146,7 @@ r92c_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
diff = rt->ht20_tx_pwr_diff[chain][group];
|
||||
htpow += diff; /* HT40->HT20 correction. */
|
||||
}
|
||||
for (ridx = RTWN_RIDX_MCS(0); ridx <= max_mcs; ridx++)
|
||||
for (ridx = RTWN_RIDX_HT_MCS(0); ridx <= max_mcs; ridx++)
|
||||
power[ridx] += htpow;
|
||||
|
||||
/* Apply max limit. */
|
||||
@ -195,26 +195,26 @@ r92c_write_txpower(struct rtwn_softc *sc, int chain,
|
||||
SM(R92C_TXAGC_RATE54, power[RTWN_RIDX_OFDM54]));
|
||||
/* Write per-MCS Tx power. */
|
||||
rtwn_bb_write(sc, R92C_TXAGC_MCS03_MCS00(chain),
|
||||
SM(R92C_TXAGC_MCS00, power[RTWN_RIDX_MCS(0)]) |
|
||||
SM(R92C_TXAGC_MCS01, power[RTWN_RIDX_MCS(1)]) |
|
||||
SM(R92C_TXAGC_MCS02, power[RTWN_RIDX_MCS(2)]) |
|
||||
SM(R92C_TXAGC_MCS03, power[RTWN_RIDX_MCS(3)]));
|
||||
SM(R92C_TXAGC_MCS00, power[RTWN_RIDX_HT_MCS(0)]) |
|
||||
SM(R92C_TXAGC_MCS01, power[RTWN_RIDX_HT_MCS(1)]) |
|
||||
SM(R92C_TXAGC_MCS02, power[RTWN_RIDX_HT_MCS(2)]) |
|
||||
SM(R92C_TXAGC_MCS03, power[RTWN_RIDX_HT_MCS(3)]));
|
||||
rtwn_bb_write(sc, R92C_TXAGC_MCS07_MCS04(chain),
|
||||
SM(R92C_TXAGC_MCS04, power[RTWN_RIDX_MCS(4)]) |
|
||||
SM(R92C_TXAGC_MCS05, power[RTWN_RIDX_MCS(5)]) |
|
||||
SM(R92C_TXAGC_MCS06, power[RTWN_RIDX_MCS(6)]) |
|
||||
SM(R92C_TXAGC_MCS07, power[RTWN_RIDX_MCS(7)]));
|
||||
SM(R92C_TXAGC_MCS04, power[RTWN_RIDX_HT_MCS(4)]) |
|
||||
SM(R92C_TXAGC_MCS05, power[RTWN_RIDX_HT_MCS(5)]) |
|
||||
SM(R92C_TXAGC_MCS06, power[RTWN_RIDX_HT_MCS(6)]) |
|
||||
SM(R92C_TXAGC_MCS07, power[RTWN_RIDX_HT_MCS(7)]));
|
||||
if (sc->ntxchains >= 2) {
|
||||
rtwn_bb_write(sc, R92C_TXAGC_MCS11_MCS08(chain),
|
||||
SM(R92C_TXAGC_MCS08, power[RTWN_RIDX_MCS(8)]) |
|
||||
SM(R92C_TXAGC_MCS09, power[RTWN_RIDX_MCS(9)]) |
|
||||
SM(R92C_TXAGC_MCS10, power[RTWN_RIDX_MCS(10)]) |
|
||||
SM(R92C_TXAGC_MCS11, power[RTWN_RIDX_MCS(11)]));
|
||||
SM(R92C_TXAGC_MCS08, power[RTWN_RIDX_HT_MCS(8)]) |
|
||||
SM(R92C_TXAGC_MCS09, power[RTWN_RIDX_HT_MCS(9)]) |
|
||||
SM(R92C_TXAGC_MCS10, power[RTWN_RIDX_HT_MCS(10)]) |
|
||||
SM(R92C_TXAGC_MCS11, power[RTWN_RIDX_HT_MCS(11)]));
|
||||
rtwn_bb_write(sc, R92C_TXAGC_MCS15_MCS12(chain),
|
||||
SM(R92C_TXAGC_MCS12, power[RTWN_RIDX_MCS(12)]) |
|
||||
SM(R92C_TXAGC_MCS13, power[RTWN_RIDX_MCS(13)]) |
|
||||
SM(R92C_TXAGC_MCS14, power[RTWN_RIDX_MCS(14)]) |
|
||||
SM(R92C_TXAGC_MCS15, power[RTWN_RIDX_MCS(15)]));
|
||||
SM(R92C_TXAGC_MCS12, power[RTWN_RIDX_HT_MCS(12)]) |
|
||||
SM(R92C_TXAGC_MCS13, power[RTWN_RIDX_HT_MCS(13)]) |
|
||||
SM(R92C_TXAGC_MCS14, power[RTWN_RIDX_HT_MCS(14)]) |
|
||||
SM(R92C_TXAGC_MCS15, power[RTWN_RIDX_HT_MCS(15)]));
|
||||
}
|
||||
}
|
||||
|
||||
@ -231,7 +231,7 @@ r92c_set_txpower(struct rtwn_softc *sc, struct ieee80211_channel *c)
|
||||
if (sc->sc_debug & RTWN_DEBUG_TXPWR) {
|
||||
int max_mcs, ridx;
|
||||
|
||||
max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1);
|
||||
max_mcs = RTWN_RIDX_HT_MCS(sc->ntxchains * 8 - 1);
|
||||
|
||||
/* Dump per-rate Tx power values. */
|
||||
printf("Tx power for chain %d:\n", i);
|
||||
|
@ -198,7 +198,7 @@ r92c_send_ra_cmd(struct rtwn_softc *sc, int macid, uint32_t rates,
|
||||
#endif
|
||||
|
||||
/* Set rates mask for unicast frames. */
|
||||
if (maxrate >= RTWN_RIDX_MCS(0))
|
||||
if (maxrate >= RTWN_RIDX_HT_MCS(0))
|
||||
mode = R92C_RAID_11GN;
|
||||
else if (maxrate >= RTWN_RIDX_OFDM6)
|
||||
mode = R92C_RAID_11BG;
|
||||
|
@ -333,7 +333,7 @@ static const struct rtwn_rf_prog rtl8192c_rf[] = {
|
||||
|
||||
|
||||
struct rtwn_r92c_txagc {
|
||||
uint8_t pwr[R92C_GROUP_2G][28]; /* RTWN_RIDX_MCS(15) + 1 */
|
||||
uint8_t pwr[R92C_GROUP_2G][28]; /* RTWN_RIDX_HT_MCS(15) + 1 */
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -117,7 +117,7 @@ r92c_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_AMPDU;
|
||||
else if (rxdw1 & R92C_RXDW1_AMPDU_MORE)
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_AMPDU_MORE;
|
||||
if ((rxdw3 & R92C_RXDW3_SPLCP) && rate >= RTWN_RIDX_MCS(0))
|
||||
if ((rxdw3 & R92C_RXDW3_SPLCP) && rate >= RTWN_RIDX_HT_MCS(0))
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_SHORTGI;
|
||||
|
||||
if (rxdw3 & R92C_RXDW3_HT40)
|
||||
@ -127,13 +127,13 @@ r92c_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
|
||||
|
||||
if (RTWN_RATE_IS_CCK(rate))
|
||||
rxs->c_phytype = IEEE80211_RX_FP_11B;
|
||||
else if (rate < RTWN_RIDX_MCS(0))
|
||||
else if (rate < RTWN_RIDX_HT_MCS(0))
|
||||
rxs->c_phytype = IEEE80211_RX_FP_11G;
|
||||
else
|
||||
rxs->c_phytype = IEEE80211_RX_FP_11NG;
|
||||
|
||||
/* Map HW rate index to 802.11 rate. */
|
||||
if (rate < RTWN_RIDX_MCS(0)) {
|
||||
if (rate < RTWN_RIDX_HT_MCS(0)) {
|
||||
rxs->c_rate = ridx2rate[rate];
|
||||
if (RTWN_RATE_IS_CCK(rate))
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_CCK;
|
||||
|
@ -99,7 +99,7 @@ r92c_tx_protection(struct rtwn_softc *sc, struct r92c_tx_desc *txd,
|
||||
|
||||
if (mode == IEEE80211_PROT_CTSONLY ||
|
||||
mode == IEEE80211_PROT_RTSCTS) {
|
||||
if (ridx >= RTWN_RIDX_MCS(0))
|
||||
if (ridx >= RTWN_RIDX_HT_MCS(0))
|
||||
rate = rtwn_ctl_mcsrate(ic->ic_rt, ridx);
|
||||
else
|
||||
rate = ieee80211_ctl_rate(ic->ic_rt, ridx2rate[ridx]);
|
||||
@ -285,7 +285,7 @@ r92c_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni,
|
||||
txd->txdw4 |= htole32(R92C_TXDW4_DATA_SHPRE);
|
||||
|
||||
prot = IEEE80211_PROT_NONE;
|
||||
if (ridx >= RTWN_RIDX_MCS(0)) {
|
||||
if (ridx >= RTWN_RIDX_HT_MCS(0)) {
|
||||
r92c_tx_set_ht40(sc, txd, ni);
|
||||
r92c_tx_set_sgi(sc, txd, ni);
|
||||
prot = ic->ic_htprotmode;
|
||||
|
@ -102,7 +102,7 @@ r92e_get_txpower(struct rtwn_softc *sc, int chain, struct ieee80211_channel *c,
|
||||
return;
|
||||
}
|
||||
|
||||
max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1);
|
||||
max_mcs = RTWN_RIDX_HT_MCS(sc->ntxchains * 8 - 1);
|
||||
|
||||
/* XXX regulatory */
|
||||
/* XXX net80211 regulatory */
|
||||
@ -124,7 +124,7 @@ r92e_get_txpower(struct rtwn_softc *sc, int chain, struct ieee80211_channel *c,
|
||||
else
|
||||
pwr_diff = rs->bw20_tx_pwr_diff_2g[chain][i];
|
||||
|
||||
min_mcs = RTWN_RIDX_MCS(i * 8);
|
||||
min_mcs = RTWN_RIDX_HT_MCS(i * 8);
|
||||
for (ridx = min_mcs; ridx <= max_mcs; ridx++)
|
||||
power[ridx] += pwr_diff;
|
||||
|
||||
|
@ -89,26 +89,26 @@ r12a_write_txpower(struct rtwn_softc *sc, int chain,
|
||||
SM(R12A_TXAGC_OFDM54, power[RTWN_RIDX_OFDM54]));
|
||||
/* Write per-MCS Tx power. */
|
||||
rtwn_bb_write(sc, R12A_TXAGC_MCS3_0(chain),
|
||||
SM(R12A_TXAGC_MCS0, power[RTWN_RIDX_MCS(0)]) |
|
||||
SM(R12A_TXAGC_MCS1, power[RTWN_RIDX_MCS(1)]) |
|
||||
SM(R12A_TXAGC_MCS2, power[RTWN_RIDX_MCS(2)]) |
|
||||
SM(R12A_TXAGC_MCS3, power[RTWN_RIDX_MCS(3)]));
|
||||
SM(R12A_TXAGC_MCS0, power[RTWN_RIDX_HT_MCS(0)]) |
|
||||
SM(R12A_TXAGC_MCS1, power[RTWN_RIDX_HT_MCS(1)]) |
|
||||
SM(R12A_TXAGC_MCS2, power[RTWN_RIDX_HT_MCS(2)]) |
|
||||
SM(R12A_TXAGC_MCS3, power[RTWN_RIDX_HT_MCS(3)]));
|
||||
rtwn_bb_write(sc, R12A_TXAGC_MCS7_4(chain),
|
||||
SM(R12A_TXAGC_MCS4, power[RTWN_RIDX_MCS(4)]) |
|
||||
SM(R12A_TXAGC_MCS5, power[RTWN_RIDX_MCS(5)]) |
|
||||
SM(R12A_TXAGC_MCS6, power[RTWN_RIDX_MCS(6)]) |
|
||||
SM(R12A_TXAGC_MCS7, power[RTWN_RIDX_MCS(7)]));
|
||||
SM(R12A_TXAGC_MCS4, power[RTWN_RIDX_HT_MCS(4)]) |
|
||||
SM(R12A_TXAGC_MCS5, power[RTWN_RIDX_HT_MCS(5)]) |
|
||||
SM(R12A_TXAGC_MCS6, power[RTWN_RIDX_HT_MCS(6)]) |
|
||||
SM(R12A_TXAGC_MCS7, power[RTWN_RIDX_HT_MCS(7)]));
|
||||
if (sc->ntxchains >= 2) {
|
||||
rtwn_bb_write(sc, R12A_TXAGC_MCS11_8(chain),
|
||||
SM(R12A_TXAGC_MCS8, power[RTWN_RIDX_MCS(8)]) |
|
||||
SM(R12A_TXAGC_MCS9, power[RTWN_RIDX_MCS(9)]) |
|
||||
SM(R12A_TXAGC_MCS10, power[RTWN_RIDX_MCS(10)]) |
|
||||
SM(R12A_TXAGC_MCS11, power[RTWN_RIDX_MCS(11)]));
|
||||
SM(R12A_TXAGC_MCS8, power[RTWN_RIDX_HT_MCS(8)]) |
|
||||
SM(R12A_TXAGC_MCS9, power[RTWN_RIDX_HT_MCS(9)]) |
|
||||
SM(R12A_TXAGC_MCS10, power[RTWN_RIDX_HT_MCS(10)]) |
|
||||
SM(R12A_TXAGC_MCS11, power[RTWN_RIDX_HT_MCS(11)]));
|
||||
rtwn_bb_write(sc, R12A_TXAGC_MCS15_12(chain),
|
||||
SM(R12A_TXAGC_MCS12, power[RTWN_RIDX_MCS(12)]) |
|
||||
SM(R12A_TXAGC_MCS13, power[RTWN_RIDX_MCS(13)]) |
|
||||
SM(R12A_TXAGC_MCS14, power[RTWN_RIDX_MCS(14)]) |
|
||||
SM(R12A_TXAGC_MCS15, power[RTWN_RIDX_MCS(15)]));
|
||||
SM(R12A_TXAGC_MCS12, power[RTWN_RIDX_HT_MCS(12)]) |
|
||||
SM(R12A_TXAGC_MCS13, power[RTWN_RIDX_HT_MCS(13)]) |
|
||||
SM(R12A_TXAGC_MCS14, power[RTWN_RIDX_HT_MCS(14)]) |
|
||||
SM(R12A_TXAGC_MCS15, power[RTWN_RIDX_HT_MCS(15)]));
|
||||
}
|
||||
|
||||
/* TODO: VHT rates */
|
||||
@ -176,7 +176,7 @@ r12a_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
}
|
||||
|
||||
/* TODO: VHT rates. */
|
||||
max_mcs = RTWN_RIDX_MCS(sc->ntxchains * 8 - 1);
|
||||
max_mcs = RTWN_RIDX_HT_MCS(sc->ntxchains * 8 - 1);
|
||||
|
||||
/* XXX regulatory */
|
||||
/* XXX net80211 regulatory */
|
||||
@ -205,7 +205,7 @@ r12a_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
else
|
||||
pwr_diff = rs->bw20_tx_pwr_diff_2g[chain][i];
|
||||
|
||||
min_mcs = RTWN_RIDX_MCS(i * 8);
|
||||
min_mcs = RTWN_RIDX_HT_MCS(i * 8);
|
||||
for (ridx = min_mcs; ridx <= max_mcs; ridx++)
|
||||
power[ridx] += pwr_diff;
|
||||
}
|
||||
@ -231,7 +231,7 @@ r12a_get_txpower(struct rtwn_softc *sc, int chain,
|
||||
else
|
||||
pwr_diff = rs->bw20_tx_pwr_diff_5g[chain][i];
|
||||
|
||||
min_mcs = RTWN_RIDX_MCS(i * 8);
|
||||
min_mcs = RTWN_RIDX_HT_MCS(i * 8);
|
||||
for (ridx = min_mcs; ridx <= max_mcs; ridx++)
|
||||
power[ridx] += pwr_diff;
|
||||
}
|
||||
|
@ -262,7 +262,7 @@ r12a_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_AMPDU_MORE;
|
||||
}
|
||||
|
||||
if ((rxdw4 & R12A_RXDW4_SPLCP) && rate >= RTWN_RIDX_MCS(0))
|
||||
if ((rxdw4 & R12A_RXDW4_SPLCP) && rate >= RTWN_RIDX_HT_MCS(0))
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_SHORTGI;
|
||||
|
||||
switch (MS(rxdw4, R12A_RXDW4_BW)) {
|
||||
@ -288,7 +288,7 @@ r12a_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
|
||||
/* XXX check with RTL8812AU */
|
||||
is5ghz = (physt->cfosho[2] != 0x01);
|
||||
|
||||
if (rate < RTWN_RIDX_MCS(0)) {
|
||||
if (rate < RTWN_RIDX_HT_MCS(0)) {
|
||||
if (is5ghz)
|
||||
rxs->c_phytype = IEEE80211_RX_FP_11A;
|
||||
else
|
||||
@ -302,7 +302,7 @@ r12a_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
|
||||
}
|
||||
|
||||
/* Map HW rate index to 802.11 rate. */
|
||||
if (rate < RTWN_RIDX_MCS(0)) {
|
||||
if (rate < RTWN_RIDX_HT_MCS(0)) {
|
||||
rxs->c_rate = ridx2rate[rate];
|
||||
if (RTWN_RATE_IS_CCK(rate))
|
||||
rxs->c_pktflags |= IEEE80211_RX_F_CCK;
|
||||
|
@ -107,7 +107,7 @@ r12a_tx_protection(struct rtwn_softc *sc, struct r12a_tx_desc *txd,
|
||||
|
||||
if (mode == IEEE80211_PROT_CTSONLY ||
|
||||
mode == IEEE80211_PROT_RTSCTS) {
|
||||
if (ridx >= RTWN_RIDX_MCS(0))
|
||||
if (ridx >= RTWN_RIDX_HT_MCS(0))
|
||||
rate = rtwn_ctl_mcsrate(ic->ic_rt, ridx);
|
||||
else
|
||||
rate = ieee80211_ctl_rate(ic->ic_rt, ridx2rate[ridx]);
|
||||
@ -292,7 +292,7 @@ r12a_fill_tx_desc(struct rtwn_softc *sc, struct ieee80211_node *ni,
|
||||
txd->txdw5 |= htole32(R12A_TXDW5_DATA_SHORT);
|
||||
|
||||
prot = IEEE80211_PROT_NONE;
|
||||
if (ridx >= RTWN_RIDX_MCS(0)) {
|
||||
if (ridx >= RTWN_RIDX_HT_MCS(0)) {
|
||||
r12a_tx_set_ht40(sc, txd, ni);
|
||||
r12a_tx_set_sgi(sc, txd, ni);
|
||||
r12a_tx_set_ldpc(sc, txd, ni);
|
||||
|
Loading…
Reference in New Issue
Block a user