aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/ieee80211_rate.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/mac80211/ieee80211_rate.h')
-rw-r--r--net/mac80211/ieee80211_rate.h73
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 21struct 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 */
25struct 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
37struct rate_control_ops { 30struct 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. */
76struct rate_control_ref *rate_control_alloc(const char *name, 69struct rate_control_ref *rate_control_alloc(const char *name,
77 struct ieee80211_local *local); 70 struct ieee80211_local *local);
71void rate_control_get_rate(struct net_device *dev,
72 struct ieee80211_hw_mode *mode, struct sk_buff *skb,
73 struct rate_selection *sel);
78struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); 74struct rate_control_ref *rate_control_get(struct rate_control_ref *ref);
79void rate_control_put(struct rate_control_ref *ref); 75void rate_control_put(struct rate_control_ref *ref);
80 76
81static inline void rate_control_tx_status(struct ieee80211_local *local, 77static 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);
91static inline struct ieee80211_rate *
92rate_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
133static inline int
134rate_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
140static inline int
141rate_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
157static inline struct ieee80211_rate *
158rate_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 */
147int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local, 166int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,