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 | ||
75a5f0cc JB |
25 | /** |
26 | * DOC: Introduction | |
27 | * | |
28 | * mac80211 is the Linux stack for 802.11 hardware that implements | |
29 | * only partial functionality in hard- or firmware. This document | |
30 | * defines the interface between mac80211 and low-level hardware | |
31 | * drivers. | |
32 | */ | |
33 | ||
34 | /** | |
35 | * DOC: Calling mac80211 from interrupts | |
36 | * | |
37 | * Only ieee80211_tx_status_irqsafe() and ieee80211_rx_irqsafe() can be | |
f0706e82 JB |
38 | * called in hardware interrupt context. The low-level driver must not call any |
39 | * other functions in hardware interrupt context. If there is a need for such | |
40 | * call, the low-level driver should first ACK the interrupt and perform the | |
2485f710 JB |
41 | * IEEE 802.11 code call after this, e.g. from a scheduled workqueue or even |
42 | * tasklet function. | |
43 | * | |
44 | * NOTE: If the driver opts to use the _irqsafe() functions, it may not also | |
45 | * use the non-irqsafe functions! | |
f0706e82 JB |
46 | */ |
47 | ||
75a5f0cc JB |
48 | /** |
49 | * DOC: Warning | |
50 | * | |
51 | * If you're reading this document and not the header file itself, it will | |
52 | * be incomplete because not all documentation has been converted yet. | |
53 | */ | |
54 | ||
55 | /** | |
56 | * DOC: Frame format | |
57 | * | |
58 | * As a general rule, when frames are passed between mac80211 and the driver, | |
59 | * they start with the IEEE 802.11 header and include the same octets that are | |
60 | * sent over the air except for the FCS which should be calculated by the | |
61 | * hardware. | |
62 | * | |
63 | * There are, however, various exceptions to this rule for advanced features: | |
64 | * | |
65 | * The first exception is for hardware encryption and decryption offload | |
66 | * where the IV/ICV may or may not be generated in hardware. | |
67 | * | |
68 | * Secondly, when the hardware handles fragmentation, the frame handed to | |
69 | * the driver from mac80211 is the MSDU, not the MPDU. | |
70 | * | |
71 | * Finally, for received frames, the driver is able to indicate that it has | |
72 | * filled a radiotap header and put that in front of the frame; if it does | |
73 | * not do so then mac80211 may add this under certain circumstances. | |
f0706e82 JB |
74 | */ |
75 | ||
84363e6e MA |
76 | /** |
77 | * enum ieee80211_notification_type - Low level driver notification | |
78 | * @IEEE80211_NOTIFY_RE_ASSOC: start the re-association sequence | |
79 | */ | |
80 | enum ieee80211_notification_types { | |
81 | IEEE80211_NOTIFY_RE_ASSOC, | |
82 | }; | |
83 | ||
10816d40 RR |
84 | /** |
85 | * struct ieee80211_ht_bss_info - describing BSS's HT characteristics | |
86 | * | |
87 | * This structure describes most essential parameters needed | |
88 | * to describe 802.11n HT characteristics in a BSS | |
89 | * | |
90 | * @primary_channel: channel number of primery channel | |
91 | * @bss_cap: 802.11n's general BSS capabilities (e.g. channel width) | |
92 | * @bss_op_mode: 802.11n's BSS operation modes (e.g. HT protection) | |
93 | */ | |
94 | struct ieee80211_ht_bss_info { | |
95 | u8 primary_channel; | |
96 | u8 bss_cap; /* use IEEE80211_HT_IE_CHA_ */ | |
97 | u8 bss_op_mode; /* use IEEE80211_HT_IE_ */ | |
98 | }; | |
99 | ||
e100bb64 JB |
100 | /** |
101 | * enum ieee80211_max_queues - maximum number of queues | |
102 | * | |
103 | * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. | |
104 | * @IEEE80211_MAX_AMPDU_QUEUES: Maximum number of queues usable | |
105 | * for A-MPDU operation. | |
106 | */ | |
107 | enum ieee80211_max_queues { | |
108 | IEEE80211_MAX_QUEUES = 16, | |
109 | IEEE80211_MAX_AMPDU_QUEUES = 16, | |
110 | }; | |
111 | ||
6b301cdf JB |
112 | /** |
113 | * struct ieee80211_tx_queue_params - transmit queue configuration | |
114 | * | |
115 | * The information provided in this structure is required for QoS | |
3330d7be | 116 | * transmit queue configuration. Cf. IEEE 802.11 7.3.2.29. |
6b301cdf JB |
117 | * |
118 | * @aifs: arbitration interface space [0..255, -1: use default] | |
119 | * @cw_min: minimum contention window [will be a value of the form | |
120 | * 2^n-1 in the range 1..1023; 0: use default] | |
121 | * @cw_max: maximum contention window [like @cw_min] | |
3330d7be | 122 | * @txop: maximum burst time in units of 32 usecs, 0 meaning disabled |
6b301cdf | 123 | */ |
f0706e82 | 124 | struct ieee80211_tx_queue_params { |
3330d7be JB |
125 | s16 aifs; |
126 | u16 cw_min; | |
127 | u16 cw_max; | |
128 | u16 txop; | |
f0706e82 JB |
129 | }; |
130 | ||
6b301cdf | 131 | /** |
57ffc589 | 132 | * struct ieee80211_tx_queue_stats - transmit queue statistics |
6b301cdf JB |
133 | * |
134 | * @len: number of packets in queue | |
135 | * @limit: queue length limit | |
136 | * @count: number of frames sent | |
137 | */ | |
57ffc589 | 138 | struct ieee80211_tx_queue_stats { |
6b301cdf JB |
139 | unsigned int len; |
140 | unsigned int limit; | |
141 | unsigned int count; | |
f0706e82 JB |
142 | }; |
143 | ||
f0706e82 JB |
144 | struct ieee80211_low_level_stats { |
145 | unsigned int dot11ACKFailureCount; | |
146 | unsigned int dot11RTSFailureCount; | |
147 | unsigned int dot11FCSErrorCount; | |
148 | unsigned int dot11RTSSuccessCount; | |
149 | }; | |
150 | ||
471b3efd JB |
151 | /** |
152 | * enum ieee80211_bss_change - BSS change notification flags | |
153 | * | |
154 | * These flags are used with the bss_info_changed() callback | |
155 | * to indicate which BSS parameter changed. | |
156 | * | |
157 | * @BSS_CHANGED_ASSOC: association status changed (associated/disassociated), | |
158 | * also implies a change in the AID. | |
159 | * @BSS_CHANGED_ERP_CTS_PROT: CTS protection changed | |
160 | * @BSS_CHANGED_ERP_PREAMBLE: preamble changed | |
38668c05 | 161 | * @BSS_CHANGED_HT: 802.11n parameters changed |
471b3efd JB |
162 | */ |
163 | enum ieee80211_bss_change { | |
164 | BSS_CHANGED_ASSOC = 1<<0, | |
165 | BSS_CHANGED_ERP_CTS_PROT = 1<<1, | |
166 | BSS_CHANGED_ERP_PREAMBLE = 1<<2, | |
38668c05 | 167 | BSS_CHANGED_HT = 1<<4, |
471b3efd JB |
168 | }; |
169 | ||
170 | /** | |
171 | * struct ieee80211_bss_conf - holds the BSS's changing parameters | |
172 | * | |
173 | * This structure keeps information about a BSS (and an association | |
174 | * to that BSS) that can change during the lifetime of the BSS. | |
175 | * | |
176 | * @assoc: association status | |
177 | * @aid: association ID number, valid only when @assoc is true | |
178 | * @use_cts_prot: use CTS protection | |
179 | * @use_short_preamble: use 802.11b short preamble | |
21c0cbe7 TW |
180 | * @timestamp: beacon timestamp |
181 | * @beacon_int: beacon interval | |
182 | * @assoc_capability: capabbilities taken from assoc resp | |
38668c05 TW |
183 | * @assoc_ht: association in HT mode |
184 | * @ht_conf: ht capabilities | |
185 | * @ht_bss_conf: ht extended capabilities | |
471b3efd JB |
186 | */ |
187 | struct ieee80211_bss_conf { | |
188 | /* association related data */ | |
189 | bool assoc; | |
190 | u16 aid; | |
191 | /* erp related data */ | |
192 | bool use_cts_prot; | |
193 | bool use_short_preamble; | |
21c0cbe7 TW |
194 | u16 beacon_int; |
195 | u16 assoc_capability; | |
196 | u64 timestamp; | |
38668c05 TW |
197 | /* ht related data */ |
198 | bool assoc_ht; | |
199 | struct ieee80211_ht_info *ht_conf; | |
200 | struct ieee80211_ht_bss_info *ht_bss_conf; | |
471b3efd JB |
201 | }; |
202 | ||
11f4b1ce RR |
203 | /** |
204 | * enum mac80211_tx_control_flags - flags to describe Tx configuration for | |
205 | * the Tx frame | |
206 | * | |
207 | * These flags are used with the @flags member of &ieee80211_tx_control | |
208 | * | |
209 | * @IEEE80211_TXCTL_REQ_TX_STATUS: request TX status callback for this frame. | |
210 | * @IEEE80211_TXCTL_DO_NOT_ENCRYPT: send this frame without encryption; | |
211 | * e.g., for EAPOL frame | |
212 | * @IEEE80211_TXCTL_USE_RTS_CTS: use RTS-CTS before sending frame | |
213 | * @IEEE80211_TXCTL_USE_CTS_PROTECT: use CTS protection for the frame (e.g., | |
214 | * for combined 802.11g / 802.11b networks) | |
215 | * @IEEE80211_TXCTL_NO_ACK: tell the low level not to wait for an ack | |
216 | * @IEEE80211_TXCTL_RATE_CTRL_PROBE | |
217 | * @EEE80211_TXCTL_CLEAR_PS_FILT: clear powersave filter | |
218 | * for destination station | |
219 | * @IEEE80211_TXCTL_REQUEUE: | |
220 | * @IEEE80211_TXCTL_FIRST_FRAGMENT: this is a first fragment of the frame | |
221 | * @IEEE80211_TXCTL_LONG_RETRY_LIMIT: this frame should be send using the | |
222 | * through set_retry_limit configured long | |
223 | * retry value | |
224 | * @IEEE80211_TXCTL_EAPOL_FRAME: internal to mac80211 | |
225 | * @IEEE80211_TXCTL_SEND_AFTER_DTIM: send this frame after DTIM beacon | |
226 | * @IEEE80211_TXCTL_AMPDU: this frame should be sent as part of an A-MPDU | |
6c5ef8a7 RR |
227 | * @IEEE80211_TXCTL_OFDM_HT: this frame can be sent in HT OFDM rates. number |
228 | * of streams when this flag is on can be extracted | |
229 | * from antenna_sel_tx, so if 1 antenna is marked | |
230 | * use SISO, 2 antennas marked use MIMO, n antennas | |
231 | * marked use MIMO_n. | |
11f4b1ce RR |
232 | * @IEEE80211_TXCTL_GREEN_FIELD: use green field protection for this frame |
233 | * @IEEE80211_TXCTL_40_MHZ_WIDTH: send this frame using 40 Mhz channel width | |
234 | * @IEEE80211_TXCTL_DUP_DATA: duplicate data frame on both 20 Mhz channels | |
235 | * @IEEE80211_TXCTL_SHORT_GI: send this frame using short guard interval | |
236 | */ | |
237 | enum mac80211_tx_control_flags { | |
238 | IEEE80211_TXCTL_REQ_TX_STATUS = (1<<0), | |
239 | IEEE80211_TXCTL_DO_NOT_ENCRYPT = (1<<1), | |
240 | IEEE80211_TXCTL_USE_RTS_CTS = (1<<2), | |
241 | IEEE80211_TXCTL_USE_CTS_PROTECT = (1<<3), | |
242 | IEEE80211_TXCTL_NO_ACK = (1<<4), | |
243 | IEEE80211_TXCTL_RATE_CTRL_PROBE = (1<<5), | |
244 | IEEE80211_TXCTL_CLEAR_PS_FILT = (1<<6), | |
245 | IEEE80211_TXCTL_REQUEUE = (1<<7), | |
246 | IEEE80211_TXCTL_FIRST_FRAGMENT = (1<<8), | |
247 | IEEE80211_TXCTL_SHORT_PREAMBLE = (1<<9), | |
248 | IEEE80211_TXCTL_LONG_RETRY_LIMIT = (1<<10), | |
249 | IEEE80211_TXCTL_EAPOL_FRAME = (1<<11), | |
250 | IEEE80211_TXCTL_SEND_AFTER_DTIM = (1<<12), | |
251 | IEEE80211_TXCTL_AMPDU = (1<<13), | |
252 | IEEE80211_TXCTL_OFDM_HT = (1<<14), | |
253 | IEEE80211_TXCTL_GREEN_FIELD = (1<<15), | |
254 | IEEE80211_TXCTL_40_MHZ_WIDTH = (1<<16), | |
255 | IEEE80211_TXCTL_DUP_DATA = (1<<17), | |
256 | IEEE80211_TXCTL_SHORT_GI = (1<<18), | |
257 | }; | |
258 | ||
f0706e82 JB |
259 | /* Transmit control fields. This data structure is passed to low-level driver |
260 | * with each TX frame. The low-level driver is responsible for configuring | |
1c014420 ID |
261 | * the hardware to use given values (depending on what is supported). |
262 | * | |
263 | * NOTE: Be careful with using the pointers outside of the ieee80211_ops->tx() | |
264 | * context (i.e. when defering the work to a workqueue). | |
265 | * The vif pointer is valid until the it has been removed with the | |
266 | * ieee80211_ops->remove_interface() callback funtion. | |
267 | * The hw_key pointer is valid until it has been removed with the | |
268 | * ieee80211_ops->set_key() callback function. | |
269 | * The tx_rate and alt_retry_rate pointers are valid until the phy is | |
270 | * deregistered. | |
271 | */ | |
f0706e82 | 272 | struct ieee80211_tx_control { |
32bfd35d | 273 | struct ieee80211_vif *vif; |
8318d78a JB |
274 | struct ieee80211_rate *tx_rate; |
275 | ||
276 | /* Transmit rate for RTS/CTS frame */ | |
277 | struct ieee80211_rate *rts_cts_rate; | |
278 | ||
279 | /* retry rate for the last retries */ | |
280 | struct ieee80211_rate *alt_retry_rate; | |
f0706e82 | 281 | |
1c014420 ID |
282 | /* Key used for hardware encryption |
283 | * NULL if IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */ | |
284 | struct ieee80211_key_conf *hw_key; | |
285 | ||
11f4b1ce | 286 | u32 flags; /* tx control flags defined above */ |
d5d08def ID |
287 | u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. |
288 | * This could be used when set_retry_limit | |
289 | * is not implemented by the driver */ | |
11f4b1ce RR |
290 | u8 antenna_sel_tx; /* 0 = default/diversity, otherwise bit |
291 | * position represents antenna number used */ | |
f0706e82 JB |
292 | u8 icv_len; /* length of the ICV/MIC field in octets */ |
293 | u8 iv_len; /* length of the IV field in octets */ | |
e100bb64 | 294 | u16 queue; /* hardware queue to use for this frame; |
f0706e82 | 295 | * 0 = highest, hw->queues-1 = lowest */ |
fff77109 | 296 | u16 aid; /* Station AID */ |
f0706e82 | 297 | int type; /* internal */ |
f0706e82 JB |
298 | }; |
299 | ||
7ac1bd6a JB |
300 | |
301 | /** | |
302 | * enum mac80211_rx_flags - receive flags | |
303 | * | |
304 | * These flags are used with the @flag member of &struct ieee80211_rx_status. | |
305 | * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame. | |
306 | * Use together with %RX_FLAG_MMIC_STRIPPED. | |
307 | * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware. | |
308 | * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header. | |
309 | * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame, | |
310 | * verification has been done by the hardware. | |
311 | * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame. | |
312 | * If this flag is set, the stack cannot do any replay detection | |
313 | * hence the driver or hardware will have to do that. | |
72abd81b JB |
314 | * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on |
315 | * the frame. | |
316 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on | |
317 | * the frame. | |
c49e5ea3 | 318 | * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) |
9d9bf77d BR |
319 | * is valid. This is useful in monitor mode and necessary for beacon frames |
320 | * to enable IBSS merging. | |
7ac1bd6a JB |
321 | */ |
322 | enum mac80211_rx_flags { | |
323 | RX_FLAG_MMIC_ERROR = 1<<0, | |
324 | RX_FLAG_DECRYPTED = 1<<1, | |
325 | RX_FLAG_RADIOTAP = 1<<2, | |
326 | RX_FLAG_MMIC_STRIPPED = 1<<3, | |
327 | RX_FLAG_IV_STRIPPED = 1<<4, | |
72abd81b JB |
328 | RX_FLAG_FAILED_FCS_CRC = 1<<5, |
329 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, | |
c49e5ea3 | 330 | RX_FLAG_TSFT = 1<<7, |
7ac1bd6a JB |
331 | }; |
332 | ||
333 | /** | |
334 | * struct ieee80211_rx_status - receive status | |
335 | * | |
336 | * The low-level driver should provide this information (the subset | |
337 | * supported by hardware) to the 802.11 code with each received | |
338 | * frame. | |
c132bec3 BR |
339 | * @mactime: value in microseconds of the 64-bit Time Synchronization Function |
340 | * (TSF) timer when the first data symbol (MPDU) arrived at the hardware. | |
8318d78a | 341 | * @band: the active band when this frame was received |
7ac1bd6a | 342 | * @freq: frequency the radio was tuned to when receiving this frame, in MHz |
7ac1bd6a JB |
343 | * @ssi: signal strength when receiving this frame |
344 | * @signal: used as 'qual' in statistics reporting | |
345 | * @noise: PHY noise when receiving this frame | |
346 | * @antenna: antenna used | |
8318d78a | 347 | * @rate_idx: index of data rate into band's supported rates |
7ac1bd6a JB |
348 | * @flag: %RX_FLAG_* |
349 | */ | |
f0706e82 JB |
350 | struct ieee80211_rx_status { |
351 | u64 mactime; | |
8318d78a | 352 | enum ieee80211_band band; |
7ac1bd6a | 353 | int freq; |
f0706e82 | 354 | int ssi; |
7ac1bd6a | 355 | int signal; |
f0706e82 JB |
356 | int noise; |
357 | int antenna; | |
8318d78a | 358 | int rate_idx; |
f0706e82 JB |
359 | int flag; |
360 | }; | |
361 | ||
6b301cdf JB |
362 | /** |
363 | * enum ieee80211_tx_status_flags - transmit status flags | |
364 | * | |
365 | * Status flags to indicate various transmit conditions. | |
366 | * | |
367 | * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted | |
368 | * because the destination STA was in powersave mode. | |
6b301cdf | 369 | * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged |
483fdcec RR |
370 | * @IEEE80211_TX_STATUS_AMPDU: The frame was aggregated, so status |
371 | * is for the whole aggregation. | |
6b301cdf JB |
372 | */ |
373 | enum ieee80211_tx_status_flags { | |
374 | IEEE80211_TX_STATUS_TX_FILTERED = 1<<0, | |
375 | IEEE80211_TX_STATUS_ACK = 1<<1, | |
483fdcec | 376 | IEEE80211_TX_STATUS_AMPDU = 1<<2, |
6b301cdf JB |
377 | }; |
378 | ||
379 | /** | |
380 | * struct ieee80211_tx_status - transmit status | |
381 | * | |
382 | * As much information as possible should be provided for each transmitted | |
383 | * frame with ieee80211_tx_status(). | |
384 | * | |
385 | * @control: a copy of the &struct ieee80211_tx_control passed to the driver | |
386 | * in the tx() callback. | |
6b301cdf | 387 | * @flags: transmit status flags, defined above |
483fdcec | 388 | * @retry_count: number of retries |
6b301cdf JB |
389 | * @excessive_retries: set to 1 if the frame was retried many times |
390 | * but not acknowledged | |
483fdcec RR |
391 | * @ampdu_ack_len: number of aggregated frames. |
392 | * relevant only if IEEE80211_TX_STATUS_AMPDU was set. | |
393 | * @ampdu_ack_map: block ack bit map for the aggregation. | |
394 | * relevant only if IEEE80211_TX_STATUS_AMPDU was set. | |
395 | * @ack_signal: signal strength of the ACK frame | |
6b301cdf | 396 | */ |
f0706e82 | 397 | struct ieee80211_tx_status { |
f0706e82 | 398 | struct ieee80211_tx_control control; |
6b301cdf | 399 | u8 flags; |
6b301cdf | 400 | u8 retry_count; |
483fdcec RR |
401 | bool excessive_retries; |
402 | u8 ampdu_ack_len; | |
403 | u64 ampdu_ack_map; | |
6b301cdf | 404 | int ack_signal; |
f0706e82 JB |
405 | }; |
406 | ||
6b301cdf JB |
407 | /** |
408 | * enum ieee80211_conf_flags - configuration flags | |
409 | * | |
410 | * Flags to define PHY configuration options | |
411 | * | |
412 | * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time | |
413 | * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported) | |
10816d40 | 414 | * @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported) |
6b301cdf JB |
415 | */ |
416 | enum ieee80211_conf_flags { | |
10816d40 RR |
417 | IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0), |
418 | IEEE80211_CONF_RADIOTAP = (1<<1), | |
419 | IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2), | |
6b301cdf | 420 | }; |
f0706e82 JB |
421 | |
422 | /** | |
423 | * struct ieee80211_conf - configuration of the device | |
424 | * | |
425 | * This struct indicates how the driver shall configure the hardware. | |
426 | * | |
427 | * @radio_enabled: when zero, driver is required to switch off the radio. | |
6b301cdf | 428 | * TODO make a flag |
6b301cdf JB |
429 | * @beacon_int: beacon interval (TODO make interface config) |
430 | * @flags: configuration flags defined above | |
8318d78a JB |
431 | * @power_level: requested transmit power (in dBm) |
432 | * @max_antenna_gain: maximum antenna gain (in dBi) | |
6b301cdf JB |
433 | * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, |
434 | * 1/2: antenna 0/1 | |
435 | * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx | |
10816d40 RR |
436 | * @ht_conf: describes current self configuration of 802.11n HT capabilies |
437 | * @ht_bss_conf: describes current BSS configuration of 802.11n HT parameters | |
8318d78a | 438 | * @channel: the channel to tune to |
f0706e82 JB |
439 | */ |
440 | struct ieee80211_conf { | |
f0706e82 JB |
441 | int radio_enabled; |
442 | ||
443 | int beacon_int; | |
6b301cdf | 444 | u32 flags; |
8318d78a JB |
445 | int power_level; |
446 | int max_antenna_gain; | |
f0706e82 JB |
447 | u8 antenna_sel_tx; |
448 | u8 antenna_sel_rx; | |
10816d40 | 449 | |
8318d78a JB |
450 | struct ieee80211_channel *channel; |
451 | ||
10816d40 RR |
452 | struct ieee80211_ht_info ht_conf; |
453 | struct ieee80211_ht_bss_info ht_bss_conf; | |
f0706e82 JB |
454 | }; |
455 | ||
456 | /** | |
457 | * enum ieee80211_if_types - types of 802.11 network interfaces | |
458 | * | |
a2897552 JB |
459 | * @IEEE80211_IF_TYPE_INVALID: invalid interface type, not used |
460 | * by mac80211 itself | |
f0706e82 JB |
461 | * @IEEE80211_IF_TYPE_AP: interface in AP mode. |
462 | * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap | |
463 | * daemon. Drivers should never see this type. | |
464 | * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode. | |
465 | * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode. | |
466 | * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode. | |
467 | * @IEEE80211_IF_TYPE_WDS: interface in WDS mode. | |
0ec3ca44 JB |
468 | * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers |
469 | * will never see this type. | |
dbbea671 | 470 | * @IEEE80211_IF_TYPE_MESH_POINT: 802.11s mesh point |
f0706e82 JB |
471 | */ |
472 | enum ieee80211_if_types { | |
a2897552 | 473 | IEEE80211_IF_TYPE_INVALID, |
0ec3ca44 | 474 | IEEE80211_IF_TYPE_AP, |
0ec3ca44 JB |
475 | IEEE80211_IF_TYPE_STA, |
476 | IEEE80211_IF_TYPE_IBSS, | |
6032f934 | 477 | IEEE80211_IF_TYPE_MESH_POINT, |
0ec3ca44 JB |
478 | IEEE80211_IF_TYPE_MNTR, |
479 | IEEE80211_IF_TYPE_WDS, | |
480 | IEEE80211_IF_TYPE_VLAN, | |
f0706e82 JB |
481 | }; |
482 | ||
32bfd35d JB |
483 | /** |
484 | * struct ieee80211_vif - per-interface data | |
485 | * | |
486 | * Data in this structure is continually present for driver | |
487 | * use during the life of a virtual interface. | |
488 | * | |
51fb61e7 | 489 | * @type: type of this virtual interface |
32bfd35d JB |
490 | * @drv_priv: data area for driver use, will always be aligned to |
491 | * sizeof(void *). | |
492 | */ | |
493 | struct ieee80211_vif { | |
51fb61e7 | 494 | enum ieee80211_if_types type; |
32bfd35d JB |
495 | /* must be last */ |
496 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); | |
497 | }; | |
498 | ||
902acc78 JB |
499 | static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) |
500 | { | |
501 | #ifdef CONFIG_MAC80211_MESH | |
502 | return vif->type == IEEE80211_IF_TYPE_MESH_POINT; | |
503 | #endif | |
504 | return false; | |
505 | } | |
506 | ||
f0706e82 JB |
507 | /** |
508 | * struct ieee80211_if_init_conf - initial configuration of an interface | |
509 | * | |
32bfd35d JB |
510 | * @vif: pointer to a driver-use per-interface structure. The pointer |
511 | * itself is also used for various functions including | |
512 | * ieee80211_beacon_get() and ieee80211_get_buffered_bc(). | |
f0706e82 JB |
513 | * @type: one of &enum ieee80211_if_types constants. Determines the type of |
514 | * added/removed interface. | |
515 | * @mac_addr: pointer to MAC address of the interface. This pointer is valid | |
516 | * until the interface is removed (i.e. it cannot be used after | |
517 | * remove_interface() callback was called for this interface). | |
518 | * | |
519 | * This structure is used in add_interface() and remove_interface() | |
520 | * callbacks of &struct ieee80211_hw. | |
4480f15c JB |
521 | * |
522 | * When you allow multiple interfaces to be added to your PHY, take care | |
523 | * that the hardware can actually handle multiple MAC addresses. However, | |
524 | * also take care that when there's no interface left with mac_addr != %NULL | |
525 | * you remove the MAC address from the device to avoid acknowledging packets | |
526 | * in pure monitor mode. | |
f0706e82 JB |
527 | */ |
528 | struct ieee80211_if_init_conf { | |
75a5f0cc | 529 | enum ieee80211_if_types type; |
32bfd35d | 530 | struct ieee80211_vif *vif; |
f0706e82 JB |
531 | void *mac_addr; |
532 | }; | |
533 | ||
534 | /** | |
535 | * struct ieee80211_if_conf - configuration of an interface | |
536 | * | |
537 | * @type: type of the interface. This is always the same as was specified in | |
538 | * &struct ieee80211_if_init_conf. The type of an interface never changes | |
539 | * during the life of the interface; this field is present only for | |
540 | * convenience. | |
541 | * @bssid: BSSID of the network we are associated to/creating. | |
542 | * @ssid: used (together with @ssid_len) by drivers for hardware that | |
543 | * generate beacons independently. The pointer is valid only during the | |
544 | * config_interface() call, so copy the value somewhere if you need | |
545 | * it. | |
546 | * @ssid_len: length of the @ssid field. | |
f0706e82 JB |
547 | * @beacon: beacon template. Valid only if @host_gen_beacon_template in |
548 | * &struct ieee80211_hw is set. The driver is responsible of freeing | |
549 | * the sk_buff. | |
550 | * @beacon_control: tx_control for the beacon template, this field is only | |
551 | * valid when the @beacon field was set. | |
552 | * | |
553 | * This structure is passed to the config_interface() callback of | |
554 | * &struct ieee80211_hw. | |
555 | */ | |
556 | struct ieee80211_if_conf { | |
557 | int type; | |
558 | u8 *bssid; | |
559 | u8 *ssid; | |
560 | size_t ssid_len; | |
f0706e82 JB |
561 | struct sk_buff *beacon; |
562 | struct ieee80211_tx_control *beacon_control; | |
563 | }; | |
564 | ||
7ac1bd6a JB |
565 | /** |
566 | * enum ieee80211_key_alg - key algorithm | |
7ac1bd6a JB |
567 | * @ALG_WEP: WEP40 or WEP104 |
568 | * @ALG_TKIP: TKIP | |
569 | * @ALG_CCMP: CCMP (AES) | |
570 | */ | |
ea49c359 | 571 | enum ieee80211_key_alg { |
8f20fc24 JB |
572 | ALG_WEP, |
573 | ALG_TKIP, | |
574 | ALG_CCMP, | |
ea49c359 | 575 | }; |
f0706e82 | 576 | |
7ac1bd6a JB |
577 | |
578 | /** | |
579 | * enum ieee80211_key_flags - key flags | |
580 | * | |
581 | * These flags are used for communication about keys between the driver | |
582 | * and mac80211, with the @flags parameter of &struct ieee80211_key_conf. | |
583 | * | |
584 | * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates | |
585 | * that the STA this key will be used with could be using QoS. | |
586 | * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the | |
587 | * driver to indicate that it requires IV generation for this | |
588 | * particular key. | |
589 | * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by | |
590 | * the driver for a TKIP key if it requires Michael MIC | |
591 | * generation in software. | |
c6adbd21 ID |
592 | * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates |
593 | * that the key is pairwise rather then a shared key. | |
7848ba7d | 594 | */ |
7ac1bd6a JB |
595 | enum ieee80211_key_flags { |
596 | IEEE80211_KEY_FLAG_WMM_STA = 1<<0, | |
597 | IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, | |
598 | IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, | |
c6adbd21 | 599 | IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, |
7ac1bd6a | 600 | }; |
11a843b7 | 601 | |
7ac1bd6a JB |
602 | /** |
603 | * struct ieee80211_key_conf - key information | |
604 | * | |
605 | * This key information is given by mac80211 to the driver by | |
606 | * the set_key() callback in &struct ieee80211_ops. | |
607 | * | |
608 | * @hw_key_idx: To be set by the driver, this is the key index the driver | |
609 | * wants to be given when a frame is transmitted and needs to be | |
6a7664d4 | 610 | * encrypted in hardware. |
7ac1bd6a JB |
611 | * @alg: The key algorithm. |
612 | * @flags: key flags, see &enum ieee80211_key_flags. | |
613 | * @keyidx: the key index (0-3) | |
614 | * @keylen: key material length | |
615 | * @key: key material | |
616 | */ | |
f0706e82 | 617 | struct ieee80211_key_conf { |
ea49c359 | 618 | enum ieee80211_key_alg alg; |
6a7664d4 | 619 | u8 hw_key_idx; |
11a843b7 | 620 | u8 flags; |
11a843b7 | 621 | s8 keyidx; |
11a843b7 | 622 | u8 keylen; |
f0706e82 JB |
623 | u8 key[0]; |
624 | }; | |
625 | ||
7ac1bd6a JB |
626 | /** |
627 | * enum set_key_cmd - key command | |
628 | * | |
629 | * Used with the set_key() callback in &struct ieee80211_ops, this | |
630 | * indicates whether a key is being removed or added. | |
631 | * | |
632 | * @SET_KEY: a key is set | |
633 | * @DISABLE_KEY: a key must be disabled | |
634 | */ | |
ea49c359 | 635 | enum set_key_cmd { |
11a843b7 | 636 | SET_KEY, DISABLE_KEY, |
ea49c359 | 637 | }; |
f0706e82 | 638 | |
478f8d2b TW |
639 | /** |
640 | * enum sta_notify_cmd - sta notify command | |
641 | * | |
642 | * Used with the sta_notify() callback in &struct ieee80211_ops, this | |
643 | * indicates addition and removal of a station to station table | |
644 | * | |
645 | * @STA_NOTIFY_ADD: a station was added to the station table | |
646 | * @STA_NOTIFY_REMOVE: a station being removed from the station table | |
647 | */ | |
648 | enum sta_notify_cmd { | |
649 | STA_NOTIFY_ADD, STA_NOTIFY_REMOVE | |
650 | }; | |
1bc0826c | 651 | |
5d2cdcd4 EG |
652 | /** |
653 | * enum ieee80211_tkip_key_type - get tkip key | |
654 | * | |
655 | * Used by drivers which need to get a tkip key for skb. Some drivers need a | |
656 | * phase 1 key, others need a phase 2 key. A single function allows the driver | |
657 | * to get the key, this enum indicates what type of key is required. | |
658 | * | |
659 | * @IEEE80211_TKIP_P1_KEY: the driver needs a phase 1 key | |
660 | * @IEEE80211_TKIP_P2_KEY: the driver needs a phase 2 key | |
661 | */ | |
662 | enum ieee80211_tkip_key_type { | |
663 | IEEE80211_TKIP_P1_KEY, | |
664 | IEEE80211_TKIP_P2_KEY, | |
665 | }; | |
666 | ||
1bc0826c JB |
667 | /** |
668 | * enum ieee80211_hw_flags - hardware flags | |
669 | * | |
670 | * These flags are used to indicate hardware capabilities to | |
671 | * the stack. Generally, flags here should have their meaning | |
672 | * done in a way that the simplest hardware doesn't need setting | |
673 | * any particular flags. There are some exceptions to this rule, | |
674 | * however, so you are advised to review these flags carefully. | |
675 | * | |
676 | * @IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE: | |
677 | * The device only needs to be supplied with a beacon template. | |
678 | * If you need the host to generate each beacon then don't use | |
679 | * this flag and call ieee80211_beacon_get() when you need the | |
680 | * next beacon frame. Note that if you set this flag, you must | |
681 | * implement the set_tim() callback for powersave mode to work | |
682 | * properly. | |
683 | * This flag is only relevant for access-point mode. | |
684 | * | |
685 | * @IEEE80211_HW_RX_INCLUDES_FCS: | |
686 | * Indicates that received frames passed to the stack include | |
687 | * the FCS at the end. | |
688 | * | |
689 | * @IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING: | |
690 | * Some wireless LAN chipsets buffer broadcast/multicast frames | |
691 | * for power saving stations in the hardware/firmware and others | |
692 | * rely on the host system for such buffering. This option is used | |
693 | * to configure the IEEE 802.11 upper layer to buffer broadcast and | |
694 | * multicast frames when there are power saving stations so that | |
695 | * the driver can fetch them with ieee80211_get_buffered_bc(). Note | |
696 | * that not setting this flag works properly only when the | |
697 | * %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is also not set because | |
698 | * otherwise the stack will not know when the DTIM beacon was sent. | |
699 | * | |
8318d78a JB |
700 | * @IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE: |
701 | * Hardware is not capable of short slot operation on the 2.4 GHz band. | |
702 | * | |
703 | * @IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE: | |
704 | * Hardware is not capable of receiving frames with short preamble on | |
705 | * the 2.4 GHz band. | |
1bc0826c JB |
706 | */ |
707 | enum ieee80211_hw_flags { | |
708 | IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0, | |
709 | IEEE80211_HW_RX_INCLUDES_FCS = 1<<1, | |
710 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2, | |
8318d78a JB |
711 | IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3, |
712 | IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE = 1<<4, | |
1bc0826c JB |
713 | }; |
714 | ||
7ac1bd6a JB |
715 | /** |
716 | * struct ieee80211_hw - hardware information and state | |
75a5f0cc JB |
717 | * |
718 | * This structure contains the configuration and hardware | |
719 | * information for an 802.11 PHY. | |
720 | * | |
721 | * @wiphy: This points to the &struct wiphy allocated for this | |
722 | * 802.11 PHY. You must fill in the @perm_addr and @dev | |
723 | * members of this structure using SET_IEEE80211_DEV() | |
8318d78a JB |
724 | * and SET_IEEE80211_PERM_ADDR(). Additionally, all supported |
725 | * bands (with channels, bitrates) are registered here. | |
75a5f0cc JB |
726 | * |
727 | * @conf: &struct ieee80211_conf, device configuration, don't use. | |
728 | * | |
729 | * @workqueue: single threaded workqueue available for driver use, | |
730 | * allocated by mac80211 on registration and flushed on | |
731 | * unregistration. | |
732 | * | |
733 | * @priv: pointer to private area that was allocated for driver use | |
734 | * along with this structure. | |
735 | * | |
736 | * @flags: hardware flags, see &enum ieee80211_hw_flags. | |
737 | * | |
738 | * @extra_tx_headroom: headroom to reserve in each transmit skb | |
739 | * for use by the driver (e.g. for transmit headers.) | |
740 | * | |
741 | * @channel_change_time: time (in microseconds) it takes to change channels. | |
742 | * | |
743 | * @max_rssi: Maximum value for ssi in RX information, use | |
744 | * negative numbers for dBm and 0 to indicate no support. | |
745 | * | |
746 | * @max_signal: like @max_rssi, but for the signal value. | |
747 | * | |
748 | * @max_noise: like @max_rssi, but for the noise value. | |
749 | * | |
750 | * @queues: number of available hardware transmit queues for | |
e100bb64 JB |
751 | * data packets. WMM/QoS requires at least four, these |
752 | * queues need to have configurable access parameters. | |
753 | * | |
754 | * @ampdu_queues: number of available hardware transmit queues | |
755 | * for A-MPDU packets, these have no access parameters | |
756 | * because they're used only for A-MPDU frames. Note that | |
757 | * mac80211 will not currently use any of the regular queues | |
758 | * for aggregation. | |
830f9038 JB |
759 | * |
760 | * @rate_control_algorithm: rate control algorithm for this hardware. | |
761 | * If unset (NULL), the default algorithm will be used. Must be | |
762 | * set before calling ieee80211_register_hw(). | |
32bfd35d JB |
763 | * |
764 | * @vif_data_size: size (in bytes) of the drv_priv data area | |
765 | * within &struct ieee80211_vif. | |
7ac1bd6a | 766 | */ |
f0706e82 | 767 | struct ieee80211_hw { |
f0706e82 | 768 | struct ieee80211_conf conf; |
75a5f0cc | 769 | struct wiphy *wiphy; |
f0706e82 | 770 | struct workqueue_struct *workqueue; |
830f9038 | 771 | const char *rate_control_algorithm; |
f0706e82 | 772 | void *priv; |
75a5f0cc | 773 | u32 flags; |
f0706e82 | 774 | unsigned int extra_tx_headroom; |
f0706e82 | 775 | int channel_change_time; |
32bfd35d | 776 | int vif_data_size; |
e100bb64 | 777 | u16 queues, ampdu_queues; |
f0706e82 JB |
778 | s8 max_rssi; |
779 | s8 max_signal; | |
780 | s8 max_noise; | |
f0706e82 JB |
781 | }; |
782 | ||
75a5f0cc JB |
783 | /** |
784 | * SET_IEEE80211_DEV - set device for 802.11 hardware | |
785 | * | |
786 | * @hw: the &struct ieee80211_hw to set the device for | |
787 | * @dev: the &struct device of this 802.11 device | |
788 | */ | |
f0706e82 JB |
789 | static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) |
790 | { | |
791 | set_wiphy_dev(hw->wiphy, dev); | |
792 | } | |
793 | ||
75a5f0cc JB |
794 | /** |
795 | * SET_IEEE80211_PERM_ADDR - set the permanenet MAC address for 802.11 hardware | |
796 | * | |
797 | * @hw: the &struct ieee80211_hw to set the MAC address for | |
798 | * @addr: the address to set | |
799 | */ | |
f0706e82 JB |
800 | static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr) |
801 | { | |
802 | memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN); | |
803 | } | |
804 | ||
75a5f0cc JB |
805 | /** |
806 | * DOC: Hardware crypto acceleration | |
807 | * | |
808 | * mac80211 is capable of taking advantage of many hardware | |
809 | * acceleration designs for encryption and decryption operations. | |
810 | * | |
811 | * The set_key() callback in the &struct ieee80211_ops for a given | |
812 | * device is called to enable hardware acceleration of encryption and | |
813 | * decryption. The callback takes an @address parameter that will be | |
814 | * the broadcast address for default keys, the other station's hardware | |
815 | * address for individual keys or the zero address for keys that will | |
816 | * be used only for transmission. | |
817 | * Multiple transmission keys with the same key index may be used when | |
818 | * VLANs are configured for an access point. | |
4150c572 | 819 | * |
75a5f0cc JB |
820 | * The @local_address parameter will always be set to our own address, |
821 | * this is only relevant if you support multiple local addresses. | |
822 | * | |
823 | * When transmitting, the TX control data will use the @hw_key_idx | |
824 | * selected by the driver by modifying the &struct ieee80211_key_conf | |
825 | * pointed to by the @key parameter to the set_key() function. | |
826 | * | |
827 | * The set_key() call for the %SET_KEY command should return 0 if | |
828 | * the key is now in use, -%EOPNOTSUPP or -%ENOSPC if it couldn't be | |
829 | * added; if you return 0 then hw_key_idx must be assigned to the | |
830 | * hardware key index, you are free to use the full u8 range. | |
831 | * | |
832 | * When the cmd is %DISABLE_KEY then it must succeed. | |
833 | * | |
834 | * Note that it is permissible to not decrypt a frame even if a key | |
835 | * for it has been uploaded to hardware, the stack will not make any | |
836 | * decision based on whether a key has been uploaded or not but rather | |
837 | * based on the receive flags. | |
838 | * | |
839 | * The &struct ieee80211_key_conf structure pointed to by the @key | |
840 | * parameter is guaranteed to be valid until another call to set_key() | |
841 | * removes it, but it can only be used as a cookie to differentiate | |
842 | * keys. | |
9ae4fda3 EG |
843 | * |
844 | * In TKIP some HW need to be provided a phase 1 key, for RX decryption | |
845 | * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key | |
846 | * handler. | |
847 | * The update_tkip_key() call updates the driver with the new phase 1 key. | |
848 | * This happens everytime the iv16 wraps around (every 65536 packets). The | |
849 | * set_key() call will happen only once for each key (unless the AP did | |
850 | * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is | |
851 | * provided by udpate_tkip_key only. The trigger that makes mac80211 call this | |
852 | * handler is software decryption with wrap around of iv16. | |
4150c572 | 853 | */ |
75a5f0cc JB |
854 | |
855 | /** | |
856 | * DOC: Frame filtering | |
857 | * | |
858 | * mac80211 requires to see many management frames for proper | |
859 | * operation, and users may want to see many more frames when | |
860 | * in monitor mode. However, for best CPU usage and power consumption, | |
861 | * having as few frames as possible percolate through the stack is | |
862 | * desirable. Hence, the hardware should filter as much as possible. | |
863 | * | |
864 | * To achieve this, mac80211 uses filter flags (see below) to tell | |
865 | * the driver's configure_filter() function which frames should be | |
866 | * passed to mac80211 and which should be filtered out. | |
867 | * | |
868 | * The configure_filter() callback is invoked with the parameters | |
869 | * @mc_count and @mc_list for the combined multicast address list | |
870 | * of all virtual interfaces, @changed_flags telling which flags | |
871 | * were changed and @total_flags with the new flag states. | |
872 | * | |
873 | * If your device has no multicast address filters your driver will | |
874 | * need to check both the %FIF_ALLMULTI flag and the @mc_count | |
875 | * parameter to see whether multicast frames should be accepted | |
876 | * or dropped. | |
877 | * | |
d0f5afbe MB |
878 | * All unsupported flags in @total_flags must be cleared. |
879 | * Hardware does not support a flag if it is incapable of _passing_ | |
880 | * the frame to the stack. Otherwise the driver must ignore | |
881 | * the flag, but not clear it. | |
882 | * You must _only_ clear the flag (announce no support for the | |
883 | * flag to mac80211) if you are not able to pass the packet type | |
884 | * to the stack (so the hardware always filters it). | |
885 | * So for example, you should clear @FIF_CONTROL, if your hardware | |
886 | * always filters control frames. If your hardware always passes | |
887 | * control frames to the kernel and is incapable of filtering them, | |
888 | * you do _not_ clear the @FIF_CONTROL flag. | |
889 | * This rule applies to all other FIF flags as well. | |
4150c572 | 890 | */ |
75a5f0cc JB |
891 | |
892 | /** | |
893 | * enum ieee80211_filter_flags - hardware filter flags | |
894 | * | |
895 | * These flags determine what the filter in hardware should be | |
896 | * programmed to let through and what should not be passed to the | |
897 | * stack. It is always safe to pass more frames than requested, | |
898 | * but this has negative impact on power consumption. | |
899 | * | |
900 | * @FIF_PROMISC_IN_BSS: promiscuous mode within your BSS, | |
901 | * think of the BSS as your network segment and then this corresponds | |
902 | * to the regular ethernet device promiscuous mode. | |
903 | * | |
904 | * @FIF_ALLMULTI: pass all multicast frames, this is used if requested | |
905 | * by the user or if the hardware is not capable of filtering by | |
906 | * multicast address. | |
907 | * | |
908 | * @FIF_FCSFAIL: pass frames with failed FCS (but you need to set the | |
909 | * %RX_FLAG_FAILED_FCS_CRC for them) | |
910 | * | |
911 | * @FIF_PLCPFAIL: pass frames with failed PLCP CRC (but you need to set | |
912 | * the %RX_FLAG_FAILED_PLCP_CRC for them | |
913 | * | |
914 | * @FIF_BCN_PRBRESP_PROMISC: This flag is set during scanning to indicate | |
915 | * to the hardware that it should not filter beacons or probe responses | |
916 | * by BSSID. Filtering them can greatly reduce the amount of processing | |
917 | * mac80211 needs to do and the amount of CPU wakeups, so you should | |
918 | * honour this flag if possible. | |
919 | * | |
920 | * @FIF_CONTROL: pass control frames, if PROMISC_IN_BSS is not set then | |
921 | * only those addressed to this station | |
922 | * | |
923 | * @FIF_OTHER_BSS: pass frames destined to other BSSes | |
4150c572 | 924 | */ |
75a5f0cc JB |
925 | enum ieee80211_filter_flags { |
926 | FIF_PROMISC_IN_BSS = 1<<0, | |
927 | FIF_ALLMULTI = 1<<1, | |
928 | FIF_FCSFAIL = 1<<2, | |
929 | FIF_PLCPFAIL = 1<<3, | |
930 | FIF_BCN_PRBRESP_PROMISC = 1<<4, | |
931 | FIF_CONTROL = 1<<5, | |
932 | FIF_OTHER_BSS = 1<<6, | |
933 | }; | |
934 | ||
1b7d03ac RR |
935 | /** |
936 | * enum ieee80211_ampdu_mlme_action - A-MPDU actions | |
937 | * | |
938 | * These flags are used with the ampdu_action() callback in | |
939 | * &struct ieee80211_ops to indicate which action is needed. | |
940 | * @IEEE80211_AMPDU_RX_START: start Rx aggregation | |
941 | * @IEEE80211_AMPDU_RX_STOP: stop Rx aggregation | |
0df3ef45 RR |
942 | * @IEEE80211_AMPDU_TX_START: start Tx aggregation |
943 | * @IEEE80211_AMPDU_TX_STOP: stop Tx aggregation | |
1b7d03ac RR |
944 | */ |
945 | enum ieee80211_ampdu_mlme_action { | |
946 | IEEE80211_AMPDU_RX_START, | |
947 | IEEE80211_AMPDU_RX_STOP, | |
0df3ef45 RR |
948 | IEEE80211_AMPDU_TX_START, |
949 | IEEE80211_AMPDU_TX_STOP, | |
1b7d03ac | 950 | }; |
75a5f0cc JB |
951 | |
952 | /** | |
953 | * struct ieee80211_ops - callbacks from mac80211 to the driver | |
954 | * | |
955 | * This structure contains various callbacks that the driver may | |
956 | * handle or, in some cases, must handle, for example to configure | |
957 | * the hardware to a new channel or to transmit a frame. | |
958 | * | |
959 | * @tx: Handler that 802.11 module calls for each transmitted frame. | |
960 | * skb contains the buffer starting from the IEEE 802.11 header. | |
961 | * The low-level driver should send the frame out based on | |
962 | * configuration in the TX control data. Must be implemented and | |
963 | * atomic. | |
964 | * | |
965 | * @start: Called before the first netdevice attached to the hardware | |
966 | * is enabled. This should turn on the hardware and must turn on | |
967 | * frame reception (for possibly enabled monitor interfaces.) | |
968 | * Returns negative error codes, these may be seen in userspace, | |
969 | * or zero. | |
970 | * When the device is started it should not have a MAC address | |
971 | * to avoid acknowledging frames before a non-monitor device | |
972 | * is added. | |
973 | * Must be implemented. | |
974 | * | |
975 | * @stop: Called after last netdevice attached to the hardware | |
976 | * is disabled. This should turn off the hardware (at least | |
977 | * it must turn off frame reception.) | |
978 | * May be called right after add_interface if that rejects | |
979 | * an interface. | |
980 | * Must be implemented. | |
981 | * | |
982 | * @add_interface: Called when a netdevice attached to the hardware is | |
983 | * enabled. Because it is not called for monitor mode devices, @open | |
984 | * and @stop must be implemented. | |
985 | * The driver should perform any initialization it needs before | |
986 | * the device can be enabled. The initial configuration for the | |
987 | * interface is given in the conf parameter. | |
988 | * The callback may refuse to add an interface by returning a | |
989 | * negative error code (which will be seen in userspace.) | |
990 | * Must be implemented. | |
991 | * | |
992 | * @remove_interface: Notifies a driver that an interface is going down. | |
993 | * The @stop callback is called after this if it is the last interface | |
994 | * and no monitor interfaces are present. | |
995 | * When all interfaces are removed, the MAC address in the hardware | |
996 | * must be cleared so the device no longer acknowledges packets, | |
997 | * the mac_addr member of the conf structure is, however, set to the | |
998 | * MAC address of the device going away. | |
999 | * Hence, this callback must be implemented. | |
1000 | * | |
1001 | * @config: Handler for configuration requests. IEEE 802.11 code calls this | |
1002 | * function to change hardware configuration, e.g., channel. | |
1003 | * | |
1004 | * @config_interface: Handler for configuration requests related to interfaces | |
1005 | * (e.g. BSSID changes.) | |
1006 | * | |
471b3efd JB |
1007 | * @bss_info_changed: Handler for configuration requests related to BSS |
1008 | * parameters that may vary during BSS's lifespan, and may affect low | |
1009 | * level driver (e.g. assoc/disassoc status, erp parameters). | |
1010 | * This function should not be used if no BSS has been set, unless | |
1011 | * for association indication. The @changed parameter indicates which | |
d18ef29f | 1012 | * of the bss parameters has changed when a call is made. |
471b3efd | 1013 | * |
75a5f0cc JB |
1014 | * @configure_filter: Configure the device's RX filter. |
1015 | * See the section "Frame filtering" for more information. | |
1016 | * This callback must be implemented and atomic. | |
1017 | * | |
1018 | * @set_tim: Set TIM bit. If the hardware/firmware takes care of beacon | |
1019 | * generation (that is, %IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE is set) | |
1020 | * mac80211 calls this function when a TIM bit must be set or cleared | |
1021 | * for a given AID. Must be atomic. | |
1022 | * | |
1023 | * @set_key: See the section "Hardware crypto acceleration" | |
1024 | * This callback can sleep, and is only called between add_interface | |
1025 | * and remove_interface calls, i.e. while the interface with the | |
1026 | * given local_address is enabled. | |
1027 | * | |
9ae4fda3 EG |
1028 | * @update_tkip_key: See the section "Hardware crypto acceleration" |
1029 | * This callback will be called in the context of Rx. Called for drivers | |
1030 | * which set IEEE80211_KEY_FLAG_TKIP_REQ_RX_P1_KEY. | |
1031 | * | |
75a5f0cc | 1032 | * @hw_scan: Ask the hardware to service the scan request, no need to start |
8318d78a JB |
1033 | * the scan state machine in stack. The scan must honour the channel |
1034 | * configuration done by the regulatory agent in the wiphy's registered | |
1035 | * bands. | |
75a5f0cc JB |
1036 | * |
1037 | * @get_stats: return low-level statistics | |
1038 | * | |
62da92fb JB |
1039 | * @get_tkip_seq: If your device implements TKIP encryption in hardware this |
1040 | * callback should be provided to read the TKIP transmit IVs (both IV32 | |
1041 | * and IV16) for the given key from hardware. | |
75a5f0cc JB |
1042 | * |
1043 | * @set_rts_threshold: Configuration of RTS threshold (if device needs it) | |
1044 | * | |
1045 | * @set_frag_threshold: Configuration of fragmentation threshold. Assign this if | |
1046 | * the device does fragmentation by itself; if this method is assigned then | |
1047 | * the stack will not do fragmentation. | |
1048 | * | |
1049 | * @set_retry_limit: Configuration of retry limits (if device needs it) | |
1050 | * | |
478f8d2b TW |
1051 | * @sta_notify: Notifies low level driver about addition or removal |
1052 | * of assocaited station or AP. | |
75a5f0cc | 1053 | * |
75a5f0cc | 1054 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), |
e100bb64 | 1055 | * bursting) for a hardware TX queue. Must be atomic. |
75a5f0cc JB |
1056 | * |
1057 | * @get_tx_stats: Get statistics of the current TX queue status. This is used | |
1058 | * to get number of currently queued packets (queue length), maximum queue | |
1059 | * size (limit), and total number of packets sent using each TX queue | |
57ffc589 JB |
1060 | * (count). The 'stats' pointer points to an array that has hw->queues + |
1061 | * hw->ampdu_queues items. | |
75a5f0cc JB |
1062 | * |
1063 | * @get_tsf: Get the current TSF timer value from firmware/hardware. Currently, | |
1064 | * this is only used for IBSS mode debugging and, as such, is not a | |
1065 | * required function. Must be atomic. | |
1066 | * | |
1067 | * @reset_tsf: Reset the TSF timer and allow firmware/hardware to synchronize | |
1068 | * with other STAs in the IBSS. This is only used in IBSS mode. This | |
1069 | * function is optional if the firmware/hardware takes full care of | |
1070 | * TSF synchronization. | |
1071 | * | |
1072 | * @beacon_update: Setup beacon data for IBSS beacons. Unlike access point, | |
1073 | * IBSS uses a fixed beacon frame which is configured using this | |
5ecc2a5d MB |
1074 | * function. |
1075 | * If the driver returns success (0) from this callback, it owns | |
1076 | * the skb. That means the driver is responsible to kfree_skb() it. | |
1077 | * The control structure is not dynamically allocated. That means the | |
1078 | * driver does not own the pointer and if it needs it somewhere | |
1079 | * outside of the context of this function, it must copy it | |
1080 | * somewhere else. | |
1081 | * This handler is required only for IBSS mode. | |
75a5f0cc JB |
1082 | * |
1083 | * @tx_last_beacon: Determine whether the last IBSS beacon was sent by us. | |
1084 | * This is needed only for IBSS mode and the result of this function is | |
1085 | * used to determine whether to reply to Probe Requests. | |
d3c990fb RR |
1086 | * |
1087 | * @conf_ht: Configures low level driver with 802.11n HT data. Must be atomic. | |
1b7d03ac RR |
1088 | * |
1089 | * @ampdu_action: Perform a certain A-MPDU action | |
1090 | * The RA/TID combination determines the destination and TID we want | |
1091 | * the ampdu action to be performed for. The action is defined through | |
1092 | * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) | |
0df3ef45 RR |
1093 | * is the first frame we expect to perform the action on. notice |
1094 | * that TX/RX_STOP can pass NULL for this parameter. | |
75a5f0cc | 1095 | */ |
f0706e82 | 1096 | struct ieee80211_ops { |
f0706e82 JB |
1097 | int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, |
1098 | struct ieee80211_tx_control *control); | |
4150c572 | 1099 | int (*start)(struct ieee80211_hw *hw); |
4150c572 | 1100 | void (*stop)(struct ieee80211_hw *hw); |
f0706e82 JB |
1101 | int (*add_interface)(struct ieee80211_hw *hw, |
1102 | struct ieee80211_if_init_conf *conf); | |
f0706e82 JB |
1103 | void (*remove_interface)(struct ieee80211_hw *hw, |
1104 | struct ieee80211_if_init_conf *conf); | |
f0706e82 | 1105 | int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); |
f0706e82 | 1106 | int (*config_interface)(struct ieee80211_hw *hw, |
32bfd35d JB |
1107 | struct ieee80211_vif *vif, |
1108 | struct ieee80211_if_conf *conf); | |
471b3efd JB |
1109 | void (*bss_info_changed)(struct ieee80211_hw *hw, |
1110 | struct ieee80211_vif *vif, | |
1111 | struct ieee80211_bss_conf *info, | |
1112 | u32 changed); | |
4150c572 JB |
1113 | void (*configure_filter)(struct ieee80211_hw *hw, |
1114 | unsigned int changed_flags, | |
1115 | unsigned int *total_flags, | |
1116 | int mc_count, struct dev_addr_list *mc_list); | |
f0706e82 | 1117 | int (*set_tim)(struct ieee80211_hw *hw, int aid, int set); |
ea49c359 | 1118 | int (*set_key)(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
11a843b7 JB |
1119 | const u8 *local_address, const u8 *address, |
1120 | struct ieee80211_key_conf *key); | |
9ae4fda3 EG |
1121 | void (*update_tkip_key)(struct ieee80211_hw *hw, |
1122 | struct ieee80211_key_conf *conf, const u8 *address, | |
1123 | u32 iv32, u16 *phase1key); | |
f0706e82 | 1124 | int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); |
f0706e82 JB |
1125 | int (*get_stats)(struct ieee80211_hw *hw, |
1126 | struct ieee80211_low_level_stats *stats); | |
62da92fb JB |
1127 | void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, |
1128 | u32 *iv32, u16 *iv16); | |
f0706e82 | 1129 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); |
f0706e82 | 1130 | int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); |
f0706e82 JB |
1131 | int (*set_retry_limit)(struct ieee80211_hw *hw, |
1132 | u32 short_retry, u32 long_retr); | |
32bfd35d | 1133 | void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
478f8d2b | 1134 | enum sta_notify_cmd, const u8 *addr); |
e100bb64 | 1135 | int (*conf_tx)(struct ieee80211_hw *hw, u16 queue, |
f0706e82 | 1136 | const struct ieee80211_tx_queue_params *params); |
f0706e82 JB |
1137 | int (*get_tx_stats)(struct ieee80211_hw *hw, |
1138 | struct ieee80211_tx_queue_stats *stats); | |
f0706e82 | 1139 | u64 (*get_tsf)(struct ieee80211_hw *hw); |
f0706e82 | 1140 | void (*reset_tsf)(struct ieee80211_hw *hw); |
f0706e82 JB |
1141 | int (*beacon_update)(struct ieee80211_hw *hw, |
1142 | struct sk_buff *skb, | |
1143 | struct ieee80211_tx_control *control); | |
f0706e82 | 1144 | int (*tx_last_beacon)(struct ieee80211_hw *hw); |
1b7d03ac RR |
1145 | int (*ampdu_action)(struct ieee80211_hw *hw, |
1146 | enum ieee80211_ampdu_mlme_action action, | |
0df3ef45 | 1147 | const u8 *addr, u16 tid, u16 *ssn); |
f0706e82 JB |
1148 | }; |
1149 | ||
75a5f0cc JB |
1150 | /** |
1151 | * ieee80211_alloc_hw - Allocate a new hardware device | |
1152 | * | |
1153 | * This must be called once for each hardware device. The returned pointer | |
1154 | * must be used to refer to this device when calling other functions. | |
1155 | * mac80211 allocates a private data area for the driver pointed to by | |
1156 | * @priv in &struct ieee80211_hw, the size of this area is given as | |
1157 | * @priv_data_len. | |
1158 | * | |
1159 | * @priv_data_len: length of private data | |
1160 | * @ops: callbacks for this device | |
f0706e82 JB |
1161 | */ |
1162 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |
1163 | const struct ieee80211_ops *ops); | |
1164 | ||
75a5f0cc JB |
1165 | /** |
1166 | * ieee80211_register_hw - Register hardware device | |
1167 | * | |
dbbea671 JB |
1168 | * You must call this function before any other functions in |
1169 | * mac80211. Note that before a hardware can be registered, you | |
1170 | * need to fill the contained wiphy's information. | |
75a5f0cc JB |
1171 | * |
1172 | * @hw: the device to register as returned by ieee80211_alloc_hw() | |
1173 | */ | |
f0706e82 JB |
1174 | int ieee80211_register_hw(struct ieee80211_hw *hw); |
1175 | ||
f0706e82 JB |
1176 | #ifdef CONFIG_MAC80211_LEDS |
1177 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); | |
1178 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); | |
47f0c502 | 1179 | extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); |
cdcb006f | 1180 | extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); |
f0706e82 | 1181 | #endif |
75a5f0cc JB |
1182 | /** |
1183 | * ieee80211_get_tx_led_name - get name of TX LED | |
1184 | * | |
1185 | * mac80211 creates a transmit LED trigger for each wireless hardware | |
1186 | * that can be used to drive LEDs if your driver registers a LED device. | |
1187 | * This function returns the name (or %NULL if not configured for LEDs) | |
1188 | * of the trigger so you can automatically link the LED device. | |
1189 | * | |
1190 | * @hw: the hardware to get the LED trigger name for | |
1191 | */ | |
f0706e82 JB |
1192 | static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw) |
1193 | { | |
1194 | #ifdef CONFIG_MAC80211_LEDS | |
1195 | return __ieee80211_get_tx_led_name(hw); | |
1196 | #else | |
1197 | return NULL; | |
1198 | #endif | |
1199 | } | |
1200 | ||
75a5f0cc JB |
1201 | /** |
1202 | * ieee80211_get_rx_led_name - get name of RX LED | |
1203 | * | |
1204 | * mac80211 creates a receive LED trigger for each wireless hardware | |
1205 | * that can be used to drive LEDs if your driver registers a LED device. | |
1206 | * This function returns the name (or %NULL if not configured for LEDs) | |
1207 | * of the trigger so you can automatically link the LED device. | |
1208 | * | |
1209 | * @hw: the hardware to get the LED trigger name for | |
1210 | */ | |
f0706e82 JB |
1211 | static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw) |
1212 | { | |
1213 | #ifdef CONFIG_MAC80211_LEDS | |
1214 | return __ieee80211_get_rx_led_name(hw); | |
1215 | #else | |
1216 | return NULL; | |
1217 | #endif | |
1218 | } | |
1219 | ||
cdcb006f ID |
1220 | /** |
1221 | * ieee80211_get_assoc_led_name - get name of association LED | |
1222 | * | |
1223 | * mac80211 creates a association LED trigger for each wireless hardware | |
1224 | * that can be used to drive LEDs if your driver registers a LED device. | |
1225 | * This function returns the name (or %NULL if not configured for LEDs) | |
1226 | * of the trigger so you can automatically link the LED device. | |
1227 | * | |
1228 | * @hw: the hardware to get the LED trigger name for | |
1229 | */ | |
47f0c502 MB |
1230 | static inline char *ieee80211_get_assoc_led_name(struct ieee80211_hw *hw) |
1231 | { | |
1232 | #ifdef CONFIG_MAC80211_LEDS | |
1233 | return __ieee80211_get_assoc_led_name(hw); | |
1234 | #else | |
1235 | return NULL; | |
1236 | #endif | |
1237 | } | |
1238 | ||
cdcb006f ID |
1239 | /** |
1240 | * ieee80211_get_radio_led_name - get name of radio LED | |
1241 | * | |
1242 | * mac80211 creates a radio change LED trigger for each wireless hardware | |
1243 | * that can be used to drive LEDs if your driver registers a LED device. | |
1244 | * This function returns the name (or %NULL if not configured for LEDs) | |
1245 | * of the trigger so you can automatically link the LED device. | |
1246 | * | |
1247 | * @hw: the hardware to get the LED trigger name for | |
1248 | */ | |
1249 | static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw) | |
1250 | { | |
1251 | #ifdef CONFIG_MAC80211_LEDS | |
1252 | return __ieee80211_get_radio_led_name(hw); | |
1253 | #else | |
1254 | return NULL; | |
1255 | #endif | |
1256 | } | |
47f0c502 | 1257 | |
75a5f0cc JB |
1258 | /** |
1259 | * ieee80211_unregister_hw - Unregister a hardware device | |
1260 | * | |
1261 | * This function instructs mac80211 to free allocated resources | |
1262 | * and unregister netdevices from the networking subsystem. | |
1263 | * | |
1264 | * @hw: the hardware to unregister | |
1265 | */ | |
f0706e82 JB |
1266 | void ieee80211_unregister_hw(struct ieee80211_hw *hw); |
1267 | ||
75a5f0cc JB |
1268 | /** |
1269 | * ieee80211_free_hw - free hardware descriptor | |
1270 | * | |
1271 | * This function frees everything that was allocated, including the | |
1272 | * private data for the driver. You must call ieee80211_unregister_hw() | |
1273 | * before calling this function | |
1274 | * | |
1275 | * @hw: the hardware to free | |
1276 | */ | |
f0706e82 JB |
1277 | void ieee80211_free_hw(struct ieee80211_hw *hw); |
1278 | ||
75a5f0cc | 1279 | /* trick to avoid symbol clashes with the ieee80211 subsystem */ |
f0706e82 JB |
1280 | void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, |
1281 | struct ieee80211_rx_status *status); | |
75a5f0cc JB |
1282 | |
1283 | /** | |
1284 | * ieee80211_rx - receive frame | |
1285 | * | |
1286 | * Use this function to hand received frames to mac80211. The receive | |
1287 | * buffer in @skb must start with an IEEE 802.11 header or a radiotap | |
1288 | * header if %RX_FLAG_RADIOTAP is set in the @status flags. | |
1289 | * | |
2485f710 JB |
1290 | * This function may not be called in IRQ context. Calls to this function |
1291 | * for a single hardware must be synchronized against each other. Calls | |
1292 | * to this function and ieee80211_rx_irqsafe() may not be mixed for a | |
1293 | * single hardware. | |
75a5f0cc JB |
1294 | * |
1295 | * @hw: the hardware this frame came in on | |
1296 | * @skb: the buffer to receive, owned by mac80211 after this call | |
1297 | * @status: status of this frame; the status pointer need not be valid | |
1298 | * after this function returns | |
1299 | */ | |
1300 | static inline void ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, | |
1301 | struct ieee80211_rx_status *status) | |
1302 | { | |
1303 | __ieee80211_rx(hw, skb, status); | |
1304 | } | |
1305 | ||
1306 | /** | |
1307 | * ieee80211_rx_irqsafe - receive frame | |
1308 | * | |
1309 | * Like ieee80211_rx() but can be called in IRQ context | |
2485f710 JB |
1310 | * (internally defers to a tasklet.) |
1311 | * | |
1312 | * Calls to this function and ieee80211_rx() may not be mixed for a | |
1313 | * single hardware. | |
75a5f0cc JB |
1314 | * |
1315 | * @hw: the hardware this frame came in on | |
1316 | * @skb: the buffer to receive, owned by mac80211 after this call | |
1317 | * @status: status of this frame; the status pointer need not be valid | |
1318 | * after this function returns and is not freed by mac80211, | |
1319 | * it is recommended that it points to a stack area | |
1320 | */ | |
f0706e82 JB |
1321 | void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, |
1322 | struct sk_buff *skb, | |
1323 | struct ieee80211_rx_status *status); | |
1324 | ||
75a5f0cc JB |
1325 | /** |
1326 | * ieee80211_tx_status - transmit status callback | |
1327 | * | |
1328 | * Call this function for all transmitted frames after they have been | |
1329 | * transmitted. It is permissible to not call this function for | |
1330 | * multicast frames but this can affect statistics. | |
1331 | * | |
2485f710 JB |
1332 | * This function may not be called in IRQ context. Calls to this function |
1333 | * for a single hardware must be synchronized against each other. Calls | |
1334 | * to this function and ieee80211_tx_status_irqsafe() may not be mixed | |
1335 | * for a single hardware. | |
1336 | * | |
75a5f0cc JB |
1337 | * @hw: the hardware the frame was transmitted by |
1338 | * @skb: the frame that was transmitted, owned by mac80211 after this call | |
1339 | * @status: status information for this frame; the status pointer need not | |
1340 | * be valid after this function returns and is not freed by mac80211, | |
1341 | * it is recommended that it points to a stack area | |
1342 | */ | |
f0706e82 JB |
1343 | void ieee80211_tx_status(struct ieee80211_hw *hw, |
1344 | struct sk_buff *skb, | |
1345 | struct ieee80211_tx_status *status); | |
2485f710 JB |
1346 | |
1347 | /** | |
1348 | * ieee80211_tx_status_irqsafe - irq-safe transmit status callback | |
1349 | * | |
1350 | * Like ieee80211_tx_status() but can be called in IRQ context | |
1351 | * (internally defers to a tasklet.) | |
1352 | * | |
1353 | * Calls to this function and ieee80211_tx_status() may not be mixed for a | |
1354 | * single hardware. | |
1355 | * | |
1356 | * @hw: the hardware the frame was transmitted by | |
1357 | * @skb: the frame that was transmitted, owned by mac80211 after this call | |
1358 | * @status: status information for this frame; the status pointer need not | |
1359 | * be valid after this function returns and is not freed by mac80211, | |
1360 | * it is recommended that it points to a stack area | |
1361 | */ | |
f0706e82 JB |
1362 | void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, |
1363 | struct sk_buff *skb, | |
1364 | struct ieee80211_tx_status *status); | |
1365 | ||
1366 | /** | |
1367 | * ieee80211_beacon_get - beacon generation function | |
1368 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1369 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 JB |
1370 | * @control: will be filled with information needed to send this beacon. |
1371 | * | |
1372 | * If the beacon frames are generated by the host system (i.e., not in | |
1373 | * hardware/firmware), the low-level driver uses this function to receive | |
1374 | * the next beacon frame from the 802.11 code. The low-level is responsible | |
1375 | * for calling this function before beacon data is needed (e.g., based on | |
1376 | * hardware interrupt). Returned skb is used only once and low-level driver | |
1377 | * is responsible of freeing it. | |
1378 | */ | |
1379 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |
32bfd35d | 1380 | struct ieee80211_vif *vif, |
f0706e82 JB |
1381 | struct ieee80211_tx_control *control); |
1382 | ||
1383 | /** | |
1384 | * ieee80211_rts_get - RTS frame generation function | |
1385 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1386 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 JB |
1387 | * @frame: pointer to the frame that is going to be protected by the RTS. |
1388 | * @frame_len: the frame length (in octets). | |
1389 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
1390 | * @rts: The buffer where to store the RTS frame. | |
1391 | * | |
1392 | * If the RTS frames are generated by the host system (i.e., not in | |
1393 | * hardware/firmware), the low-level driver uses this function to receive | |
1394 | * the next RTS frame from the 802.11 code. The low-level is responsible | |
1395 | * for calling this function before and RTS frame is needed. | |
1396 | */ | |
32bfd35d | 1397 | void ieee80211_rts_get(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
f0706e82 JB |
1398 | const void *frame, size_t frame_len, |
1399 | const struct ieee80211_tx_control *frame_txctl, | |
1400 | struct ieee80211_rts *rts); | |
1401 | ||
1402 | /** | |
1403 | * ieee80211_rts_duration - Get the duration field for an RTS frame | |
1404 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1405 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 JB |
1406 | * @frame_len: the length of the frame that is going to be protected by the RTS. |
1407 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
1408 | * | |
1409 | * If the RTS is generated in firmware, but the host system must provide | |
1410 | * the duration field, the low-level driver uses this function to receive | |
1411 | * the duration field value in little-endian byteorder. | |
1412 | */ | |
32bfd35d JB |
1413 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, |
1414 | struct ieee80211_vif *vif, size_t frame_len, | |
f0706e82 JB |
1415 | const struct ieee80211_tx_control *frame_txctl); |
1416 | ||
1417 | /** | |
1418 | * ieee80211_ctstoself_get - CTS-to-self frame generation function | |
1419 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1420 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 JB |
1421 | * @frame: pointer to the frame that is going to be protected by the CTS-to-self. |
1422 | * @frame_len: the frame length (in octets). | |
1423 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
1424 | * @cts: The buffer where to store the CTS-to-self frame. | |
1425 | * | |
1426 | * If the CTS-to-self frames are generated by the host system (i.e., not in | |
1427 | * hardware/firmware), the low-level driver uses this function to receive | |
1428 | * the next CTS-to-self frame from the 802.11 code. The low-level is responsible | |
1429 | * for calling this function before and CTS-to-self frame is needed. | |
1430 | */ | |
32bfd35d JB |
1431 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, |
1432 | struct ieee80211_vif *vif, | |
f0706e82 JB |
1433 | const void *frame, size_t frame_len, |
1434 | const struct ieee80211_tx_control *frame_txctl, | |
1435 | struct ieee80211_cts *cts); | |
1436 | ||
1437 | /** | |
1438 | * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame | |
1439 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1440 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 JB |
1441 | * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. |
1442 | * @frame_txctl: &struct ieee80211_tx_control of the frame. | |
1443 | * | |
1444 | * If the CTS-to-self is generated in firmware, but the host system must provide | |
1445 | * the duration field, the low-level driver uses this function to receive | |
1446 | * the duration field value in little-endian byteorder. | |
1447 | */ | |
32bfd35d JB |
1448 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, |
1449 | struct ieee80211_vif *vif, | |
f0706e82 JB |
1450 | size_t frame_len, |
1451 | const struct ieee80211_tx_control *frame_txctl); | |
1452 | ||
1453 | /** | |
1454 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame | |
1455 | * @hw: pointer obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1456 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 | 1457 | * @frame_len: the length of the frame. |
8318d78a | 1458 | * @rate: the rate at which the frame is going to be transmitted. |
f0706e82 JB |
1459 | * |
1460 | * Calculate the duration field of some generic frame, given its | |
1461 | * length and transmission rate (in 100kbps). | |
1462 | */ | |
32bfd35d JB |
1463 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, |
1464 | struct ieee80211_vif *vif, | |
f0706e82 | 1465 | size_t frame_len, |
8318d78a | 1466 | struct ieee80211_rate *rate); |
f0706e82 JB |
1467 | |
1468 | /** | |
1469 | * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames | |
1470 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
32bfd35d | 1471 | * @vif: &struct ieee80211_vif pointer from &struct ieee80211_if_init_conf. |
f0706e82 JB |
1472 | * @control: will be filled with information needed to send returned frame. |
1473 | * | |
1474 | * Function for accessing buffered broadcast and multicast frames. If | |
1475 | * hardware/firmware does not implement buffering of broadcast/multicast | |
1476 | * frames when power saving is used, 802.11 code buffers them in the host | |
1477 | * memory. The low-level driver uses this function to fetch next buffered | |
1478 | * frame. In most cases, this is used when generating beacon frame. This | |
1479 | * function returns a pointer to the next buffered skb or NULL if no more | |
1480 | * buffered frames are available. | |
1481 | * | |
1482 | * Note: buffered frames are returned only after DTIM beacon frame was | |
1483 | * generated with ieee80211_beacon_get() and the low-level driver must thus | |
1484 | * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns | |
1485 | * NULL if the previous generated beacon was not DTIM, so the low-level driver | |
1486 | * does not need to check for DTIM beacons separately and should be able to | |
1487 | * use common code for all beacons. | |
1488 | */ | |
1489 | struct sk_buff * | |
32bfd35d | 1490 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
f0706e82 JB |
1491 | struct ieee80211_tx_control *control); |
1492 | ||
75a5f0cc JB |
1493 | /** |
1494 | * ieee80211_get_hdrlen_from_skb - get header length from data | |
1495 | * | |
1496 | * Given an skb with a raw 802.11 header at the data pointer this function | |
f0706e82 JB |
1497 | * returns the 802.11 header length in bytes (not including encryption |
1498 | * headers). If the data in the sk_buff is too short to contain a valid 802.11 | |
1499 | * header the function returns 0. | |
75a5f0cc JB |
1500 | * |
1501 | * @skb: the frame | |
f0706e82 JB |
1502 | */ |
1503 | int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); | |
1504 | ||
75a5f0cc JB |
1505 | /** |
1506 | * ieee80211_get_hdrlen - get header length from frame control | |
1507 | * | |
1508 | * This function returns the 802.11 header length in bytes (not including | |
1509 | * encryption headers.) | |
1510 | * | |
1511 | * @fc: the frame control field (in CPU endianness) | |
1512 | */ | |
f0706e82 JB |
1513 | int ieee80211_get_hdrlen(u16 fc); |
1514 | ||
5d2cdcd4 EG |
1515 | /** |
1516 | * ieee80211_get_tkip_key - get a TKIP rc4 for skb | |
1517 | * | |
1518 | * This function computes a TKIP rc4 key for an skb. It computes | |
1519 | * a phase 1 key if needed (iv16 wraps around). This function is to | |
1520 | * be used by drivers which can do HW encryption but need to compute | |
1521 | * to phase 1/2 key in SW. | |
1522 | * | |
1523 | * @keyconf: the parameter passed with the set key | |
1524 | * @skb: the skb for which the key is needed | |
1525 | * @rc4key: a buffer to which the key will be written | |
1526 | */ | |
1527 | void ieee80211_get_tkip_key(struct ieee80211_key_conf *keyconf, | |
1528 | struct sk_buff *skb, | |
1529 | enum ieee80211_tkip_key_type type, u8 *key); | |
f0706e82 JB |
1530 | /** |
1531 | * ieee80211_wake_queue - wake specific queue | |
1532 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1533 | * @queue: queue number (counted from zero). | |
1534 | * | |
1535 | * Drivers should use this function instead of netif_wake_queue. | |
1536 | */ | |
1537 | void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue); | |
1538 | ||
1539 | /** | |
1540 | * ieee80211_stop_queue - stop specific queue | |
1541 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1542 | * @queue: queue number (counted from zero). | |
1543 | * | |
1544 | * Drivers should use this function instead of netif_stop_queue. | |
1545 | */ | |
1546 | void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue); | |
1547 | ||
1548 | /** | |
1549 | * ieee80211_start_queues - start all queues | |
1550 | * @hw: pointer to as obtained from ieee80211_alloc_hw(). | |
1551 | * | |
1552 | * Drivers should use this function instead of netif_start_queue. | |
1553 | */ | |
1554 | void ieee80211_start_queues(struct ieee80211_hw *hw); | |
1555 | ||
1556 | /** | |
1557 | * ieee80211_stop_queues - stop all queues | |
1558 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1559 | * | |
1560 | * Drivers should use this function instead of netif_stop_queue. | |
1561 | */ | |
1562 | void ieee80211_stop_queues(struct ieee80211_hw *hw); | |
1563 | ||
1564 | /** | |
1565 | * ieee80211_wake_queues - wake all queues | |
1566 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1567 | * | |
1568 | * Drivers should use this function instead of netif_wake_queue. | |
1569 | */ | |
1570 | void ieee80211_wake_queues(struct ieee80211_hw *hw); | |
1571 | ||
75a5f0cc JB |
1572 | /** |
1573 | * ieee80211_scan_completed - completed hardware scan | |
1574 | * | |
1575 | * When hardware scan offload is used (i.e. the hw_scan() callback is | |
1576 | * assigned) this function needs to be called by the driver to notify | |
1577 | * mac80211 that the scan finished. | |
1578 | * | |
1579 | * @hw: the hardware that finished the scan | |
1580 | */ | |
f0706e82 JB |
1581 | void ieee80211_scan_completed(struct ieee80211_hw *hw); |
1582 | ||
dabeb344 JB |
1583 | /** |
1584 | * ieee80211_iterate_active_interfaces - iterate active interfaces | |
1585 | * | |
1586 | * This function iterates over the interfaces associated with a given | |
1587 | * hardware that are currently active and calls the callback for them. | |
dabeb344 JB |
1588 | * |
1589 | * @hw: the hardware struct of which the interfaces should be iterated over | |
e38bad47 | 1590 | * @iterator: the iterator function to call, cannot sleep |
dabeb344 JB |
1591 | * @data: first argument of the iterator function |
1592 | */ | |
1593 | void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, | |
1594 | void (*iterator)(void *data, u8 *mac, | |
32bfd35d | 1595 | struct ieee80211_vif *vif), |
dabeb344 JB |
1596 | void *data); |
1597 | ||
0df3ef45 RR |
1598 | /** |
1599 | * ieee80211_start_tx_ba_session - Start a tx Block Ack session. | |
1600 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1601 | * @ra: receiver address of the BA session recipient | |
1602 | * @tid: the TID to BA on. | |
1603 | * @return: success if addBA request was sent, failure otherwise | |
1604 | * | |
1605 | * Although mac80211/low level driver/user space application can estimate | |
1606 | * the need to start aggregation on a certain RA/TID, the session level | |
1607 | * will be managed by the mac80211. | |
1608 | */ | |
1609 | int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid); | |
1610 | ||
1611 | /** | |
1612 | * ieee80211_start_tx_ba_cb - low level driver ready to aggregate. | |
1613 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1614 | * @ra: receiver address of the BA session recipient. | |
1615 | * @tid: the TID to BA on. | |
1616 | * | |
1617 | * This function must be called by low level driver once it has | |
1618 | * finished with preparations for the BA session. | |
1619 | */ | |
1620 | void ieee80211_start_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u16 tid); | |
1621 | ||
1622 | /** | |
1623 | * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate. | |
1624 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1625 | * @ra: receiver address of the BA session recipient. | |
1626 | * @tid: the TID to BA on. | |
1627 | * | |
1628 | * This function must be called by low level driver once it has | |
1629 | * finished with preparations for the BA session. | |
1630 | * This version of the function is irq safe. | |
1631 | */ | |
1632 | void ieee80211_start_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra, | |
1633 | u16 tid); | |
1634 | ||
1635 | /** | |
1636 | * ieee80211_stop_tx_ba_session - Stop a Block Ack session. | |
1637 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1638 | * @ra: receiver address of the BA session recipient | |
1639 | * @tid: the TID to stop BA. | |
1640 | * @initiator: if indicates initiator DELBA frame will be sent. | |
1641 | * @return: error if no sta with matching da found, success otherwise | |
1642 | * | |
1643 | * Although mac80211/low level driver/user space application can estimate | |
1644 | * the need to stop aggregation on a certain RA/TID, the session level | |
1645 | * will be managed by the mac80211. | |
1646 | */ | |
1647 | int ieee80211_stop_tx_ba_session(struct ieee80211_hw *hw, | |
1648 | u8 *ra, u16 tid, | |
1649 | enum ieee80211_back_parties initiator); | |
1650 | ||
1651 | /** | |
1652 | * ieee80211_stop_tx_ba_cb - low level driver ready to stop aggregate. | |
1653 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1654 | * @ra: receiver address of the BA session recipient. | |
1655 | * @tid: the desired TID to BA on. | |
1656 | * | |
1657 | * This function must be called by low level driver once it has | |
1658 | * finished with preparations for the BA session tear down. | |
1659 | */ | |
1660 | void ieee80211_stop_tx_ba_cb(struct ieee80211_hw *hw, u8 *ra, u8 tid); | |
1661 | ||
1662 | /** | |
1663 | * ieee80211_stop_tx_ba_cb_irqsafe - low level driver ready to stop aggregate. | |
1664 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1665 | * @ra: receiver address of the BA session recipient. | |
1666 | * @tid: the desired TID to BA on. | |
1667 | * | |
1668 | * This function must be called by low level driver once it has | |
1669 | * finished with preparations for the BA session tear down. | |
1670 | * This version of the function is irq safe. | |
1671 | */ | |
1672 | void ieee80211_stop_tx_ba_cb_irqsafe(struct ieee80211_hw *hw, const u8 *ra, | |
1673 | u16 tid); | |
1674 | ||
84363e6e MA |
1675 | /** |
1676 | * ieee80211_notify_mac - low level driver notification | |
1677 | * @hw: pointer as obtained from ieee80211_alloc_hw(). | |
1678 | * @notification_types: enum ieee80211_notification_types | |
1679 | * | |
1680 | * This function must be called by low level driver to inform mac80211 of | |
1681 | * low level driver status change or force mac80211 to re-assoc for low | |
1682 | * level driver internal error that require re-assoc. | |
1683 | */ | |
1684 | void ieee80211_notify_mac(struct ieee80211_hw *hw, | |
1685 | enum ieee80211_notification_types notif_type); | |
f0706e82 | 1686 | #endif /* MAC80211_H */ |