]>
Commit | Line | Data |
---|---|---|
f0706e82 JB |
1 | /* |
2 | * Copyright 2002-2005, Instant802 Networks, Inc. | |
3 | * Copyright 2005, Devicescape Software, Inc. | |
4 | * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | */ | |
10 | ||
11 | #ifndef IEEE80211_RATE_H | |
12 | #define IEEE80211_RATE_H | |
13 | ||
14 | #include <linux/netdevice.h> | |
15 | #include <linux/skbuff.h> | |
16 | #include <linux/types.h> | |
17 | #include <net/mac80211.h> | |
18 | #include "ieee80211_i.h" | |
19 | #include "sta_info.h" | |
20 | ||
21 | #define RATE_CONTROL_NUM_DOWN 20 | |
22 | #define RATE_CONTROL_NUM_UP 15 | |
23 | ||
24 | ||
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; | |
30 | ||
31 | /* parameters from the caller to rate_control_get_rate(): */ | |
32 | struct ieee80211_hw_mode *mode; | |
33 | int mgmt_data; /* this is data frame that is used for management | |
34 | * (e.g., IEEE 802.1X EAPOL) */ | |
35 | u16 ethertype; | |
36 | }; | |
37 | ||
38 | ||
39 | struct rate_control_ops { | |
40 | struct module *module; | |
41 | const char *name; | |
42 | void (*tx_status)(void *priv, struct net_device *dev, | |
43 | struct sk_buff *skb, | |
44 | struct ieee80211_tx_status *status); | |
45 | struct ieee80211_rate *(*get_rate)(void *priv, struct net_device *dev, | |
46 | struct sk_buff *skb, | |
47 | struct rate_control_extra *extra); | |
48 | void (*rate_init)(void *priv, void *priv_sta, | |
49 | struct ieee80211_local *local, struct sta_info *sta); | |
50 | void (*clear)(void *priv); | |
51 | ||
52 | void *(*alloc)(struct ieee80211_local *local); | |
53 | void (*free)(void *priv); | |
54 | void *(*alloc_sta)(void *priv, gfp_t gfp); | |
55 | void (*free_sta)(void *priv, void *priv_sta); | |
56 | ||
57 | int (*add_attrs)(void *priv, struct kobject *kobj); | |
58 | void (*remove_attrs)(void *priv, struct kobject *kobj); | |
e9f207f0 JB |
59 | void (*add_sta_debugfs)(void *priv, void *priv_sta, |
60 | struct dentry *dir); | |
61 | void (*remove_sta_debugfs)(void *priv, void *priv_sta); | |
f0706e82 JB |
62 | }; |
63 | ||
64 | struct rate_control_ref { | |
65 | struct rate_control_ops *ops; | |
66 | void *priv; | |
67 | struct kref kref; | |
68 | }; | |
69 | ||
70 | int ieee80211_rate_control_register(struct rate_control_ops *ops); | |
71 | void ieee80211_rate_control_unregister(struct rate_control_ops *ops); | |
72 | ||
73 | /* Get a reference to the rate control algorithm. If `name' is NULL, get the | |
74 | * first available algorithm. */ | |
75 | struct rate_control_ref *rate_control_alloc(const char *name, | |
76 | struct ieee80211_local *local); | |
77 | struct rate_control_ref *rate_control_get(struct rate_control_ref *ref); | |
78 | void rate_control_put(struct rate_control_ref *ref); | |
79 | ||
80 | static inline void rate_control_tx_status(struct ieee80211_local *local, | |
81 | struct net_device *dev, | |
82 | struct sk_buff *skb, | |
83 | struct ieee80211_tx_status *status) | |
84 | { | |
85 | struct rate_control_ref *ref = local->rate_ctrl; | |
86 | ref->ops->tx_status(ref->priv, dev, skb, status); | |
87 | } | |
88 | ||
89 | ||
90 | static inline struct ieee80211_rate * | |
91 | rate_control_get_rate(struct ieee80211_local *local, struct net_device *dev, | |
92 | struct sk_buff *skb, struct rate_control_extra *extra) | |
93 | { | |
94 | struct rate_control_ref *ref = local->rate_ctrl; | |
95 | return ref->ops->get_rate(ref->priv, dev, skb, extra); | |
96 | } | |
97 | ||
98 | ||
99 | static inline void rate_control_rate_init(struct sta_info *sta, | |
100 | struct ieee80211_local *local) | |
101 | { | |
102 | struct rate_control_ref *ref = sta->rate_ctrl; | |
103 | ref->ops->rate_init(ref->priv, sta->rate_ctrl_priv, local, sta); | |
104 | } | |
105 | ||
106 | ||
107 | static inline void rate_control_clear(struct ieee80211_local *local) | |
108 | { | |
109 | struct rate_control_ref *ref = local->rate_ctrl; | |
110 | ref->ops->clear(ref->priv); | |
111 | } | |
112 | ||
113 | static inline void *rate_control_alloc_sta(struct rate_control_ref *ref, | |
114 | gfp_t gfp) | |
115 | { | |
116 | return ref->ops->alloc_sta(ref->priv, gfp); | |
117 | } | |
118 | ||
119 | static inline void rate_control_free_sta(struct rate_control_ref *ref, | |
120 | void *priv) | |
121 | { | |
122 | ref->ops->free_sta(ref->priv, priv); | |
123 | } | |
124 | ||
e9f207f0 JB |
125 | static inline void rate_control_add_sta_debugfs(struct sta_info *sta) |
126 | { | |
127 | #ifdef CONFIG_MAC80211_DEBUGFS | |
128 | struct rate_control_ref *ref = sta->rate_ctrl; | |
129 | if (sta->debugfs.dir && ref->ops->add_sta_debugfs) | |
130 | ref->ops->add_sta_debugfs(ref->priv, sta->rate_ctrl_priv, | |
131 | sta->debugfs.dir); | |
132 | #endif | |
133 | } | |
134 | ||
135 | static inline void rate_control_remove_sta_debugfs(struct sta_info *sta) | |
136 | { | |
137 | #ifdef CONFIG_MAC80211_DEBUGFS | |
138 | struct rate_control_ref *ref = sta->rate_ctrl; | |
139 | if (ref->ops->remove_sta_debugfs) | |
140 | ref->ops->remove_sta_debugfs(ref->priv, sta->rate_ctrl_priv); | |
141 | #endif | |
142 | } | |
143 | ||
f0706e82 | 144 | #endif /* IEEE80211_RATE_H */ |