Commit 81cb7623ad3b408f871fa36b774fc20d8dfccac0

Authored by Sujith
Committed by John W. Linville
1 parent b06e786d4c

mac80211: Extend the rate control API with an update callback

The AP can switch dynamically between 20/40 Mhz channel width,
in which case we switch the local operating channel, but the
rate control algorithm is not notified. This patch adds a new callback
to indicate such changes to the RC algorithm.

Currently, HT channel width change is notified, but this callback
can be used to indicate any new requirements that might come up later on.

Signed-off-by: Sujith <Sujith.Manoharan@atheros.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Showing 3 changed files with 38 additions and 0 deletions Side-by-side Diff

include/net/mac80211.h
... ... @@ -1975,6 +1975,16 @@
1975 1975 /* Rate control API */
1976 1976  
1977 1977 /**
  1978 + * enum rate_control_changed - flags to indicate which parameter changed
  1979 + *
  1980 + * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have
  1981 + * changed, rate control algorithm can update its internal state if needed.
  1982 + */
  1983 +enum rate_control_changed {
  1984 + IEEE80211_RC_HT_CHANGED = BIT(0)
  1985 +};
  1986 +
  1987 +/**
1978 1988 * struct ieee80211_tx_rate_control - rate control information for/from RC algo
1979 1989 *
1980 1990 * @hw: The hardware the algorithm is invoked for.
... ... @@ -2010,6 +2020,9 @@
2010 2020 void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp);
2011 2021 void (*rate_init)(void *priv, struct ieee80211_supported_band *sband,
2012 2022 struct ieee80211_sta *sta, void *priv_sta);
  2023 + void (*rate_update)(void *priv, struct ieee80211_supported_band *sband,
  2024 + struct ieee80211_sta *sta,
  2025 + void *priv_sta, u32 changed);
2013 2026 void (*free_sta)(void *priv, struct ieee80211_sta *sta,
2014 2027 void *priv_sta);
2015 2028  
... ... @@ -17,6 +17,7 @@
17 17 #include <net/wireless.h>
18 18 #include <net/mac80211.h>
19 19 #include "ieee80211_i.h"
  20 +#include "rate.h"
20 21  
21 22 void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband,
22 23 struct ieee80211_ht_cap *ht_cap_ie,
23 24  
... ... @@ -93,7 +94,9 @@
93 94 {
94 95 struct ieee80211_local *local = sdata->local;
95 96 struct ieee80211_supported_band *sband;
  97 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd;
96 98 struct ieee80211_bss_ht_conf ht;
  99 + struct sta_info *sta;
97 100 u32 changed = 0;
98 101 bool enable_ht = true, ht_changed;
99 102 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT;
... ... @@ -136,6 +139,16 @@
136 139 if (ht_changed) {
137 140 /* channel_type change automatically detected */
138 141 ieee80211_hw_config(local, 0);
  142 +
  143 + rcu_read_lock();
  144 +
  145 + sta = sta_info_get(local, ifmgd->bssid);
  146 + if (sta)
  147 + rate_control_rate_update(local, sband, sta,
  148 + IEEE80211_RC_HT_CHANGED);
  149 +
  150 + rcu_read_unlock();
  151 +
139 152 }
140 153  
141 154 /* disable HT */
... ... @@ -62,6 +62,18 @@
62 62 ref->ops->rate_init(ref->priv, sband, ista, priv_sta);
63 63 }
64 64  
  65 +static inline void rate_control_rate_update(struct ieee80211_local *local,
  66 + struct ieee80211_supported_band *sband,
  67 + struct sta_info *sta, u32 changed)
  68 +{
  69 + struct rate_control_ref *ref = local->rate_ctrl;
  70 + struct ieee80211_sta *ista = &sta->sta;
  71 + void *priv_sta = sta->rate_ctrl_priv;
  72 +
  73 + if (ref->ops->rate_update)
  74 + ref->ops->rate_update(ref->priv, sband, ista,
  75 + priv_sta, changed);
  76 +}
65 77  
66 78 static inline void *rate_control_alloc_sta(struct rate_control_ref *ref,
67 79 struct ieee80211_sta *sta,