1 #ifndef IEEE80211SOFTMAC_H_
2 #define IEEE80211SOFTMAC_H_
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>
10 /* Once the API is considered more or less stable,
11 * this should be incremented on API incompatible changes.
13 #define IEEE80211SOFTMAC_API 0
15 #define IEEE80211SOFTMAC_MAX_RATES_LEN 8
16 #define IEEE80211SOFTMAC_MAX_EX_RATES_LEN 255
18 struct ieee80211softmac_ratesinfo
{
20 u8 rates
[IEEE80211SOFTMAC_MAX_RATES_LEN
+ IEEE80211SOFTMAC_MAX_EX_RATES_LEN
];
23 /* internal structures */
24 struct ieee80211softmac_network
;
25 struct ieee80211softmac_scaninfo
;
27 struct ieee80211softmac_essid
{
29 char data
[IW_ESSID_MAX_SIZE
+1];
32 struct ieee80211softmac_wpa
{
39 * Information about association
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?
46 struct ieee80211softmac_assoc_info
{
48 * This is the requested ESSID. It is written
49 * only by the WX handlers.
52 struct ieee80211softmac_essid req_essid
;
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'
59 struct ieee80211softmac_essid associate_essid
;
61 /* BSSID we're trying to associate to */
65 * static_essid is valid if the essid is constant,
66 * this is for use by the wx handlers only.
68 * associating is true, if the network has been
69 * auth'ed on and we are in the process of associating.
71 * bssvalid is true if we found a matching network
72 * and saved it's BSSID into the bssid above.
78 /* Scan retries remaining */
81 struct work_struct work
;
82 struct work_struct timeout
;
86 IEEE80211SOFTMAC_AUTH_OPEN_REQUEST
= 1,
87 IEEE80211SOFTMAC_AUTH_OPEN_RESPONSE
= 2,
91 IEEE80211SOFTMAC_AUTH_SHARED_REQUEST
= 1,
92 IEEE80211SOFTMAC_AUTH_SHARED_CHALLENGE
= 2,
93 IEEE80211SOFTMAC_AUTH_SHARED_RESPONSE
= 3,
94 IEEE80211SOFTMAC_AUTH_SHARED_PASS
= 4,
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
103 struct ieee80211softmac_txrates
{
104 /* The Bit-Rate to be used for multicast frames. */
106 /* The Bit-Rate to be used for multicast fallback
107 * (If the device supports fallback and hardware-retry)
110 /* The Bit-Rate to be used for any other (normal) data packet. */
112 /* The Bit-Rate to be used for default fallback
113 * (If the device supports fallback and hardware-retry)
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 */
124 struct ieee80211softmac_device
{
125 /* 802.11 structure for data stuff */
126 struct ieee80211_device
*ieee
;
127 struct net_device
*dev
;
129 /* only valid if associated, then holds the Association ID */
132 /* the following methods are callbacks that the driver
133 * using this framework has to assign
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
);
140 /* assign if you need it, informational only */
141 void (*link_change
)(struct net_device
*dev
);
143 /* If the hardware can do scanning, assign _all_ three of these callbacks.
144 * When the scan finishes, call ieee80211softmac_scan_finished().
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
);
160 /* we'll need something about beacons here too, for AP or ad-hoc modes */
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.
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
);
172 /* private stuff follows */
173 /* this lock protects this structure */
176 /* couple of flags */
177 u8 scanning
:1, /* protects scanning from being done multiple times at once */
180 /* workquere for scannning, ... */
181 struct workqueue_struct
*workqueue
;
183 struct ieee80211softmac_scaninfo
*scaninfo
;
184 struct ieee80211softmac_assoc_info associnfo
;
186 struct list_head auth_queue
;
187 struct list_head events
;
189 struct ieee80211softmac_ratesinfo ratesinfo
;
193 struct ieee80211softmac_wpa wpa
;
195 /* we need to keep a list of network structs we copied */
196 struct list_head network_list
;
198 /* This must be the last item so that it points to the data
199 * allocated beyond this structure by alloc_ieee80211 */
203 extern void ieee80211softmac_scan_finished(struct ieee80211softmac_device
*sm
);
205 static inline void * ieee80211softmac_priv(struct net_device
*dev
)
207 return ((struct ieee80211softmac_device
*)ieee80211_priv(dev
))->priv
;
210 extern struct net_device
* alloc_ieee80211softmac(int sizeof_priv
);
211 extern void free_ieee80211softmac(struct net_device
*dev
);
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.
218 extern 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. */
224 extern void ieee80211softmac_set_rates(struct net_device
*dev
, u8 count
, u8
*rates
);
226 /* Start the SoftMAC. Call this after you initialized the device
227 * and it is ready to run.
229 extern void ieee80211softmac_start(struct net_device
*dev
);
230 /* Stop the SoftMAC. Call this before you shutdown the device. */
231 extern void ieee80211softmac_stop(struct net_device
*dev
);
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
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.
257 typedef void (*notify_function_ptr
)(struct net_device
*dev
, void *context
);
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);
262 extern int ieee80211softmac_notify_gfp(struct net_device
*dev
,
263 int event
, notify_function_ptr fun
, void *context
, gfp_t gfp_mask
);
265 /* To clear pending work (for ifconfig down, etc.) */
267 ieee80211softmac_clear_pending_work(struct ieee80211softmac_device
*sm
);
269 #endif /* IEEE80211SOFTMAC_H_ */