[PATCH] x86_64: reliable stack trace support (x86-64 IRQ stack
[linux-2.6/verdex.git] / include / net / ieee80211softmac.h
blob7a483ab4022f98cd20d4946dc7f61054d08e30f0
1 /*
2 * ieee80211softmac.h - public interface to the softmac
4 * Copyright (c) 2005 Johannes Berg <johannes@sipsolutions.net>
5 * Joseph Jezak <josejx@gentoo.org>
6 * Larry Finger <Larry.Finger@lwfinger.net>
7 * Danny van Dyk <kugelfang@gentoo.org>
8 * Michael Buesch <mbuesch@freenet.de>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 * The full GNU General Public License is included in this distribution in the
24 * file called COPYING.
27 #ifndef IEEE80211SOFTMAC_H_
28 #define IEEE80211SOFTMAC_H_
30 #include <linux/kernel.h>
31 #include <linux/spinlock.h>
32 #include <linux/workqueue.h>
33 #include <linux/list.h>
34 #include <net/ieee80211.h>
36 /* Once the API is considered more or less stable,
37 * this should be incremented on API incompatible changes.
39 #define IEEE80211SOFTMAC_API 0
41 #define IEEE80211SOFTMAC_MAX_RATES_LEN 8
42 #define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255
44 struct ieee80211softmac_ratesinfo {
45 u8 count;
46 u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN];
49 /* internal structures */
50 struct ieee80211softmac_network;
51 struct ieee80211softmac_scaninfo;
53 struct ieee80211softmac_essid {
54 u8 len;
55 char data[IW_ESSID_MAX_SIZE+1];
58 struct ieee80211softmac_wpa {
59 char *IE;
60 int IElen;
61 int IEbuflen;
65 * Information about association
67 * Do we need a lock for this?
68 * We only ever use this structure inlined
69 * into our global struct. I've used its lock,
70 * but maybe we need a local one here?
72 struct ieee80211softmac_assoc_info {
74 * This is the requested ESSID. It is written
75 * only by the WX handlers.
78 struct ieee80211softmac_essid req_essid;
80 * the ESSID of the network we're currently
81 * associated (or trying) to. This is
82 * updated to the network's actual ESSID
83 * even if the requested ESSID was 'ANY'
85 struct ieee80211softmac_essid associate_essid;
87 /* BSSID we're trying to associate to */
88 char bssid[ETH_ALEN];
90 /* Rates supported by the network */
91 struct ieee80211softmac_ratesinfo supported_rates;
93 /* some flags.
94 * static_essid is valid if the essid is constant,
95 * this is for use by the wx handlers only.
97 * associating is true, if the network has been
98 * auth'ed on and we are in the process of associating.
100 * bssvalid is true if we found a matching network
101 * and saved it's BSSID into the bssid above.
103 * bssfixed is used for SIOCSIWAP.
105 u8 static_essid:1,
106 associating:1,
107 bssvalid:1,
108 bssfixed:1;
110 /* Scan retries remaining */
111 int scan_retry;
113 struct work_struct work;
114 struct work_struct timeout;
117 enum {
118 IEEE80211SOFTMAC_AUTH_OPEN_REQUEST = 1,
119 IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE = 2,
122 enum {
123 IEEE80211SOFTMAC_AUTH_SHARED_REQUEST = 1,
124 IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2,
125 IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE = 3,
126 IEEE80211SOFTMAC_AUTH_SHARED_PASS = 4,
129 /* We should make these tunable
130 * AUTH_TIMEOUT seems really long, but that's what it is in BSD */
131 #define IEEE80211SOFTMAC_AUTH_TIMEOUT (12 * HZ)
132 #define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT 5
133 #define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT 3
135 struct ieee80211softmac_txrates {
136 /* The Bit-Rate to be used for multicast frames. */
137 u8 mcast_rate;
139 /* The Bit-Rate to be used for multicast management frames. */
140 u8 mgt_mcast_rate;
142 /* The Bit-Rate to be used for any other (normal) data packet. */
143 u8 default_rate;
144 /* The Bit-Rate to be used for default fallback
145 * (If the device supports fallback and hardware-retry)
147 u8 default_fallback;
149 /* This is the rate that the user asked for */
150 u8 user_rate;
153 /* Bits for txrates_change callback. */
154 #define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */
155 #define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */
156 #define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */
157 #define IEEE80211SOFTMAC_TXRATECHG_MGT_MCAST (1 << 3) /* mgt_mcast_rate */
159 struct ieee80211softmac_device {
160 /* 802.11 structure for data stuff */
161 struct ieee80211_device *ieee;
162 struct net_device *dev;
164 /* only valid if associated, then holds the Association ID */
165 u16 association_id;
167 /* the following methods are callbacks that the driver
168 * using this framework has to assign
171 /* always assign these */
172 void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid);
173 void (*set_channel)(struct net_device *dev, u8 channel);
175 /* assign if you need it, informational only */
176 void (*link_change)(struct net_device *dev);
178 /* If the hardware can do scanning, assign _all_ three of these callbacks.
179 * When the scan finishes, call ieee80211softmac_scan_finished().
182 /* when called, start_scan is guaranteed to not be called again
183 * until you call ieee80211softmac_scan_finished.
184 * Return 0 if scanning could start, error otherwise.
185 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */
186 int (*start_scan)(struct net_device *dev);
187 /* this should block until after ieee80211softmac_scan_finished was called
188 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */
189 void (*wait_for_scan)(struct net_device *dev);
190 /* stop_scan aborts a scan, but is asynchronous.
191 * if you want to wait for it too, use wait_for_scan
192 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */
193 void (*stop_scan)(struct net_device *dev);
195 /* we'll need something about beacons here too, for AP or ad-hoc modes */
197 /* Transmission rates to be used by the driver.
198 * The SoftMAC figures out the best possible rates.
199 * The driver just needs to read them.
201 struct ieee80211softmac_txrates txrates;
202 /* If the driver needs to do stuff on TX rate changes, assign this callback. */
203 void (*txrates_change)(struct net_device *dev,
204 u32 changes, /* see IEEE80211SOFTMAC_TXRATECHG flags */
205 const struct ieee80211softmac_txrates *rates_before_change);
207 /* private stuff follows */
208 /* this lock protects this structure */
209 spinlock_t lock;
211 /* couple of flags */
212 u8 scanning:1, /* protects scanning from being done multiple times at once */
213 associated:1,
214 running:1;
216 struct ieee80211softmac_scaninfo *scaninfo;
217 struct ieee80211softmac_assoc_info associnfo;
219 struct list_head auth_queue;
220 struct list_head events;
222 struct ieee80211softmac_ratesinfo ratesinfo;
223 int txrate_badness;
225 /* WPA stuff */
226 struct ieee80211softmac_wpa wpa;
228 /* we need to keep a list of network structs we copied */
229 struct list_head network_list;
231 /* This must be the last item so that it points to the data
232 * allocated beyond this structure by alloc_ieee80211 */
233 u8 priv[0];
236 extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm);
238 static inline void * ieee80211softmac_priv(struct net_device *dev)
240 return ((struct ieee80211softmac_device *)ieee80211_priv(dev))->priv;
243 extern struct net_device * alloc_ieee80211softmac(int sizeof_priv);
244 extern void free_ieee80211softmac(struct net_device *dev);
246 /* Call this function if you detect a lost TX fragment.
247 * (If the device indicates failure of ACK RX, for example.)
248 * It is wise to call this function if you are able to detect lost packets,
249 * because it contributes to the TX Rates auto adjustment.
251 extern void ieee80211softmac_fragment_lost(struct net_device *dev,
252 u16 wireless_sequence_number);
253 /* Call this function before _start to tell the softmac what rates
254 * the hw supports. The rates parameter is copied, so you can
255 * free it right after calling this function.
256 * Note that the rates need to be sorted. */
257 extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates);
259 /* Helper function which advises you the rate at which a frame should be
260 * transmitted at. */
261 static inline u8 ieee80211softmac_suggest_txrate(struct ieee80211softmac_device *mac,
262 int is_multicast,
263 int is_mgt)
265 struct ieee80211softmac_txrates *txrates = &mac->txrates;
267 if (!mac->associated)
268 return txrates->mgt_mcast_rate;
270 /* We are associated, sending unicast frame */
271 if (!is_multicast)
272 return txrates->default_rate;
274 /* We are associated, sending multicast frame */
275 if (is_mgt)
276 return txrates->mgt_mcast_rate;
277 else
278 return txrates->mcast_rate;
281 /* Start the SoftMAC. Call this after you initialized the device
282 * and it is ready to run.
284 extern void ieee80211softmac_start(struct net_device *dev);
285 /* Stop the SoftMAC. Call this before you shutdown the device. */
286 extern void ieee80211softmac_stop(struct net_device *dev);
289 * Event system
292 /* valid event types */
293 #define IEEE80211SOFTMAC_EVENT_ANY -1 /*private use only*/
294 #define IEEE80211SOFTMAC_EVENT_SCAN_FINISHED 0
295 #define IEEE80211SOFTMAC_EVENT_ASSOCIATED 1
296 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED 2
297 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT 3
298 #define IEEE80211SOFTMAC_EVENT_AUTHENTICATED 4
299 #define IEEE80211SOFTMAC_EVENT_AUTH_FAILED 5
300 #define IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT 6
301 #define IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND 7
302 #define IEEE80211SOFTMAC_EVENT_DISASSOCIATED 8
303 /* keep this updated! */
304 #define IEEE80211SOFTMAC_EVENT_LAST 8
306 * If you want to be notified of certain events, you can call
307 * ieee80211softmac_notify[_atomic] with
308 * - event set to one of the constants below
309 * - fun set to a function pointer of the appropriate type
310 * - context set to the context data you want passed
311 * The return value is 0, or an error.
313 typedef void (*notify_function_ptr)(struct net_device *dev, int event_type, void *context);
315 #define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL);
316 #define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC);
318 extern int ieee80211softmac_notify_gfp(struct net_device *dev,
319 int event, notify_function_ptr fun, void *context, gfp_t gfp_mask);
321 /* To clear pending work (for ifconfig down, etc.) */
322 extern void
323 ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm);
325 #endif /* IEEE80211SOFTMAC_H_ */