Commit 545750d3 authored by Felix Fietkau's avatar Felix Fietkau Committed by John W. Linville

ath9k: properly use the mac80211 rate control api

This patch changes ath9k to pass proper MCS indexes and flags
between the RC and the rest of the driver code.
sc->cur_rate_table remains, as it's used by the RC code internally,
but the rest of the driver code no longer uses it, so a potential
new RC for ath9k would not have to update it.
Signed-off-by: default avatarFelix Fietkau <nbd@openwrt.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 04658fba
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/leds.h> #include <linux/leds.h>
#include "rc.h"
#include "debug.h" #include "debug.h"
#include "common.h" #include "common.h"
...@@ -423,6 +422,7 @@ struct ath_led { ...@@ -423,6 +422,7 @@ struct ath_led {
#define SC_OP_BT_PRIORITY_DETECTED BIT(21) #define SC_OP_BT_PRIORITY_DETECTED BIT(21)
struct ath_wiphy; struct ath_wiphy;
struct ath_rate_table;
struct ath_softc { struct ath_softc {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
...@@ -467,9 +467,8 @@ struct ath_softc { ...@@ -467,9 +467,8 @@ struct ath_softc {
struct ath_rx rx; struct ath_rx rx;
struct ath_tx tx; struct ath_tx tx;
struct ath_beacon beacon; struct ath_beacon beacon;
struct ieee80211_rate rates[IEEE80211_NUM_BANDS][ATH_RATE_MAX];
const struct ath_rate_table *hw_rate_table[ATH9K_MODE_MAX];
const struct ath_rate_table *cur_rate_table; const struct ath_rate_table *cur_rate_table;
enum wireless_mode cur_rate_mode;
struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];
struct ath_led radio_led; struct ath_led radio_led;
......
...@@ -65,9 +65,9 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp, ...@@ -65,9 +65,9 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
struct ath_desc *ds; struct ath_desc *ds;
struct ath9k_11n_rate_series series[4]; struct ath9k_11n_rate_series series[4];
const struct ath_rate_table *rt;
int flags, antenna, ctsrate = 0, ctsduration = 0; int flags, antenna, ctsrate = 0, ctsduration = 0;
u8 rate; struct ieee80211_supported_band *sband;
u8 rate = 0;
ds = bf->bf_desc; ds = bf->bf_desc;
flags = ATH9K_TXDESC_NOACK; flags = ATH9K_TXDESC_NOACK;
...@@ -91,10 +91,10 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp, ...@@ -91,10 +91,10 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,
ds->ds_data = bf->bf_buf_addr; ds->ds_data = bf->bf_buf_addr;
rt = sc->cur_rate_table; sband = &sc->sbands[common->hw->conf.channel->band];
rate = rt->info[0].ratecode; rate = sband->bitrates[0].hw_value;
if (sc->sc_flags & SC_OP_PREAMBLE_SHORT) if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
rate |= rt->info[0].short_preamble; rate |= sband->bitrates[0].hw_value_short;
ath9k_hw_set11n_txdesc(ah, ds, skb->len + FCS_LEN, ath9k_hw_set11n_txdesc(ah, ds, skb->len + FCS_LEN,
ATH9K_PKT_TYPE_BEACON, ATH9K_PKT_TYPE_BEACON,
......
...@@ -255,21 +255,11 @@ static const struct file_operations fops_interrupt = { ...@@ -255,21 +255,11 @@ static const struct file_operations fops_interrupt = {
.owner = THIS_MODULE .owner = THIS_MODULE
}; };
void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb) void ath_debug_stat_rc(struct ath_softc *sc, int final_rate)
{ {
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
struct ieee80211_tx_rate *rates = tx_info->status.rates;
int final_ts_idx = 0, idx, i;
struct ath_rc_stats *stats; struct ath_rc_stats *stats;
for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { stats = &sc->debug.stats.rcstats[final_rate];
if (!rates[i].count)
break;
final_ts_idx = i;
}
idx = rates[final_ts_idx].idx;
stats = &sc->debug.stats.rcstats[idx];
stats->success++; stats->success++;
} }
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define DEBUG_H #define DEBUG_H
#include "hw.h" #include "hw.h"
#include "rc.h"
struct ath_txq; struct ath_txq;
struct ath_buf; struct ath_buf;
...@@ -138,7 +139,7 @@ void ath9k_exit_debug(struct ath_hw *ah); ...@@ -138,7 +139,7 @@ void ath9k_exit_debug(struct ath_hw *ah);
int ath9k_debug_create_root(void); int ath9k_debug_create_root(void);
void ath9k_debug_remove_root(void); void ath9k_debug_remove_root(void);
void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status);
void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb); void ath_debug_stat_rc(struct ath_softc *sc, int final_rate);
void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq, void ath_debug_stat_tx(struct ath_softc *sc, struct ath_txq *txq,
struct ath_buf *bf); struct ath_buf *bf);
void ath_debug_stat_retries(struct ath_softc *sc, int rix, void ath_debug_stat_retries(struct ath_softc *sc, int rix,
...@@ -170,7 +171,7 @@ static inline void ath_debug_stat_interrupt(struct ath_softc *sc, ...@@ -170,7 +171,7 @@ static inline void ath_debug_stat_interrupt(struct ath_softc *sc,
} }
static inline void ath_debug_stat_rc(struct ath_softc *sc, static inline void ath_debug_stat_rc(struct ath_softc *sc,
struct sk_buff *skb) int final_rate)
{ {
} }
......
...@@ -148,22 +148,19 @@ bool ath9k_get_channel_edges(struct ath_hw *ah, ...@@ -148,22 +148,19 @@ bool ath9k_get_channel_edges(struct ath_hw *ah,
} }
u16 ath9k_hw_computetxtime(struct ath_hw *ah, u16 ath9k_hw_computetxtime(struct ath_hw *ah,
const struct ath_rate_table *rates, u8 phy, int kbps,
u32 frameLen, u16 rateix, u32 frameLen, u16 rateix,
bool shortPreamble) bool shortPreamble)
{ {
u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime; u32 bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
u32 kbps;
kbps = rates->info[rateix].ratekbps;
if (kbps == 0) if (kbps == 0)
return 0; return 0;
switch (rates->info[rateix].phy) { switch (phy) {
case WLAN_RC_PHY_CCK: case WLAN_RC_PHY_CCK:
phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS; phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
if (shortPreamble && rates->info[rateix].short_preamble) if (shortPreamble)
phyTime >>= 1; phyTime >>= 1;
numBits = frameLen << 3; numBits = frameLen << 3;
txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps); txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps);
...@@ -194,8 +191,7 @@ u16 ath9k_hw_computetxtime(struct ath_hw *ah, ...@@ -194,8 +191,7 @@ u16 ath9k_hw_computetxtime(struct ath_hw *ah,
break; break;
default: default:
ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL, ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
"Unknown phy %u (rate ix %u)\n", "Unknown phy %u (rate ix %u)\n", phy, rateix);
rates->info[rateix].phy, rateix);
txTime = 0; txTime = 0;
break; break;
} }
......
...@@ -647,7 +647,7 @@ bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout); ...@@ -647,7 +647,7 @@ bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
u32 ath9k_hw_reverse_bits(u32 val, u32 n); u32 ath9k_hw_reverse_bits(u32 val, u32 n);
bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high); bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high);
u16 ath9k_hw_computetxtime(struct ath_hw *ah, u16 ath9k_hw_computetxtime(struct ath_hw *ah,
const struct ath_rate_table *rates, u8 phy, int kbps,
u32 frameLen, u16 rateix, bool shortPreamble); u32 frameLen, u16 rateix, bool shortPreamble);
void ath9k_hw_get_channel_centers(struct ath_hw *ah, void ath9k_hw_get_channel_centers(struct ath_hw *ah,
struct ath9k_channel *chan, struct ath9k_channel *chan,
......
...@@ -616,7 +616,6 @@ enum ath9k_cipher { ...@@ -616,7 +616,6 @@ enum ath9k_cipher {
struct ath_hw; struct ath_hw;
struct ath9k_channel; struct ath9k_channel;
struct ath_rate_table;
u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q); u32 ath9k_hw_gettxbuf(struct ath_hw *ah, u32 q);
void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp); void ath9k_hw_puttxbuf(struct ath_hw *ah, u32 q, u32 txdp);
......
...@@ -104,37 +104,55 @@ static struct ieee80211_channel ath9k_5ghz_chantable[] = { ...@@ -104,37 +104,55 @@ static struct ieee80211_channel ath9k_5ghz_chantable[] = {
CHAN5G(5825, 37), /* Channel 165 */ CHAN5G(5825, 37), /* Channel 165 */
}; };
/* Atheros hardware rate code addition for short premble */
#define SHPCHECK(__hw_rate, __flags) \
((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0)
#define RATE(_bitrate, _hw_rate, _flags) { \
.bitrate = (_bitrate), \
.flags = (_flags), \
.hw_value = (_hw_rate), \
.hw_value_short = (SHPCHECK(_hw_rate, _flags)) \
}
static struct ieee80211_rate ath9k_legacy_rates[] = {
RATE(10, 0x1b, 0),
RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE),
RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE),
RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE),
RATE(60, 0x0b, 0),
RATE(90, 0x0f, 0),
RATE(120, 0x0a, 0),
RATE(180, 0x0e, 0),
RATE(240, 0x09, 0),
RATE(360, 0x0d, 0),
RATE(480, 0x08, 0),
RATE(540, 0x0c, 0),
};
static void ath_cache_conf_rate(struct ath_softc *sc, static void ath_cache_conf_rate(struct ath_softc *sc,
struct ieee80211_conf *conf) struct ieee80211_conf *conf)
{ {
switch (conf->channel->band) { switch (conf->channel->band) {
case IEEE80211_BAND_2GHZ: case IEEE80211_BAND_2GHZ:
if (conf_is_ht20(conf)) if (conf_is_ht20(conf))
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11NG_HT20;
sc->hw_rate_table[ATH9K_MODE_11NG_HT20];
else if (conf_is_ht40_minus(conf)) else if (conf_is_ht40_minus(conf))
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11NG_HT40MINUS;
sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS];
else if (conf_is_ht40_plus(conf)) else if (conf_is_ht40_plus(conf))
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11NG_HT40PLUS;
sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS];
else else
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11G;
sc->hw_rate_table[ATH9K_MODE_11G];
break; break;
case IEEE80211_BAND_5GHZ: case IEEE80211_BAND_5GHZ:
if (conf_is_ht20(conf)) if (conf_is_ht20(conf))
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11NA_HT20;
sc->hw_rate_table[ATH9K_MODE_11NA_HT20];
else if (conf_is_ht40_minus(conf)) else if (conf_is_ht40_minus(conf))
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11NA_HT40MINUS;
sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS];
else if (conf_is_ht40_plus(conf)) else if (conf_is_ht40_plus(conf))
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11NA_HT40PLUS;
sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS];
else else
sc->cur_rate_table = sc->cur_rate_mode = ATH9K_MODE_11A;
sc->hw_rate_table[ATH9K_MODE_11A];
break; break;
default: default:
BUG_ON(1); BUG_ON(1);
...@@ -190,51 +208,6 @@ static u8 parse_mpdudensity(u8 mpdudensity) ...@@ -190,51 +208,6 @@ static u8 parse_mpdudensity(u8 mpdudensity)
} }
} }
static void ath_setup_rates(struct ath_softc *sc, enum ieee80211_band band)
{
const struct ath_rate_table *rate_table = NULL;
struct ieee80211_supported_band *sband;
struct ieee80211_rate *rate;
int i, maxrates;
switch (band) {
case IEEE80211_BAND_2GHZ:
rate_table = sc->hw_rate_table[ATH9K_MODE_11G];
break;
case IEEE80211_BAND_5GHZ:
rate_table = sc->hw_rate_table[ATH9K_MODE_11A];
break;
default:
break;
}
if (rate_table == NULL)
return;
sband = &sc->sbands[band];
rate = sc->rates[band];
if (rate_table->rate_cnt > ATH_RATE_MAX)
maxrates = ATH_RATE_MAX;
else
maxrates = rate_table->rate_cnt;
for (i = 0; i < maxrates; i++) {
rate[i].bitrate = rate_table->info[i].ratekbps / 100;
rate[i].hw_value = rate_table->info[i].ratecode;
if (rate_table->info[i].short_preamble) {
rate[i].hw_value_short = rate_table->info[i].ratecode |
rate_table->info[i].short_preamble;
rate[i].flags = IEEE80211_RATE_SHORT_PREAMBLE;
}
sband->n_bitrates++;
ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
"Rate: %2dMbps, ratecode: %2d\n",
rate[i].bitrate / 10, rate[i].hw_value);
}
}
static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc, static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc,
struct ieee80211_hw *hw) struct ieee80211_hw *hw)
{ {
...@@ -1701,12 +1674,6 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, ...@@ -1701,12 +1674,6 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
/* default to MONITOR mode */ /* default to MONITOR mode */
sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR; sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR;
/* Setup rate tables */
ath_rate_attach(sc);
ath_setup_rates(sc, IEEE80211_BAND_2GHZ);
ath_setup_rates(sc, IEEE80211_BAND_5GHZ);
/* /*
* Allocate hardware transmit queues: one queue for * Allocate hardware transmit queues: one queue for
* beacon frames and one data queue for each QoS * beacon frames and one data queue for each QoS
...@@ -1827,19 +1794,22 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, ...@@ -1827,19 +1794,22 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid,
/* setup channels and rates */ /* setup channels and rates */
sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable; sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
sc->sbands[IEEE80211_BAND_2GHZ].bitrates =
sc->rates[IEEE80211_BAND_2GHZ];
sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
sc->sbands[IEEE80211_BAND_2GHZ].n_channels = sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
ARRAY_SIZE(ath9k_2ghz_chantable); ARRAY_SIZE(ath9k_2ghz_chantable);
sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates;
sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates =
ARRAY_SIZE(ath9k_legacy_rates);
if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) { if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable; sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
sc->rates[IEEE80211_BAND_5GHZ];
sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
sc->sbands[IEEE80211_BAND_5GHZ].n_channels = sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
ARRAY_SIZE(ath9k_5ghz_chantable); ARRAY_SIZE(ath9k_5ghz_chantable);
sc->sbands[IEEE80211_BAND_5GHZ].bitrates =
ath9k_legacy_rates + 4;
sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
ARRAY_SIZE(ath9k_legacy_rates) - 4;
} }
switch (ah->btcoex_hw.scheme) { switch (ah->btcoex_hw.scheme) {
......
This diff is collapsed.
...@@ -104,6 +104,7 @@ enum { ...@@ -104,6 +104,7 @@ enum {
*/ */
struct ath_rate_table { struct ath_rate_table {
int rate_cnt; int rate_cnt;
int mcs_start;
struct { struct {
int valid; int valid;
int valid_single_stream; int valid_single_stream;
...@@ -179,8 +180,6 @@ enum ath9k_internal_frame_type { ...@@ -179,8 +180,6 @@ enum ath9k_internal_frame_type {
ATH9K_INT_UNPAUSE ATH9K_INT_UNPAUSE
}; };
void ath_rate_attach(struct ath_softc *sc);
u8 ath_rate_findrateix(struct ath_softc *sc, u8 dot11_rate);
int ath_rate_control_register(void); int ath_rate_control_register(void);
void ath_rate_control_unregister(void); void ath_rate_control_unregister(void);
......
...@@ -70,6 +70,29 @@ static int ath_tx_num_badfrms(struct ath_softc *sc, struct ath_buf *bf, ...@@ -70,6 +70,29 @@ static int ath_tx_num_badfrms(struct ath_softc *sc, struct ath_buf *bf,
static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds, static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds,
int nbad, int txok, bool update_rc); int nbad, int txok, bool update_rc);
enum {
MCS_DEFAULT,
MCS_HT40,
MCS_HT40_SGI,
};
static int ath_max_4ms_framelen[3][16] = {
[MCS_DEFAULT] = {
3216, 6434, 9650, 12868, 19304, 25740, 28956, 32180,
6430, 12860, 19300, 25736, 38600, 51472, 57890, 64320,
},
[MCS_HT40] = {
6684, 13368, 20052, 26738, 40104, 53476, 60156, 66840,
13360, 26720, 40080, 53440, 80160, 106880, 120240, 133600,
},
[MCS_HT40_SGI] = {
/* TODO: Only MCS 7 and 15 updated, recalculate the rest */
6684, 13368, 20052, 26738, 40104, 53476, 60156, 74200,
13360, 26720, 40080, 53440, 80160, 106880, 120240, 148400,
}
};
/*********************/ /*********************/
/* Aggregation logic */ /* Aggregation logic */
/*********************/ /*********************/
...@@ -459,7 +482,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, ...@@ -459,7 +482,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq,
static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
struct ath_atx_tid *tid) struct ath_atx_tid *tid)
{ {
const struct ath_rate_table *rate_table = sc->cur_rate_table;
struct sk_buff *skb; struct sk_buff *skb;
struct ieee80211_tx_info *tx_info; struct ieee80211_tx_info *tx_info;
struct ieee80211_tx_rate *rates; struct ieee80211_tx_rate *rates;
...@@ -480,12 +502,20 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, ...@@ -480,12 +502,20 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
if (rates[i].count) { if (rates[i].count) {
if (!WLAN_RC_PHY_HT(rate_table->info[rates[i].idx].phy)) { int modeidx;
if (!(rates[i].flags & IEEE80211_TX_RC_MCS)) {
legacy = 1; legacy = 1;
break; break;
} }
frmlen = rate_table->info[rates[i].idx].max_4ms_framelen; if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI)
modeidx = MCS_HT40_SGI;
else if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
modeidx = MCS_HT40;
else
modeidx = MCS_DEFAULT;
frmlen = ath_max_4ms_framelen[modeidx][rates[i].idx];
max_4ms_framelen = min(max_4ms_framelen, frmlen); max_4ms_framelen = min(max_4ms_framelen, frmlen);
} }
} }
...@@ -523,12 +553,11 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf, ...@@ -523,12 +553,11 @@ static u32 ath_lookup_rate(struct ath_softc *sc, struct ath_buf *bf,
static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid, static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
struct ath_buf *bf, u16 frmlen) struct ath_buf *bf, u16 frmlen)
{ {
const struct ath_rate_table *rt = sc->cur_rate_table;
struct sk_buff *skb = bf->bf_mpdu; struct sk_buff *skb = bf->bf_mpdu;
struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb);
u32 nsymbits, nsymbols; u32 nsymbits, nsymbols;
u16 minlen; u16 minlen;
u8 rc, flags, rix; u8 flags, rix;
int width, half_gi, ndelim, mindelim; int width, half_gi, ndelim, mindelim;
/* Select standard number of delimiters based on frame length alone */ /* Select standard number of delimiters based on frame length alone */
...@@ -558,7 +587,6 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid, ...@@ -558,7 +587,6 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
rix = tx_info->control.rates[0].idx; rix = tx_info->control.rates[0].idx;
flags = tx_info->control.rates[0].flags; flags = tx_info->control.rates[0].flags;
rc = rt->info[rix].ratecode;
width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0; width = (flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ? 1 : 0;
half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0; half_gi = (flags & IEEE80211_TX_RC_SHORT_GI) ? 1 : 0;
...@@ -570,7 +598,7 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid, ...@@ -570,7 +598,7 @@ static int ath_compute_num_delims(struct ath_softc *sc, struct ath_atx_tid *tid,
if (nsymbols == 0) if (nsymbols == 0)
nsymbols = 1; nsymbols = 1;
nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width]; nsymbits = bits_per_symbol[rix][width];
minlen = (nsymbols * nsymbits) / BITS_PER_BYTE; minlen = (nsymbols * nsymbits) / BITS_PER_BYTE;
if (frmlen < minlen) { if (frmlen < minlen) {
...@@ -1425,22 +1453,14 @@ static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb, ...@@ -1425,22 +1453,14 @@ static int setup_tx_flags(struct ath_softc *sc, struct sk_buff *skb,
static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
int width, int half_gi, bool shortPreamble) int width, int half_gi, bool shortPreamble)
{ {
const struct ath_rate_table *rate_table = sc->cur_rate_table;
u32 nbits, nsymbits, duration, nsymbols; u32 nbits, nsymbits, duration, nsymbols;
u8 rc;
int streams, pktlen; int streams, pktlen;
pktlen = bf_isaggr(bf) ? bf->bf_al : bf->bf_frmlen; pktlen = bf_isaggr(bf) ? bf->bf_al : bf->bf_frmlen;
rc = rate_table->info[rix].ratecode;
/* for legacy rates, use old function to compute packet duration */
if (!IS_HT_RATE(rc))
return ath9k_hw_computetxtime(sc->sc_ah, rate_table, pktlen,
rix, shortPreamble);
/* find number of symbols: PLCP + data */ /* find number of symbols: PLCP + data */
nbits = (pktlen << 3) + OFDM_PLCP_BITS; nbits = (pktlen << 3) + OFDM_PLCP_BITS;
nsymbits = bits_per_symbol[HT_RC_2_MCS(rc)][width]; nsymbits = bits_per_symbol[rix][width];
nsymbols = (nbits + nsymbits - 1) / nsymbits; nsymbols = (nbits + nsymbits - 1) / nsymbits;
if (!half_gi) if (!half_gi)
...@@ -1449,7 +1469,7 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, ...@@ -1449,7 +1469,7 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
duration = SYMBOL_TIME_HALFGI(nsymbols); duration = SYMBOL_TIME_HALFGI(nsymbols);
/* addup duration for legacy/ht training and signal fields */ /* addup duration for legacy/ht training and signal fields */
streams = HT_RC_2_STREAMS(rc); streams = HT_RC_2_STREAMS(rix);
duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams); duration += L_STF + L_LTF + L_SIG + HT_SIG + HT_STF + HT_LTF(streams);
return duration; return duration;
...@@ -1458,11 +1478,11 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf, ...@@ -1458,11 +1478,11 @@ static u32 ath_pkt_duration(struct ath_softc *sc, u8 rix, struct ath_buf *bf,
static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
{ {
struct ath_common *common = ath9k_hw_common(sc->sc_ah); struct ath_common *common = ath9k_hw_common(sc->sc_ah);
const struct ath_rate_table *rt = sc->cur_rate_table;
struct ath9k_11n_rate_series series[4]; struct ath9k_11n_rate_series series[4];
struct sk_buff *skb; struct sk_buff *skb;
struct ieee80211_tx_info *tx_info; struct ieee80211_tx_info *tx_info;
struct ieee80211_tx_rate *rates; struct ieee80211_tx_rate *rates;
const struct ieee80211_rate *rate;
struct ieee80211_hdr *hdr; struct ieee80211_hdr *hdr;
int i, flags = 0; int i, flags = 0;
u8 rix = 0, ctsrate = 0; u8 rix = 0, ctsrate = 0;
...@@ -1481,11 +1501,10 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) ...@@ -1481,11 +1501,10 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
* checking the BSS's global flag. * checking the BSS's global flag.
* But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used. * But for the rate series, IEEE80211_TX_RC_USE_SHORT_PREAMBLE is used.
*/ */
rate = ieee80211_get_rts_cts_rate(sc->hw, tx_info);
ctsrate = rate->hw_value;
if (sc->sc_flags & SC_OP_PREAMBLE_SHORT) if (sc->sc_flags & SC_OP_PREAMBLE_SHORT)
ctsrate = rt->info[tx_info->control.rts_cts_rate_idx].ratecode | ctsrate |= rate->hw_value_short;
rt->info[tx_info->control.rts_cts_rate_idx].short_preamble;
else
ctsrate = rt->info[tx_info->control.rts_cts_rate_idx].ratecode;
/* /*
* ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive. * ATH9K_TXDESC_RTSENA and ATH9K_TXDESC_CTSENA are mutually exclusive.
...@@ -1508,6 +1527,9 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) ...@@ -1508,6 +1527,9 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
flags &= ~(ATH9K_TXDESC_RTSENA); flags &= ~(ATH9K_TXDESC_RTSENA);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
bool is_40, is_sgi, is_sp;
int phy;
if (!rates[i].count || (rates[i].idx < 0)) if (!rates[i].count || (rates[i].idx < 0))
continue; continue;
...@@ -1515,12 +1537,6 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) ...@@ -1515,12 +1537,6 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
series[i].Tries = rates[i].count; series[i].Tries = rates[i].count;
series[i].ChSel = common->tx_chainmask; series[i].ChSel = common->tx_chainmask;
if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
series[i].Rate = rt->info[rix].ratecode |
rt->info[rix].short_preamble;
else
series[i].Rate = rt->info[rix].ratecode;
if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS) if (rates[i].flags & IEEE80211_TX_RC_USE_RTS_CTS)
series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS; series[i].RateFlags |= ATH9K_RATESERIES_RTS_CTS;
if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) if (rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
...@@ -1528,10 +1544,36 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf) ...@@ -1528,10 +1544,36 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf)
if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI) if (rates[i].flags & IEEE80211_TX_RC_SHORT_GI)
series[i].RateFlags |= ATH9K_RATESERIES_HALFGI; series[i].RateFlags |= ATH9K_RATESERIES_HALFGI;
is_sgi = !!(rates[i].flags & IEEE80211_TX_RC_SHORT_GI);
is_40 = !!(rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH);
is_sp = !!(rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE);
if (rates[i].flags & IEEE80211_TX_RC_MCS) {
/* MCS rates */
series[i].Rate = rix | 0x80;
series[i].PktDuration = ath_pkt_duration(sc, rix, bf, series[i].PktDuration = ath_pkt_duration(sc, rix, bf,
(rates[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH) != 0, is_40, is_sgi, is_sp);
(rates[i].flags & IEEE80211_TX_RC_SHORT_GI), continue;
(rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)); }
/* legcay rates */
if ((tx_info->band == IEEE80211_BAND_2GHZ) &&
!(rate->flags & IEEE80211_RATE_ERP_G))
phy = WLAN_RC_PHY_CCK;
else
phy = WLAN_RC_PHY_OFDM;
rate = &sc->sbands[tx_info->band].bitrates[rates[i].idx];
series[i].Rate = rate->hw_value;
if (rate->hw_value_short) {
if (rates[i].flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE)
series[i].Rate |= rate->hw_value_short;
} else {
is_sp = false;
}
series[i].PktDuration = ath9k_hw_computetxtime(sc->sc_ah,
phy, rate->bitrate * 100, bf->bf_frmlen, rix, is_sp);
} }
/* set dur_update_en for l-sig computation except for PS-Poll frames */ /* set dur_update_en for l-sig computation except for PS-Poll frames */
...@@ -1920,8 +1962,10 @@ static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds, ...@@ -1920,8 +1962,10 @@ static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds,
} }
} }
for (i = tx_rateindex + 1; i < hw->max_rates; i++) for (i = tx_rateindex + 1; i < hw->max_rates; i++) {
tx_info->status.rates[i].count = 0; tx_info->status.rates[i].count = 0;
tx_info->status.rates[i].idx = -1;
}
tx_info->status.rates[tx_rateindex].count = bf->bf_retries + 1; tx_info->status.rates[tx_rateindex].count = bf->bf_retries + 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