diff options
author | Mattias Nissler <mattias.nissler@gmx.de> | 2007-12-20 13:50:07 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 14:59:17 -0800 |
commit | 1abbe498e4b5e4f2000dfc30a0fa25be9553530e (patch) | |
tree | 8f899d2f623b2316f874fd8ae4b84838ad4e8b40 /drivers/net/wireless | |
parent | 98f0b0a3a412eade153c7cf00c6b863600980d89 (diff) |
mac80211: clean up rate selection
Move some code out of rc80211_simple since it's probably needed for all rate
selection algorithms, and fix iwlwifi accordingly. While at it, clean up the
rate_control_get_rate() interface.
Signed-off-by: Stefano Brivio <stefano.brivio@polimi.it>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-rs.c | 44 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965-rs.c | 46 |
2 files changed, 17 insertions, 73 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c index c48b1b537d2..ea7f459e961 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945-rs.c @@ -562,22 +562,6 @@ static void rs_tx_status(void *priv_rate, return; } -static struct ieee80211_rate *iwl_get_lowest_rate(struct ieee80211_local - *local) -{ - struct ieee80211_hw_mode *mode = local->oper_hw_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; - } - - return &mode->rates[0]; -} - static u16 iwl_get_adjacent_rate(struct iwl_rate_scale_priv *rs_priv, u8 index, u16 rate_mask, int phymode) { @@ -656,10 +640,9 @@ static u16 iwl_get_adjacent_rate(struct iwl_rate_scale_priv *rs_priv, * rate table and must reference the driver allocated rate table * */ -static struct ieee80211_rate *rs_get_rate(void *priv_rate, - struct net_device *dev, - struct sk_buff *skb, - struct rate_control_extra *extra) +static void rs_get_rate(void *priv_rate, struct net_device *dev, + struct ieee80211_hw_mode *mode, struct sk_buff *skb, + struct rate_selection *sel) { u8 low = IWL_RATE_INVALID; u8 high = IWL_RATE_INVALID; @@ -676,32 +659,19 @@ static struct ieee80211_rate *rs_get_rate(void *priv_rate, struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct sta_info *sta; - u16 fc, rate_mask; + u16 rate_mask; struct iwl_priv *priv = (struct iwl_priv *)priv_rate; DECLARE_MAC_BUF(mac); IWL_DEBUG_RATE("enter\n"); - memset(extra, 0, sizeof(*extra)); - - fc = le16_to_cpu(hdr->frame_control); - if (((fc & IEEE80211_FCTL_FTYPE) != IEEE80211_FTYPE_DATA) || - (is_multicast_ether_addr(hdr->addr1))) { - /* Send management frames and broadcast/multicast data using - * lowest rate. */ - /* TODO: this could probably be improved.. */ - IWL_DEBUG_RATE("leave: lowest rate (not data or is " - "multicast)\n"); - - return iwl_get_lowest_rate(local); - } - sta = sta_info_get(local, hdr->addr1); if (!sta || !sta->rate_ctrl_priv) { IWL_DEBUG_RATE("leave: No STA priv data to update!\n"); + sel->rate = rate_lowest(local, local->oper_hw_mode, sta); if (sta) sta_info_put(sta); - return NULL; + return; } rate_mask = sta->supp_rates; @@ -846,7 +816,7 @@ static struct ieee80211_rate *rs_get_rate(void *priv_rate, IWL_DEBUG_RATE("leave: %d\n", index); - return &priv->ieee_rates[index]; + sel->rate = &priv->ieee_rates[index]; } static struct rate_control_ops rs_ops = { diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c index 8dc78c0bf1f..62a3b52b327 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-rs.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965-rs.c @@ -1693,55 +1693,27 @@ static void rs_initialize_lq(struct iwl_priv *priv, return; } -static struct ieee80211_rate *rs_get_lowest_rate(struct ieee80211_local - *local) -{ - struct ieee80211_hw_mode *mode = local->oper_hw_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; - } - - return &mode->rates[0]; -} - -static struct ieee80211_rate *rs_get_rate(void *priv_rate, - struct net_device *dev, - struct sk_buff *skb, - struct rate_control_extra - *extra) +static void rs_get_rate(void *priv_rate, struct net_device *dev, + struct ieee80211_hw_mode *mode, struct sk_buff *skb, + struct rate_selection *sel) { int i; struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; struct sta_info *sta; - u16 fc; struct iwl_priv *priv = (struct iwl_priv *)priv_rate; struct iwl_rate_scale_priv *lq; IWL_DEBUG_RATE_LIMIT("rate scale calculate new rate for skb\n"); - memset(extra, 0, sizeof(*extra)); - - fc = le16_to_cpu(hdr->frame_control); - if (!ieee80211_is_data(fc) || is_multicast_ether_addr(hdr->addr1)) { - /* Send management frames and broadcast/multicast data using - * lowest rate. */ - /* TODO: this could probably be improved.. */ - return rs_get_lowest_rate(local); - } - sta = sta_info_get(local, hdr->addr1); if (!sta || !sta->rate_ctrl_priv) { + sel->rate = rate_lowest(local, local->oper_hw_mode, sta); if (sta) sta_info_put(sta); - return rs_get_lowest_rate(local); + return; } lq = (struct iwl_rate_scale_priv *)sta->rate_ctrl_priv; @@ -1768,11 +1740,13 @@ static struct ieee80211_rate *rs_get_rate(void *priv_rate, } done: + if ((i < 0) || (i > IWL_RATE_COUNT)) { + sel->rate = rate_lowest(local, local->oper_hw_mode, sta); + return; + } sta_info_put(sta); - if ((i < 0) || (i > IWL_RATE_COUNT)) - return rs_get_lowest_rate(local); - return &priv->ieee_rates[i]; + sel->rate = &priv->ieee_rates[i]; } static void *rs_alloc_sta(void *priv, gfp_t gfp) |