Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1 | /* |
Johannes Berg | 3017b80 | 2007-08-28 17:01:53 -0400 | [diff] [blame] | 2 | * mac80211 <-> driver interface |
| 3 | * |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 4 | * Copyright 2002-2005, Devicescape Software, Inc. |
| 5 | * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> |
Johannes Berg | 3017b80 | 2007-08-28 17:01:53 -0400 | [diff] [blame] | 6 | * Copyright 2007 Johannes Berg <johannes@sipsolutions.net> |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 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 |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 76 | #define IEEE80211_RATE_MANDATORY 0x00000100 |
| 77 | |
| 78 | #define IEEE80211_RATE_CCK_2 (IEEE80211_RATE_CCK | IEEE80211_RATE_PREAMBLE2) |
| 79 | #define IEEE80211_RATE_MODULATION(f) \ |
| 80 | (f & (IEEE80211_RATE_CCK | IEEE80211_RATE_OFDM)) |
| 81 | |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 82 | /* Low-level driver should set PREAMBLE2, OFDM and CCK flags. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 83 | * BASIC, SUPPORTED, ERP, and MANDATORY flags are set in 80211.o based on the |
| 84 | * configuration. */ |
| 85 | struct ieee80211_rate { |
| 86 | int rate; /* rate in 100 kbps */ |
| 87 | int val; /* hw specific value for the rate */ |
| 88 | int flags; /* IEEE80211_RATE_ flags */ |
| 89 | int val2; /* hw specific value for the rate when using short preamble |
| 90 | * (only when IEEE80211_RATE_PREAMBLE2 flag is set, i.e., for |
| 91 | * 2, 5.5, and 11 Mbps) */ |
| 92 | signed char min_rssi_ack; |
| 93 | unsigned char min_rssi_ack_delta; |
| 94 | |
| 95 | /* following fields are set by 80211.o and need not be filled by the |
| 96 | * low-level driver */ |
| 97 | int rate_inv; /* inverse of the rate (LCM(all rates) / rate) for |
| 98 | * optimizing channel utilization estimates */ |
| 99 | }; |
| 100 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 101 | /** |
| 102 | * enum ieee80211_phymode - PHY modes |
| 103 | * |
| 104 | * @MODE_IEEE80211A: 5GHz as defined by 802.11a/802.11h |
| 105 | * @MODE_IEEE80211B: 2.4 GHz as defined by 802.11b |
| 106 | * @MODE_IEEE80211G: 2.4 GHz as defined by 802.11g (with OFDM), |
| 107 | * backwards compatible with 11b mode |
| 108 | * @NUM_IEEE80211_MODES: internal |
| 109 | */ |
Johannes Berg | b708e61 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 110 | enum ieee80211_phymode { |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 111 | MODE_IEEE80211A, |
| 112 | MODE_IEEE80211B, |
| 113 | MODE_IEEE80211G, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 114 | |
| 115 | /* keep last */ |
| 116 | NUM_IEEE80211_MODES |
| 117 | }; |
| 118 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 119 | /** |
| 120 | * struct ieee80211_hw_mode - PHY mode definition |
| 121 | * |
| 122 | * This structure describes the capabilities supported by the device |
| 123 | * in a single PHY mode. |
| 124 | * |
| 125 | * @mode: the PHY mode for this definition |
| 126 | * @num_channels: number of supported channels |
| 127 | * @channels: pointer to array of supported channels |
| 128 | * @num_rates: number of supported bitrates |
| 129 | * @rates: pointer to array of supported bitrates |
| 130 | * @list: internal |
| 131 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 132 | struct ieee80211_hw_mode { |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 133 | struct list_head list; |
| 134 | struct ieee80211_channel *channels; |
| 135 | struct ieee80211_rate *rates; |
| 136 | enum ieee80211_phymode mode; |
| 137 | int num_channels; |
| 138 | int num_rates; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 139 | }; |
| 140 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 141 | /** |
| 142 | * struct ieee80211_tx_queue_params - transmit queue configuration |
| 143 | * |
| 144 | * The information provided in this structure is required for QoS |
| 145 | * transmit queue configuration. |
| 146 | * |
| 147 | * @aifs: arbitration interface space [0..255, -1: use default] |
| 148 | * @cw_min: minimum contention window [will be a value of the form |
| 149 | * 2^n-1 in the range 1..1023; 0: use default] |
| 150 | * @cw_max: maximum contention window [like @cw_min] |
| 151 | * @burst_time: maximum burst time in units of 0.1ms, 0 meaning disabled |
| 152 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 153 | struct ieee80211_tx_queue_params { |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 154 | int aifs; |
| 155 | int cw_min; |
| 156 | int cw_max; |
| 157 | int burst_time; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 158 | }; |
| 159 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 160 | /** |
| 161 | * struct ieee80211_tx_queue_stats_data - transmit queue statistics |
| 162 | * |
| 163 | * @len: number of packets in queue |
| 164 | * @limit: queue length limit |
| 165 | * @count: number of frames sent |
| 166 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 167 | struct ieee80211_tx_queue_stats_data { |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 168 | unsigned int len; |
| 169 | unsigned int limit; |
| 170 | unsigned int count; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 171 | }; |
| 172 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 173 | /** |
| 174 | * enum ieee80211_tx_queue - transmit queue number |
| 175 | * |
| 176 | * These constants are used with some callbacks that take a |
| 177 | * queue number to set parameters for a queue. |
| 178 | * |
| 179 | * @IEEE80211_TX_QUEUE_DATA0: data queue 0 |
| 180 | * @IEEE80211_TX_QUEUE_DATA1: data queue 1 |
| 181 | * @IEEE80211_TX_QUEUE_DATA2: data queue 2 |
| 182 | * @IEEE80211_TX_QUEUE_DATA3: data queue 3 |
| 183 | * @IEEE80211_TX_QUEUE_DATA4: data queue 4 |
| 184 | * @IEEE80211_TX_QUEUE_SVP: ?? |
| 185 | * @NUM_TX_DATA_QUEUES: number of data queues |
| 186 | * @IEEE80211_TX_QUEUE_AFTER_BEACON: transmit queue for frames to be |
| 187 | * sent after a beacon |
| 188 | * @IEEE80211_TX_QUEUE_BEACON: transmit queue for beacon frames |
| 189 | */ |
| 190 | enum ieee80211_tx_queue { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 191 | IEEE80211_TX_QUEUE_DATA0, |
| 192 | IEEE80211_TX_QUEUE_DATA1, |
| 193 | IEEE80211_TX_QUEUE_DATA2, |
| 194 | IEEE80211_TX_QUEUE_DATA3, |
| 195 | IEEE80211_TX_QUEUE_DATA4, |
| 196 | IEEE80211_TX_QUEUE_SVP, |
| 197 | |
| 198 | NUM_TX_DATA_QUEUES, |
| 199 | |
| 200 | /* due to stupidity in the sub-ioctl userspace interface, the items in |
| 201 | * this struct need to have fixed values. As soon as it is removed, we can |
| 202 | * fix these entries. */ |
| 203 | IEEE80211_TX_QUEUE_AFTER_BEACON = 6, |
| 204 | IEEE80211_TX_QUEUE_BEACON = 7 |
| 205 | }; |
| 206 | |
| 207 | struct ieee80211_tx_queue_stats { |
| 208 | struct ieee80211_tx_queue_stats_data data[NUM_TX_DATA_QUEUES]; |
| 209 | }; |
| 210 | |
| 211 | struct ieee80211_low_level_stats { |
| 212 | unsigned int dot11ACKFailureCount; |
| 213 | unsigned int dot11RTSFailureCount; |
| 214 | unsigned int dot11FCSErrorCount; |
| 215 | unsigned int dot11RTSSuccessCount; |
| 216 | }; |
| 217 | |
| 218 | /* Transmit control fields. This data structure is passed to low-level driver |
| 219 | * with each TX frame. The low-level driver is responsible for configuring |
| 220 | * the hardware to use given values (depending on what is supported). */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 221 | |
| 222 | struct ieee80211_tx_control { |
| 223 | int tx_rate; /* Transmit rate, given as the hw specific value for the |
| 224 | * rate (from struct ieee80211_rate) */ |
| 225 | int rts_cts_rate; /* Transmit rate for RTS/CTS frame, given as the hw |
| 226 | * specific value for the rate (from |
| 227 | * struct ieee80211_rate) */ |
| 228 | |
| 229 | #define IEEE80211_TXCTL_REQ_TX_STATUS (1<<0)/* request TX status callback for |
| 230 | * this frame */ |
| 231 | #define IEEE80211_TXCTL_DO_NOT_ENCRYPT (1<<1) /* send this frame without |
| 232 | * encryption; e.g., for EAPOL |
| 233 | * frames */ |
| 234 | #define IEEE80211_TXCTL_USE_RTS_CTS (1<<2) /* use RTS-CTS before sending |
| 235 | * frame */ |
| 236 | #define IEEE80211_TXCTL_USE_CTS_PROTECT (1<<3) /* use CTS protection for the |
| 237 | * frame (e.g., for combined |
| 238 | * 802.11g / 802.11b networks) */ |
| 239 | #define IEEE80211_TXCTL_NO_ACK (1<<4) /* tell the low level not to |
| 240 | * wait for an ack */ |
| 241 | #define IEEE80211_TXCTL_RATE_CTRL_PROBE (1<<5) |
| 242 | #define IEEE80211_TXCTL_CLEAR_DST_MASK (1<<6) |
| 243 | #define IEEE80211_TXCTL_REQUEUE (1<<7) |
| 244 | #define IEEE80211_TXCTL_FIRST_FRAGMENT (1<<8) /* this is a first fragment of |
| 245 | * the frame */ |
Ivo van Doorn | d5d08de | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 246 | #define IEEE80211_TXCTL_LONG_RETRY_LIMIT (1<<10) /* this frame should be send |
| 247 | * using the through |
| 248 | * set_retry_limit configured |
| 249 | * long retry value */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 250 | u32 flags; /* tx control flags defined |
| 251 | * above */ |
Johannes Berg | 6a7664d | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 252 | u8 key_idx; /* keyidx from hw->set_key(), undefined if |
| 253 | * IEEE80211_TXCTL_DO_NOT_ENCRYPT is set */ |
Ivo van Doorn | d5d08de | 2007-07-27 15:43:23 +0200 | [diff] [blame] | 254 | u8 retry_limit; /* 1 = only first attempt, 2 = one retry, .. |
| 255 | * This could be used when set_retry_limit |
| 256 | * is not implemented by the driver */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 257 | u8 power_level; /* per-packet transmit power level, in dBm */ |
| 258 | u8 antenna_sel_tx; /* 0 = default/diversity, 1 = Ant0, 2 = Ant1 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 259 | u8 icv_len; /* length of the ICV/MIC field in octets */ |
| 260 | u8 iv_len; /* length of the IV field in octets */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 261 | u8 queue; /* hardware queue to use for this frame; |
| 262 | * 0 = highest, hw->queues-1 = lowest */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 263 | struct ieee80211_rate *rate; /* internal 80211.o rate */ |
| 264 | struct ieee80211_rate *rts_rate; /* internal 80211.o rate |
| 265 | * for RTS/CTS */ |
| 266 | int alt_retry_rate; /* retry rate for the last retries, given as the |
| 267 | * hw specific value for the rate (from |
| 268 | * struct ieee80211_rate). To be used to limit |
| 269 | * packet dropping when probing higher rates, if hw |
| 270 | * supports multiple retry rates. -1 = not used */ |
| 271 | int type; /* internal */ |
| 272 | int ifindex; /* internal */ |
| 273 | }; |
| 274 | |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 275 | |
| 276 | /** |
| 277 | * enum mac80211_rx_flags - receive flags |
| 278 | * |
| 279 | * These flags are used with the @flag member of &struct ieee80211_rx_status. |
| 280 | * @RX_FLAG_MMIC_ERROR: Michael MIC error was reported on this frame. |
| 281 | * Use together with %RX_FLAG_MMIC_STRIPPED. |
| 282 | * @RX_FLAG_DECRYPTED: This frame was decrypted in hardware. |
| 283 | * @RX_FLAG_RADIOTAP: This frame starts with a radiotap header. |
| 284 | * @RX_FLAG_MMIC_STRIPPED: the Michael MIC is stripped off this frame, |
| 285 | * verification has been done by the hardware. |
| 286 | * @RX_FLAG_IV_STRIPPED: The IV/ICV are stripped from this frame. |
| 287 | * If this flag is set, the stack cannot do any replay detection |
| 288 | * hence the driver or hardware will have to do that. |
Johannes Berg | 72abd81 | 2007-09-17 01:29:22 -0400 | [diff] [blame] | 289 | * @RX_FLAG_FAILED_FCS_CRC: Set this flag if the FCS check failed on |
| 290 | * the frame. |
| 291 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on |
| 292 | * the frame. |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 293 | */ |
| 294 | enum mac80211_rx_flags { |
| 295 | RX_FLAG_MMIC_ERROR = 1<<0, |
| 296 | RX_FLAG_DECRYPTED = 1<<1, |
| 297 | RX_FLAG_RADIOTAP = 1<<2, |
| 298 | RX_FLAG_MMIC_STRIPPED = 1<<3, |
| 299 | RX_FLAG_IV_STRIPPED = 1<<4, |
Johannes Berg | 72abd81 | 2007-09-17 01:29:22 -0400 | [diff] [blame] | 300 | RX_FLAG_FAILED_FCS_CRC = 1<<5, |
| 301 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 302 | }; |
| 303 | |
| 304 | /** |
| 305 | * struct ieee80211_rx_status - receive status |
| 306 | * |
| 307 | * The low-level driver should provide this information (the subset |
| 308 | * supported by hardware) to the 802.11 code with each received |
| 309 | * frame. |
| 310 | * @mactime: MAC timestamp as defined by 802.11 |
| 311 | * @freq: frequency the radio was tuned to when receiving this frame, in MHz |
| 312 | * @channel: channel the radio was tuned to |
| 313 | * @phymode: active PHY mode |
| 314 | * @ssi: signal strength when receiving this frame |
| 315 | * @signal: used as 'qual' in statistics reporting |
| 316 | * @noise: PHY noise when receiving this frame |
| 317 | * @antenna: antenna used |
| 318 | * @rate: data rate |
| 319 | * @flag: %RX_FLAG_* |
| 320 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 321 | struct ieee80211_rx_status { |
| 322 | u64 mactime; |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 323 | int freq; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 324 | int channel; |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 325 | enum ieee80211_phymode phymode; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 326 | int ssi; |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 327 | int signal; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 328 | int noise; |
| 329 | int antenna; |
| 330 | int rate; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 331 | int flag; |
| 332 | }; |
| 333 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 334 | /** |
| 335 | * enum ieee80211_tx_status_flags - transmit status flags |
| 336 | * |
| 337 | * Status flags to indicate various transmit conditions. |
| 338 | * |
| 339 | * @IEEE80211_TX_STATUS_TX_FILTERED: The frame was not transmitted |
| 340 | * because the destination STA was in powersave mode. |
| 341 | * |
| 342 | * @IEEE80211_TX_STATUS_ACK: Frame was acknowledged |
| 343 | */ |
| 344 | enum ieee80211_tx_status_flags { |
| 345 | IEEE80211_TX_STATUS_TX_FILTERED = 1<<0, |
| 346 | IEEE80211_TX_STATUS_ACK = 1<<1, |
| 347 | }; |
| 348 | |
| 349 | /** |
| 350 | * struct ieee80211_tx_status - transmit status |
| 351 | * |
| 352 | * As much information as possible should be provided for each transmitted |
| 353 | * frame with ieee80211_tx_status(). |
| 354 | * |
| 355 | * @control: a copy of the &struct ieee80211_tx_control passed to the driver |
| 356 | * in the tx() callback. |
| 357 | * |
| 358 | * @flags: transmit status flags, defined above |
| 359 | * |
| 360 | * @ack_signal: signal strength of the ACK frame |
| 361 | * |
| 362 | * @excessive_retries: set to 1 if the frame was retried many times |
| 363 | * but not acknowledged |
| 364 | * |
| 365 | * @retry_count: number of retries |
| 366 | * |
| 367 | * @queue_length: ?? REMOVE |
| 368 | * @queue_number: ?? REMOVE |
| 369 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 370 | struct ieee80211_tx_status { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 371 | struct ieee80211_tx_control control; |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 372 | u8 flags; |
| 373 | bool excessive_retries; |
| 374 | u8 retry_count; |
| 375 | int ack_signal; |
| 376 | int queue_length; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 377 | int queue_number; |
| 378 | }; |
| 379 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 380 | /** |
| 381 | * enum ieee80211_conf_flags - configuration flags |
| 382 | * |
| 383 | * Flags to define PHY configuration options |
| 384 | * |
| 385 | * @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time |
| 386 | * @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported) |
| 387 | * |
| 388 | */ |
| 389 | enum ieee80211_conf_flags { |
| 390 | IEEE80211_CONF_SHORT_SLOT_TIME = 1<<0, |
| 391 | IEEE80211_CONF_RADIOTAP = 1<<1, |
| 392 | }; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 393 | |
| 394 | /** |
| 395 | * struct ieee80211_conf - configuration of the device |
| 396 | * |
| 397 | * This struct indicates how the driver shall configure the hardware. |
| 398 | * |
| 399 | * @radio_enabled: when zero, driver is required to switch off the radio. |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 400 | * TODO make a flag |
| 401 | * @channel: IEEE 802.11 channel number |
| 402 | * @freq: frequency in MHz |
| 403 | * @channel_val: hardware specific channel value for the channel |
| 404 | * @phymode: PHY mode to activate (REMOVE) |
| 405 | * @chan: channel to switch to, pointer to the channel information |
| 406 | * @mode: pointer to mode definition |
| 407 | * @regulatory_domain: ?? |
| 408 | * @beacon_int: beacon interval (TODO make interface config) |
| 409 | * @flags: configuration flags defined above |
| 410 | * @power_level: transmit power limit for current regulatory domain in dBm |
| 411 | * @antenna_max: maximum antenna gain |
| 412 | * @antenna_sel_tx: transmit antenna selection, 0: default/diversity, |
| 413 | * 1/2: antenna 0/1 |
| 414 | * @antenna_sel_rx: receive antenna selection, like @antenna_sel_tx |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 415 | */ |
| 416 | struct ieee80211_conf { |
| 417 | int channel; /* IEEE 802.11 channel number */ |
| 418 | int freq; /* MHz */ |
| 419 | int channel_val; /* hw specific value for the channel */ |
| 420 | |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 421 | enum ieee80211_phymode phymode; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 422 | struct ieee80211_channel *chan; |
| 423 | struct ieee80211_hw_mode *mode; |
| 424 | unsigned int regulatory_domain; |
| 425 | int radio_enabled; |
| 426 | |
| 427 | int beacon_int; |
Johannes Berg | 6b301cd | 2007-09-18 17:29:20 -0400 | [diff] [blame] | 428 | u32 flags; |
| 429 | u8 power_level; |
| 430 | u8 antenna_max; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 431 | u8 antenna_sel_tx; |
| 432 | u8 antenna_sel_rx; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 433 | }; |
| 434 | |
| 435 | /** |
| 436 | * enum ieee80211_if_types - types of 802.11 network interfaces |
| 437 | * |
| 438 | * @IEEE80211_IF_TYPE_AP: interface in AP mode. |
| 439 | * @IEEE80211_IF_TYPE_MGMT: special interface for communication with hostap |
| 440 | * daemon. Drivers should never see this type. |
| 441 | * @IEEE80211_IF_TYPE_STA: interface in STA (client) mode. |
| 442 | * @IEEE80211_IF_TYPE_IBSS: interface in IBSS (ad-hoc) mode. |
| 443 | * @IEEE80211_IF_TYPE_MNTR: interface in monitor (rfmon) mode. |
| 444 | * @IEEE80211_IF_TYPE_WDS: interface in WDS mode. |
Johannes Berg | 0ec3ca4 | 2007-09-17 01:29:24 -0400 | [diff] [blame^] | 445 | * @IEEE80211_IF_TYPE_VLAN: VLAN interface bound to an AP, drivers |
| 446 | * will never see this type. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 447 | */ |
| 448 | enum ieee80211_if_types { |
Johannes Berg | 0ec3ca4 | 2007-09-17 01:29:24 -0400 | [diff] [blame^] | 449 | IEEE80211_IF_TYPE_AP, |
| 450 | IEEE80211_IF_TYPE_MGMT, |
| 451 | IEEE80211_IF_TYPE_STA, |
| 452 | IEEE80211_IF_TYPE_IBSS, |
| 453 | IEEE80211_IF_TYPE_MNTR, |
| 454 | IEEE80211_IF_TYPE_WDS, |
| 455 | IEEE80211_IF_TYPE_VLAN, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 456 | }; |
| 457 | |
| 458 | /** |
| 459 | * struct ieee80211_if_init_conf - initial configuration of an interface |
| 460 | * |
| 461 | * @if_id: internal interface ID. This number has no particular meaning to |
| 462 | * drivers and the only allowed usage is to pass it to |
| 463 | * ieee80211_beacon_get() and ieee80211_get_buffered_bc() functions. |
| 464 | * This field is not valid for monitor interfaces |
| 465 | * (interfaces of %IEEE80211_IF_TYPE_MNTR type). |
| 466 | * @type: one of &enum ieee80211_if_types constants. Determines the type of |
| 467 | * added/removed interface. |
| 468 | * @mac_addr: pointer to MAC address of the interface. This pointer is valid |
| 469 | * until the interface is removed (i.e. it cannot be used after |
| 470 | * remove_interface() callback was called for this interface). |
| 471 | * |
| 472 | * This structure is used in add_interface() and remove_interface() |
| 473 | * callbacks of &struct ieee80211_hw. |
Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 474 | * |
| 475 | * When you allow multiple interfaces to be added to your PHY, take care |
| 476 | * that the hardware can actually handle multiple MAC addresses. However, |
| 477 | * also take care that when there's no interface left with mac_addr != %NULL |
| 478 | * you remove the MAC address from the device to avoid acknowledging packets |
| 479 | * in pure monitor mode. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 480 | */ |
| 481 | struct ieee80211_if_init_conf { |
| 482 | int if_id; |
| 483 | int type; |
| 484 | void *mac_addr; |
| 485 | }; |
| 486 | |
| 487 | /** |
| 488 | * struct ieee80211_if_conf - configuration of an interface |
| 489 | * |
| 490 | * @type: type of the interface. This is always the same as was specified in |
| 491 | * &struct ieee80211_if_init_conf. The type of an interface never changes |
| 492 | * during the life of the interface; this field is present only for |
| 493 | * convenience. |
| 494 | * @bssid: BSSID of the network we are associated to/creating. |
| 495 | * @ssid: used (together with @ssid_len) by drivers for hardware that |
| 496 | * generate beacons independently. The pointer is valid only during the |
| 497 | * config_interface() call, so copy the value somewhere if you need |
| 498 | * it. |
| 499 | * @ssid_len: length of the @ssid field. |
| 500 | * @generic_elem: used (together with @generic_elem_len) by drivers for |
| 501 | * hardware that generate beacons independently. The pointer is valid |
| 502 | * only during the config_interface() call, so copy the value somewhere |
| 503 | * if you need it. |
| 504 | * @generic_elem_len: length of the generic element. |
| 505 | * @beacon: beacon template. Valid only if @host_gen_beacon_template in |
| 506 | * &struct ieee80211_hw is set. The driver is responsible of freeing |
| 507 | * the sk_buff. |
| 508 | * @beacon_control: tx_control for the beacon template, this field is only |
| 509 | * valid when the @beacon field was set. |
| 510 | * |
| 511 | * This structure is passed to the config_interface() callback of |
| 512 | * &struct ieee80211_hw. |
| 513 | */ |
| 514 | struct ieee80211_if_conf { |
| 515 | int type; |
| 516 | u8 *bssid; |
| 517 | u8 *ssid; |
| 518 | size_t ssid_len; |
| 519 | u8 *generic_elem; |
| 520 | size_t generic_elem_len; |
| 521 | struct sk_buff *beacon; |
| 522 | struct ieee80211_tx_control *beacon_control; |
| 523 | }; |
| 524 | |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 525 | /** |
| 526 | * enum ieee80211_key_alg - key algorithm |
| 527 | * @ALG_NONE: Unset key algorithm, will never be passed to the driver |
| 528 | * @ALG_WEP: WEP40 or WEP104 |
| 529 | * @ALG_TKIP: TKIP |
| 530 | * @ALG_CCMP: CCMP (AES) |
| 531 | */ |
| 532 | typedef enum ieee80211_key_alg { |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 533 | ALG_NONE, |
| 534 | ALG_WEP, |
| 535 | ALG_TKIP, |
| 536 | ALG_CCMP, |
| 537 | } ieee80211_key_alg; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 538 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 539 | |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 540 | /** |
| 541 | * enum ieee80211_key_flags - key flags |
| 542 | * |
| 543 | * These flags are used for communication about keys between the driver |
| 544 | * and mac80211, with the @flags parameter of &struct ieee80211_key_conf. |
| 545 | * |
| 546 | * @IEEE80211_KEY_FLAG_WMM_STA: Set by mac80211, this flag indicates |
| 547 | * that the STA this key will be used with could be using QoS. |
| 548 | * @IEEE80211_KEY_FLAG_GENERATE_IV: This flag should be set by the |
| 549 | * driver to indicate that it requires IV generation for this |
| 550 | * particular key. |
| 551 | * @IEEE80211_KEY_FLAG_GENERATE_MMIC: This flag should be set by |
| 552 | * the driver for a TKIP key if it requires Michael MIC |
| 553 | * generation in software. |
| 554 | */ |
| 555 | enum ieee80211_key_flags { |
| 556 | IEEE80211_KEY_FLAG_WMM_STA = 1<<0, |
| 557 | IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, |
| 558 | IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, |
| 559 | }; |
| 560 | |
| 561 | /** |
| 562 | * struct ieee80211_key_conf - key information |
| 563 | * |
| 564 | * This key information is given by mac80211 to the driver by |
| 565 | * the set_key() callback in &struct ieee80211_ops. |
| 566 | * |
| 567 | * @hw_key_idx: To be set by the driver, this is the key index the driver |
| 568 | * wants to be given when a frame is transmitted and needs to be |
Johannes Berg | 6a7664d | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 569 | * encrypted in hardware. |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 570 | * @alg: The key algorithm. |
| 571 | * @flags: key flags, see &enum ieee80211_key_flags. |
| 572 | * @keyidx: the key index (0-3) |
| 573 | * @keylen: key material length |
| 574 | * @key: key material |
| 575 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 576 | struct ieee80211_key_conf { |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 577 | ieee80211_key_alg alg; |
Johannes Berg | 6a7664d | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 578 | u8 hw_key_idx; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 579 | u8 flags; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 580 | s8 keyidx; |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 581 | u8 keylen; |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 582 | u8 key[0]; |
| 583 | }; |
| 584 | |
| 585 | #define IEEE80211_SEQ_COUNTER_RX 0 |
| 586 | #define IEEE80211_SEQ_COUNTER_TX 1 |
| 587 | |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 588 | /** |
| 589 | * enum set_key_cmd - key command |
| 590 | * |
| 591 | * Used with the set_key() callback in &struct ieee80211_ops, this |
| 592 | * indicates whether a key is being removed or added. |
| 593 | * |
| 594 | * @SET_KEY: a key is set |
| 595 | * @DISABLE_KEY: a key must be disabled |
| 596 | */ |
| 597 | typedef enum set_key_cmd { |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 598 | SET_KEY, DISABLE_KEY, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 599 | } set_key_cmd; |
| 600 | |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 601 | /** |
| 602 | * struct ieee80211_hw - hardware information and state |
| 603 | * TODO: move documentation into kernel-doc format |
| 604 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 605 | struct ieee80211_hw { |
| 606 | /* points to the cfg80211 wiphy for this piece. Note |
| 607 | * that you must fill in the perm_addr and dev fields |
| 608 | * of this structure, use the macros provided below. */ |
| 609 | struct wiphy *wiphy; |
| 610 | |
| 611 | /* assigned by mac80211, don't write */ |
| 612 | struct ieee80211_conf conf; |
| 613 | |
| 614 | /* Single thread workqueue available for driver use |
| 615 | * Allocated by mac80211 on registration */ |
| 616 | struct workqueue_struct *workqueue; |
| 617 | |
| 618 | /* Pointer to the private area that was |
| 619 | * allocated with this struct for you. */ |
| 620 | void *priv; |
| 621 | |
| 622 | /* The rest is information about your hardware */ |
| 623 | |
| 624 | /* TODO: frame_type 802.11/802.3, sw_encryption requirements */ |
| 625 | |
Johannes Berg | 0ef6e49 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 626 | /* hole at 0 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 627 | |
Johannes Berg | 0ef6e49 | 2007-08-28 17:01:52 -0400 | [diff] [blame] | 628 | /* |
| 629 | * The device only needs to be supplied with a beacon template. |
| 630 | * If you need the host to generate each beacon then don't use |
| 631 | * this flag and use ieee80211_beacon_get(). |
| 632 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 633 | #define IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE (1<<1) |
| 634 | |
Johannes Berg | 7848ba7 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 635 | /* hole at 2 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 636 | |
| 637 | /* Whether RX frames passed to ieee80211_rx() include FCS in the end */ |
| 638 | #define IEEE80211_HW_RX_INCLUDES_FCS (1<<3) |
| 639 | |
| 640 | /* Some wireless LAN chipsets buffer broadcast/multicast frames for |
| 641 | * power saving stations in the hardware/firmware and others rely on |
| 642 | * the host system for such buffering. This option is used to |
| 643 | * configure the IEEE 802.11 upper layer to buffer broadcast/multicast |
| 644 | * frames when there are power saving stations so that low-level driver |
| 645 | * can fetch them with ieee80211_get_buffered_bc(). */ |
| 646 | #define IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING (1<<4) |
| 647 | |
Johannes Berg | 7848ba7 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 648 | /* hole at 5 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 649 | |
Johannes Berg | aaa92e9 | 2007-09-06 03:36:10 -0700 | [diff] [blame] | 650 | /* hole at 6 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 651 | |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 652 | /* hole at 7 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 653 | |
Johannes Berg | 7848ba7 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 654 | /* hole at 8 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 655 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 656 | /* hole at 9 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 657 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 658 | /* hole at 10 */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 659 | |
| 660 | /* Channels are already configured to the default regulatory domain |
| 661 | * specified in the device's EEPROM */ |
| 662 | #define IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED (1<<11) |
| 663 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 664 | u32 flags; /* hardware flags defined above */ |
| 665 | |
| 666 | /* Set to the size of a needed device specific skb headroom for TX skbs. */ |
| 667 | unsigned int extra_tx_headroom; |
| 668 | |
| 669 | /* This is the time in us to change channels |
| 670 | */ |
| 671 | int channel_change_time; |
| 672 | /* Maximum values for various statistics. |
| 673 | * Leave at 0 to indicate no support. Use negative numbers for dBm. */ |
| 674 | s8 max_rssi; |
| 675 | s8 max_signal; |
| 676 | s8 max_noise; |
| 677 | |
| 678 | /* Number of available hardware TX queues for data packets. |
| 679 | * WMM requires at least four queues. */ |
| 680 | int queues; |
| 681 | }; |
| 682 | |
| 683 | static inline void SET_IEEE80211_DEV(struct ieee80211_hw *hw, struct device *dev) |
| 684 | { |
| 685 | set_wiphy_dev(hw->wiphy, dev); |
| 686 | } |
| 687 | |
| 688 | static inline void SET_IEEE80211_PERM_ADDR(struct ieee80211_hw *hw, u8 *addr) |
| 689 | { |
| 690 | memcpy(hw->wiphy->perm_addr, addr, ETH_ALEN); |
| 691 | } |
| 692 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 693 | /* |
| 694 | * flags for change_filter_flags() |
| 695 | * |
| 696 | * Note that e.g. if PROMISC_IN_BSS is unset then |
| 697 | * you should still do MAC address filtering if |
| 698 | * possible even if OTHER_BSS is set to indicate |
| 699 | * no BSSID filtering should be done. |
| 700 | */ |
| 701 | /* |
| 702 | * promiscuous mode within your BSS, |
| 703 | * think of the BSS as your network segment and then this corresponds |
| 704 | * to the regular ethernet device promiscuous mode |
| 705 | */ |
| 706 | #define FIF_PROMISC_IN_BSS 0x01 |
| 707 | /* show all multicast frames */ |
| 708 | #define FIF_ALLMULTI 0x02 |
| 709 | /* show frames with failed FCS, but set RX_FLAG_FAILED_FCS_CRC for them */ |
| 710 | #define FIF_FCSFAIL 0x04 |
| 711 | /* show frames with failed PLCP CRC, but set RX_FLAG_FAILED_PLCP_CRC for them */ |
| 712 | #define FIF_PLCPFAIL 0x08 |
| 713 | /* |
| 714 | * This flag is set during scanning to indicate to the hardware |
| 715 | * that it should not filter beacons or probe responses by BSSID. |
| 716 | */ |
| 717 | #define FIF_BCN_PRBRESP_PROMISC 0x10 |
| 718 | /* |
| 719 | * show control frames, if PROMISC_IN_BSS is not set then |
| 720 | * only those addressed to this station |
| 721 | */ |
| 722 | #define FIF_CONTROL 0x20 |
| 723 | /* show frames from other BSSes */ |
| 724 | #define FIF_OTHER_BSS 0x40 |
| 725 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 726 | /* Configuration block used by the low-level driver to tell the 802.11 code |
| 727 | * about supported hardware features and to pass function pointers to callback |
| 728 | * functions. */ |
| 729 | struct ieee80211_ops { |
| 730 | /* Handler that 802.11 module calls for each transmitted frame. |
| 731 | * skb contains the buffer starting from the IEEE 802.11 header. |
| 732 | * The low-level driver should send the frame out based on |
| 733 | * configuration in the TX control data. |
| 734 | * Must be atomic. */ |
| 735 | int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb, |
| 736 | struct ieee80211_tx_control *control); |
| 737 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 738 | /* |
| 739 | * Called before the first netdevice attached to the hardware |
| 740 | * is enabled. This should turn on the hardware and must turn on |
| 741 | * frame reception (for possibly enabled monitor interfaces.) |
| 742 | * Returns negative error codes, these may be seen in userspace, |
| 743 | * or zero. |
| 744 | * When the device is started it should not have a MAC address |
| 745 | * to avoid acknowledging frames before a non-monitor device |
| 746 | * is added. |
| 747 | * |
| 748 | * Must be implemented. |
| 749 | */ |
| 750 | int (*start)(struct ieee80211_hw *hw); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 751 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 752 | /* |
| 753 | * Called after last netdevice attached to the hardware |
| 754 | * is disabled. This should turn off the hardware (at least |
| 755 | * it must turn off frame reception.) |
| 756 | * May be called right after add_interface if that rejects |
| 757 | * an interface. |
| 758 | * |
| 759 | * Must be implemented. |
| 760 | */ |
| 761 | void (*stop)(struct ieee80211_hw *hw); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 762 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 763 | /* |
| 764 | * Called when a netdevice attached to the hardware is enabled. |
| 765 | * Because it is not called for monitor mode devices, open() |
| 766 | * and stop() must be implemented. |
| 767 | * The driver should perform any initialization it needs before |
| 768 | * the device can be enabled. The initial configuration for the |
| 769 | * interface is given in the conf parameter. |
| 770 | * |
| 771 | * Must be implemented. |
Johannes Berg | 4480f15c | 2007-07-10 19:32:10 +0200 | [diff] [blame] | 772 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 773 | int (*add_interface)(struct ieee80211_hw *hw, |
| 774 | struct ieee80211_if_init_conf *conf); |
| 775 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 776 | /* |
| 777 | * Notifies a driver that an interface is going down. The stop() handler |
| 778 | * is called after this if it is the last interface and no monitor |
| 779 | * interfaces are present. |
| 780 | * When all interfaces are removed, the MAC address in the hardware |
| 781 | * must be cleared so the device no longer acknowledges packets, |
| 782 | * the mac_addr member of the conf structure is, however, set to the |
| 783 | * MAC address of the device going away. |
| 784 | * |
| 785 | * Hence, this callback must be implemented. |
| 786 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 787 | void (*remove_interface)(struct ieee80211_hw *hw, |
| 788 | struct ieee80211_if_init_conf *conf); |
| 789 | |
| 790 | /* Handler for configuration requests. IEEE 802.11 code calls this |
| 791 | * function to change hardware configuration, e.g., channel. */ |
| 792 | int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf); |
| 793 | |
| 794 | /* Handler for configuration requests related to interfaces (e.g. |
| 795 | * BSSID). */ |
| 796 | int (*config_interface)(struct ieee80211_hw *hw, |
| 797 | int if_id, struct ieee80211_if_conf *conf); |
| 798 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 799 | /* |
| 800 | * Configure the device's RX filter. |
| 801 | * |
| 802 | * The multicast address filter must be changed if the hardware flags |
| 803 | * indicate that one is present. |
| 804 | * |
| 805 | * All unsupported flags in 'total_flags' must be cleared, |
| 806 | * clear all bits except those you honoured. |
| 807 | * |
| 808 | * The callback must be implemented and must be atomic. |
| 809 | */ |
| 810 | void (*configure_filter)(struct ieee80211_hw *hw, |
| 811 | unsigned int changed_flags, |
| 812 | unsigned int *total_flags, |
| 813 | int mc_count, struct dev_addr_list *mc_list); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 814 | |
| 815 | /* Set TIM bit handler. If the hardware/firmware takes care of beacon |
| 816 | * generation, IEEE 802.11 code uses this function to tell the |
| 817 | * low-level to set (or clear if set==0) TIM bit for the given aid. If |
| 818 | * host system is used to generate beacons, this handler is not used |
| 819 | * and low-level driver should set it to NULL. |
| 820 | * Must be atomic. */ |
| 821 | int (*set_tim)(struct ieee80211_hw *hw, int aid, int set); |
| 822 | |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 823 | /* |
| 824 | * Set encryption key. |
| 825 | * |
| 826 | * This is called to enable hardware acceleration of encryption and |
| 827 | * decryption. The address will be the broadcast address for default |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 828 | * keys, the other station's hardware address for individual keys or |
| 829 | * the zero address for keys that will be used only for transmission. |
| 830 | * |
| 831 | * The local_address parameter will always be set to our own address, |
| 832 | * this is only relevant if you support multiple local addresses. |
| 833 | * |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 834 | * When transmitting, the TX control data will use the hw_key_idx |
| 835 | * selected by the low-level driver. |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 836 | * |
| 837 | * Return 0 if the key is now in use, -EOPNOTSUPP or -ENOSPC if it |
Johannes Berg | 6a7664d | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 838 | * couldn't be added; if you return 0 then hw_key_idx must be assigned |
| 839 | * to the hardware key index, you are free to use the full u8 range. |
| 840 | * |
| 841 | * When the cmd is DISABLE_KEY then it must succeed. |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 842 | * |
Johannes Berg | 7ac1bd6 | 2007-09-14 11:10:25 -0400 | [diff] [blame] | 843 | * Note that it is permissible to not decrypt a frame even if a key |
| 844 | * for it has been uploaded to hardware, the stack will not make any |
| 845 | * decision based on whether a key has been uploaded or not but rather |
| 846 | * based on the receive flags. |
| 847 | * |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 848 | * This callback can sleep, and is only called between add_interface |
| 849 | * and remove_interface calls, i.e. while the interface with the |
| 850 | * given local_address is enabled. |
| 851 | * |
| 852 | * The ieee80211_key_conf structure pointed to by the key parameter |
| 853 | * is guaranteed to be valid until another call to set_key removes |
| 854 | * it, but it can only be used as a cookie to differentiate keys. |
Johannes Berg | 8f20fc2 | 2007-08-28 17:01:54 -0400 | [diff] [blame] | 855 | */ |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 856 | int (*set_key)(struct ieee80211_hw *hw, set_key_cmd cmd, |
Johannes Berg | 11a843b | 2007-08-28 17:01:55 -0400 | [diff] [blame] | 857 | const u8 *local_address, const u8 *address, |
| 858 | struct ieee80211_key_conf *key); |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 859 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 860 | /* Enable/disable IEEE 802.1X. This item requests wlan card to pass |
| 861 | * unencrypted EAPOL-Key frames even when encryption is configured. |
| 862 | * If the wlan card does not require such a configuration, this |
| 863 | * function pointer can be set to NULL. */ |
| 864 | int (*set_ieee8021x)(struct ieee80211_hw *hw, int use_ieee8021x); |
| 865 | |
| 866 | /* Set port authorization state (IEEE 802.1X PAE) to be authorized |
| 867 | * (authorized=1) or unauthorized (authorized=0). This function can be |
| 868 | * used if the wlan hardware or low-level driver implements PAE. |
| 869 | * 80211.o module will anyway filter frames based on authorization |
| 870 | * state, so this function pointer can be NULL if low-level driver does |
| 871 | * not require event notification about port state changes. |
| 872 | * Currently unused. */ |
| 873 | int (*set_port_auth)(struct ieee80211_hw *hw, u8 *addr, |
| 874 | int authorized); |
| 875 | |
| 876 | /* Ask the hardware to service the scan request, no need to start |
| 877 | * the scan state machine in stack. */ |
| 878 | int (*hw_scan)(struct ieee80211_hw *hw, u8 *ssid, size_t len); |
| 879 | |
| 880 | /* return low-level statistics */ |
| 881 | int (*get_stats)(struct ieee80211_hw *hw, |
| 882 | struct ieee80211_low_level_stats *stats); |
| 883 | |
| 884 | /* For devices that generate their own beacons and probe response |
| 885 | * or association responses this updates the state of privacy_invoked |
| 886 | * returns 0 for success or an error number */ |
| 887 | int (*set_privacy_invoked)(struct ieee80211_hw *hw, |
| 888 | int privacy_invoked); |
| 889 | |
| 890 | /* For devices that have internal sequence counters, allow 802.11 |
| 891 | * code to access the current value of a counter */ |
| 892 | int (*get_sequence_counter)(struct ieee80211_hw *hw, |
| 893 | u8* addr, u8 keyidx, u8 txrx, |
| 894 | u32* iv32, u16* iv16); |
| 895 | |
| 896 | /* Configuration of RTS threshold (if device needs it) */ |
| 897 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); |
| 898 | |
| 899 | /* Configuration of fragmentation threshold. |
| 900 | * Assign this if the device does fragmentation by itself, |
| 901 | * if this method is assigned then the stack will not do |
| 902 | * fragmentation. */ |
| 903 | int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); |
| 904 | |
| 905 | /* Configuration of retry limits (if device needs it) */ |
| 906 | int (*set_retry_limit)(struct ieee80211_hw *hw, |
| 907 | u32 short_retry, u32 long_retr); |
| 908 | |
| 909 | /* Number of STAs in STA table notification (NULL = disabled). |
| 910 | * Must be atomic. */ |
| 911 | void (*sta_table_notification)(struct ieee80211_hw *hw, |
| 912 | int num_sta); |
| 913 | |
Daniel Drake | d9430a3 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 914 | /* Handle ERP IE change notifications. Must be atomic. */ |
| 915 | void (*erp_ie_changed)(struct ieee80211_hw *hw, u8 changes, |
| 916 | int cts_protection, int preamble); |
| 917 | |
| 918 | /* Flags for the erp_ie_changed changes parameter */ |
| 919 | #define IEEE80211_ERP_CHANGE_PROTECTION (1<<0) /* protection flag changed */ |
| 920 | #define IEEE80211_ERP_CHANGE_PREAMBLE (1<<1) /* barker preamble mode changed */ |
| 921 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 922 | /* Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), |
| 923 | * bursting) for a hardware TX queue. |
| 924 | * queue = IEEE80211_TX_QUEUE_*. |
| 925 | * Must be atomic. */ |
| 926 | int (*conf_tx)(struct ieee80211_hw *hw, int queue, |
| 927 | const struct ieee80211_tx_queue_params *params); |
| 928 | |
| 929 | /* Get statistics of the current TX queue status. This is used to get |
| 930 | * number of currently queued packets (queue length), maximum queue |
| 931 | * size (limit), and total number of packets sent using each TX queue |
| 932 | * (count). |
| 933 | * Currently unused. */ |
| 934 | int (*get_tx_stats)(struct ieee80211_hw *hw, |
| 935 | struct ieee80211_tx_queue_stats *stats); |
| 936 | |
| 937 | /* Get the current TSF timer value from firmware/hardware. Currently, |
| 938 | * this is only used for IBSS mode debugging and, as such, is not a |
| 939 | * required function. |
| 940 | * Must be atomic. */ |
| 941 | u64 (*get_tsf)(struct ieee80211_hw *hw); |
| 942 | |
| 943 | /* Reset the TSF timer and allow firmware/hardware to synchronize with |
| 944 | * other STAs in the IBSS. This is only used in IBSS mode. This |
| 945 | * function is optional if the firmware/hardware takes full care of |
| 946 | * TSF synchronization. */ |
| 947 | void (*reset_tsf)(struct ieee80211_hw *hw); |
| 948 | |
| 949 | /* Setup beacon data for IBSS beacons. Unlike access point (Master), |
| 950 | * IBSS uses a fixed beacon frame which is configured using this |
| 951 | * function. This handler is required only for IBSS mode. */ |
| 952 | int (*beacon_update)(struct ieee80211_hw *hw, |
| 953 | struct sk_buff *skb, |
| 954 | struct ieee80211_tx_control *control); |
| 955 | |
| 956 | /* Determine whether the last IBSS beacon was sent by us. This is |
| 957 | * needed only for IBSS mode and the result of this function is used to |
| 958 | * determine whether to reply to Probe Requests. */ |
| 959 | int (*tx_last_beacon)(struct ieee80211_hw *hw); |
| 960 | }; |
| 961 | |
| 962 | /* Allocate a new hardware device. This must be called once for each |
| 963 | * hardware device. The returned pointer must be used to refer to this |
| 964 | * device when calling other functions. 802.11 code allocates a private data |
| 965 | * area for the low-level driver. The size of this area is given as |
| 966 | * priv_data_len. |
| 967 | */ |
| 968 | struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, |
| 969 | const struct ieee80211_ops *ops); |
| 970 | |
| 971 | /* Register hardware device to the IEEE 802.11 code and kernel. Low-level |
| 972 | * drivers must call this function before using any other IEEE 802.11 |
| 973 | * function except ieee80211_register_hwmode. */ |
| 974 | int ieee80211_register_hw(struct ieee80211_hw *hw); |
| 975 | |
| 976 | /* driver can use this and ieee80211_get_rx_led_name to get the |
| 977 | * name of the registered LEDs after ieee80211_register_hw |
| 978 | * was called. |
| 979 | * This is useful to set the default trigger on the LED class |
| 980 | * device that your driver should export for each LED the device |
| 981 | * has, that way the default behaviour will be as expected but |
| 982 | * the user can still change it/turn off the LED etc. |
| 983 | */ |
| 984 | #ifdef CONFIG_MAC80211_LEDS |
| 985 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); |
| 986 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); |
| 987 | #endif |
| 988 | static inline char *ieee80211_get_tx_led_name(struct ieee80211_hw *hw) |
| 989 | { |
| 990 | #ifdef CONFIG_MAC80211_LEDS |
| 991 | return __ieee80211_get_tx_led_name(hw); |
| 992 | #else |
| 993 | return NULL; |
| 994 | #endif |
| 995 | } |
| 996 | |
| 997 | static inline char *ieee80211_get_rx_led_name(struct ieee80211_hw *hw) |
| 998 | { |
| 999 | #ifdef CONFIG_MAC80211_LEDS |
| 1000 | return __ieee80211_get_rx_led_name(hw); |
| 1001 | #else |
| 1002 | return NULL; |
| 1003 | #endif |
| 1004 | } |
| 1005 | |
| 1006 | /* Register a new hardware PHYMODE capability to the stack. */ |
| 1007 | int ieee80211_register_hwmode(struct ieee80211_hw *hw, |
| 1008 | struct ieee80211_hw_mode *mode); |
| 1009 | |
| 1010 | /* Unregister a hardware device. This function instructs 802.11 code to free |
| 1011 | * allocated resources and unregister netdevices from the kernel. */ |
| 1012 | void ieee80211_unregister_hw(struct ieee80211_hw *hw); |
| 1013 | |
| 1014 | /* Free everything that was allocated including private data of a driver. */ |
| 1015 | void ieee80211_free_hw(struct ieee80211_hw *hw); |
| 1016 | |
| 1017 | /* Receive frame callback function. The low-level driver uses this function to |
| 1018 | * send received frames to the IEEE 802.11 code. Receive buffer (skb) must |
| 1019 | * start with IEEE 802.11 header. */ |
| 1020 | void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb, |
| 1021 | struct ieee80211_rx_status *status); |
| 1022 | void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, |
| 1023 | struct sk_buff *skb, |
| 1024 | struct ieee80211_rx_status *status); |
| 1025 | |
| 1026 | /* Transmit status callback function. The low-level driver must call this |
| 1027 | * function to report transmit status for all the TX frames that had |
| 1028 | * req_tx_status set in the transmit control fields. In addition, this should |
| 1029 | * be called at least for all unicast frames to provide information for TX rate |
| 1030 | * control algorithm. In order to maintain all statistics, this function is |
| 1031 | * recommended to be called after each frame, including multicast/broadcast, is |
| 1032 | * sent. */ |
| 1033 | void ieee80211_tx_status(struct ieee80211_hw *hw, |
| 1034 | struct sk_buff *skb, |
| 1035 | struct ieee80211_tx_status *status); |
| 1036 | void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, |
| 1037 | struct sk_buff *skb, |
| 1038 | struct ieee80211_tx_status *status); |
| 1039 | |
| 1040 | /** |
| 1041 | * ieee80211_beacon_get - beacon generation function |
| 1042 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
| 1043 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
| 1044 | * @control: will be filled with information needed to send this beacon. |
| 1045 | * |
| 1046 | * If the beacon frames are generated by the host system (i.e., not in |
| 1047 | * hardware/firmware), the low-level driver uses this function to receive |
| 1048 | * the next beacon frame from the 802.11 code. The low-level is responsible |
| 1049 | * for calling this function before beacon data is needed (e.g., based on |
| 1050 | * hardware interrupt). Returned skb is used only once and low-level driver |
| 1051 | * is responsible of freeing it. |
| 1052 | */ |
| 1053 | struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, |
| 1054 | int if_id, |
| 1055 | struct ieee80211_tx_control *control); |
| 1056 | |
| 1057 | /** |
| 1058 | * ieee80211_rts_get - RTS frame generation function |
| 1059 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1060 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1061 | * @frame: pointer to the frame that is going to be protected by the RTS. |
| 1062 | * @frame_len: the frame length (in octets). |
| 1063 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
| 1064 | * @rts: The buffer where to store the RTS frame. |
| 1065 | * |
| 1066 | * If the RTS frames are generated by the host system (i.e., not in |
| 1067 | * hardware/firmware), the low-level driver uses this function to receive |
| 1068 | * the next RTS frame from the 802.11 code. The low-level is responsible |
| 1069 | * for calling this function before and RTS frame is needed. |
| 1070 | */ |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1071 | void ieee80211_rts_get(struct ieee80211_hw *hw, int if_id, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1072 | const void *frame, size_t frame_len, |
| 1073 | const struct ieee80211_tx_control *frame_txctl, |
| 1074 | struct ieee80211_rts *rts); |
| 1075 | |
| 1076 | /** |
| 1077 | * ieee80211_rts_duration - Get the duration field for an RTS frame |
| 1078 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1079 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1080 | * @frame_len: the length of the frame that is going to be protected by the RTS. |
| 1081 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
| 1082 | * |
| 1083 | * If the RTS is generated in firmware, but the host system must provide |
| 1084 | * the duration field, the low-level driver uses this function to receive |
| 1085 | * the duration field value in little-endian byteorder. |
| 1086 | */ |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1087 | __le16 ieee80211_rts_duration(struct ieee80211_hw *hw, int if_id, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1088 | size_t frame_len, |
| 1089 | const struct ieee80211_tx_control *frame_txctl); |
| 1090 | |
| 1091 | /** |
| 1092 | * ieee80211_ctstoself_get - CTS-to-self frame generation function |
| 1093 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1094 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1095 | * @frame: pointer to the frame that is going to be protected by the CTS-to-self. |
| 1096 | * @frame_len: the frame length (in octets). |
| 1097 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
| 1098 | * @cts: The buffer where to store the CTS-to-self frame. |
| 1099 | * |
| 1100 | * If the CTS-to-self frames are generated by the host system (i.e., not in |
| 1101 | * hardware/firmware), the low-level driver uses this function to receive |
| 1102 | * the next CTS-to-self frame from the 802.11 code. The low-level is responsible |
| 1103 | * for calling this function before and CTS-to-self frame is needed. |
| 1104 | */ |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1105 | void ieee80211_ctstoself_get(struct ieee80211_hw *hw, int if_id, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1106 | const void *frame, size_t frame_len, |
| 1107 | const struct ieee80211_tx_control *frame_txctl, |
| 1108 | struct ieee80211_cts *cts); |
| 1109 | |
| 1110 | /** |
| 1111 | * ieee80211_ctstoself_duration - Get the duration field for a CTS-to-self frame |
| 1112 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1113 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1114 | * @frame_len: the length of the frame that is going to be protected by the CTS-to-self. |
| 1115 | * @frame_txctl: &struct ieee80211_tx_control of the frame. |
| 1116 | * |
| 1117 | * If the CTS-to-self is generated in firmware, but the host system must provide |
| 1118 | * the duration field, the low-level driver uses this function to receive |
| 1119 | * the duration field value in little-endian byteorder. |
| 1120 | */ |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1121 | __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, int if_id, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1122 | size_t frame_len, |
| 1123 | const struct ieee80211_tx_control *frame_txctl); |
| 1124 | |
| 1125 | /** |
| 1126 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame |
| 1127 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1128 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1129 | * @frame_len: the length of the frame. |
| 1130 | * @rate: the rate (in 100kbps) at which the frame is going to be transmitted. |
| 1131 | * |
| 1132 | * Calculate the duration field of some generic frame, given its |
| 1133 | * length and transmission rate (in 100kbps). |
| 1134 | */ |
Daniel Drake | 7e9ed18 | 2007-07-27 15:43:24 +0200 | [diff] [blame] | 1135 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, int if_id, |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1136 | size_t frame_len, |
| 1137 | int rate); |
| 1138 | |
| 1139 | /** |
| 1140 | * ieee80211_get_buffered_bc - accessing buffered broadcast and multicast frames |
| 1141 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
| 1142 | * @if_id: interface ID from &struct ieee80211_if_init_conf. |
| 1143 | * @control: will be filled with information needed to send returned frame. |
| 1144 | * |
| 1145 | * Function for accessing buffered broadcast and multicast frames. If |
| 1146 | * hardware/firmware does not implement buffering of broadcast/multicast |
| 1147 | * frames when power saving is used, 802.11 code buffers them in the host |
| 1148 | * memory. The low-level driver uses this function to fetch next buffered |
| 1149 | * frame. In most cases, this is used when generating beacon frame. This |
| 1150 | * function returns a pointer to the next buffered skb or NULL if no more |
| 1151 | * buffered frames are available. |
| 1152 | * |
| 1153 | * Note: buffered frames are returned only after DTIM beacon frame was |
| 1154 | * generated with ieee80211_beacon_get() and the low-level driver must thus |
| 1155 | * call ieee80211_beacon_get() first. ieee80211_get_buffered_bc() returns |
| 1156 | * NULL if the previous generated beacon was not DTIM, so the low-level driver |
| 1157 | * does not need to check for DTIM beacons separately and should be able to |
| 1158 | * use common code for all beacons. |
| 1159 | */ |
| 1160 | struct sk_buff * |
| 1161 | ieee80211_get_buffered_bc(struct ieee80211_hw *hw, int if_id, |
| 1162 | struct ieee80211_tx_control *control); |
| 1163 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1164 | /* Given an sk_buff with a raw 802.11 header at the data pointer this function |
| 1165 | * returns the 802.11 header length in bytes (not including encryption |
| 1166 | * headers). If the data in the sk_buff is too short to contain a valid 802.11 |
| 1167 | * header the function returns 0. |
| 1168 | */ |
| 1169 | int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); |
| 1170 | |
| 1171 | /* Like ieee80211_get_hdrlen_from_skb() but takes a FC in CPU order. */ |
| 1172 | int ieee80211_get_hdrlen(u16 fc); |
| 1173 | |
| 1174 | /** |
| 1175 | * ieee80211_wake_queue - wake specific queue |
| 1176 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
| 1177 | * @queue: queue number (counted from zero). |
| 1178 | * |
| 1179 | * Drivers should use this function instead of netif_wake_queue. |
| 1180 | */ |
| 1181 | void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue); |
| 1182 | |
| 1183 | /** |
| 1184 | * ieee80211_stop_queue - stop specific queue |
| 1185 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
| 1186 | * @queue: queue number (counted from zero). |
| 1187 | * |
| 1188 | * Drivers should use this function instead of netif_stop_queue. |
| 1189 | */ |
| 1190 | void ieee80211_stop_queue(struct ieee80211_hw *hw, int queue); |
| 1191 | |
| 1192 | /** |
| 1193 | * ieee80211_start_queues - start all queues |
| 1194 | * @hw: pointer to as obtained from ieee80211_alloc_hw(). |
| 1195 | * |
| 1196 | * Drivers should use this function instead of netif_start_queue. |
| 1197 | */ |
| 1198 | void ieee80211_start_queues(struct ieee80211_hw *hw); |
| 1199 | |
| 1200 | /** |
| 1201 | * ieee80211_stop_queues - stop all queues |
| 1202 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
| 1203 | * |
| 1204 | * Drivers should use this function instead of netif_stop_queue. |
| 1205 | */ |
| 1206 | void ieee80211_stop_queues(struct ieee80211_hw *hw); |
| 1207 | |
| 1208 | /** |
| 1209 | * ieee80211_wake_queues - wake all queues |
| 1210 | * @hw: pointer as obtained from ieee80211_alloc_hw(). |
| 1211 | * |
| 1212 | * Drivers should use this function instead of netif_wake_queue. |
| 1213 | */ |
| 1214 | void ieee80211_wake_queues(struct ieee80211_hw *hw); |
| 1215 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1216 | /* called by driver to notify scan status completed */ |
| 1217 | void ieee80211_scan_completed(struct ieee80211_hw *hw); |
| 1218 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1219 | /* return a pointer to the source address (SA) */ |
| 1220 | static inline u8 *ieee80211_get_SA(struct ieee80211_hdr *hdr) |
| 1221 | { |
| 1222 | u8 *raw = (u8 *) hdr; |
| 1223 | u8 tofrom = (*(raw+1)) & 3; /* get the TODS and FROMDS bits */ |
| 1224 | |
| 1225 | switch (tofrom) { |
| 1226 | case 2: |
| 1227 | return hdr->addr3; |
| 1228 | case 3: |
| 1229 | return hdr->addr4; |
| 1230 | } |
| 1231 | return hdr->addr2; |
| 1232 | } |
| 1233 | |
| 1234 | /* return a pointer to the destination address (DA) */ |
| 1235 | static inline u8 *ieee80211_get_DA(struct ieee80211_hdr *hdr) |
| 1236 | { |
| 1237 | u8 *raw = (u8 *) hdr; |
| 1238 | u8 to_ds = (*(raw+1)) & 1; /* get the TODS bit */ |
| 1239 | |
| 1240 | if (to_ds) |
| 1241 | return hdr->addr3; |
| 1242 | return hdr->addr1; |
| 1243 | } |
| 1244 | |
| 1245 | static inline int ieee80211_get_morefrag(struct ieee80211_hdr *hdr) |
| 1246 | { |
| 1247 | return (le16_to_cpu(hdr->frame_control) & |
| 1248 | IEEE80211_FCTL_MOREFRAGS) != 0; |
| 1249 | } |
| 1250 | |
Jiri Benc | f0706e8 | 2007-05-05 11:45:53 -0700 | [diff] [blame] | 1251 | #endif /* MAC80211_H */ |