diff options
Diffstat (limited to 'net/mac80211/rc80211_simple.c')
-rw-r--r-- | net/mac80211/rc80211_simple.c | 82 |
1 files changed, 37 insertions, 45 deletions
diff --git a/net/mac80211/rc80211_simple.c b/net/mac80211/rc80211_simple.c index da72737364e..934676d687d 100644 --- a/net/mac80211/rc80211_simple.c +++ b/net/mac80211/rc80211_simple.c @@ -13,6 +13,7 @@ #include <linux/slab.h> #include <linux/skbuff.h> #include <linux/compiler.h> +#include <linux/module.h> #include <net/mac80211.h> #include "ieee80211_i.h" @@ -23,6 +24,8 @@ /* This is a minimal implementation of TX rate controlling that can be used * as the default when no improved mechanisms are available. */ +#define RATE_CONTROL_NUM_DOWN 20 +#define RATE_CONTROL_NUM_UP 15 #define RATE_CONTROL_EMERG_DEC 2 #define RATE_CONTROL_INTERVAL (HZ / 20) @@ -87,26 +90,6 @@ static void rate_control_rate_dec(struct ieee80211_local *local, } } - -static struct ieee80211_rate * -rate_control_lowest_rate(struct ieee80211_local *local, - struct ieee80211_hw_mode *mode) -{ - int i; - - for (i = 0; i < mode->num_rates; i++) { - struct ieee80211_rate *rate = &mode->rates[i]; - - if (rate->flags & IEEE80211_RATE_SUPPORTED) - return rate; - } - - printk(KERN_DEBUG "rate_control_lowest_rate - no supported rates " - "found\n"); - return &mode->rates[0]; -} - - struct global_rate_control { int dummy; }; @@ -216,35 +199,33 @@ static void rate_control_simple_tx_status(void *priv, struct net_device *dev, } -static struct ieee80211_rate * +static void rate_control_simple_get_rate(void *priv, struct net_device *dev, + struct ieee80211_hw_mode *mode, struct sk_buff *skb, - struct rate_control_extra *extra) + struct rate_selection *sel) { struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); - struct ieee80211_sub_if_data *sdata; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; - struct ieee80211_hw_mode *mode = extra->mode; + struct ieee80211_sub_if_data *sdata; struct sta_info *sta; - int rateidx, nonerp_idx; + int rateidx; u16 fc; - memset(extra, 0, sizeof(*extra)); + sta = sta_info_get(local, hdr->addr1); + /* Send management frames and broadcast/multicast data using lowest + * rate. */ fc = le16_to_cpu(hdr->frame_control); if ((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA || - (hdr->addr1[0] & 0x01)) { - /* Send management frames and broadcast/multicast data using - * lowest rate. */ - /* TODO: this could probably be improved.. */ - return rate_control_lowest_rate(local, mode); + is_multicast_ether_addr(hdr->addr1) || !sta) { + sel->rate = rate_lowest(local, mode, sta); + if (sta) + sta_info_put(sta); + return; } - sta = sta_info_get(local, hdr->addr1); - - if (!sta) - return rate_control_lowest_rate(local, mode); - + /* If a forced rate is in effect, select it. */ sdata = IEEE80211_DEV_TO_SUB_IF(dev); if (sdata->bss && sdata->bss->force_unicast_rateidx > -1) sta->txrate = sdata->bss->force_unicast_rateidx; @@ -255,17 +236,10 @@ rate_control_simple_get_rate(void *priv, struct net_device *dev, rateidx = mode->num_rates - 1; sta->last_txrate = rateidx; - nonerp_idx = rateidx; - while (nonerp_idx > 0 && - ((mode->rates[nonerp_idx].flags & IEEE80211_RATE_ERP) || - !(mode->rates[nonerp_idx].flags & IEEE80211_RATE_SUPPORTED) || - !(sta->supp_rates & BIT(nonerp_idx)))) - nonerp_idx--; - extra->nonerp = &mode->rates[nonerp_idx]; sta_info_put(sta); - return &mode->rates[rateidx]; + sel->rate = &mode->rates[rateidx]; } @@ -391,7 +365,7 @@ static void rate_control_simple_remove_sta_debugfs(void *priv, void *priv_sta) } #endif -struct rate_control_ops mac80211_rcsimple = { +static struct rate_control_ops mac80211_rcsimple = { .name = "simple", .tx_status = rate_control_simple_tx_status, .get_rate = rate_control_simple_get_rate, @@ -406,3 +380,21 @@ struct rate_control_ops mac80211_rcsimple = { .remove_sta_debugfs = rate_control_simple_remove_sta_debugfs, #endif }; + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Simple rate control algorithm"); + +int __init rc80211_simple_init(void) +{ + return ieee80211_rate_control_register(&mac80211_rcsimple); +} + +void __exit rc80211_simple_exit(void) +{ + ieee80211_rate_control_unregister(&mac80211_rcsimple); +} + +#ifdef CONFIG_MAC80211_RC_SIMPLE_MODULE +module_init(rc80211_simple_init); +module_exit(rc80211_simple_exit); +#endif |