Commit | Line | Data |
---|---|---|
f0706e82 | 1 | /* |
3017b80b JB |
2 | * mac80211 <-> driver interface |
3 | * | |
f0706e82 JB |
4 | * Copyright 2002-2005, Devicescape Software, Inc. |
5 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> | |
3017b80b | 6 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
f0706e82 JB |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License version 2 as | |
10 | * published by the Free Software Foundation. | |
11 | */ | |
12 | ||
13 | #ifndef MAC80211_H | |
14 | #define MAC80211_H | |
15 | ||
16 | #include <linux/kernel.h> | |
17 | #include <linux/if_ether.h> | |
18 | #include <linux/skbuff.h> | |
19 | #include <linux/wireless.h> | |
20 | #include <linux/device.h> | |
21 | #include <linux/ieee80211.h> | |
22 | #include <net/wireless.h> | |
23 | #include <net/cfg80211.h> | |
24 | ||
25 | /* Note! Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be | |
26 | * called in hardware interrupt context. The low-level driver must not call any | |
27 | * other functions in hardware interrupt context. If there is a need for such | |
28 | * call, the low-level driver should first ACK the interrupt and perform the | |
29 | * IEEE 802.11 code call after this, e.g., from a scheduled tasklet (in | |
30 | * software interrupt context). | |
31 | */ | |
32 | ||
33 | /* | |
34 | * Frame format used when passing frame between low-level hardware drivers | |
35 | * and IEEE 802.11 driver the same as used in the wireless media, i.e., | |
36 | * buffers start with IEEE 802.11 header and include the same octets that | |
37 | * are sent over air. | |
38 | * | |
39 | * If hardware uses IEEE 802.3 headers (and perform 802.3 <-> 802.11 | |
40 | * conversion in firmware), upper layer 802.11 code needs to be changed to | |
41 | * support this. | |
42 | * | |
43 | * If the receive frame format is not the same as the real frame sent | |
44 | * on the wireless media (e.g., due to padding etc.), upper layer 802.11 code | |
45 | * could be updated to provide support for such format assuming this would | |
46 | * optimize the performance, e.g., by removing need to re-allocation and | |
47 | * copying of the data. | |
48 | */ | |
49 | ||
50 | #define IEEE80211_CHAN_W_SCAN 0x00000001 | |
51 | #define IEEE80211_CHAN_W_ACTIVE_SCAN 0x00000002 | |
52 | #define IEEE80211_CHAN_W_IBSS 0x00000004 | |
53 | ||
54 | /* Channel information structure. Low-level driver is expected to fill in chan, | |
55 | * freq, and val fields. Other fields will be filled in by 80211.o based on | |
56 | * hostapd information and low-level driver does not need to use them. The | |
57 | * limits for each channel will be provided in 'struct ieee80211_conf' when | |
58 | * configuring the low-level driver with hw->config callback. If a device has | |
59 | * a default regulatory domain, IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED | |
60 | * can be set to let the driver configure all fields */ | |
61 | struct ieee80211_channel { | |
62 | short chan; /* channel number (IEEE 802.11) */ | |
63 | short freq; /* frequency in MHz */ | |
64 | int val; /* hw specific value for the channel */ | |
65 | int flag; /* flag for hostapd use (IEEE80211_CHAN_*) */ | |
66 | unsigned char power_level; | |
67 | unsigned char antenna_max; | |
68 | }; | |
69 | ||
70 | #define IEEE80211_RATE_ERP 0x00000001 | |
71 | #define IEEE80211_RATE_BASIC 0x00000002 | |
72 | #define IEEE80211_RATE_PREAMBLE2 0x00000004 | |
73 | #define IEEE80211_RATE_SUPPORTED 0x00000010 | |
74 | #define IEEE80211_RATE_OFDM 0x00000020 | |
75 | #define IEEE80211_RATE_CCK 0x00000040 | |
76 | #define IEEE80211_RATE_TURBO 0x00000080 | |
77 | #define IEEE80211_RATE_MANDATORY 0x00000100 | |
78 | ||
79 | #define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2) | |
80 | #define IEEE80211_RATE_MODULATION(f) \ | |
81 | (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM)) | |
82 | ||
83 | /* Low-level driver should set PREAMBLE2, OFDM, CCK, and TURBO flags. | |
84 | * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the | |
85 | * configuration. */ | |
86 | struct ieee80211_rate { | |
87 | int rate; /* rate in 100 kbps */ | |
88 | int val; /* hw specific value for the rate */ | |
89 | int flags; /* IEEE80211_RATE_ flags */ | |
90 | int val2; /* hw specific value for the rate when using short preamble | |
91 | * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for | |
92 | * 2, 5.5, and 11 Mbps) */ | |
93 | signed char min_rssi_ack; | |
94 | unsigned char min_rssi_ack_delta; | |
95 | ||
96 | /* following fields are set by 80211.o and need not be filled by the | |
97 | * low-level driver */ | |
98 | int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for | |
99 | * optimizing channel utilization estimates */ | |
100 | }; | |
101 | ||
102 | /* 802.11g is backwards-compatible with 802.11b, so a wlan card can | |
103 | * actually be both in 11b and 11g modes at the same time. */ | |
104 | enum { | |
105 | MODE_IEEE80211A, /* IEEE 802.11a */ | |
106 | MODE_IEEE80211B, /* IEEE 802.11b only */ | |
107 | MODE_ATHEROS_TURBO, /* Atheros Turbo mode (2x.11a at 5 GHz) */ | |
108 | MODE_IEEE80211G, /* IEEE 802.11g (and 802.11b compatibility) */ | |
109 | MODE_ATHEROS_TURBOG, /* Atheros Turbo mode (2x.11g at 2.4 GHz) */ | |
110 | ||
111 | /* keep last */ | |
112 | NUM_IEEE80211_MODES | |
113 | }; | |
114 | ||
115 | struct ieee80211_hw_mode { | |
116 | int mode; /* MODE_IEEE80211... */ | |
117 | int num_channels; /* Number of channels (below) */ | |
118 | struct ieee80211_channel *channels; /* Array of supported channels */ | |
119 | int num_rates; /* Number of rates (below) */ | |
120 | struct ieee80211_rate *rates; /* Array of supported rates */ | |
121 | ||
122 | struct list_head list; /* Internal, don't touch */ | |
123 | }; | |
124 | ||
125 | struct ieee80211_tx_queue_params { | |
126 | int aifs; /* 0 .. 255; -1 = use default */ | |
127 | int cw_min; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */ | |
128 | int cw_max; /* 2^n-1: 1, 3, 7, .. , 1023; 0 = use default */ | |
129 | int burst_time; /* maximum burst time in 0.1 ms (i.e., 10 = 1 ms); | |
130 | * 0 = disabled */ | |
131 | }; | |
132 | ||
133 | struct ieee80211_tx_queue_stats_data { | |
134 | unsigned int len; /* num packets in queue */ | |
135 | unsigned int limit; /* queue len (soft) limit */ | |
136 | unsigned int count; /* total num frames sent */ | |
137 | }; | |
138 | ||
139 | enum { | |
140 | IEEE80211_TX_QUEUE_DATA0, | |
141 | IEEE80211_TX_QUEUE_DATA1, | |
142 | IEEE80211_TX_QUEUE_DATA2, | |
143 | IEEE80211_TX_QUEUE_DATA3, | |
144 | IEEE80211_TX_QUEUE_DATA4, | |
145 | IEEE80211_TX_QUEUE_SVP, | |
146 | ||
147 | NUM_TX_DATA_QUEUES, | |
148 | ||
149 | /* due to stupidity in the sub-ioctl userspace interface, the items in | |
150 | * this struct need to have fixed values. As soon as it is removed, we can | |
151 | * fix these entries. */ | |
152 | IEEE80211_TX_QUEUE_AFTER_BEACON = 6, | |
153 | IEEE80211_TX_QUEUE_BEACON = 7 | |
154 | }; | |
155 | ||
156 | struct ieee80211_tx_queue_stats { | |
157 | struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES]; | |
158 | }; | |
159 | ||
160 | struct ieee80211_low_level_stats { | |
161 | unsigned int dot11ACKFailureCount; | |
162 | unsigned int dot11RTSFailureCount; | |
163 | unsigned int dot11FCSErrorCount; | |
164 | unsigned int dot11RTSSuccessCount; | |
165 | }; | |
166 | ||
167 | /* Transmit control fields. This data structure is passed to low-level driver | |
168 | * with each TX frame. The low-level driver is responsible for configuring | |
169 | * the hardware to use given values (depending on what is supported). */ | |
170 | #define HW_KEY_IDX_INVALID -1 | |
171 | ||
172 | struct ieee80211_tx_control { | |
173 | int tx_rate; /* Transmit rate, given as the hw specific value for the | |
174 | * rate (from struct ieee80211_rate) */ | |
175 | int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw | |
176 | * specific value for the rate (from | |
177 | * struct ieee80211_rate) */ | |
178 | ||
179 | #define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for | |
180 | * this frame */ | |
181 | #define IEEE80211_TXCTL_DO_NOT_ENCRYPT (1<<1) /* send this frame without | |
182 | * encryption; e.g., for EAPOL | |
183 | * frames */ | |
184 | #define IEEE80211_TXCTL_USE_RTS_CTS (1<<2) /* use RTS-CTS before sending | |
185 | * frame */ | |
186 | #define IEEE80211_TXCTL_USE_CTS_PROTECT (1<<3) /* use CTS protection for the | |
187 | * frame (e.g., for combined | |
188 | * 802.11g / 802.11b networks) */ | |
189 | #define IEEE80211_TXCTL_NO_ACK (1<<4) /* tell the low level not to | |
190 | * wait for an ack */ | |
191 | #define IEEE80211_TXCTL_RATE_CTRL_PROBE (1<<5) | |
192 | #define IEEE80211_TXCTL_CLEAR_DST_MASK (1<<6) | |
193 | #define IEEE80211_TXCTL_REQUEUE (1<<7) | |
194 | #define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of | |
195 | * the frame */ | |
196 | #define IEEE80211_TXCTL_TKIP_NEW_PHASE1_KEY (1<<9) | |
d5d08def ID |
197 | #define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send |
198 | * using the through | |
199 | * set_retry_limit configured | |
200 | * long retry value */ | |
f0706e82 JB |
201 | u32 flags; /* tx control flags defined |
202 | * above */ | |
d5d08def ID |
203 | u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. |
204 | * This could be used when set_retry_limit | |
205 | * is not implemented by the driver */ | |
f0706e82 JB |
206 | u8 power_level; /* per-packet transmit power level, in dBm */ |
207 | u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ | |
208 | s8 key_idx; /* -1 = do not encrypt, >= 0 keyidx from | |
209 | * hw->set_key() */ | |
210 | u8 icv_len; /* length of the ICV/MIC field in octets */ | |
211 | u8 iv_len; /* length of the IV field in octets */ | |
212 | u8 tkip_key[16]; /* generated phase2/phase1 key for hw TKIP */ | |
213 | u8 queue; /* hardware queue to use for this frame; | |
214 | * 0 = highest, hw->queues-1 = lowest */ | |
215 | u8 sw_retry_attempt; /* number of times hw has tried to | |
216 | * transmit frame (not incl. hw retries) */ | |
217 | ||
218 | struct ieee80211_rate *rate; /* internal 80211.o rate */ | |
219 | struct ieee80211_rate *rts_rate; /* internal 80211.o rate | |
220 | * for RTS/CTS */ | |
221 | int alt_retry_rate; /* retry rate for the last retries, given as the | |
222 | * hw specific value for the rate (from | |
223 | * struct ieee80211_rate). To be used to limit | |
224 | * packet dropping when probing higher rates, if hw | |
225 | * supports multiple retry rates. -1 = not used */ | |
226 | int type; /* internal */ | |
227 | int ifindex; /* internal */ | |
228 | }; | |
229 | ||
230 | /* Receive status. The low-level driver should provide this information | |
231 | * (the subset supported by hardware) to the 802.11 code with each received | |
232 | * frame. */ | |
233 | struct ieee80211_rx_status { | |
234 | u64 mactime; | |
235 | int freq; /* receive frequency in Mhz */ | |
236 | int channel; | |
237 | int phymode; | |
238 | int ssi; | |
239 | int signal; /* used as qual in statistics reporting */ | |
240 | int noise; | |
241 | int antenna; | |
242 | int rate; | |
243 | #define RX_FLAG_MMIC_ERROR (1<<0) | |
244 | #define RX_FLAG_DECRYPTED (1<<1) | |
245 | #define RX_FLAG_RADIOTAP (1<<2) | |
246 | int flag; | |
247 | }; | |
248 | ||
249 | /* Transmit status. The low-level driver should provide this information | |
250 | * (the subset supported by hardware) to the 802.11 code for each transmit | |
251 | * frame. */ | |
252 | struct ieee80211_tx_status { | |
253 | /* copied ieee80211_tx_control structure */ | |
254 | struct ieee80211_tx_control control; | |
255 | ||
256 | #define IEEE80211_TX_STATUS_TX_FILTERED (1<<0) | |
257 | #define IEEE80211_TX_STATUS_ACK (1<<1) /* whether the TX frame was ACKed */ | |
258 | u32 flags; /* tx staus flags defined above */ | |
259 | ||
260 | int ack_signal; /* measured signal strength of the ACK frame */ | |
261 | int excessive_retries; | |
262 | int retry_count; | |
263 | ||
264 | int queue_length; /* information about TX queue */ | |
265 | int queue_number; | |
266 | }; | |
267 | ||
268 | ||
269 | /** | |
270 | * struct ieee80211_conf - configuration of the device | |
271 | * | |
272 | * This struct indicates how the driver shall configure the hardware. | |
273 | * | |
274 | * @radio_enabled: when zero, driver is required to switch off the radio. | |
275 | */ | |
276 | struct ieee80211_conf { | |
277 | int channel; /* IEEE 802.11 channel number */ | |
278 | int freq; /* MHz */ | |
279 | int channel_val; /* hw specific value for the channel */ | |
280 | ||
281 | int phymode; /* MODE_IEEE80211A, .. */ | |
282 | struct ieee80211_channel *chan; | |
283 | struct ieee80211_hw_mode *mode; | |
284 | unsigned int regulatory_domain; | |
285 | int radio_enabled; | |
286 | ||
287 | int beacon_int; | |
288 | ||
289 | #define IEEE80211_CONF_SHORT_SLOT_TIME (1<<0) /* use IEEE 802.11g Short Slot | |
290 | * Time */ | |
291 | #define IEEE80211_CONF_SSID_HIDDEN (1<<1) /* do not broadcast the ssid */ | |
292 | #define IEEE80211_CONF_RADIOTAP (1<<2) /* use radiotap if supported | |
293 | check this bit at RX time */ | |
294 | u32 flags; /* configuration flags defined above */ | |
295 | ||
296 | u8 power_level; /* transmit power limit for current | |
297 | * regulatory domain; in dBm */ | |
298 | u8 antenna_max; /* maximum antenna gain */ | |
f0706e82 JB |
299 | |
300 | /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ | |
301 | u8 antenna_sel_tx; | |
302 | u8 antenna_sel_rx; | |
f0706e82 JB |
303 | }; |
304 | ||
305 | /** | |
306 | * enum ieee80211_if_types - types of 802.11 network interfaces | |
307 | * | |
308 | * @IEEE80211_IF_TYPE_AP: interface in AP mode. | |
309 | * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap | |
310 | * daemon. Drivers should never see this type. | |
311 | * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode. | |
312 | * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode. | |
313 | * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode. | |
314 | * @IEEE80211_IF_TYPE_WDS: interface in WDS mode. | |
315 | * @IEEE80211_IF_TYPE_VLAN: not used. | |
316 | */ | |
317 | enum ieee80211_if_types { | |
318 | IEEE80211_IF_TYPE_AP = 0x00000000, | |
319 | IEEE80211_IF_TYPE_MGMT = 0x00000001, | |
320 | IEEE80211_IF_TYPE_STA = 0x00000002, | |
321 | IEEE80211_IF_TYPE_IBSS = 0x00000003, | |
322 | IEEE80211_IF_TYPE_MNTR = 0x00000004, | |
323 | IEEE80211_IF_TYPE_WDS = 0x5A580211, | |
324 | IEEE80211_IF_TYPE_VLAN = 0x00080211, | |
325 | }; | |
326 | ||
327 | /** | |
328 | * struct ieee80211_if_init_conf - initial configuration of an interface | |
329 | * | |
330 | * @if_id: internal interface ID. This number has no particular meaning to | |
331 | * drivers and the only allowed usage is to pass it to | |
332 | * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions. | |
333 | * This field is not valid for monitor interfaces | |
334 | * (interfaces of %IEEE80211_IF_TYPE_MNTR type). | |
335 | * @type: one of &enum ieee80211_if_types constants. Determines the type of | |
336 | * added/removed interface. | |
337 | * @mac_addr: pointer to MAC address of the interface. This pointer is valid | |
338 | * until the interface is removed (i.e. it cannot be used after | |
339 | * remove_interface() callback was called for this interface). | |
4480f15c | 340 | * This pointer will be %NULL for monitor interfaces, be careful. |
f0706e82 JB |
341 | * |
342 | * This structure is used in add_interface() and remove_interface() | |
343 | * callbacks of &struct ieee80211_hw. | |
4480f15c JB |
344 | * |
345 | * When you allow multiple interfaces to be added to your PHY, take care | |
346 | * that the hardware can actually handle multiple MAC addresses. However, | |
347 | * also take care that when there's no interface left with mac_addr != %NULL | |
348 | * you remove the MAC address from the device to avoid acknowledging packets | |
349 | * in pure monitor mode. | |
f0706e82 JB |
350 | */ |
351 | struct ieee80211_if_init_conf { | |
352 | int if_id; | |
353 | int type; | |
354 | void *mac_addr; | |
355 | }; | |
356 | ||
357 | /** | |
358 | * struct ieee80211_if_conf - configuration of an interface | |
359 | * | |
360 | * @type: type of the interface. This is always the same as was specified in | |
361 | * &struct ieee80211_if_init_conf. The type of an interface never changes | |
362 | * during the life of the interface; this field is present only for | |
363 | * convenience. | |
364 | * @bssid: BSSID of the network we are associated to/creating. | |
365 | * @ssid: used (together with @ssid_len) by drivers for hardware that | |
366 | * generate beacons independently. The pointer is valid only during the | |
367 | * config_interface() call, so copy the value somewhere if you need | |
368 | * it. | |
369 | * @ssid_len: length of the @ssid field. | |
370 | * @generic_elem: used (together with @generic_elem_len) by drivers for | |
371 | * hardware that generate beacons independently. The pointer is valid | |
372 | * only during the config_interface() call, so copy the value somewhere | |
373 | * if you need it. | |
374 | * @generic_elem_len: length of the generic element. | |
375 | * @beacon: beacon template. Valid only if @host_gen_beacon_template in | |
376 | * &struct ieee80211_hw is set. The driver is responsible of freeing | |
377 | * the sk_buff. | |
378 | * @beacon_control: tx_control for the beacon template, this field is only | |
379 | * valid when the @beacon field was set. | |
380 | * | |
381 | * This structure is passed to the config_interface() callback of | |
382 | * &struct ieee80211_hw. | |
383 | */ | |
384 | struct ieee80211_if_conf { | |
385 | int type; | |
386 | u8 *bssid; | |
387 | u8 *ssid; | |
388 | size_t ssid_len; | |
389 | u8 *generic_elem; | |
390 | size_t generic_elem_len; | |
391 | struct sk_buff *beacon; | |
392 | struct ieee80211_tx_control *beacon_control; | |
393 | }; | |
394 | ||
395 | typedef enum { ALG_NONE, ALG_WEP, ALG_TKIP, ALG_CCMP, ALG_NULL } | |
396 | ieee80211_key_alg; | |
397 | ||
398 | ||
399 | struct ieee80211_key_conf { | |
400 | ||
401 | int hw_key_idx; /* filled + used by low-level driver */ | |
402 | ieee80211_key_alg alg; | |
403 | int keylen; | |
404 | ||
405 | #define IEEE80211_KEY_FORCE_SW_ENCRYPT (1<<0) /* to be cleared by low-level | |
406 | driver */ | |
407 | #define IEEE80211_KEY_DEFAULT_TX_KEY (1<<1) /* This key is the new default TX | |
408 | key (used only for broadcast | |
409 | keys). */ | |
410 | #define IEEE80211_KEY_DEFAULT_WEP_ONLY (1<<2) /* static WEP is the only | |
411 | configured security policy; | |
412 | this allows some low-level | |
413 | drivers to determine when | |
414 | hwaccel can be used */ | |
415 | u32 flags; /* key configuration flags defined above */ | |
416 | ||
417 | s8 keyidx; /* WEP key index */ | |
418 | u8 key[0]; | |
419 | }; | |
420 | ||
421 | #define IEEE80211_SEQ_COUNTER_RX 0 | |
422 | #define IEEE80211_SEQ_COUNTER_TX 1 | |
423 | ||
424 | typedef enum { | |
425 | SET_KEY, DISABLE_KEY, REMOVE_ALL_KEYS, | |
426 | } set_key_cmd; | |
427 | ||
428 | /* This is driver-visible part of the per-hw state the stack keeps. */ | |
429 | struct ieee80211_hw { | |
430 | /* points to the cfg80211 wiphy for this piece. Note | |
431 | * that you must fill in the perm_addr and dev fields | |
432 | * of this structure, use the macros provided below. */ | |
433 | struct wiphy *wiphy; | |
434 | ||
435 | /* assigned by mac80211, don't write */ | |
436 | struct ieee80211_conf conf; | |
437 | ||
438 | /* Single thread workqueue available for driver use | |
439 | * Allocated by mac80211 on registration */ | |
440 | struct workqueue_struct *workqueue; | |
441 | ||
442 | /* Pointer to the private area that was | |
443 | * allocated with this struct for you. */ | |
444 | void *priv; | |
445 | ||
446 | /* The rest is information about your hardware */ | |
447 | ||
448 | /* TODO: frame_type 802.11/802.3, sw_encryption requirements */ | |
449 | ||
0ef6e49b JB |
450 | /* hole at 0 */ |
451 | ||
452 | /* | |
453 | * The device only needs to be supplied with a beacon template. | |
454 | * If you need the host to generate each beacon then don't use | |
455 | * this flag and use ieee80211_beacon_get(). | |
456 | */ | |
f0706e82 JB |
457 | #define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1) |
458 | ||
3017b80b JB |
459 | /* |
460 | * Some devices handle decryption internally and do not | |
f0706e82 JB |
461 | * indicate whether the frame was encrypted (unencrypted frames |
462 | * will be dropped by the hardware, unless specifically allowed | |
3017b80b JB |
463 | * through.) |
464 | * It is permissible to not handle all encrypted frames and fall | |
465 | * back to software encryption; however, if this flag is set | |
466 | * unencrypted frames must be dropped unless the driver is told | |
467 | * otherwise via the set_ieee8021x() callback. | |
468 | */ | |
f0706e82 JB |
469 | #define IEEE80211_HW_DEVICE_HIDES_WEP (1<<2) |
470 | ||
471 | /* Whether RX frames passed to ieee80211_rx() include FCS in the end */ | |
472 | #define IEEE80211_HW_RX_INCLUDES_FCS (1<<3) | |
473 | ||
474 | /* Some wireless LAN chipsets buffer broadcast/multicast frames for | |
475 | * power saving stations in the hardware/firmware and others rely on | |
476 | * the host system for such buffering. This option is used to | |
477 | * configure the IEEE 802.11 upper layer to buffer broadcast/multicast | |
478 | * frames when there are power saving stations so that low-level driver | |
479 | * can fetch them with ieee80211_get_buffered_bc(). */ | |
480 | #define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4) | |
481 | ||
3017b80b JB |
482 | /* |
483 | * This flag is only relevant if hardware encryption is used. | |
484 | * If set, it has two meanings: | |
485 | * 1) the IV and ICV are present in received frames that have | |
486 | * been decrypted (unless IEEE80211_HW_DEVICE_HIDES_WEP is | |
487 | * also set) | |
488 | * 2) on transmission, the IV should be generated in software. | |
489 | * | |
490 | * Please let us know if you *don't* use this flag, the stack would | |
491 | * really like to be able to get the IV to keep key statistics | |
492 | * accurate. | |
493 | */ | |
f0706e82 JB |
494 | #define IEEE80211_HW_WEP_INCLUDE_IV (1<<5) |
495 | ||
aaa92e9a | 496 | /* hole at 6 */ |
f0706e82 JB |
497 | |
498 | /* Force software encryption for TKIP packets if WMM is enabled. */ | |
499 | #define IEEE80211_HW_NO_TKIP_WMM_HWACCEL (1<<7) | |
500 | ||
3017b80b JB |
501 | /* |
502 | * Some devices handle Michael MIC internally and do not include MIC in | |
503 | * the received packets passed up. This flag must be set for such | |
504 | * devices. The 'encryption' frame control bit is expected to be still | |
505 | * set in the IEEE 802.11 header with this option unlike with the | |
506 | * IEEE80211_HW_DEVICE_HIDES_WEP flag. | |
f0706e82 JB |
507 | */ |
508 | #define IEEE80211_HW_DEVICE_STRIPS_MIC (1<<8) | |
509 | ||
510 | /* Device is capable of performing full monitor mode even during | |
511 | * normal operation. */ | |
512 | #define IEEE80211_HW_MONITOR_DURING_OPER (1<<9) | |
513 | ||
514 | /* Device does not need BSSID filter set to broadcast in order to | |
515 | * receive all probe responses while scanning */ | |
516 | #define IEEE80211_HW_NO_PROBE_FILTERING (1<<10) | |
517 | ||
518 | /* Channels are already configured to the default regulatory domain | |
519 | * specified in the device's EEPROM */ | |
520 | #define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11) | |
521 | ||
522 | /* calculate Michael MIC for an MSDU when doing hwcrypto */ | |
523 | #define IEEE80211_HW_TKIP_INCLUDE_MMIC (1<<12) | |
524 | /* Do TKIP phase1 key mixing in stack to support cards only do | |
525 | * phase2 key mixing when doing hwcrypto */ | |
526 | #define IEEE80211_HW_TKIP_REQ_PHASE1_KEY (1<<13) | |
527 | /* Do TKIP phase1 and phase2 key mixing in stack and send the generated | |
528 | * per-packet RC4 key with each TX frame when doing hwcrypto */ | |
529 | #define IEEE80211_HW_TKIP_REQ_PHASE2_KEY (1<<14) | |
530 | ||
531 | u32 flags; /* hardware flags defined above */ | |
532 | ||
533 | /* Set to the size of a needed device specific skb headroom for TX skbs. */ | |
534 | unsigned int extra_tx_headroom; | |
535 | ||
536 | /* This is the time in us to change channels | |
537 | */ | |
538 | int channel_change_time; | |
539 | /* Maximum values for various statistics. | |
540 | * Leave at 0 to indicate no support. Use negative numbers for dBm. */ | |
541 | s8 max_rssi; | |
542 | s8 max_signal; | |
543 | s8 max_noise; | |
544 | ||
545 | /* Number of available hardware TX queues for data packets. | |
546 | * WMM requires at least four queues. */ | |
547 | int queues; | |
548 | }; | |
549 | ||
550 | static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) | |
551 | { | |
552 | set_wiphy_dev(hw->wiphy, dev); | |
553 | } | |
554 | ||
555 | static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr) | |
556 | { | |
557 | memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN); | |
558 | } | |
559 | ||
560 | /* Configuration block used by the low-level driver to tell the 802.11 code | |
561 | * about supported hardware features and to pass function pointers to callback | |
562 | * functions. */ | |
563 | struct ieee80211_ops { | |
564 | /* Handler that 802.11 module calls for each transmitted frame. | |
565 | * skb contains the buffer starting from the IEEE 802.11 header. | |
566 | * The low-level driver should send the frame out based on | |
567 | * configuration in the TX control data. | |
568 | * Must be atomic. */ | |
569 | int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, | |
570 | struct ieee80211_tx_control *control); | |
571 | ||
f0706e82 JB |
572 | /* Handler that is called when any netdevice attached to the hardware |
573 | * device is set UP for the first time. This can be used, e.g., to | |
574 | * enable interrupts and beacon sending. */ | |
575 | int (*open)(struct ieee80211_hw *hw); | |
576 | ||
577 | /* Handler that is called when the last netdevice attached to the | |
578 | * hardware device is set DOWN. This can be used, e.g., to disable | |
579 | * interrupts and beacon sending. */ | |
580 | int (*stop)(struct ieee80211_hw *hw); | |
581 | ||
582 | /* Handler for asking a driver if a new interface can be added (or, | |
583 | * more exactly, set UP). If the handler returns zero, the interface | |
584 | * is added. Driver should perform any initialization it needs prior | |
585 | * to returning zero. By returning non-zero addition of the interface | |
586 | * is inhibited. Unless monitor_during_oper is set, it is guaranteed | |
587 | * that monitor interfaces and normal interfaces are mutually | |
4480f15c JB |
588 | * exclusive. If assigned, the open() handler is called after |
589 | * add_interface() if this is the first device added. The | |
590 | * add_interface() callback has to be assigned because it is the only | |
591 | * way to obtain the requested MAC address for any interface. | |
592 | */ | |
f0706e82 JB |
593 | int (*add_interface)(struct ieee80211_hw *hw, |
594 | struct ieee80211_if_init_conf *conf); | |
595 | ||
596 | /* Notify a driver that an interface is going down. The stop() handler | |
597 | * is called prior to this if this is a last interface. */ | |
598 | void (*remove_interface)(struct ieee80211_hw *hw, | |
599 | struct ieee80211_if_init_conf *conf); | |
600 | ||
601 | /* Handler for configuration requests. IEEE 802.11 code calls this | |
602 | * function to change hardware configuration, e.g., channel. */ | |
603 | int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); | |
604 | ||
605 | /* Handler for configuration requests related to interfaces (e.g. | |
606 | * BSSID). */ | |
607 | int (*config_interface)(struct ieee80211_hw *hw, | |
608 | int if_id, struct ieee80211_if_conf *conf); | |
609 | ||
610 | /* ieee80211 drivers do not have access to the &struct net_device | |
611 | * that is (are) connected with their device. Hence (and because | |
612 | * we need to combine the multicast lists and flags for multiple | |
613 | * virtual interfaces), they cannot assign set_multicast_list. | |
614 | * The parameters here replace dev->flags and dev->mc_count, | |
615 | * dev->mc_list is replaced by calling ieee80211_get_mc_list_item. | |
616 | * Must be atomic. */ | |
617 | void (*set_multicast_list)(struct ieee80211_hw *hw, | |
618 | unsigned short flags, int mc_count); | |
619 | ||
620 | /* Set TIM bit handler. If the hardware/firmware takes care of beacon | |
621 | * generation, IEEE 802.11 code uses this function to tell the | |
622 | * low-level to set (or clear if set==0) TIM bit for the given aid. If | |
623 | * host system is used to generate beacons, this handler is not used | |
624 | * and low-level driver should set it to NULL. | |
625 | * Must be atomic. */ | |
626 | int (*set_tim)(struct ieee80211_hw *hw, int aid, int set); | |
627 | ||
628 | /* Set encryption key. IEEE 802.11 module calls this function to set | |
629 | * encryption keys. addr is ff:ff:ff:ff:ff:ff for default keys and | |
630 | * station hwaddr for individual keys. aid of the station is given | |
631 | * to help low-level driver in selecting which key->hw_key_idx to use | |
632 | * for this key. TX control data will use the hw_key_idx selected by | |
be8755e1 | 633 | * the low-level driver. */ |
f0706e82 JB |
634 | int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd, |
635 | u8 *addr, struct ieee80211_key_conf *key, int aid); | |
636 | ||
637 | /* Set TX key index for default/broadcast keys. This is needed in cases | |
638 | * where wlan card is doing full WEP/TKIP encapsulation (wep_include_iv | |
639 | * is not set), in other cases, this function pointer can be set to | |
640 | * NULL since the IEEE 802. 11 module takes care of selecting the key | |
641 | * index for each TX frame. */ | |
642 | int (*set_key_idx)(struct ieee80211_hw *hw, int idx); | |
643 | ||
644 | /* Enable/disable IEEE 802.1X. This item requests wlan card to pass | |
645 | * unencrypted EAPOL-Key frames even when encryption is configured. | |
646 | * If the wlan card does not require such a configuration, this | |
647 | * function pointer can be set to NULL. */ | |
648 | int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x); | |
649 | ||
650 | /* Set port authorization state (IEEE 802.1X PAE) to be authorized | |
651 | * (authorized=1) or unauthorized (authorized=0). This function can be | |
652 | * used if the wlan hardware or low-level driver implements PAE. | |
653 | * 80211.o module will anyway filter frames based on authorization | |
654 | * state, so this function pointer can be NULL if low-level driver does | |
655 | * not require event notification about port state changes. | |
656 | * Currently unused. */ | |
657 | int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr, | |
658 | int authorized); | |
659 | ||
660 | /* Ask the hardware to service the scan request, no need to start | |
661 | * the scan state machine in stack. */ | |
662 | int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); | |
663 | ||
664 | /* return low-level statistics */ | |
665 | int (*get_stats)(struct ieee80211_hw *hw, | |
666 | struct ieee80211_low_level_stats *stats); | |
667 | ||
668 | /* For devices that generate their own beacons and probe response | |
669 | * or association responses this updates the state of privacy_invoked | |
670 | * returns 0 for success or an error number */ | |
671 | int (*set_privacy_invoked)(struct ieee80211_hw *hw, | |
672 | int privacy_invoked); | |
673 | ||
674 | /* For devices that have internal sequence counters, allow 802.11 | |
675 | * code to access the current value of a counter */ | |
676 | int (*get_sequence_counter)(struct ieee80211_hw *hw, | |
677 | u8* addr, u8 keyidx, u8 txrx, | |
678 | u32* iv32, u16* iv16); | |
679 | ||
680 | /* Configuration of RTS threshold (if device needs it) */ | |
681 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); | |
682 | ||
683 | /* Configuration of fragmentation threshold. | |
684 | * Assign this if the device does fragmentation by itself, | |
685 | * if this method is assigned then the stack will not do | |
686 | * fragmentation. */ | |
687 | int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); | |
688 | ||
689 | /* Configuration of retry limits (if device needs it) */ | |
690 | int (*set_retry_limit)(struct ieee80211_hw *hw, | |
691 | u32 short_retry, u32 long_retr); | |
692 | ||
693 | /* Number of STAs in STA table notification (NULL = disabled). | |
694 | * Must be atomic. */ | |
695 | void (*sta_table_notification)(struct ieee80211_hw *hw, | |
696 | int num_sta); | |
697 | ||
d9430a32 DD |
698 | /* Handle ERP IE change notifications. Must be atomic. */ |
699 | void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes, | |
700 | int cts_protection, int preamble); | |
701 | ||
702 | /* Flags for the erp_ie_changed changes parameter */ | |
703 | #define IEEE80211_ERP_CHANGE_PROTECTION (1<<0) /* protection flag changed */ | |
704 | #define IEEE80211_ERP_CHANGE_PREAMBLE (1<<1) /* barker preamble mode changed */ | |
705 | ||
f0706e82 JB |
706 | /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), |
707 | * bursting) for a hardware TX queue. | |
708 | * queue = IEEE80211_TX_QUEUE_*. | |
709 | * Must be atomic. */ | |
710 | int (*conf_tx)(struct ieee80211_hw *hw, int queue, | |
711 | const struct ieee80211_tx_queue_params *params); | |
712 | ||
713 | /* Get statistics of the current TX queue status. This is used to get | |
714 | * number of currently queued packets (queue length), maximum queue | |
715 | * size (limit), and total number of packets sent using each TX queue | |
716 | * (count). | |
717 | * Currently unused. */ | |
718 | int (*get_tx_stats)(struct ieee80211_hw *hw, | |
719 | struct ieee80211_tx_queue_stats *stats); | |
720 | ||
721 | /* Get the current TSF timer value from firmware/hardware. Currently, | |
722 | * this is only used for IBSS mode debugging and, as such, is not a | |
723 | * required function. | |
724 | * Must be atomic. */ | |
725 | u64 (*get_tsf)(struct ieee80211_hw *hw); | |
726 | ||
727 | /* Reset the TSF timer and allow firmware/hardware to synchronize with | |
728 | * other STAs in the IBSS. This is only used in IBSS mode. This | |
729 | * function is optional if the firmware/hardware takes full care of | |
730 | * TSF synchronization. */ | |
731 | void (*reset_tsf)(struct ieee80211_hw *hw); | |
732 | ||
733 | /* Setup beacon data for IBSS beacons. Unlike access point (Master), | |
734 | * IBSS uses a fixed beacon frame which is configured using this | |
735 | * function. This handler is required only for IBSS mode. */ | |
736 | int (*beacon_update)(struct ieee80211_hw *hw, | |
737 | struct sk_buff *skb, | |
738 | struct ieee80211_tx_control *control); | |
739 | ||
740 | /* Determine whether the last IBSS beacon was sent by us. This is | |
741 | * needed only for IBSS mode and the result of this function is used to | |
742 | * determine whether to reply to Probe Requests. */ | |
743 | int (*tx_last_beacon)(struct ieee80211_hw *hw); | |
744 | }; | |
745 | ||
746 | /* Allocate a new hardware device. This must be called once for each | |
747 | * hardware device. The returned pointer must be used to refer to this | |
748 | * device when calling other functions. 802.11 code allocates a private data | |
749 | * area for the low-level driver. The size of this area is given as | |
750 | * priv_data_len. | |
751 | */ | |
752 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |
753 | const struct ieee80211_ops *ops); | |
754 | ||
755 | /* Register hardware device to the IEEE 802.11 code and kernel. Low-level | |
756 | * drivers must call this function before using any other IEEE 802.11 | |
757 | * function except ieee80211_register_hwmode. */ | |
758 | int ieee80211_register_hw(struct ieee80211_hw *hw); | |
759 | ||
760 | /* driver can use this and ieee80211_get_rx_led_name to get the | |
761 | * name of the registered LEDs after ieee80211_register_hw | |
762 | * was called. | |
763 | * This is useful to set the default trigger on the LED class | |
764 | * device that your driver should export for each LED the device | |
765 | * has, that way the default behaviour will be as expected but | |
766 | * the user can still change it/turn off the LED etc. | |
767 | */ | |
768 | #ifdef CONFIG_MAC80211_LEDS | |
769 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); | |
770 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); | |
771 | #endif | |
772 | static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw) | |
773 | { | |
774 | #ifdef CONFIG_MAC80211_LEDS | |
775 | return __ieee80211_get_tx_led_name(hw); | |
776 | #else | |
777 | return NULL; | |
778 | #endif | |
779 | } | |
780 | ||
781 | static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw) | |
782 | { | |
783 | #ifdef CONFIG_MAC80211_LEDS | |
784 | return __ieee80211_get_rx_led_name(hw); | |
785 | #else | |
786 | return NULL; | |
787 | #endif | |
788 | } | |
789 | ||
790 | /* Register a new hardware PHYMODE capability to the stack. */ | |
791 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, | |
792 | struct ieee80211_hw_mode *mode); | |
793 | ||
794 | /* Unregister a hardware device. This function instructs 802.11 code to free | |
795 | * allocated resources and unregister netdevices from the kernel. */ | |
796 | void ieee80211_unregister_hw(struct ieee80211_hw *hw); | |
797 | ||
798 | /* Free everything that was allocated including private data of a driver. */ | |
799 | void ieee80211_free_hw(struct ieee80211_hw *hw); | |
800 | ||
801 | /* Receive frame callback function. The low-level driver uses this function to | |
802 | * send received frames to the IEEE 802.11 code. Receive buffer (skb) must | |
803 | * start with IEEE 802.11 header. */ | |
804 | void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |
805 | struct ieee80211_rx_status *status); | |
806 | void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, | |
807 | struct sk_buff *skb, | |
808 | struct ieee80211_rx_status *status); | |
809 | ||
810 | /* Transmit status callback function. The low-level driver must call this | |
811 | * function to report transmit status for all the TX frames that had | |
812 | * req_tx_status set in the transmit control fields. In addition, this should | |
813 | * be called at least for all unicast frames to provide information for TX rate | |
814 | * control algorithm. In order to maintain all statistics, this function is | |
815 | * recommended to be called after each frame, including multicast/broadcast, is | |
816 | * sent. */ | |
817 | void ieee80211_tx_status(struct ieee80211_hw *hw, | |
818 | struct sk_buff *skb, | |
819 | struct ieee80211_tx_status *status); | |
820 | void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, | |
821 | struct sk_buff *skb, | |
822 | struct ieee80211_tx_status *status); | |
823 | ||
824 | /** | |
825 | * ieee80211_beacon_get - beacon generation function | |
826 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
827 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | |
828 | * @control: will be filled with information needed to send this beacon. | |
829 | * | |
830 | * If the beacon frames are generated by the host system (i.e., not in | |
831 | * hardware/firmware), the low-level driver uses this function to receive | |
832 | * the next beacon frame from the 802.11 code. The low-level is responsible | |
833 | * for calling this function before beacon data is needed (e.g., based on | |
834 | * hardware interrupt). Returned skb is used only once and low-level driver | |
835 | * is responsible of freeing it. | |
836 | */ | |
837 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |
838 | int if_id, | |
839 | struct ieee80211_tx_control *control); | |
840 | ||
841 | /** | |
842 | * ieee80211_rts_get - RTS frame generation function | |
843 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
7e9ed188 | 844 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
f0706e82 JB |
845 | * @frame: pointer to the frame that is going to be protected by the RTS. |
846 | * @frame_len: the frame length (in octets). | |
847 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
848 | * @rts: The buffer where to store the RTS frame. | |
849 | * | |
850 | * If the RTS frames are generated by the host system (i.e., not in | |
851 | * hardware/firmware), the low-level driver uses this function to receive | |
852 | * the next RTS frame from the 802.11 code. The low-level is responsible | |
853 | * for calling this function before and RTS frame is needed. | |
854 | */ | |
7e9ed188 | 855 | void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, |
f0706e82 JB |
856 | const void *frame, size_t frame_len, |
857 | const struct ieee80211_tx_control *frame_txctl, | |
858 | struct ieee80211_rts *rts); | |
859 | ||
860 | /** | |
861 | * ieee80211_rts_duration - Get the duration field for an RTS frame | |
862 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
7e9ed188 | 863 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
f0706e82 JB |
864 | * @frame_len: the length of the frame that is going to be protected by the RTS. |
865 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
866 | * | |
867 | * If the RTS is generated in firmware, but the host system must provide | |
868 | * the duration field, the low-level driver uses this function to receive | |
869 | * the duration field value in little-endian byteorder. | |
870 | */ | |
7e9ed188 | 871 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, |
f0706e82 JB |
872 | size_t frame_len, |
873 | const struct ieee80211_tx_control *frame_txctl); | |
874 | ||
875 | /** | |
876 | * ieee80211_ctstoself_get - CTS-to-self frame generation function | |
877 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
7e9ed188 | 878 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
f0706e82 JB |
879 | * @frame: pointer to the frame that is going to be protected by the CTS-to-self. |
880 | * @frame_len: the frame length (in octets). | |
881 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
882 | * @cts: The buffer where to store the CTS-to-self frame. | |
883 | * | |
884 | * If the CTS-to-self frames are generated by the host system (i.e., not in | |
885 | * hardware/firmware), the low-level driver uses this function to receive | |
886 | * the next CTS-to-self frame from the 802.11 code. The low-level is responsible | |
887 | * for calling this function before and CTS-to-self frame is needed. | |
888 | */ | |
7e9ed188 | 889 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, |
f0706e82 JB |
890 | const void *frame, size_t frame_len, |
891 | const struct ieee80211_tx_control *frame_txctl, | |
892 | struct ieee80211_cts *cts); | |
893 | ||
894 | /** | |
895 | * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame | |
896 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
7e9ed188 | 897 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
f0706e82 JB |
898 | * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. |
899 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
900 | * | |
901 | * If the CTS-to-self is generated in firmware, but the host system must provide | |
902 | * the duration field, the low-level driver uses this function to receive | |
903 | * the duration field value in little-endian byteorder. | |
904 | */ | |
7e9ed188 | 905 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, |
f0706e82 JB |
906 | size_t frame_len, |
907 | const struct ieee80211_tx_control *frame_txctl); | |
908 | ||
909 | /** | |
910 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame | |
911 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
7e9ed188 | 912 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
f0706e82 JB |
913 | * @frame_len: the length of the frame. |
914 | * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. | |
915 | * | |
916 | * Calculate the duration field of some generic frame, given its | |
917 | * length and transmission rate (in 100kbps). | |
918 | */ | |
7e9ed188 | 919 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, |
f0706e82 JB |
920 | size_t frame_len, |
921 | int rate); | |
922 | ||
923 | /** | |
924 | * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames | |
925 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
926 | * @if_id: interface ID from &struct ieee80211_if_init_conf. | |
927 | * @control: will be filled with information needed to send returned frame. | |
928 | * | |
929 | * Function for accessing buffered broadcast and multicast frames. If | |
930 | * hardware/firmware does not implement buffering of broadcast/multicast | |
931 | * frames when power saving is used, 802.11 code buffers them in the host | |
932 | * memory. The low-level driver uses this function to fetch next buffered | |
933 | * frame. In most cases, this is used when generating beacon frame. This | |
934 | * function returns a pointer to the next buffered skb or NULL if no more | |
935 | * buffered frames are available. | |
936 | * | |
937 | * Note: buffered frames are returned only after DTIM beacon frame was | |
938 | * generated with ieee80211_beacon_get() and the low-level driver must thus | |
939 | * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns | |
940 | * NULL if the previous generated beacon was not DTIM, so the low-level driver | |
941 | * does not need to check for DTIM beacons separately and should be able to | |
942 | * use common code for all beacons. | |
943 | */ | |
944 | struct sk_buff * | |
945 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, | |
946 | struct ieee80211_tx_control *control); | |
947 | ||
f0706e82 JB |
948 | /* Given an sk_buff with a raw 802.11 header at the data pointer this function |
949 | * returns the 802.11 header length in bytes (not including encryption | |
950 | * headers). If the data in the sk_buff is too short to contain a valid 802.11 | |
951 | * header the function returns 0. | |
952 | */ | |
953 | int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); | |
954 | ||
955 | /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */ | |
956 | int ieee80211_get_hdrlen(u16 fc); | |
957 | ||
958 | /** | |
959 | * ieee80211_wake_queue - wake specific queue | |
960 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
961 | * @queue: queue number (counted from zero). | |
962 | * | |
963 | * Drivers should use this function instead of netif_wake_queue. | |
964 | */ | |
965 | void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue); | |
966 | ||
967 | /** | |
968 | * ieee80211_stop_queue - stop specific queue | |
969 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
970 | * @queue: queue number (counted from zero). | |
971 | * | |
972 | * Drivers should use this function instead of netif_stop_queue. | |
973 | */ | |
974 | void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue); | |
975 | ||
976 | /** | |
977 | * ieee80211_start_queues - start all queues | |
978 | * @hw: pointer to as obtained from ieee80211_alloc_hw(). | |
979 | * | |
980 | * Drivers should use this function instead of netif_start_queue. | |
981 | */ | |
982 | void ieee80211_start_queues(struct ieee80211_hw *hw); | |
983 | ||
984 | /** | |
985 | * ieee80211_stop_queues - stop all queues | |
986 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
987 | * | |
988 | * Drivers should use this function instead of netif_stop_queue. | |
989 | */ | |
990 | void ieee80211_stop_queues(struct ieee80211_hw *hw); | |
991 | ||
992 | /** | |
993 | * ieee80211_wake_queues - wake all queues | |
994 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
995 | * | |
996 | * Drivers should use this function instead of netif_wake_queue. | |
997 | */ | |
998 | void ieee80211_wake_queues(struct ieee80211_hw *hw); | |
999 | ||
1000 | /** | |
1001 | * ieee80211_get_mc_list_item - iteration over items in multicast list | |
1002 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1003 | * @prev: value returned by previous call to ieee80211_get_mc_list_item() or | |
1004 | * NULL to start a new iteration. | |
1005 | * @ptr: pointer to buffer of void * type for internal usage of | |
1006 | * ieee80211_get_mc_list_item(). | |
1007 | * | |
1008 | * Iterates over items in multicast list of given device. To get the first | |
1009 | * item, pass NULL in @prev and in *@ptr. In subsequent calls, pass the | |
1010 | * value returned by previous call in @prev. Don't alter *@ptr during | |
1011 | * iteration. When there are no more items, NULL is returned. | |
1012 | */ | |
1013 | struct dev_mc_list * | |
1014 | ieee80211_get_mc_list_item(struct ieee80211_hw *hw, | |
1015 | struct dev_mc_list *prev, | |
1016 | void **ptr); | |
1017 | ||
1018 | /* called by driver to notify scan status completed */ | |
1019 | void ieee80211_scan_completed(struct ieee80211_hw *hw); | |
1020 | ||
f0706e82 JB |
1021 | /* return a pointer to the source address (SA) */ |
1022 | static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr) | |
1023 | { | |
1024 | u8 *raw = (u8 *) hdr; | |
1025 | u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */ | |
1026 | ||
1027 | switch (tofrom) { | |
1028 | case 2: | |
1029 | return hdr->addr3; | |
1030 | case 3: | |
1031 | return hdr->addr4; | |
1032 | } | |
1033 | return hdr->addr2; | |
1034 | } | |
1035 | ||
1036 | /* return a pointer to the destination address (DA) */ | |
1037 | static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr) | |
1038 | { | |
1039 | u8 *raw = (u8 *) hdr; | |
1040 | u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */ | |
1041 | ||
1042 | if (to_ds) | |
1043 | return hdr->addr3; | |
1044 | return hdr->addr1; | |
1045 | } | |
1046 | ||
1047 | static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr) | |
1048 | { | |
1049 | return (le16_to_cpu(hdr->frame_control) & | |
1050 | IEEE80211_FCTL_MOREFRAGS) != 0; | |
1051 | } | |
1052 | ||
1053 | #define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" | |
1054 | #define MAC_ARG(x) ((u8*)(x))[0], ((u8*)(x))[1], ((u8*)(x))[2], \ | |
1055 | ((u8*)(x))[3], ((u8*)(x))[4], ((u8*)(x))[5] | |
1056 | ||
1057 | #endif /* MAC80211_H */ |