Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
#include <linux/device.h>
#include <linux/leds.h>

#include "rc.h"
#include "debug.h"
#include "common.h"

@@ -423,6 +422,7 @@ struct ath_led {
#define SC_OP_BT_PRIORITY_DETECTED BIT(21)

struct ath_wiphy;
struct ath_rate_table;

struct ath_softc {
	struct ieee80211_hw *hw;
@@ -467,9 +467,8 @@ struct ath_softc {
	struct ath_rx rx;
	struct ath_tx tx;
	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;
	enum wireless_mode cur_rate_mode;
	struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS];

	struct ath_led radio_led;
+5 −5
Original line number Diff line number Diff line
@@ -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_desc *ds;
	struct ath9k_11n_rate_series series[4];
	const struct ath_rate_table *rt;
	int flags, antenna, ctsrate = 0, ctsduration = 0;
	u8 rate;
	struct ieee80211_supported_band *sband;
	u8 rate = 0;

	ds = bf->bf_desc;
	flags = ATH9K_TXDESC_NOACK;
@@ -91,10 +91,10 @@ static void ath_beacon_setup(struct ath_softc *sc, struct ath_vif *avp,

	ds->ds_data = bf->bf_buf_addr;

	rt = sc->cur_rate_table;
	rate = rt->info[0].ratecode;
	sband = &sc->sbands[common->hw->conf.channel->band];
	rate = sband->bitrates[0].hw_value;
	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_PKT_TYPE_BEACON,
+2 −12
Original line number Diff line number Diff line
@@ -255,21 +255,11 @@ static const struct file_operations fops_interrupt = {
	.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;

	for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {
		if (!rates[i].count)
			break;

		final_ts_idx = i;
	}
	idx = rates[final_ts_idx].idx;
	stats = &sc->debug.stats.rcstats[idx];
	stats = &sc->debug.stats.rcstats[final_rate];
	stats->success++;
}

+3 −2
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#define DEBUG_H

#include "hw.h"
#include "rc.h"

struct ath_txq;
struct ath_buf;
@@ -138,7 +139,7 @@ void ath9k_exit_debug(struct ath_hw *ah);
int ath9k_debug_create_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_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,
		       struct ath_buf *bf);
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,
}

static inline void ath_debug_stat_rc(struct ath_softc *sc,
				     struct sk_buff *skb)
				     int final_rate)
{
}

+4 −8
Original line number Diff line number Diff line
@@ -148,22 +148,19 @@ bool ath9k_get_channel_edges(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 bitsPerSymbol, numBits, numSymbols, phyTime, txTime;
	u32 kbps;

	kbps = rates->info[rateix].ratekbps;

	if (kbps == 0)
		return 0;

	switch (rates->info[rateix].phy) {
	switch (phy) {
	case WLAN_RC_PHY_CCK:
		phyTime = CCK_PREAMBLE_BITS + CCK_PLCP_BITS;
		if (shortPreamble && rates->info[rateix].short_preamble)
		if (shortPreamble)
			phyTime >>= 1;
		numBits = frameLen << 3;
		txTime = CCK_SIFS_TIME + phyTime + ((numBits * 1000) / kbps);
@@ -194,8 +191,7 @@ u16 ath9k_hw_computetxtime(struct ath_hw *ah,
		break;
	default:
		ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
			  "Unknown phy %u (rate ix %u)\n",
			  rates->info[rateix].phy, rateix);
			  "Unknown phy %u (rate ix %u)\n", phy, rateix);
		txTime = 0;
		break;
	}
Loading