diff options
author | Mattias Nissler <mattias.nissler@gmx.de> | 2007-12-20 07:50:07 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:59:17 -0500 |
commit | 1abbe498e4b5e4f2000dfc30a0fa25be9553530e (patch) | |
tree | 8f899d2f623b2316f874fd8ae4b84838ad4e8b40 /net/mac80211/ieee80211_rate.h | |
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 'net/mac80211/ieee80211_rate.h')
-rw-r--r-- | net/mac80211/ieee80211_rate.h | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/net/mac80211/ieee80211_rate.h b/net/mac80211/ieee80211_rate.h index 23688139ffb3..787134bd6abf 100644 --- a/net/mac80211/ieee80211_rate.h +++ b/net/mac80211/ieee80211_rate.h | |||
@@ -18,31 +18,24 @@ | |||
18 | #include "ieee80211_i.h" | 18 | #include "ieee80211_i.h" |
19 | #include "sta_info.h" | 19 | #include "sta_info.h" |
20 | 20 | ||
21 | #define RATE_CONTROL_NUM_DOWN 20 | 21 | struct rate_selection { |
22 | #define RATE_CONTROL_NUM_UP 15 | 22 | /* Selected transmission rate */ |
23 | 23 | struct ieee80211_rate *rate; | |
24 | 24 | /* Non-ERP rate to use if mac80211 decides it cannot use an ERP rate */ | |
25 | struct rate_control_extra { | ||
26 | /* values from rate_control_get_rate() to the caller: */ | ||
27 | struct ieee80211_rate *probe; /* probe with this rate, or NULL for no | ||
28 | * probing */ | ||
29 | struct ieee80211_rate *nonerp; | 25 | struct ieee80211_rate *nonerp; |
30 | 26 | /* probe with this rate, or NULL for no probing */ | |
31 | /* parameters from the caller to rate_control_get_rate(): */ | 27 | struct ieee80211_rate *probe; |
32 | struct ieee80211_hw_mode *mode; | ||
33 | u16 ethertype; | ||
34 | }; | 28 | }; |
35 | 29 | ||
36 | |||
37 | struct rate_control_ops { | 30 | struct rate_control_ops { |
38 | struct module *module; | 31 | struct module *module; |
39 | const char *name; | 32 | const char *name; |
40 | void (*tx_status)(void *priv, struct net_device *dev, | 33 | void (*tx_status)(void *priv, struct net_device *dev, |
41 | struct sk_buff *skb, | 34 | struct sk_buff *skb, |
42 | struct ieee80211_tx_status *status); | 35 | struct ieee80211_tx_status *status); |
43 | struct ieee80211_rate *(*get_rate)(void *priv, struct net_device *dev, | 36 | void (*get_rate)(void *priv, struct net_device *dev, |
44 | struct sk_buff *skb, | 37 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, |
45 | struct rate_control_extra *extra); | 38 | struct rate_selection *sel); |
46 | void (*rate_init)(void *priv, void *priv_sta, | 39 | void (*rate_init)(void *priv, void *priv_sta, |
47 | struct ieee80211_local *local, struct sta_info *sta); | 40 | struct ieee80211_local *local, struct sta_info *sta); |
48 | void (*clear)(void *priv); | 41 | void (*clear)(void *priv); |
@@ -75,25 +68,20 @@ void ieee80211_rate_control_unregister(struct rate_control_ops *ops); | |||
75 | * first available algorithm. */ | 68 | * first available algorithm. */ |
76 | struct rate_control_ref *rate_control_alloc(const char *name, | 69 | struct rate_control_ref *rate_control_alloc(const char *name, |
77 | struct ieee80211_local *local); | 70 | struct ieee80211_local *local); |
71 | void rate_control_get_rate(struct net_device *dev, | ||
72 | struct ieee80211_hw_mode *mode, struct sk_buff *skb, | ||
73 | struct rate_selection *sel); | ||
78 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); | 74 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); |
79 | void rate_control_put(struct rate_control_ref *ref); | 75 | void rate_control_put(struct rate_control_ref *ref); |
80 | 76 | ||
81 | static inline void rate_control_tx_status(struct ieee80211_local *local, | 77 | static inline void rate_control_tx_status(struct net_device *dev, |
82 | struct net_device *dev, | ||
83 | struct sk_buff *skb, | 78 | struct sk_buff *skb, |
84 | struct ieee80211_tx_status *status) | 79 | struct ieee80211_tx_status *status) |
85 | { | 80 | { |
81 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | ||
86 | struct rate_control_ref *ref = local->rate_ctrl; | 82 | struct rate_control_ref *ref = local->rate_ctrl; |
87 | ref->ops->tx_status(ref->priv, dev, skb, status); | ||
88 | } | ||
89 | 83 | ||
90 | 84 | ref->ops->tx_status(ref->priv, dev, skb, status); | |
91 | static inline struct ieee80211_rate * | ||
92 | rate_control_get_rate(struct ieee80211_local *local, struct net_device *dev, | ||
93 | struct sk_buff *skb, struct rate_control_extra *extra) | ||
94 | { | ||
95 | struct rate_control_ref *ref = local->rate_ctrl; | ||
96 | return ref->ops->get_rate(ref->priv, dev, skb, extra); | ||
97 | } | 85 | } |
98 | 86 | ||
99 | 87 | ||
@@ -142,6 +130,37 @@ static inline void rate_control_remove_sta_debugfs(struct sta_info *sta) | |||
142 | #endif | 130 | #endif |
143 | } | 131 | } |
144 | 132 | ||
133 | static inline int | ||
134 | rate_supported(struct sta_info *sta, struct ieee80211_hw_mode *mode, int index) | ||
135 | { | ||
136 | return (sta == NULL || sta->supp_rates & BIT(index)) && | ||
137 | (mode->rates[index].flags & IEEE80211_RATE_SUPPORTED); | ||
138 | } | ||
139 | |||
140 | static inline int | ||
141 | rate_lowest_index(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, | ||
142 | struct sta_info *sta) | ||
143 | { | ||
144 | int i; | ||
145 | |||
146 | for (i = 0; i < mode->num_rates; i++) { | ||
147 | if (rate_supported(sta, mode, i)) | ||
148 | return i; | ||
149 | } | ||
150 | |||
151 | /* warn when we cannot find a rate. */ | ||
152 | WARN_ON(1); | ||
153 | |||
154 | return 0; | ||
155 | } | ||
156 | |||
157 | static inline struct ieee80211_rate * | ||
158 | rate_lowest(struct ieee80211_local *local, struct ieee80211_hw_mode *mode, | ||
159 | struct sta_info *sta) | ||
160 | { | ||
161 | return &mode->rates[rate_lowest_index(local, mode, sta)]; | ||
162 | } | ||
163 | |||
145 | 164 | ||
146 | /* functions for rate control related to a device */ | 165 | /* functions for rate control related to a device */ |
147 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, | 166 | int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, |