Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 1 | /* |
Ivo van Doorn | 811aa9c | 2008-02-03 15:42:53 +0100 | [diff] [blame] | 2 | Copyright (C) 2004 - 2008 rt2x00 SourceForge Project |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 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: rt2x00lib |
| 23 | Abstract: Data structures and definitions for the rt2x00lib module. |
| 24 | */ |
| 25 | |
| 26 | #ifndef RT2X00LIB_H |
| 27 | #define RT2X00LIB_H |
| 28 | |
| 29 | /* |
| 30 | * Interval defines |
Ivo van Doorn | 81873e9 | 2007-10-06 14:14:06 +0200 | [diff] [blame] | 31 | * Both the link tuner as the rfkill will be called once per second. |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 32 | */ |
Anton Blanchard | b239bd7 | 2007-10-15 00:40:34 -0500 | [diff] [blame] | 33 | #define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) ) |
Ivo van Doorn | 81873e9 | 2007-10-06 14:14:06 +0200 | [diff] [blame] | 34 | #define RFKILL_POLL_INTERVAL ( 1000 ) |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 35 | |
| 36 | /* |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 37 | * rt2x00_rate: Per rate device information |
| 38 | */ |
| 39 | struct rt2x00_rate { |
| 40 | unsigned short flags; |
Ivo van Doorn | 31562e8 | 2008-02-17 17:35:05 +0100 | [diff] [blame] | 41 | #define DEV_RATE_CCK 0x0001 |
| 42 | #define DEV_RATE_OFDM 0x0002 |
| 43 | #define DEV_RATE_SHORT_PREAMBLE 0x0004 |
Ivo van Doorn | 70e2fed | 2008-02-03 15:50:40 +0100 | [diff] [blame] | 44 | |
| 45 | unsigned short bitrate; /* In 100kbit/s */ |
| 46 | |
| 47 | unsigned short ratemask; |
| 48 | #define DEV_RATEMASK_1MB ( (1 << 1) - 1 ) |
| 49 | #define DEV_RATEMASK_2MB ( (1 << 2) - 1 ) |
| 50 | #define DEV_RATEMASK_5_5MB ( (1 << 3) - 1 ) |
| 51 | #define DEV_RATEMASK_11MB ( (1 << 4) - 1 ) |
| 52 | #define DEV_RATEMASK_6MB ( (1 << 5) - 1 ) |
| 53 | #define DEV_RATEMASK_9MB ( (1 << 6) - 1 ) |
| 54 | #define DEV_RATEMASK_12MB ( (1 << 7) - 1 ) |
| 55 | #define DEV_RATEMASK_18MB ( (1 << 8) - 1 ) |
| 56 | #define DEV_RATEMASK_24MB ( (1 << 9) - 1 ) |
| 57 | #define DEV_RATEMASK_36MB ( (1 << 10) - 1 ) |
| 58 | #define DEV_RATEMASK_48MB ( (1 << 11) - 1 ) |
| 59 | #define DEV_RATEMASK_54MB ( (1 << 12) - 1 ) |
| 60 | |
| 61 | unsigned short plcp; |
| 62 | }; |
| 63 | |
| 64 | extern const struct rt2x00_rate rt2x00_supported_rates[12]; |
| 65 | |
| 66 | static inline u16 rt2x00_create_rate_hw_value(const u16 index, |
| 67 | const u16 short_preamble) |
| 68 | { |
| 69 | return (short_preamble << 8) | (index & 0xff); |
| 70 | } |
| 71 | |
| 72 | static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value) |
| 73 | { |
| 74 | return &rt2x00_supported_rates[hw_value & 0xff]; |
| 75 | } |
| 76 | |
| 77 | static inline int rt2x00_get_rate_preamble(const u16 hw_value) |
| 78 | { |
| 79 | return (hw_value & 0xff00); |
| 80 | } |
| 81 | |
| 82 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 83 | * Radio control handlers. |
| 84 | */ |
| 85 | int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev); |
| 86 | void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev); |
Ivo van Doorn | 5cbf830 | 2007-10-06 14:16:09 +0200 | [diff] [blame] | 87 | void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 88 | void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev); |
| 89 | |
| 90 | /* |
| 91 | * Initialization handlers. |
| 92 | */ |
Ivo van Doorn | e37ea21 | 2008-01-06 23:40:07 +0100 | [diff] [blame] | 93 | int rt2x00lib_start(struct rt2x00_dev *rt2x00dev); |
| 94 | void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * Configuration handlers. |
| 98 | */ |
Ivo van Doorn | 6bb40dd | 2008-02-03 15:49:59 +0100 | [diff] [blame] | 99 | void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev, |
| 100 | struct rt2x00_intf *intf, |
| 101 | enum ieee80211_if_types type, |
| 102 | u8 *mac, u8 *bssid); |
| 103 | void rt2x00lib_config_preamble(struct rt2x00_dev *rt2x00dev, |
| 104 | struct rt2x00_intf *intf, |
| 105 | const unsigned int short_preamble); |
Ivo van Doorn | 69f81a2 | 2007-10-13 16:26:36 +0200 | [diff] [blame] | 106 | void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, |
| 107 | enum antenna rx, enum antenna tx); |
Ivo van Doorn | 066cb63 | 2007-09-25 20:55:39 +0200 | [diff] [blame] | 108 | void rt2x00lib_config(struct rt2x00_dev *rt2x00dev, |
| 109 | struct ieee80211_conf *conf, const int force_config); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 110 | |
| 111 | /* |
Ivo van Doorn | 181d690 | 2008-02-05 16:42:23 -0500 | [diff] [blame] | 112 | * Queue handlers. |
| 113 | */ |
| 114 | void rt2x00queue_init_rx(struct rt2x00_dev *rt2x00dev); |
| 115 | void rt2x00queue_init_tx(struct rt2x00_dev *rt2x00dev); |
| 116 | int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev); |
| 117 | void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev); |
| 118 | int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev); |
| 119 | void rt2x00queue_free(struct rt2x00_dev *rt2x00dev); |
| 120 | |
| 121 | /* |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 122 | * Firmware handlers. |
| 123 | */ |
| 124 | #ifdef CONFIG_RT2X00_LIB_FIRMWARE |
| 125 | int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev); |
| 126 | void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev); |
| 127 | #else |
| 128 | static inline int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev) |
| 129 | { |
| 130 | return 0; |
| 131 | } |
| 132 | static inline void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev) |
| 133 | { |
| 134 | } |
| 135 | #endif /* CONFIG_RT2X00_LIB_FIRMWARE */ |
| 136 | |
| 137 | /* |
| 138 | * Debugfs handlers. |
| 139 | */ |
| 140 | #ifdef CONFIG_RT2X00_LIB_DEBUGFS |
| 141 | void rt2x00debug_register(struct rt2x00_dev *rt2x00dev); |
| 142 | void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev); |
Ivo van Doorn | 4d8dd66 | 2007-11-27 21:49:29 +0100 | [diff] [blame] | 143 | void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 144 | #else |
| 145 | static inline void rt2x00debug_register(struct rt2x00_dev *rt2x00dev) |
| 146 | { |
| 147 | } |
| 148 | |
| 149 | static inline void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev) |
| 150 | { |
| 151 | } |
Ivo van Doorn | 4d8dd66 | 2007-11-27 21:49:29 +0100 | [diff] [blame] | 152 | |
| 153 | static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, |
John W. Linville | 2b1ea59 | 2007-12-04 17:24:35 -0500 | [diff] [blame] | 154 | struct sk_buff *skb) |
Ivo van Doorn | 4d8dd66 | 2007-11-27 21:49:29 +0100 | [diff] [blame] | 155 | { |
| 156 | } |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 157 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
| 158 | |
| 159 | /* |
| 160 | * RFkill handlers. |
| 161 | */ |
| 162 | #ifdef CONFIG_RT2X00_LIB_RFKILL |
| 163 | int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev); |
| 164 | void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev); |
| 165 | int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev); |
| 166 | void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev); |
| 167 | #else |
| 168 | static inline int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) |
| 169 | { |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 170 | return 0; |
| 171 | } |
| 172 | |
| 173 | static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) |
| 174 | { |
| 175 | } |
| 176 | |
| 177 | static inline int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) |
| 178 | { |
| 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) |
| 183 | { |
| 184 | } |
| 185 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ |
| 186 | |
Ivo van Doorn | a9450b7 | 2008-02-03 15:53:40 +0100 | [diff] [blame] | 187 | /* |
| 188 | * LED handlers |
| 189 | */ |
| 190 | #ifdef CONFIG_RT2X00_LIB_LEDS |
| 191 | void rt2x00leds_led_quality(struct rt2x00_dev *rt2x00dev, int rssi); |
| 192 | int rt2x00leds_register(struct rt2x00_dev *rt2x00dev); |
| 193 | void rt2x00leds_unregister(struct rt2x00_dev *rt2x00dev); |
| 194 | void rt2x00leds_suspend(struct rt2x00_dev *rt2x00dev); |
| 195 | void rt2x00leds_resume(struct rt2x00_dev *rt2x00dev); |
| 196 | #else |
| 197 | static inline void rt2x00leds_led_quality(struct rt2x00_dev *rt2x00dev, |
| 198 | int rssi) |
| 199 | { |
| 200 | } |
| 201 | |
| 202 | static inline int rt2x00leds_register(struct rt2x00_dev *rt2x00dev) |
| 203 | { |
| 204 | return 0; |
| 205 | } |
| 206 | |
| 207 | static inline void rt2x00leds_unregister(struct rt2x00_dev *rt2x00dev) |
| 208 | { |
| 209 | } |
| 210 | |
| 211 | static inline void rt2x00leds_suspend(struct rt2x00_dev *rt2x00dev) |
| 212 | { |
| 213 | } |
| 214 | |
| 215 | static inline void rt2x00leds_resume(struct rt2x00_dev *rt2x00dev) |
| 216 | { |
| 217 | } |
| 218 | #endif /* CONFIG_RT2X00_LIB_LEDS */ |
| 219 | |
Ivo van Doorn | 95ea362 | 2007-09-25 17:57:13 -0700 | [diff] [blame] | 220 | #endif /* RT2X00LIB_H */ |