Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | Copyright (C) 2004 - 2007 rt2x00 SourceForge Project |
| 3 | <http://rt2x00.serialmonkey.com> |
| 4 | |
| 5 | This program is free software; you can redistribute it and/or modify |
| 6 | it under the terms of the GNU General Public License as published by |
| 7 | the Free Software Foundation; either version 2 of the License, or |
| 8 | (at your option) any later version. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | GNU General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU General Public License |
| 16 | along with this program; if not, write to the |
| 17 | Free Software Foundation, Inc., |
| 18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | Module: rt2x00 |
| 23 | Abstract: rt2x00 global information. |
| 24 | */ |
| 25 | |
| 26 | #ifndef RT2X00_H |
| 27 | #define RT2X00_H |
| 28 | |
| 29 | #include <linux/bitops.h> |
| 30 | #include <linux/prefetch.h> |
| 31 | #include <linux/skbuff.h> |
| 32 | #include <linux/workqueue.h> |
| 33 | #include <linux/firmware.h> |
Adam Baker | 3d82346 | 2007-10-27 13:43:29 +0200 | [diff] [blame] | 34 | #include <linux/mutex.h> |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 35 | #include <linux/etherdevice.h> |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 36 | |
| 37 | #include <net/mac80211.h> |
| 38 | |
| 39 | #include "rt2x00debug.h" |
| 40 | #include "rt2x00reg.h" |
| 41 | #include "rt2x00ring.h" |
| 42 | |
| 43 | /* |
| 44 | * Module information. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 45 | */ |
Ivo van Doorn | 5a6012e | 2007-11-27 21:52:13 +0100 | [diff] [blame] | 46 | #define DRV_VERSION "2.0.13" |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 47 | #define DRV_PROJECT "http://rt2x00.serialmonkey.com" |
| 48 | |
| 49 | /* |
| 50 | * Debug definitions. |
| 51 | * Debug output has to be enabled during compile time. |
| 52 | */ |
| 53 | #define DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, __args...) \ |
| 54 | printk(__kernlvl "%s -> %s: %s - " __msg, \ |
| 55 | wiphy_name((__dev)->hw->wiphy), __FUNCTION__, __lvl, ##__args) |
| 56 | |
| 57 | #define DEBUG_PRINTK_PROBE(__kernlvl, __lvl, __msg, __args...) \ |
| 58 | printk(__kernlvl "%s -> %s: %s - " __msg, \ |
Ivo van Doorn | 2360157 | 2007-11-27 21:47:34 +0100 | [diff] [blame] | 59 | KBUILD_MODNAME, __FUNCTION__, __lvl, ##__args) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 60 | |
| 61 | #ifdef CONFIG_RT2X00_DEBUG |
| 62 | #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \ |
| 63 | DEBUG_PRINTK_MSG(__dev, __kernlvl, __lvl, __msg, ##__args); |
| 64 | #else |
| 65 | #define DEBUG_PRINTK(__dev, __kernlvl, __lvl, __msg, __args...) \ |
| 66 | do { } while (0) |
| 67 | #endif /* CONFIG_RT2X00_DEBUG */ |
| 68 | |
| 69 | /* |
| 70 | * Various debug levels. |
| 71 | * The debug levels PANIC and ERROR both indicate serious problems, |
| 72 | * for this reason they should never be ignored. |
| 73 | * The special ERROR_PROBE message is for messages that are generated |
| 74 | * when the rt2x00_dev is not yet initialized. |
| 75 | */ |
| 76 | #define PANIC(__dev, __msg, __args...) \ |
| 77 | DEBUG_PRINTK_MSG(__dev, KERN_CRIT, "Panic", __msg, ##__args) |
| 78 | #define ERROR(__dev, __msg, __args...) \ |
| 79 | DEBUG_PRINTK_MSG(__dev, KERN_ERR, "Error", __msg, ##__args) |
| 80 | #define ERROR_PROBE(__msg, __args...) \ |
| 81 | DEBUG_PRINTK_PROBE(KERN_ERR, "Error", __msg, ##__args) |
| 82 | #define WARNING(__dev, __msg, __args...) \ |
| 83 | DEBUG_PRINTK(__dev, KERN_WARNING, "Warning", __msg, ##__args) |
| 84 | #define NOTICE(__dev, __msg, __args...) \ |
| 85 | DEBUG_PRINTK(__dev, KERN_NOTICE, "Notice", __msg, ##__args) |
| 86 | #define INFO(__dev, __msg, __args...) \ |
| 87 | DEBUG_PRINTK(__dev, KERN_INFO, "Info", __msg, ##__args) |
| 88 | #define DEBUG(__dev, __msg, __args...) \ |
| 89 | DEBUG_PRINTK(__dev, KERN_DEBUG, "Debug", __msg, ##__args) |
| 90 | #define EEPROM(__dev, __msg, __args...) \ |
| 91 | DEBUG_PRINTK(__dev, KERN_DEBUG, "EEPROM recovery", __msg, ##__args) |
| 92 | |
| 93 | /* |
| 94 | * Ring sizes. |
| 95 | * Ralink PCI devices demand the Frame size to be a multiple of 128 bytes. |
| 96 | * DATA_FRAME_SIZE is used for TX, RX, ATIM and PRIO rings. |
| 97 | * MGMT_FRAME_SIZE is used for the BEACON ring. |
| 98 | */ |
| 99 | #define DATA_FRAME_SIZE 2432 |
| 100 | #define MGMT_FRAME_SIZE 256 |
| 101 | |
| 102 | /* |
| 103 | * Number of entries in a packet ring. |
| 104 | * PCI devices only need 1 Beacon entry, |
| 105 | * but USB devices require a second because they |
| 106 | * have to send a Guardian byte first. |
| 107 | */ |
| 108 | #define RX_ENTRIES 12 |
| 109 | #define TX_ENTRIES 12 |
| 110 | #define ATIM_ENTRIES 1 |
| 111 | #define BEACON_ENTRIES 2 |
| 112 | |
| 113 | /* |
| 114 | * Standard timing and size defines. |
| 115 | * These values should follow the ieee80211 specifications. |
| 116 | */ |
| 117 | #define ACK_SIZE 14 |
| 118 | #define IEEE80211_HEADER 24 |
| 119 | #define PLCP 48 |
| 120 | #define BEACON 100 |
| 121 | #define PREAMBLE 144 |
| 122 | #define SHORT_PREAMBLE 72 |
| 123 | #define SLOT_TIME 20 |
| 124 | #define SHORT_SLOT_TIME 9 |
| 125 | #define SIFS 10 |
| 126 | #define PIFS ( SIFS + SLOT_TIME ) |
| 127 | #define SHORT_PIFS ( SIFS + SHORT_SLOT_TIME ) |
| 128 | #define DIFS ( PIFS + SLOT_TIME ) |
| 129 | #define SHORT_DIFS ( SHORT_PIFS + SHORT_SLOT_TIME ) |
| 130 | #define EIFS ( SIFS + (8 * (IEEE80211_HEADER + ACK_SIZE)) ) |
| 131 | |
| 132 | /* |
| 133 | * IEEE802.11 header defines |
| 134 | */ |
| 135 | static inline int is_rts_frame(u16 fc) |
| 136 | { |
Ivo van Doorn | ddc827f | 2007-10-13 16:26:42 +0200 | [diff] [blame] | 137 | return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && |
| 138 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_RTS)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | static inline int is_cts_frame(u16 fc) |
| 142 | { |
Ivo van Doorn | ddc827f | 2007-10-13 16:26:42 +0200 | [diff] [blame] | 143 | return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_CTL) && |
| 144 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_CTS)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | static inline int is_probe_resp(u16 fc) |
| 148 | { |
Ivo van Doorn | ddc827f | 2007-10-13 16:26:42 +0200 | [diff] [blame] | 149 | return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && |
| 150 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_PROBE_RESP)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 151 | } |
| 152 | |
Mattias Nissler | 61af43c | 2007-11-27 21:50:26 +0100 | [diff] [blame] | 153 | static inline int is_beacon(u16 fc) |
| 154 | { |
| 155 | return (((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_MGMT) && |
| 156 | ((fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON)); |
| 157 | } |
| 158 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 159 | /* |
| 160 | * Chipset identification |
| 161 | * The chipset on the device is composed of a RT and RF chip. |
| 162 | * The chipset combination is important for determining device capabilities. |
| 163 | */ |
| 164 | struct rt2x00_chip { |
| 165 | u16 rt; |
| 166 | #define RT2460 0x0101 |
| 167 | #define RT2560 0x0201 |
| 168 | #define RT2570 0x1201 |
Ivo van Doorn | 12dadb9 | 2007-09-25 20:54:44 +0200 | [diff] [blame] | 169 | #define RT2561s 0x0301 /* Turbo */ |
| 170 | #define RT2561 0x0302 |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 171 | #define RT2661 0x0401 |
| 172 | #define RT2571 0x1300 |
| 173 | |
| 174 | u16 rf; |
| 175 | u32 rev; |
| 176 | }; |
| 177 | |
| 178 | /* |
| 179 | * RF register values that belong to a particular channel. |
| 180 | */ |
| 181 | struct rf_channel { |
| 182 | int channel; |
| 183 | u32 rf1; |
| 184 | u32 rf2; |
| 185 | u32 rf3; |
| 186 | u32 rf4; |
| 187 | }; |
| 188 | |
| 189 | /* |
Ivo van Doorn | addc81bd | 2007-10-13 16:26:23 +0200 | [diff] [blame] | 190 | * Antenna setup values. |
| 191 | */ |
| 192 | struct antenna_setup { |
| 193 | enum antenna rx; |
| 194 | enum antenna tx; |
| 195 | }; |
| 196 | |
| 197 | /* |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 198 | * Quality statistics about the currently active link. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 199 | */ |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 200 | struct link_qual { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 201 | /* |
| 202 | * Statistics required for Link tuning. |
| 203 | * For the average RSSI value we use the "Walking average" approach. |
| 204 | * When adding RSSI to the average value the following calculation |
| 205 | * is needed: |
| 206 | * |
| 207 | * avg_rssi = ((avg_rssi * 7) + rssi) / 8; |
| 208 | * |
| 209 | * The advantage of this approach is that we only need 1 variable |
| 210 | * to store the average in (No need for a count and a total). |
| 211 | * But more importantly, normal average values will over time |
| 212 | * move less and less towards newly added values this results |
| 213 | * that with link tuning, the device can have a very good RSSI |
| 214 | * for a few minutes but when the device is moved away from the AP |
| 215 | * the average will not decrease fast enough to compensate. |
| 216 | * The walking average compensates this and will move towards |
| 217 | * the new values correctly allowing a effective link tuning. |
| 218 | */ |
| 219 | int avg_rssi; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 220 | int false_cca; |
| 221 | |
| 222 | /* |
| 223 | * Statistics required for Signal quality calculation. |
| 224 | * For calculating the Signal quality we have to determine |
| 225 | * the total number of success and failed RX and TX frames. |
| 226 | * After that we also use the average RSSI value to help |
| 227 | * determining the signal quality. |
| 228 | * For the calculation we will use the following algorithm: |
| 229 | * |
| 230 | * rssi_percentage = (avg_rssi * 100) / rssi_offset |
| 231 | * rx_percentage = (rx_success * 100) / rx_total |
| 232 | * tx_percentage = (tx_success * 100) / tx_total |
| 233 | * avg_signal = ((WEIGHT_RSSI * avg_rssi) + |
| 234 | * (WEIGHT_TX * tx_percentage) + |
| 235 | * (WEIGHT_RX * rx_percentage)) / 100 |
| 236 | * |
| 237 | * This value should then be checked to not be greated then 100. |
| 238 | */ |
| 239 | int rx_percentage; |
| 240 | int rx_success; |
| 241 | int rx_failed; |
| 242 | int tx_percentage; |
| 243 | int tx_success; |
| 244 | int tx_failed; |
| 245 | #define WEIGHT_RSSI 20 |
| 246 | #define WEIGHT_RX 40 |
| 247 | #define WEIGHT_TX 40 |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 248 | }; |
| 249 | |
| 250 | /* |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 251 | * Antenna settings about the currently active link. |
| 252 | */ |
| 253 | struct link_ant { |
| 254 | /* |
| 255 | * Antenna flags |
| 256 | */ |
| 257 | unsigned int flags; |
| 258 | #define ANTENNA_RX_DIVERSITY 0x00000001 |
| 259 | #define ANTENNA_TX_DIVERSITY 0x00000002 |
| 260 | #define ANTENNA_MODE_SAMPLE 0x00000004 |
| 261 | |
| 262 | /* |
| 263 | * Currently active TX/RX antenna setup. |
| 264 | * When software diversity is used, this will indicate |
| 265 | * which antenna is actually used at this time. |
| 266 | */ |
| 267 | struct antenna_setup active; |
| 268 | |
| 269 | /* |
| 270 | * RSSI information for the different antenna's. |
| 271 | * These statistics are used to determine when |
| 272 | * to switch antenna when using software diversity. |
| 273 | * |
| 274 | * rssi[0] -> Antenna A RSSI |
| 275 | * rssi[1] -> Antenna B RSSI |
| 276 | */ |
| 277 | int rssi_history[2]; |
| 278 | |
| 279 | /* |
| 280 | * Current RSSI average of the currently active antenna. |
| 281 | * Similar to the avg_rssi in the link_qual structure |
| 282 | * this value is updated by using the walking average. |
| 283 | */ |
| 284 | int rssi_ant; |
| 285 | }; |
| 286 | |
| 287 | /* |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 288 | * To optimize the quality of the link we need to store |
| 289 | * the quality of received frames and periodically |
| 290 | * optimize the link. |
| 291 | */ |
| 292 | struct link { |
| 293 | /* |
| 294 | * Link tuner counter |
| 295 | * The number of times the link has been tuned |
| 296 | * since the radio has been switched on. |
| 297 | */ |
| 298 | u32 count; |
| 299 | |
| 300 | /* |
| 301 | * Quality measurement values. |
| 302 | */ |
| 303 | struct link_qual qual; |
| 304 | |
| 305 | /* |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 306 | * TX/RX antenna setup. |
Ivo van Doorn | addc81bd | 2007-10-13 16:26:23 +0200 | [diff] [blame] | 307 | */ |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 308 | struct link_ant ant; |
Ivo van Doorn | addc81bd | 2007-10-13 16:26:23 +0200 | [diff] [blame] | 309 | |
| 310 | /* |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 311 | * Active VGC level |
| 312 | */ |
| 313 | int vgc_level; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 314 | |
| 315 | /* |
| 316 | * Work structure for scheduling periodic link tuning. |
| 317 | */ |
| 318 | struct delayed_work work; |
| 319 | }; |
| 320 | |
| 321 | /* |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 322 | * Small helper macro to work with moving/walking averages. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 323 | */ |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 324 | #define MOVING_AVERAGE(__avg, __val, __samples) \ |
| 325 | ( (((__avg) * ((__samples) - 1)) + (__val)) / (__samples) ) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 326 | |
| 327 | /* |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 328 | * When we lack RSSI information return something less then -80 to |
| 329 | * tell the driver to tune the device to maximum sensitivity. |
| 330 | */ |
| 331 | #define DEFAULT_RSSI ( -128 ) |
| 332 | |
| 333 | /* |
| 334 | * Link quality access functions. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 335 | */ |
| 336 | static inline int rt2x00_get_link_rssi(struct link *link) |
| 337 | { |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 338 | if (link->qual.avg_rssi && link->qual.rx_success) |
| 339 | return link->qual.avg_rssi; |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 340 | return DEFAULT_RSSI; |
| 341 | } |
| 342 | |
| 343 | static inline int rt2x00_get_link_ant_rssi(struct link *link) |
| 344 | { |
| 345 | if (link->ant.rssi_ant && link->qual.rx_success) |
| 346 | return link->ant.rssi_ant; |
| 347 | return DEFAULT_RSSI; |
| 348 | } |
| 349 | |
| 350 | static inline int rt2x00_get_link_ant_rssi_history(struct link *link, |
| 351 | enum antenna ant) |
| 352 | { |
| 353 | if (link->ant.rssi_history[ant - ANTENNA_A]) |
| 354 | return link->ant.rssi_history[ant - ANTENNA_A]; |
| 355 | return DEFAULT_RSSI; |
| 356 | } |
| 357 | |
| 358 | static inline int rt2x00_update_ant_rssi(struct link *link, int rssi) |
| 359 | { |
| 360 | int old_rssi = link->ant.rssi_history[link->ant.active.rx - ANTENNA_A]; |
| 361 | link->ant.rssi_history[link->ant.active.rx - ANTENNA_A] = rssi; |
| 362 | return old_rssi; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | /* |
| 366 | * Interface structure |
| 367 | * Configuration details about the current interface. |
| 368 | */ |
| 369 | struct interface { |
| 370 | /* |
| 371 | * Interface identification. The value is assigned |
| 372 | * to us by the 80211 stack, and is used to request |
| 373 | * new beacons. |
| 374 | */ |
| 375 | int id; |
| 376 | |
| 377 | /* |
| 378 | * Current working type (IEEE80211_IF_TYPE_*). |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 379 | */ |
| 380 | int type; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 381 | |
| 382 | /* |
| 383 | * MAC of the device. |
| 384 | */ |
| 385 | u8 mac[ETH_ALEN]; |
| 386 | |
| 387 | /* |
| 388 | * BBSID of the AP to associate with. |
| 389 | */ |
| 390 | u8 bssid[ETH_ALEN]; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 391 | }; |
| 392 | |
| 393 | static inline int is_interface_present(struct interface *intf) |
| 394 | { |
| 395 | return !!intf->id; |
| 396 | } |
| 397 | |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 398 | static inline int is_interface_type(struct interface *intf, int type) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 399 | { |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 400 | return intf->type == type; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | /* |
| 404 | * Details about the supported modes, rates and channels |
| 405 | * of a particular chipset. This is used by rt2x00lib |
| 406 | * to build the ieee80211_hw_mode array for mac80211. |
| 407 | */ |
| 408 | struct hw_mode_spec { |
| 409 | /* |
| 410 | * Number of modes, rates and channels. |
| 411 | */ |
| 412 | int num_modes; |
| 413 | int num_rates; |
| 414 | int num_channels; |
| 415 | |
| 416 | /* |
| 417 | * txpower values. |
| 418 | */ |
| 419 | const u8 *tx_power_a; |
| 420 | const u8 *tx_power_bg; |
| 421 | u8 tx_power_default; |
| 422 | |
| 423 | /* |
| 424 | * Device/chipset specific value. |
| 425 | */ |
| 426 | const struct rf_channel *channels; |
| 427 | }; |
| 428 | |
| 429 | /* |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 430 | * Configuration structure wrapper around the |
| 431 | * mac80211 configuration structure. |
| 432 | * When mac80211 configures the driver, rt2x00lib |
| 433 | * can precalculate values which are equal for all |
| 434 | * rt2x00 drivers. Those values can be stored in here. |
| 435 | */ |
| 436 | struct rt2x00lib_conf { |
| 437 | struct ieee80211_conf *conf; |
| 438 | struct rf_channel rf; |
| 439 | |
Ivo van Doorn | addc81bd | 2007-10-13 16:26:23 +0200 | [diff] [blame] | 440 | struct antenna_setup ant; |
| 441 | |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 442 | int phymode; |
| 443 | |
| 444 | int basic_rates; |
| 445 | int slot_time; |
| 446 | |
| 447 | short sifs; |
| 448 | short pifs; |
| 449 | short difs; |
| 450 | short eifs; |
| 451 | }; |
| 452 | |
| 453 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 454 | * rt2x00lib callback functions. |
| 455 | */ |
| 456 | struct rt2x00lib_ops { |
| 457 | /* |
| 458 | * Interrupt handlers. |
| 459 | */ |
| 460 | irq_handler_t irq_handler; |
| 461 | |
| 462 | /* |
| 463 | * Device init handlers. |
| 464 | */ |
| 465 | int (*probe_hw) (struct rt2x00_dev *rt2x00dev); |
| 466 | char *(*get_firmware_name) (struct rt2x00_dev *rt2x00dev); |
| 467 | int (*load_firmware) (struct rt2x00_dev *rt2x00dev, void *data, |
| 468 | const size_t len); |
| 469 | |
| 470 | /* |
| 471 | * Device initialization/deinitialization handlers. |
| 472 | */ |
| 473 | int (*initialize) (struct rt2x00_dev *rt2x00dev); |
| 474 | void (*uninitialize) (struct rt2x00_dev *rt2x00dev); |
| 475 | |
| 476 | /* |
| 477 | * Radio control handlers. |
| 478 | */ |
| 479 | int (*set_device_state) (struct rt2x00_dev *rt2x00dev, |
| 480 | enum dev_state state); |
| 481 | int (*rfkill_poll) (struct rt2x00_dev *rt2x00dev); |
Ivo van Doorn | ebcf26d | 2007-10-13 16:26:12 +0200 | [diff] [blame] | 482 | void (*link_stats) (struct rt2x00_dev *rt2x00dev, |
| 483 | struct link_qual *qual); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 484 | void (*reset_tuner) (struct rt2x00_dev *rt2x00dev); |
| 485 | void (*link_tuner) (struct rt2x00_dev *rt2x00dev); |
| 486 | |
| 487 | /* |
| 488 | * TX control handlers |
| 489 | */ |
| 490 | void (*write_tx_desc) (struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 4bd7c45 | 2008-01-24 00:48:03 -0800 | [diff] [blame] | 491 | __le32 *txd, |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 492 | struct txdata_entry_desc *desc, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 493 | struct ieee80211_hdr *ieee80211hdr, |
| 494 | unsigned int length, |
| 495 | struct ieee80211_tx_control *control); |
| 496 | int (*write_tx_data) (struct rt2x00_dev *rt2x00dev, |
| 497 | struct data_ring *ring, struct sk_buff *skb, |
| 498 | struct ieee80211_tx_control *control); |
Ivo van Doorn | b242e89 | 2007-11-15 23:41:31 +0100 | [diff] [blame] | 499 | int (*get_tx_data_len) (struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | dd9fa2d | 2007-10-06 14:15:46 +0200 | [diff] [blame] | 500 | struct sk_buff *skb); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 501 | void (*kick_tx_queue) (struct rt2x00_dev *rt2x00dev, |
| 502 | unsigned int queue); |
| 503 | |
| 504 | /* |
| 505 | * RX control handlers |
| 506 | */ |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 507 | void (*fill_rxdone) (struct data_entry *entry, |
| 508 | struct rxdata_entry_desc *desc); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 509 | |
| 510 | /* |
| 511 | * Configuration handlers. |
| 512 | */ |
Ivo van Doorn | 4abee4b | 2007-10-06 14:11:46 +0200 | [diff] [blame] | 513 | void (*config_mac_addr) (struct rt2x00_dev *rt2x00dev, __le32 *mac); |
| 514 | void (*config_bssid) (struct rt2x00_dev *rt2x00dev, __le32 *bssid); |
Ivo van Doorn | feb2469 | 2007-10-06 14:14:29 +0200 | [diff] [blame] | 515 | void (*config_type) (struct rt2x00_dev *rt2x00dev, const int type, |
| 516 | const int tsf_sync); |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 517 | void (*config_preamble) (struct rt2x00_dev *rt2x00dev, |
| 518 | const int short_preamble, |
| 519 | const int ack_timeout, |
| 520 | const int ack_consume_time); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 521 | void (*config) (struct rt2x00_dev *rt2x00dev, const unsigned int flags, |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 522 | struct rt2x00lib_conf *libconf); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 523 | #define CONFIG_UPDATE_PHYMODE ( 1 << 1 ) |
| 524 | #define CONFIG_UPDATE_CHANNEL ( 1 << 2 ) |
| 525 | #define CONFIG_UPDATE_TXPOWER ( 1 << 3 ) |
| 526 | #define CONFIG_UPDATE_ANTENNA ( 1 << 4 ) |
| 527 | #define CONFIG_UPDATE_SLOT_TIME ( 1 << 5 ) |
| 528 | #define CONFIG_UPDATE_BEACON_INT ( 1 << 6 ) |
| 529 | #define CONFIG_UPDATE_ALL 0xffff |
| 530 | }; |
| 531 | |
| 532 | /* |
| 533 | * rt2x00 driver callback operation structure. |
| 534 | */ |
| 535 | struct rt2x00_ops { |
| 536 | const char *name; |
| 537 | const unsigned int rxd_size; |
| 538 | const unsigned int txd_size; |
| 539 | const unsigned int eeprom_size; |
| 540 | const unsigned int rf_size; |
| 541 | const struct rt2x00lib_ops *lib; |
| 542 | const struct ieee80211_ops *hw; |
| 543 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
| 544 | const struct rt2x00debug *debugfs; |
| 545 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
| 546 | }; |
| 547 | |
| 548 | /* |
Ivo van Doorn | 483272f | 2007-10-06 14:13:06 +0200 | [diff] [blame] | 549 | * rt2x00 device flags |
| 550 | */ |
| 551 | enum rt2x00_flags { |
| 552 | /* |
| 553 | * Device state flags |
| 554 | */ |
| 555 | DEVICE_PRESENT, |
| 556 | DEVICE_REGISTERED_HW, |
| 557 | DEVICE_INITIALIZED, |
| 558 | DEVICE_STARTED, |
| 559 | DEVICE_STARTED_SUSPEND, |
| 560 | DEVICE_ENABLED_RADIO, |
Ivo van Doorn | 81873e9 | 2007-10-06 14:14:06 +0200 | [diff] [blame] | 561 | DEVICE_DISABLED_RADIO_HW, |
Ivo van Doorn | 483272f | 2007-10-06 14:13:06 +0200 | [diff] [blame] | 562 | |
| 563 | /* |
| 564 | * Driver features |
| 565 | */ |
| 566 | DRIVER_REQUIRE_FIRMWARE, |
| 567 | DRIVER_REQUIRE_BEACON_RING, |
| 568 | |
| 569 | /* |
| 570 | * Driver configuration |
| 571 | */ |
| 572 | CONFIG_SUPPORT_HW_BUTTON, |
| 573 | CONFIG_FRAME_TYPE, |
| 574 | CONFIG_RF_SEQUENCE, |
| 575 | CONFIG_EXTERNAL_LNA_A, |
| 576 | CONFIG_EXTERNAL_LNA_BG, |
| 577 | CONFIG_DOUBLE_ANTENNA, |
| 578 | CONFIG_DISABLE_LINK_TUNING, |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 579 | CONFIG_SHORT_PREAMBLE, |
Ivo van Doorn | 483272f | 2007-10-06 14:13:06 +0200 | [diff] [blame] | 580 | }; |
| 581 | |
| 582 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 583 | * rt2x00 device structure. |
| 584 | */ |
| 585 | struct rt2x00_dev { |
| 586 | /* |
| 587 | * Device structure. |
| 588 | * The structure stored in here depends on the |
| 589 | * system bus (PCI or USB). |
| 590 | * When accessing this variable, the rt2x00dev_{pci,usb} |
| 591 | * macro's should be used for correct typecasting. |
| 592 | */ |
| 593 | void *dev; |
| 594 | #define rt2x00dev_pci(__dev) ( (struct pci_dev*)(__dev)->dev ) |
| 595 | #define rt2x00dev_usb(__dev) ( (struct usb_interface*)(__dev)->dev ) |
| 596 | |
| 597 | /* |
| 598 | * Callback functions. |
| 599 | */ |
| 600 | const struct rt2x00_ops *ops; |
| 601 | |
| 602 | /* |
| 603 | * IEEE80211 control structure. |
| 604 | */ |
| 605 | struct ieee80211_hw *hw; |
| 606 | struct ieee80211_hw_mode *hwmodes; |
| 607 | unsigned int curr_hwmode; |
| 608 | #define HWMODE_B 0 |
| 609 | #define HWMODE_G 1 |
| 610 | #define HWMODE_A 2 |
| 611 | |
| 612 | /* |
| 613 | * rfkill structure for RF state switching support. |
| 614 | * This will only be compiled in when required. |
| 615 | */ |
| 616 | #ifdef CONFIG_RT2X00_LIB_RFKILL |
| 617 | struct rfkill *rfkill; |
| 618 | struct input_polled_dev *poll_dev; |
| 619 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ |
| 620 | |
| 621 | /* |
| 622 | * If enabled, the debugfs interface structures |
| 623 | * required for deregistration of debugfs. |
| 624 | */ |
| 625 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
Ivo van Doorn | 4d8dd66 | 2007-11-27 21:49:29 +0100 | [diff] [blame] | 626 | struct rt2x00debug_intf *debugfs_intf; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 627 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
| 628 | |
| 629 | /* |
| 630 | * Device flags. |
| 631 | * In these flags the current status and some |
| 632 | * of the device capabilities are stored. |
| 633 | */ |
| 634 | unsigned long flags; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 635 | |
| 636 | /* |
| 637 | * Chipset identification. |
| 638 | */ |
| 639 | struct rt2x00_chip chip; |
| 640 | |
| 641 | /* |
| 642 | * hw capability specifications. |
| 643 | */ |
| 644 | struct hw_mode_spec spec; |
| 645 | |
| 646 | /* |
Ivo van Doorn | addc81bd | 2007-10-13 16:26:23 +0200 | [diff] [blame] | 647 | * This is the default TX/RX antenna setup as indicated |
| 648 | * by the device's EEPROM. When mac80211 sets its |
| 649 | * antenna value to 0 we should be using these values. |
| 650 | */ |
| 651 | struct antenna_setup default_ant; |
| 652 | |
| 653 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 654 | * Register pointers |
| 655 | * csr_addr: Base register address. (PCI) |
| 656 | * csr_cache: CSR cache for usb_control_msg. (USB) |
| 657 | */ |
| 658 | void __iomem *csr_addr; |
| 659 | void *csr_cache; |
| 660 | |
| 661 | /* |
Adam Baker | 3d82346 | 2007-10-27 13:43:29 +0200 | [diff] [blame] | 662 | * Mutex to protect register accesses on USB devices. |
| 663 | * There are 2 reasons this is needed, one is to ensure |
| 664 | * use of the csr_cache (for USB devices) by one thread |
| 665 | * isn't corrupted by another thread trying to access it. |
| 666 | * The other is that access to BBP and RF registers |
| 667 | * require multiple BUS transactions and if another thread |
| 668 | * attempted to access one of those registers at the same |
| 669 | * time one of the writes could silently fail. |
| 670 | */ |
| 671 | struct mutex usb_cache_mutex; |
| 672 | |
| 673 | /* |
Ivo van Doorn | 3c4f208 | 2008-01-06 23:40:49 +0100 | [diff] [blame^] | 674 | * Current packet filter configuration for the device. |
| 675 | * This contains all currently active FIF_* flags send |
| 676 | * to us by mac80211 during configure_filter(). |
| 677 | */ |
| 678 | unsigned int packet_filter; |
| 679 | |
| 680 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 681 | * Interface configuration. |
| 682 | */ |
| 683 | struct interface interface; |
| 684 | |
| 685 | /* |
| 686 | * Link quality |
| 687 | */ |
| 688 | struct link link; |
| 689 | |
| 690 | /* |
| 691 | * EEPROM data. |
| 692 | */ |
| 693 | __le16 *eeprom; |
| 694 | |
| 695 | /* |
| 696 | * Active RF register values. |
| 697 | * These are stored here so we don't need |
| 698 | * to read the rf registers and can directly |
| 699 | * use this value instead. |
| 700 | * This field should be accessed by using |
| 701 | * rt2x00_rf_read() and rt2x00_rf_write(). |
| 702 | */ |
| 703 | u32 *rf; |
| 704 | |
| 705 | /* |
Ivo van Doorn | b242e89 | 2007-11-15 23:41:31 +0100 | [diff] [blame] | 706 | * USB Max frame size (for rt2500usb & rt73usb). |
| 707 | */ |
| 708 | u16 usb_maxpacket; |
| 709 | |
| 710 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 711 | * Current TX power value. |
| 712 | */ |
| 713 | u16 tx_power; |
| 714 | |
| 715 | /* |
| 716 | * LED register (for rt61pci & rt73usb). |
| 717 | */ |
| 718 | u16 led_reg; |
| 719 | |
| 720 | /* |
| 721 | * Led mode (LED_MODE_*) |
| 722 | */ |
| 723 | u8 led_mode; |
| 724 | |
| 725 | /* |
| 726 | * Rssi <-> Dbm offset |
| 727 | */ |
| 728 | u8 rssi_offset; |
| 729 | |
| 730 | /* |
| 731 | * Frequency offset (for rt61pci & rt73usb). |
| 732 | */ |
| 733 | u8 freq_offset; |
| 734 | |
| 735 | /* |
| 736 | * Low level statistics which will have |
| 737 | * to be kept up to date while device is running. |
| 738 | */ |
| 739 | struct ieee80211_low_level_stats low_level_stats; |
| 740 | |
| 741 | /* |
| 742 | * RX configuration information. |
| 743 | */ |
| 744 | struct ieee80211_rx_status rx_status; |
| 745 | |
| 746 | /* |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 747 | * Scheduled work. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 748 | */ |
| 749 | struct work_struct beacon_work; |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 750 | struct work_struct filter_work; |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 751 | struct work_struct config_work; |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 752 | |
| 753 | /* |
| 754 | * Data ring arrays for RX, TX and Beacon. |
| 755 | * The Beacon array also contains the Atim ring |
| 756 | * if that is supported by the device. |
| 757 | */ |
| 758 | int data_rings; |
| 759 | struct data_ring *rx; |
| 760 | struct data_ring *tx; |
| 761 | struct data_ring *bcn; |
| 762 | |
| 763 | /* |
| 764 | * Firmware image. |
| 765 | */ |
| 766 | const struct firmware *fw; |
| 767 | }; |
| 768 | |
| 769 | /* |
| 770 | * For-each loop for the ring array. |
| 771 | * All rings have been allocated as a single array, |
| 772 | * this means we can create a very simply loop macro |
| 773 | * that is capable of looping through all rings. |
| 774 | * ring_end(), txring_end() and ring_loop() are helper macro's which |
| 775 | * should not be used directly. Instead the following should be used: |
| 776 | * ring_for_each() - Loops through all rings (RX, TX, Beacon & Atim) |
| 777 | * txring_for_each() - Loops through TX data rings (TX only) |
| 778 | * txringall_for_each() - Loops through all TX rings (TX, Beacon & Atim) |
| 779 | */ |
| 780 | #define ring_end(__dev) \ |
| 781 | &(__dev)->rx[(__dev)->data_rings] |
| 782 | |
| 783 | #define txring_end(__dev) \ |
| 784 | &(__dev)->tx[(__dev)->hw->queues] |
| 785 | |
| 786 | #define ring_loop(__entry, __start, __end) \ |
| 787 | for ((__entry) = (__start); \ |
| 788 | prefetch(&(__entry)[1]), (__entry) != (__end); \ |
| 789 | (__entry) = &(__entry)[1]) |
| 790 | |
| 791 | #define ring_for_each(__dev, __entry) \ |
| 792 | ring_loop(__entry, (__dev)->rx, ring_end(__dev)) |
| 793 | |
| 794 | #define txring_for_each(__dev, __entry) \ |
| 795 | ring_loop(__entry, (__dev)->tx, txring_end(__dev)) |
| 796 | |
| 797 | #define txringall_for_each(__dev, __entry) \ |
| 798 | ring_loop(__entry, (__dev)->tx, ring_end(__dev)) |
| 799 | |
| 800 | /* |
| 801 | * Generic RF access. |
| 802 | * The RF is being accessed by word index. |
| 803 | */ |
Adam Baker | 0e14f6d | 2007-10-27 13:41:25 +0200 | [diff] [blame] | 804 | static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 805 | const unsigned int word, u32 *data) |
| 806 | { |
| 807 | *data = rt2x00dev->rf[word]; |
| 808 | } |
| 809 | |
Adam Baker | 0e14f6d | 2007-10-27 13:41:25 +0200 | [diff] [blame] | 810 | static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 811 | const unsigned int word, u32 data) |
| 812 | { |
| 813 | rt2x00dev->rf[word] = data; |
| 814 | } |
| 815 | |
| 816 | /* |
| 817 | * Generic EEPROM access. |
| 818 | * The EEPROM is being accessed by word index. |
| 819 | */ |
Adam Baker | 0e14f6d | 2007-10-27 13:41:25 +0200 | [diff] [blame] | 820 | static inline void *rt2x00_eeprom_addr(struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 821 | const unsigned int word) |
| 822 | { |
| 823 | return (void *)&rt2x00dev->eeprom[word]; |
| 824 | } |
| 825 | |
Adam Baker | 0e14f6d | 2007-10-27 13:41:25 +0200 | [diff] [blame] | 826 | static inline void rt2x00_eeprom_read(struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 827 | const unsigned int word, u16 *data) |
| 828 | { |
| 829 | *data = le16_to_cpu(rt2x00dev->eeprom[word]); |
| 830 | } |
| 831 | |
Adam Baker | 0e14f6d | 2007-10-27 13:41:25 +0200 | [diff] [blame] | 832 | static inline void rt2x00_eeprom_write(struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 833 | const unsigned int word, u16 data) |
| 834 | { |
| 835 | rt2x00dev->eeprom[word] = cpu_to_le16(data); |
| 836 | } |
| 837 | |
| 838 | /* |
| 839 | * Chipset handlers |
| 840 | */ |
| 841 | static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev, |
| 842 | const u16 rt, const u16 rf, const u32 rev) |
| 843 | { |
| 844 | INFO(rt2x00dev, |
| 845 | "Chipset detected - rt: %04x, rf: %04x, rev: %08x.\n", |
| 846 | rt, rf, rev); |
| 847 | |
| 848 | rt2x00dev->chip.rt = rt; |
| 849 | rt2x00dev->chip.rf = rf; |
| 850 | rt2x00dev->chip.rev = rev; |
| 851 | } |
| 852 | |
| 853 | static inline char rt2x00_rt(const struct rt2x00_chip *chipset, const u16 chip) |
| 854 | { |
| 855 | return (chipset->rt == chip); |
| 856 | } |
| 857 | |
| 858 | static inline char rt2x00_rf(const struct rt2x00_chip *chipset, const u16 chip) |
| 859 | { |
| 860 | return (chipset->rf == chip); |
| 861 | } |
| 862 | |
Ivo van Doorn | 755a957 | 2007-11-12 15:02:22 +0100 | [diff] [blame] | 863 | static inline u16 rt2x00_rev(const struct rt2x00_chip *chipset) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 864 | { |
| 865 | return chipset->rev; |
| 866 | } |
| 867 | |
Ivo van Doorn | 755a957 | 2007-11-12 15:02:22 +0100 | [diff] [blame] | 868 | static inline u16 rt2x00_check_rev(const struct rt2x00_chip *chipset, |
| 869 | const u32 rev) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 870 | { |
Ivo van Doorn | 755a957 | 2007-11-12 15:02:22 +0100 | [diff] [blame] | 871 | return (((chipset->rev & 0xffff0) == rev) && |
| 872 | !!(chipset->rev & 0x0000f)); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | /* |
| 876 | * Duration calculations |
| 877 | * The rate variable passed is: 100kbs. |
| 878 | * To convert from bytes to bits we multiply size with 8, |
| 879 | * then the size is multiplied with 10 to make the |
| 880 | * real rate -> rate argument correction. |
| 881 | */ |
| 882 | static inline u16 get_duration(const unsigned int size, const u8 rate) |
| 883 | { |
| 884 | return ((size * 8 * 10) / rate); |
| 885 | } |
| 886 | |
| 887 | static inline u16 get_duration_res(const unsigned int size, const u8 rate) |
| 888 | { |
| 889 | return ((size * 8 * 10) % rate); |
| 890 | } |
| 891 | |
| 892 | /* |
| 893 | * Library functions. |
| 894 | */ |
| 895 | struct data_ring *rt2x00lib_get_ring(struct rt2x00_dev *rt2x00dev, |
| 896 | const unsigned int queue); |
| 897 | |
| 898 | /* |
| 899 | * Interrupt context handlers. |
| 900 | */ |
| 901 | void rt2x00lib_beacondone(struct rt2x00_dev *rt2x00dev); |
| 902 | void rt2x00lib_txdone(struct data_entry *entry, |
| 903 | const int status, const int retry); |
| 904 | void rt2x00lib_rxdone(struct data_entry *entry, struct sk_buff *skb, |
Johannes Berg | 4150c57 | 2007-09-17 01:29:23 -0400 | [diff] [blame] | 905 | struct rxdata_entry_desc *desc); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 906 | |
| 907 | /* |
| 908 | * TX descriptor initializer |
| 909 | */ |
| 910 | void rt2x00lib_write_tx_desc(struct rt2x00_dev *rt2x00dev, |
Ivo van Doorn | 08992f7 | 2008-01-24 01:56:25 -0800 | [diff] [blame] | 911 | struct sk_buff *skb, |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 912 | struct ieee80211_tx_control *control); |
| 913 | |
| 914 | /* |
| 915 | * mac80211 handlers. |
| 916 | */ |
| 917 | int rt2x00mac_tx(struct ieee80211_hw *hw, struct sk_buff *skb, |
| 918 | struct ieee80211_tx_control *control); |
| 919 | int rt2x00mac_start(struct ieee80211_hw *hw); |
| 920 | void rt2x00mac_stop(struct ieee80211_hw *hw); |
| 921 | int rt2x00mac_add_interface(struct ieee80211_hw *hw, |
| 922 | struct ieee80211_if_init_conf *conf); |
| 923 | void rt2x00mac_remove_interface(struct ieee80211_hw *hw, |
| 924 | struct ieee80211_if_init_conf *conf); |
| 925 | int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf); |
| 926 | int rt2x00mac_config_interface(struct ieee80211_hw *hw, int if_id, |
| 927 | struct ieee80211_if_conf *conf); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 928 | int rt2x00mac_get_stats(struct ieee80211_hw *hw, |
| 929 | struct ieee80211_low_level_stats *stats); |
| 930 | int rt2x00mac_get_tx_stats(struct ieee80211_hw *hw, |
| 931 | struct ieee80211_tx_queue_stats *stats); |
Ivo van Doorn | 5c58ee5 | 2007-10-06 13:34:52 +0200 | [diff] [blame] | 932 | void rt2x00mac_erp_ie_changed(struct ieee80211_hw *hw, u8 changes, |
| 933 | int cts_protection, int preamble); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 934 | int rt2x00mac_conf_tx(struct ieee80211_hw *hw, int queue, |
| 935 | const struct ieee80211_tx_queue_params *params); |
| 936 | |
| 937 | /* |
| 938 | * Driver allocation handlers. |
| 939 | */ |
| 940 | int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev); |
| 941 | void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev); |
| 942 | #ifdef CONFIG_PM |
| 943 | int rt2x00lib_suspend(struct rt2x00_dev *rt2x00dev, pm_message_t state); |
| 944 | int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev); |
| 945 | #endif /* CONFIG_PM */ |
| 946 | |
| 947 | #endif /* RT2X00_H */ |