aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2006-01-04 10:32:16 -0500
committerJohn W. Linville <linville@tuxdriver.com>2006-03-22 22:16:50 -0500
commit370121e5190a86a2d8a717ecd6f33028c7dc6fd4 (patch)
tree2bd809d8dea7a831f9c47d06572e98194bfc0ccc /include
parent1c2e02750b992703a8a18634e08b04353face243 (diff)
[PATCH] wireless: Add softmac layer to the kernel
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include')
-rw-r--r--include/net/ieee80211softmac.h269
-rw-r--r--include/net/ieee80211softmac_wx.h66
2 files changed, 335 insertions, 0 deletions
diff --git a/include/net/ieee80211softmac.h b/include/net/ieee80211softmac.h
new file mode 100644
index 000000000000..0b5f2df29f02
--- /dev/null
+++ b/include/net/ieee80211softmac.h
@@ -0,0 +1,269 @@
1#ifndef IEEE80211SOFTMAC_H_
2#define IEEE80211SOFTMAC_H_
3
4#include <linux/kernel.h>
5#include <linux/spinlock.h>
6#include <linux/workqueue.h>
7#include <linux/list.h>
8#include <net/ieee80211.h>
9
10/* Once the API is considered more or less stable,
11 * this should be incremented on API incompatible changes.
12 */
13#define IEEE80211SOFTMAC_API 0
14
15#define IEEE80211SOFTMAC_MAX_RATES_LEN 8
16#define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255
17
18struct ieee80211softmac_ratesinfo {
19 u8 count;
20 u8 rates[IEEE80211SOFTMAC_MAX_RATES_LEN + IEEE80211SOFTMAC_MAX_EX_RATES_LEN];
21};
22
23/* internal structures */
24struct ieee80211softmac_network;
25struct ieee80211softmac_scaninfo;
26
27struct ieee80211softmac_essid {
28 u8 len;
29 char data[IW_ESSID_MAX_SIZE+1];
30};
31
32struct ieee80211softmac_wpa {
33 char *IE;
34 int IElen;
35 int IEbuflen;
36};
37
38/*
39 * Information about association
40 *
41 * Do we need a lock for this?
42 * We only ever use this structure inlined
43 * into our global struct. I've used its lock,
44 * but maybe we need a local one here?
45 */
46struct ieee80211softmac_assoc_info {
47 /*
48 * This is the requested ESSID. It is written
49 * only by the WX handlers.
50 *
51 */
52 struct ieee80211softmac_essid req_essid;
53 /*
54 * the ESSID of the network we're currently
55 * associated (or trying) to. This is
56 * updated to the network's actual ESSID
57 * even if the requested ESSID was 'ANY'
58 */
59 struct ieee80211softmac_essid associate_essid;
60
61 /* BSSID we're trying to associate to */
62 char bssid[ETH_ALEN];
63
64 /* some flags.
65 * static_essid is valid if the essid is constant,
66 * this is for use by the wx handlers only.
67 *
68 * associating is true, if the network has been
69 * auth'ed on and we are in the process of associating.
70 *
71 * bssvalid is true if we found a matching network
72 * and saved it's BSSID into the bssid above.
73 */
74 u8 static_essid:1,
75 associating:1,
76 bssvalid:1;
77
78 /* Scan retries remaining */
79 int scan_retry;
80
81 struct work_struct work;
82 struct work_struct timeout;
83};
84
85enum {
86 IEEE80211SOFTMAC_AUTH_OPEN_REQUEST = 1,
87 IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE = 2,
88};
89
90enum {
91 IEEE80211SOFTMAC_AUTH_SHARED_REQUEST = 1,
92 IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE = 2,
93 IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE = 3,
94 IEEE80211SOFTMAC_AUTH_SHARED_PASS = 4,
95};
96
97/* We should make these tunable
98 * AUTH_TIMEOUT seems really long, but that's what it is in BSD */
99#define IEEE80211SOFTMAC_AUTH_TIMEOUT (12 * HZ)
100#define IEEE80211SOFTMAC_AUTH_RETRY_LIMIT 5
101#define IEEE80211SOFTMAC_ASSOC_SCAN_RETRY_LIMIT 3
102
103struct ieee80211softmac_txrates {
104 /* The Bit-Rate to be used for multicast frames. */
105 u8 mcast_rate;
106 /* The Bit-Rate to be used for multicast fallback
107 * (If the device supports fallback and hardware-retry)
108 */
109 u8 mcast_fallback;
110 /* The Bit-Rate to be used for any other (normal) data packet. */
111 u8 default_rate;
112 /* The Bit-Rate to be used for default fallback
113 * (If the device supports fallback and hardware-retry)
114 */
115 u8 default_fallback;
116};
117
118/* Bits for txrates_change callback. */
119#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT (1 << 0) /* default_rate */
120#define IEEE80211SOFTMAC_TXRATECHG_DEFAULT_FBACK (1 << 1) /* default_fallback */
121#define IEEE80211SOFTMAC_TXRATECHG_MCAST (1 << 2) /* mcast_rate */
122#define IEEE80211SOFTMAC_TXRATECHG_MCAST_FBACK (1 << 3) /* mcast_fallback */
123
124struct ieee80211softmac_device {
125 /* 802.11 structure for data stuff */
126 struct ieee80211_device *ieee;
127 struct net_device *dev;
128
129 /* only valid if associated, then holds the Association ID */
130 u16 association_id;
131
132 /* the following methods are callbacks that the driver
133 * using this framework has to assign
134 */
135
136 /* always assign these */
137 void (*set_bssid_filter)(struct net_device *dev, const u8 *bssid);
138 void (*set_channel)(struct net_device *dev, u8 channel);
139
140 /* assign if you need it, informational only */
141 void (*link_change)(struct net_device *dev);
142
143 /* If the hardware can do scanning, assign _all_ three of these callbacks.
144 * When the scan finishes, call ieee80211softmac_scan_finished().
145 */
146
147 /* when called, start_scan is guaranteed to not be called again
148 * until you call ieee80211softmac_scan_finished.
149 * Return 0 if scanning could start, error otherwise.
150 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_start_scan */
151 int (*start_scan)(struct net_device *dev);
152 /* this should block until after ieee80211softmac_scan_finished was called
153 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_wait_for_scan */
154 void (*wait_for_scan)(struct net_device *dev);
155 /* stop_scan aborts a scan, but is asynchronous.
156 * if you want to wait for it too, use wait_for_scan
157 * SOFTMAC AUTHORS: don't call this, use ieee80211softmac_stop_scan */
158 void (*stop_scan)(struct net_device *dev);
159
160 /* we'll need something about beacons here too, for AP or ad-hoc modes */
161
162 /* Transmission rates to be used by the driver.
163 * The SoftMAC figures out the best possible rates.
164 * The driver just needs to read them.
165 */
166 struct ieee80211softmac_txrates txrates;
167 /* If the driver needs to do stuff on TX rate changes, assign this callback. */
168 void (*txrates_change)(struct net_device *dev,
169 u32 changes, /* see IEEE80211SOFTMAC_TXRATECHG flags */
170 const struct ieee80211softmac_txrates *rates_before_change);
171
172 /* private stuff follows */
173 /* this lock protects this structure */
174 spinlock_t lock;
175
176 /* couple of flags */
177 u8 scanning:1, /* protects scanning from being done multiple times at once */
178 associated:1;
179
180 /* workquere for scannning, ... */
181 struct workqueue_struct *workqueue;
182
183 struct ieee80211softmac_scaninfo *scaninfo;
184 struct ieee80211softmac_assoc_info associnfo;
185
186 struct list_head auth_queue;
187 struct list_head events;
188
189 struct ieee80211softmac_ratesinfo ratesinfo;
190 int txrate_badness;
191
192 /* WPA stuff */
193 struct ieee80211softmac_wpa wpa;
194
195 /* we need to keep a list of network structs we copied */
196 struct list_head network_list;
197
198 /* This must be the last item so that it points to the data
199 * allocated beyond this structure by alloc_ieee80211 */
200 u8 priv[0];
201};
202
203extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device *sm);
204
205static inline void * ieee80211softmac_priv(struct net_device *dev)
206{
207 return ((struct ieee80211softmac_device *)ieee80211_priv(dev))->priv;
208}
209
210extern struct net_device * alloc_ieee80211softmac(int sizeof_priv);
211extern void free_ieee80211softmac(struct net_device *dev);
212
213/* Call this function if you detect a lost TX fragment.
214 * (If the device indicates failure of ACK RX, for example.)
215 * It is wise to call this function if you are able to detect lost packets,
216 * because it contributes to the TX Rates auto adjustment.
217 */
218extern void ieee80211softmac_fragment_lost(struct net_device *dev,
219 u16 wireless_sequence_number);
220/* Call this function before _start to tell the softmac what rates
221 * the hw supports. The rates parameter is copied, so you can
222 * free it right after calling this function.
223 * Note that the rates need to be sorted. */
224extern void ieee80211softmac_set_rates(struct net_device *dev, u8 count, u8 *rates);
225
226/* Start the SoftMAC. Call this after you initialized the device
227 * and it is ready to run.
228 */
229extern void ieee80211softmac_start(struct net_device *dev);
230/* Stop the SoftMAC. Call this before you shutdown the device. */
231extern void ieee80211softmac_stop(struct net_device *dev);
232
233/*
234 * Event system
235 */
236
237/* valid event types */
238#define IEEE80211SOFTMAC_EVENT_ANY -1 /*private use only*/
239#define IEEE80211SOFTMAC_EVENT_SCAN_FINISHED 0
240#define IEEE80211SOFTMAC_EVENT_ASSOCIATED 1
241#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_FAILED 2
242#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_TIMEOUT 3
243#define IEEE80211SOFTMAC_EVENT_AUTHENTICATED 4
244#define IEEE80211SOFTMAC_EVENT_AUTH_FAILED 5
245#define IEEE80211SOFTMAC_EVENT_AUTH_TIMEOUT 6
246#define IEEE80211SOFTMAC_EVENT_ASSOCIATE_NET_NOT_FOUND 7
247/* keep this updated! */
248#define IEEE80211SOFTMAC_EVENT_LAST 7
249/*
250 * If you want to be notified of certain events, you can call
251 * ieee80211softmac_notify[_atomic] with
252 * - event set to one of the constants below
253 * - fun set to a function pointer of the appropriate type
254 * - context set to the context data you want passed
255 * The return value is 0, or an error.
256 */
257typedef void (*notify_function_ptr)(struct net_device *dev, void *context);
258
259#define ieee80211softmac_notify(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_KERNEL);
260#define ieee80211softmac_notify_atomic(dev, event, fun, context) ieee80211softmac_notify_gfp(dev, event, fun, context, GFP_ATOMIC);
261
262extern int ieee80211softmac_notify_gfp(struct net_device *dev,
263 int event, notify_function_ptr fun, void *context, gfp_t gfp_mask);
264
265/* To clear pending work (for ifconfig down, etc.) */
266extern void
267ieee80211softmac_clear_pending_work(struct ieee80211softmac_device *sm);
268
269#endif /* IEEE80211SOFTMAC_H_ */
diff --git a/include/net/ieee80211softmac_wx.h b/include/net/ieee80211softmac_wx.h
new file mode 100644
index 000000000000..165ea4c78ee0
--- /dev/null
+++ b/include/net/ieee80211softmac_wx.h
@@ -0,0 +1,66 @@
1#ifndef _IEEE80211SOFTMAC_WX_H
2#define _IEEE80211SOFTMAC_WX_H
3
4#include <net/ieee80211softmac.h>
5#include <net/iw_handler.h>
6
7extern int
8ieee80211softmac_wx_trigger_scan(struct net_device *net_dev,
9 struct iw_request_info *info,
10 union iwreq_data *data,
11 char *extra);
12
13extern int
14ieee80211softmac_wx_get_scan_results(struct net_device *net_dev,
15 struct iw_request_info *info,
16 union iwreq_data *data,
17 char *extra);
18
19extern int
20ieee80211softmac_wx_set_essid(struct net_device *net_dev,
21 struct iw_request_info *info,
22 union iwreq_data *data,
23 char *extra);
24
25extern int
26ieee80211softmac_wx_get_essid(struct net_device *net_dev,
27 struct iw_request_info *info,
28 union iwreq_data *data,
29 char *extra);
30
31extern int
32ieee80211softmac_wx_set_rate(struct net_device *net_dev,
33 struct iw_request_info *info,
34 union iwreq_data *data,
35 char *extra);
36
37extern int
38ieee80211softmac_wx_get_rate(struct net_device *net_dev,
39 struct iw_request_info *info,
40 union iwreq_data *data,
41 char *extra);
42
43extern int
44ieee80211softmac_wx_get_wap(struct net_device *net_dev,
45 struct iw_request_info *info,
46 union iwreq_data *data,
47 char *extra);
48
49extern int
50ieee80211softmac_wx_set_wap(struct net_device *net_dev,
51 struct iw_request_info *info,
52 union iwreq_data *data,
53 char *extra);
54
55extern int
56ieee80211softmac_wx_set_genie(struct net_device *dev,
57 struct iw_request_info *info,
58 union iwreq_data *wrqu,
59 char *extra);
60
61extern int
62ieee80211softmac_wx_get_genie(struct net_device *dev,
63 struct iw_request_info *info,
64 union iwreq_data *wrqu,
65 char *extra);
66#endif /* _IEEE80211SOFTMAC_WX */