diff options
author | Felix Fietkau <nbd@openwrt.org> | 2009-11-23 16:21:01 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-28 15:04:24 -0500 |
commit | 545750d36fa78203e28acefb4bab61ebb7c4d197 (patch) | |
tree | c9810428acf0bd673c6cd9ed74e6eb273c923842 /drivers/net/wireless/ath/ath9k/main.c | |
parent | 04658fba2314d6d70d5fa05c0b5995e6428aacc3 (diff) |
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: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/main.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/main.c | 112 |
1 files changed, 41 insertions, 71 deletions
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index cbf5d2a1bb26..bd1e2de3a1f9 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -104,37 +104,55 @@ static struct ieee80211_channel ath9k_5ghz_chantable[] = { | |||
104 | CHAN5G(5825, 37), /* Channel 165 */ | 104 | CHAN5G(5825, 37), /* Channel 165 */ |
105 | }; | 105 | }; |
106 | 106 | ||
107 | /* Atheros hardware rate code addition for short premble */ | ||
108 | #define SHPCHECK(__hw_rate, __flags) \ | ||
109 | ((__flags & IEEE80211_RATE_SHORT_PREAMBLE) ? (__hw_rate | 0x04 ) : 0) | ||
110 | |||
111 | #define RATE(_bitrate, _hw_rate, _flags) { \ | ||
112 | .bitrate = (_bitrate), \ | ||
113 | .flags = (_flags), \ | ||
114 | .hw_value = (_hw_rate), \ | ||
115 | .hw_value_short = (SHPCHECK(_hw_rate, _flags)) \ | ||
116 | } | ||
117 | |||
118 | static struct ieee80211_rate ath9k_legacy_rates[] = { | ||
119 | RATE(10, 0x1b, 0), | ||
120 | RATE(20, 0x1a, IEEE80211_RATE_SHORT_PREAMBLE), | ||
121 | RATE(55, 0x19, IEEE80211_RATE_SHORT_PREAMBLE), | ||
122 | RATE(110, 0x18, IEEE80211_RATE_SHORT_PREAMBLE), | ||
123 | RATE(60, 0x0b, 0), | ||
124 | RATE(90, 0x0f, 0), | ||
125 | RATE(120, 0x0a, 0), | ||
126 | RATE(180, 0x0e, 0), | ||
127 | RATE(240, 0x09, 0), | ||
128 | RATE(360, 0x0d, 0), | ||
129 | RATE(480, 0x08, 0), | ||
130 | RATE(540, 0x0c, 0), | ||
131 | }; | ||
132 | |||
107 | static void ath_cache_conf_rate(struct ath_softc *sc, | 133 | static void ath_cache_conf_rate(struct ath_softc *sc, |
108 | struct ieee80211_conf *conf) | 134 | struct ieee80211_conf *conf) |
109 | { | 135 | { |
110 | switch (conf->channel->band) { | 136 | switch (conf->channel->band) { |
111 | case IEEE80211_BAND_2GHZ: | 137 | case IEEE80211_BAND_2GHZ: |
112 | if (conf_is_ht20(conf)) | 138 | if (conf_is_ht20(conf)) |
113 | sc->cur_rate_table = | 139 | sc->cur_rate_mode = ATH9K_MODE_11NG_HT20; |
114 | sc->hw_rate_table[ATH9K_MODE_11NG_HT20]; | ||
115 | else if (conf_is_ht40_minus(conf)) | 140 | else if (conf_is_ht40_minus(conf)) |
116 | sc->cur_rate_table = | 141 | sc->cur_rate_mode = ATH9K_MODE_11NG_HT40MINUS; |
117 | sc->hw_rate_table[ATH9K_MODE_11NG_HT40MINUS]; | ||
118 | else if (conf_is_ht40_plus(conf)) | 142 | else if (conf_is_ht40_plus(conf)) |
119 | sc->cur_rate_table = | 143 | sc->cur_rate_mode = ATH9K_MODE_11NG_HT40PLUS; |
120 | sc->hw_rate_table[ATH9K_MODE_11NG_HT40PLUS]; | ||
121 | else | 144 | else |
122 | sc->cur_rate_table = | 145 | sc->cur_rate_mode = ATH9K_MODE_11G; |
123 | sc->hw_rate_table[ATH9K_MODE_11G]; | ||
124 | break; | 146 | break; |
125 | case IEEE80211_BAND_5GHZ: | 147 | case IEEE80211_BAND_5GHZ: |
126 | if (conf_is_ht20(conf)) | 148 | if (conf_is_ht20(conf)) |
127 | sc->cur_rate_table = | 149 | sc->cur_rate_mode = ATH9K_MODE_11NA_HT20; |
128 | sc->hw_rate_table[ATH9K_MODE_11NA_HT20]; | ||
129 | else if (conf_is_ht40_minus(conf)) | 150 | else if (conf_is_ht40_minus(conf)) |
130 | sc->cur_rate_table = | 151 | sc->cur_rate_mode = ATH9K_MODE_11NA_HT40MINUS; |
131 | sc->hw_rate_table[ATH9K_MODE_11NA_HT40MINUS]; | ||
132 | else if (conf_is_ht40_plus(conf)) | 152 | else if (conf_is_ht40_plus(conf)) |
133 | sc->cur_rate_table = | 153 | sc->cur_rate_mode = ATH9K_MODE_11NA_HT40PLUS; |
134 | sc->hw_rate_table[ATH9K_MODE_11NA_HT40PLUS]; | ||
135 | else | 154 | else |
136 | sc->cur_rate_table = | 155 | sc->cur_rate_mode = ATH9K_MODE_11A; |
137 | sc->hw_rate_table[ATH9K_MODE_11A]; | ||
138 | break; | 156 | break; |
139 | default: | 157 | default: |
140 | BUG_ON(1); | 158 | BUG_ON(1); |
@@ -190,51 +208,6 @@ static u8 parse_mpdudensity(u8 mpdudensity) | |||
190 | } | 208 | } |
191 | } | 209 | } |
192 | 210 | ||
193 | static void ath_setup_rates(struct ath_softc *sc, enum ieee80211_band band) | ||
194 | { | ||
195 | const struct ath_rate_table *rate_table = NULL; | ||
196 | struct ieee80211_supported_band *sband; | ||
197 | struct ieee80211_rate *rate; | ||
198 | int i, maxrates; | ||
199 | |||
200 | switch (band) { | ||
201 | case IEEE80211_BAND_2GHZ: | ||
202 | rate_table = sc->hw_rate_table[ATH9K_MODE_11G]; | ||
203 | break; | ||
204 | case IEEE80211_BAND_5GHZ: | ||
205 | rate_table = sc->hw_rate_table[ATH9K_MODE_11A]; | ||
206 | break; | ||
207 | default: | ||
208 | break; | ||
209 | } | ||
210 | |||
211 | if (rate_table == NULL) | ||
212 | return; | ||
213 | |||
214 | sband = &sc->sbands[band]; | ||
215 | rate = sc->rates[band]; | ||
216 | |||
217 | if (rate_table->rate_cnt > ATH_RATE_MAX) | ||
218 | maxrates = ATH_RATE_MAX; | ||
219 | else | ||
220 | maxrates = rate_table->rate_cnt; | ||
221 | |||
222 | for (i = 0; i < maxrates; i++) { | ||
223 | rate[i].bitrate = rate_table->info[i].ratekbps / 100; | ||
224 | rate[i].hw_value = rate_table->info[i].ratecode; | ||
225 | if (rate_table->info[i].short_preamble) { | ||
226 | rate[i].hw_value_short = rate_table->info[i].ratecode | | ||
227 | rate_table->info[i].short_preamble; | ||
228 | rate[i].flags = IEEE80211_RATE_SHORT_PREAMBLE; | ||
229 | } | ||
230 | sband->n_bitrates++; | ||
231 | |||
232 | ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG, | ||
233 | "Rate: %2dMbps, ratecode: %2d\n", | ||
234 | rate[i].bitrate / 10, rate[i].hw_value); | ||
235 | } | ||
236 | } | ||
237 | |||
238 | static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc, | 211 | static struct ath9k_channel *ath_get_curchannel(struct ath_softc *sc, |
239 | struct ieee80211_hw *hw) | 212 | struct ieee80211_hw *hw) |
240 | { | 213 | { |
@@ -1701,12 +1674,6 @@ static int ath_init_softc(u16 devid, struct ath_softc *sc, u16 subsysid, | |||
1701 | /* default to MONITOR mode */ | 1674 | /* default to MONITOR mode */ |
1702 | sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR; | 1675 | sc->sc_ah->opmode = NL80211_IFTYPE_MONITOR; |
1703 | 1676 | ||
1704 | /* Setup rate tables */ | ||
1705 | |||
1706 | ath_rate_attach(sc); | ||
1707 | ath_setup_rates(sc, IEEE80211_BAND_2GHZ); | ||
1708 | ath_setup_rates(sc, IEEE80211_BAND_5GHZ); | ||
1709 | |||
1710 | /* | 1677 | /* |
1711 | * Allocate hardware transmit queues: one queue for | 1678 | * Allocate hardware transmit queues: one queue for |
1712 | * beacon frames and one data queue for each QoS | 1679 | * 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 | /* setup channels and rates */ | 1794 | /* setup channels and rates */ |
1828 | 1795 | ||
1829 | sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable; | 1796 | sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable; |
1830 | sc->sbands[IEEE80211_BAND_2GHZ].bitrates = | ||
1831 | sc->rates[IEEE80211_BAND_2GHZ]; | ||
1832 | sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; | 1797 | sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ; |
1833 | sc->sbands[IEEE80211_BAND_2GHZ].n_channels = | 1798 | sc->sbands[IEEE80211_BAND_2GHZ].n_channels = |
1834 | ARRAY_SIZE(ath9k_2ghz_chantable); | 1799 | ARRAY_SIZE(ath9k_2ghz_chantable); |
1800 | sc->sbands[IEEE80211_BAND_2GHZ].bitrates = ath9k_legacy_rates; | ||
1801 | sc->sbands[IEEE80211_BAND_2GHZ].n_bitrates = | ||
1802 | ARRAY_SIZE(ath9k_legacy_rates); | ||
1835 | 1803 | ||
1836 | if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) { | 1804 | if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) { |
1837 | sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable; | 1805 | sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable; |
1838 | sc->sbands[IEEE80211_BAND_5GHZ].bitrates = | ||
1839 | sc->rates[IEEE80211_BAND_5GHZ]; | ||
1840 | sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; | 1806 | sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ; |
1841 | sc->sbands[IEEE80211_BAND_5GHZ].n_channels = | 1807 | sc->sbands[IEEE80211_BAND_5GHZ].n_channels = |
1842 | ARRAY_SIZE(ath9k_5ghz_chantable); | 1808 | ARRAY_SIZE(ath9k_5ghz_chantable); |
1809 | sc->sbands[IEEE80211_BAND_5GHZ].bitrates = | ||
1810 | ath9k_legacy_rates + 4; | ||
1811 | sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates = | ||
1812 | ARRAY_SIZE(ath9k_legacy_rates) - 4; | ||
1843 | } | 1813 | } |
1844 | 1814 | ||
1845 | switch (ah->btcoex_hw.scheme) { | 1815 | switch (ah->btcoex_hw.scheme) { |