2 * Copyright 2002-2005, Instant802 Networks, Inc.
3 * Copyright 2005, Devicescape Software, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
13 #define RATE_CONTROL_NUM_DOWN 20
14 #define RATE_CONTROL_NUM_UP 15
17 struct rate_control_extra {
18 /* values from rate_control_get_rate() to the caller: */
19 struct ieee80211_rate *probe; /* probe with this rate, or NULL for no
21 int startidx, endidx, rateidx;
22 struct ieee80211_rate *nonerp;
25 /* parameters from the caller to rate_control_get_rate(): */
26 int mgmt_data; /* this is data frame that is used for management
27 * (e.g., IEEE 802.1X EAPOL) */
32 struct rate_control_ops {
34 void (*tx_status)(struct net_device *dev, struct sk_buff *skb,
35 struct ieee80211_tx_status *status);
36 struct ieee80211_rate *
37 (*get_rate)(struct net_device *dev, struct sk_buff *skb,
38 struct rate_control_extra *extra);
39 void (*rate_init)(struct ieee80211_local *local, struct sta_info *sta);
40 void (*clear)(void *priv);
41 int (*status_sta)(struct ieee80211_local *local,
42 struct sta_info *sta, char *buf);
43 int (*status_global)(struct ieee80211_local *local, char *buf);
45 void * (*alloc)(struct ieee80211_local *local);
46 void (*free)(void *priv);
47 void * (*alloc_sta)(void);
48 void (*free_sta)(void *priv);
52 int ieee80211_rate_control_register(struct rate_control_ops *ops);
53 void ieee80211_rate_control_unregister(struct rate_control_ops *ops);
56 static inline void rate_control_tx_status(struct net_device *dev,
58 struct ieee80211_tx_status *status)
60 struct ieee80211_local *local = dev->priv;
61 local->rate_ctrl->tx_status(dev, skb, status);
65 static inline struct ieee80211_rate *
66 rate_control_get_rate(struct net_device *dev, struct sk_buff *skb,
67 struct rate_control_extra *extra)
69 struct ieee80211_local *local = dev->priv;
70 return local->rate_ctrl->get_rate(dev, skb, extra);
74 static inline void rate_control_rate_init(struct ieee80211_local *local,
77 local->rate_ctrl->rate_init(local, sta);
81 static inline void rate_control_clear(struct ieee80211_local *local)
83 local->rate_ctrl->clear(local->rate_ctrl_priv);
87 static inline int rate_control_status_sta(struct ieee80211_local *local,
88 struct sta_info *sta, char *buf)
90 return local->rate_ctrl->status_sta(local, sta, buf);
94 static inline int rate_control_status_global(struct ieee80211_local *local,
97 return local->rate_ctrl->status_global(local, buf);
101 static inline void * rate_control_alloc(struct ieee80211_local *local)
103 return local->rate_ctrl->alloc(local);
107 static inline void rate_control_free(struct ieee80211_local *local)
109 if (local->rate_ctrl == NULL || local->rate_ctrl_priv == NULL)
111 local->rate_ctrl->free(local->rate_ctrl_priv);
112 local->rate_ctrl_priv = NULL;
116 static inline void * rate_control_alloc_sta(struct ieee80211_local *local)
118 return local->rate_ctrl->alloc_sta();
122 static inline void rate_control_free_sta(struct ieee80211_local *local,
125 local->rate_ctrl->free_sta(priv);
128 #endif /* RATE_CONTROL */