rtwn(4): de-hardcode ('h/w rate index' - 'corresponding MCS index') constant

This commit is contained in:
Andriy Voskoboinyk 2018-03-16 01:03:10 +00:00
parent 46e18fc6d4
commit 5f792f7478
4 changed files with 12 additions and 7 deletions

View File

@ -36,7 +36,9 @@
#define RTWN_RIDX_OFDM36 9
#define RTWN_RIDX_OFDM48 10
#define RTWN_RIDX_OFDM54 11
#define RTWN_RIDX_HT_MCS(i) (12 + (i))
#define RTWN_RIDX_HT_MCS_SHIFT 12
#define RTWN_RIDX_HT_MCS(i) (RTWN_RIDX_HT_MCS_SHIFT + (i))
#define RTWN_RIDX_COUNT 28
#define RTWN_RIDX_UNKNOWN (uint8_t)-1
@ -53,8 +55,7 @@ static __inline uint8_t
rate2ridx(uint8_t rate)
{
if (rate & IEEE80211_RATE_MCS) {
/* 11n rates start at idx 12 */
return ((rate & 0xf) + 12);
return ((rate & 0xf) + RTWN_RIDX_HT_MCS_SHIFT);
}
switch (rate) {
/* 11g */

View File

@ -108,7 +108,8 @@ r88e_ratectl_tx_complete(struct rtwn_softc *sc, uint8_t *buf, int len)
txs.long_retries = ntries;
if (rpt->final_rate > RTWN_RIDX_OFDM54) { /* MCS */
txs.final_rate =
(rpt->final_rate - 12) | IEEE80211_RATE_MCS;
rpt->final_rate - RTWN_RIDX_HT_MCS_SHIFT;
txs.final_rate |= IEEE80211_RATE_MCS;
} else
txs.final_rate = ridx2rate[rpt->final_rate];
if (rpt->rptb1 & R88E_RPTB1_PKT_OK)

View File

@ -140,7 +140,8 @@ r92c_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
else
rxs->c_pktflags |= IEEE80211_RX_F_OFDM;
} else { /* MCS0~15. */
rxs->c_rate = IEEE80211_RATE_MCS | (rate - 12);
rxs->c_rate =
IEEE80211_RATE_MCS | (rate - RTWN_RIDX_HT_MCS_SHIFT);
rxs->c_pktflags |= IEEE80211_RX_F_HT;
}
}

View File

@ -115,7 +115,8 @@ r12a_ratectl_tx_complete(struct rtwn_softc *sc, uint8_t *buf, int len)
txs.long_retries = ntries;
if (rpt->final_rate > RTWN_RIDX_OFDM54) { /* MCS */
txs.final_rate =
(rpt->final_rate - 12) | IEEE80211_RATE_MCS;
rpt->final_rate - RTWN_RIDX_HT_MCS_SHIFT;
txs.final_rate |= IEEE80211_RATE_MCS;
} else
txs.final_rate = ridx2rate[rpt->final_rate];
if (rpt->txrptb0 & R12A_TXRPTB0_RETRY_OVER)
@ -310,7 +311,8 @@ r12a_get_rx_stats(struct rtwn_softc *sc, struct ieee80211_rx_stats *rxs,
rxs->c_pktflags |= IEEE80211_RX_F_OFDM;
} else { /* MCS0~15. */
/* TODO: VHT rates */
rxs->c_rate = IEEE80211_RATE_MCS | (rate - 12);
rxs->c_rate =
IEEE80211_RATE_MCS | (rate - RTWN_RIDX_HT_MCS_SHIFT);
rxs->c_pktflags |= IEEE80211_RX_F_HT;
}