aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/rc80211_simple.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-01-24 13:38:38 -0500
committerJohn W. Linville <linville@tuxdriver.com>2008-02-29 15:19:32 -0500
commit8318d78a44d49ac1edf2bdec7299de3617c4232e (patch)
treed434634418edd7399737801615d247be06616fdd /net/mac80211/rc80211_simple.c
parent10b6b80145cc93887dd8aab99bfffa375e9add31 (diff)
cfg80211 API for channels/bitrates, mac80211 and driver conversion
This patch creates new cfg80211 wiphy API for channel and bitrate registration and converts mac80211 and drivers to the new API. The old mac80211 API is completely ripped out. All drivers (except ath5k) are updated to the new API, in many cases I expect that optimisations can be done. Along with the regulatory code I've also ripped out the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag, I believe it to be unnecessary if the hardware simply gives us whatever channels it wants to support and we then enable/disable them as required, which is pretty much required for travelling. Additionally, the patch adds proper "basic" rate handling for STA mode interface, AP mode interface will have to have new API added to allow userspace to set the basic rate set, currently it'll be empty... However, the basic rate handling will need to be moved to the BSS conf stuff. I do expect there to be bugs in this, especially wrt. transmit power handling where I'm basically clueless about how it should work. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/rc80211_simple.c')
-rw-r--r--net/mac80211/rc80211_simple.c66
1 files changed, 29 insertions, 37 deletions
diff --git a/net/mac80211/rc80211_simple.c b/net/mac80211/rc80211_simple.c
index 9a78b116acf..c4678905a14 100644
--- a/net/mac80211/rc80211_simple.c
+++ b/net/mac80211/rc80211_simple.c
@@ -35,8 +35,8 @@ static void rate_control_rate_inc(struct ieee80211_local *local,
35 struct sta_info *sta) 35 struct sta_info *sta)
36{ 36{
37 struct ieee80211_sub_if_data *sdata; 37 struct ieee80211_sub_if_data *sdata;
38 struct ieee80211_hw_mode *mode; 38 struct ieee80211_supported_band *sband;
39 int i = sta->txrate; 39 int i = sta->txrate_idx;
40 int maxrate; 40 int maxrate;
41 41
42 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 42 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
@@ -45,18 +45,17 @@ static void rate_control_rate_inc(struct ieee80211_local *local,
45 return; 45 return;
46 } 46 }
47 47
48 mode = local->oper_hw_mode; 48 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
49 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1; 49 maxrate = sdata->bss ? sdata->bss->max_ratectrl_rateidx : -1;
50 50
51 if (i > mode->num_rates) 51 if (i > sband->n_bitrates)
52 i = mode->num_rates - 2; 52 i = sband->n_bitrates - 2;
53 53
54 while (i + 1 < mode->num_rates) { 54 while (i + 1 < sband->n_bitrates) {
55 i++; 55 i++;
56 if (sta->supp_rates & BIT(i) && 56 if (rate_supported(sta, sband->band, i) &&
57 mode->rates[i].flags & IEEE80211_RATE_SUPPORTED &&
58 (maxrate < 0 || i <= maxrate)) { 57 (maxrate < 0 || i <= maxrate)) {
59 sta->txrate = i; 58 sta->txrate_idx = i;
60 break; 59 break;
61 } 60 }
62 } 61 }
@@ -67,8 +66,8 @@ static void rate_control_rate_dec(struct ieee80211_local *local,
67 struct sta_info *sta) 66 struct sta_info *sta)
68{ 67{
69 struct ieee80211_sub_if_data *sdata; 68 struct ieee80211_sub_if_data *sdata;
70 struct ieee80211_hw_mode *mode; 69 struct ieee80211_supported_band *sband;
71 int i = sta->txrate; 70 int i = sta->txrate_idx;
72 71
73 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev); 72 sdata = IEEE80211_DEV_TO_SUB_IF(sta->dev);
74 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) { 73 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) {
@@ -76,15 +75,14 @@ static void rate_control_rate_dec(struct ieee80211_local *local,
76 return; 75 return;
77 } 76 }
78 77
79 mode = local->oper_hw_mode; 78 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
80 if (i > mode->num_rates) 79 if (i > sband->n_bitrates)
81 i = mode->num_rates; 80 i = sband->n_bitrates;
82 81
83 while (i > 0) { 82 while (i > 0) {
84 i--; 83 i--;
85 if (sta->supp_rates & BIT(i) && 84 if (rate_supported(sta, sband->band, i)) {
86 mode->rates[i].flags & IEEE80211_RATE_SUPPORTED) { 85 sta->txrate_idx = i;
87 sta->txrate = i;
88 break; 86 break;
89 } 87 }
90 } 88 }
@@ -168,7 +166,7 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev,
168 } else if (per_failed < RATE_CONTROL_NUM_UP) { 166 } else if (per_failed < RATE_CONTROL_NUM_UP) {
169 rate_control_rate_inc(local, sta); 167 rate_control_rate_inc(local, sta);
170 } 168 }
171 srctrl->tx_avg_rate_sum += status->control.rate->rate; 169 srctrl->tx_avg_rate_sum += status->control.tx_rate->bitrate;
172 srctrl->tx_avg_rate_num++; 170 srctrl->tx_avg_rate_num++;
173 srctrl->tx_num_failures = 0; 171 srctrl->tx_num_failures = 0;
174 srctrl->tx_num_xmit = 0; 172 srctrl->tx_num_xmit = 0;
@@ -201,7 +199,7 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev,
201 199
202static void 200static void
203rate_control_simple_get_rate(void *priv, struct net_device *dev, 201rate_control_simple_get_rate(void *priv, struct net_device *dev,
204 struct ieee80211_hw_mode *mode, 202 struct ieee80211_supported_band *sband,
205 struct sk_buff *skb, 203 struct sk_buff *skb,
206 struct rate_selection *sel) 204 struct rate_selection *sel)
207{ 205{
@@ -219,7 +217,7 @@ rate_control_simple_get_rate(void *priv, struct net_device *dev,
219 fc = le16_to_cpu(hdr->frame_control); 217 fc = le16_to_cpu(hdr->frame_control);
220 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || 218 if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA ||
221 is_multicast_ether_addr(hdr->addr1) || !sta) { 219 is_multicast_ether_addr(hdr->addr1) || !sta) {
222 sel->rate = rate_lowest(local, mode, sta); 220 sel->rate = rate_lowest(local, sband, sta);
223 if (sta) 221 if (sta)
224 sta_info_put(sta); 222 sta_info_put(sta);
225 return; 223 return;
@@ -228,18 +226,18 @@ rate_control_simple_get_rate(void *priv, struct net_device *dev,
228 /* If a forced rate is in effect, select it. */ 226 /* If a forced rate is in effect, select it. */
229 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 227 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
230 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) 228 if (sdata->bss && sdata->bss->force_unicast_rateidx > -1)
231 sta->txrate = sdata->bss->force_unicast_rateidx; 229 sta->txrate_idx = sdata->bss->force_unicast_rateidx;
232 230
233 rateidx = sta->txrate; 231 rateidx = sta->txrate_idx;
234 232
235 if (rateidx >= mode->num_rates) 233 if (rateidx >= sband->n_bitrates)
236 rateidx = mode->num_rates - 1; 234 rateidx = sband->n_bitrates - 1;
237 235
238 sta->last_txrate = rateidx; 236 sta->last_txrate_idx = rateidx;
239 237
240 sta_info_put(sta); 238 sta_info_put(sta);
241 239
242 sel->rate = &mode->rates[rateidx]; 240 sel->rate = &sband->bitrates[rateidx];
243} 241}
244 242
245 243
@@ -247,21 +245,15 @@ static void rate_control_simple_rate_init(void *priv, void *priv_sta,
247 struct ieee80211_local *local, 245 struct ieee80211_local *local,
248 struct sta_info *sta) 246 struct sta_info *sta)
249{ 247{
250 struct ieee80211_hw_mode *mode; 248 struct ieee80211_supported_band *sband;
251 int i; 249
252 sta->txrate = 0; 250 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
253 mode = local->oper_hw_mode; 251
254 /* TODO: This routine should consider using RSSI from previous packets 252 /* TODO: This routine should consider using RSSI from previous packets
255 * as we need to have IEEE 802.1X auth succeed immediately after assoc.. 253 * as we need to have IEEE 802.1X auth succeed immediately after assoc..
256 * Until that method is implemented, we will use the lowest supported rate 254 * Until that method is implemented, we will use the lowest supported rate
257 * as a workaround, */ 255 * as a workaround, */
258 for (i = 0; i < mode->num_rates; i++) { 256 sta->txrate_idx = rate_lowest_index(local, sband, sta);
259 if ((sta->supp_rates & BIT(i)) &&
260 (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) {
261 sta->txrate = i;
262 break;
263 }
264 }
265} 257}
266 258
267 259