blob: ca9630c755202488970b4c2ef68e1ae176057b25 [file] [log] [blame]
Ivo van Doorn95ea3622007-09-25 17:57:13 -07001/*
Ivo van Doorn811aa9c2008-02-03 15:42:53 +01002 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project
Ivo van Doorn95ea3622007-09-25 17:57:13 -07003 <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 Doorn81873e92007-10-06 14:14:06 +020031 * Both the link tuner as the rfkill will be called once per second.
Ivo van Doorn95ea3622007-09-25 17:57:13 -070032 */
Anton Blanchardb239bd72007-10-15 00:40:34 -050033#define LINK_TUNE_INTERVAL ( round_jiffies_relative(HZ) )
Ivo van Doorn81873e92007-10-06 14:14:06 +020034#define RFKILL_POLL_INTERVAL ( 1000 )
Ivo van Doorn95ea3622007-09-25 17:57:13 -070035
36/*
Ivo van Doorn70e2fed2008-02-03 15:50:40 +010037 * rt2x00_rate: Per rate device information
38 */
39struct rt2x00_rate {
40 unsigned short flags;
41#define DEV_RATE_OFDM 0x0001
42#define DEV_RATE_SHORT_PREAMBLE 0x0002
43
44 unsigned short bitrate; /* In 100kbit/s */
45
46 unsigned short ratemask;
47#define DEV_RATEMASK_1MB ( (1 << 1) - 1 )
48#define DEV_RATEMASK_2MB ( (1 << 2) - 1 )
49#define DEV_RATEMASK_5_5MB ( (1 << 3) - 1 )
50#define DEV_RATEMASK_11MB ( (1 << 4) - 1 )
51#define DEV_RATEMASK_6MB ( (1 << 5) - 1 )
52#define DEV_RATEMASK_9MB ( (1 << 6) - 1 )
53#define DEV_RATEMASK_12MB ( (1 << 7) - 1 )
54#define DEV_RATEMASK_18MB ( (1 << 8) - 1 )
55#define DEV_RATEMASK_24MB ( (1 << 9) - 1 )
56#define DEV_RATEMASK_36MB ( (1 << 10) - 1 )
57#define DEV_RATEMASK_48MB ( (1 << 11) - 1 )
58#define DEV_RATEMASK_54MB ( (1 << 12) - 1 )
59
60 unsigned short plcp;
61};
62
63extern const struct rt2x00_rate rt2x00_supported_rates[12];
64
65static inline u16 rt2x00_create_rate_hw_value(const u16 index,
66 const u16 short_preamble)
67{
68 return (short_preamble << 8) | (index & 0xff);
69}
70
71static inline const struct rt2x00_rate *rt2x00_get_rate(const u16 hw_value)
72{
73 return &rt2x00_supported_rates[hw_value & 0xff];
74}
75
76static inline int rt2x00_get_rate_preamble(const u16 hw_value)
77{
78 return (hw_value & 0xff00);
79}
80
81/*
Ivo van Doorn95ea3622007-09-25 17:57:13 -070082 * Radio control handlers.
83 */
84int rt2x00lib_enable_radio(struct rt2x00_dev *rt2x00dev);
85void rt2x00lib_disable_radio(struct rt2x00_dev *rt2x00dev);
Ivo van Doorn5cbf8302007-10-06 14:16:09 +020086void rt2x00lib_toggle_rx(struct rt2x00_dev *rt2x00dev, enum dev_state state);
Ivo van Doorn95ea3622007-09-25 17:57:13 -070087void rt2x00lib_reset_link_tuner(struct rt2x00_dev *rt2x00dev);
88
89/*
90 * Initialization handlers.
91 */
Ivo van Doorne37ea212008-01-06 23:40:07 +010092int rt2x00lib_start(struct rt2x00_dev *rt2x00dev);
93void rt2x00lib_stop(struct rt2x00_dev *rt2x00dev);
Ivo van Doorn95ea3622007-09-25 17:57:13 -070094
95/*
96 * Configuration handlers.
97 */
Ivo van Doorn6bb40dd2008-02-03 15:49:59 +010098void rt2x00lib_config_intf(struct rt2x00_dev *rt2x00dev,
99 struct rt2x00_intf *intf,
100 enum ieee80211_if_types type,
101 u8 *mac, u8 *bssid);
102void rt2x00lib_config_preamble(struct rt2x00_dev *rt2x00dev,
103 struct rt2x00_intf *intf,
104 const unsigned int short_preamble);
Ivo van Doorn69f81a22007-10-13 16:26:36 +0200105void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev,
106 enum antenna rx, enum antenna tx);
Ivo van Doorn066cb632007-09-25 20:55:39 +0200107void rt2x00lib_config(struct rt2x00_dev *rt2x00dev,
108 struct ieee80211_conf *conf, const int force_config);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700109
110/*
Ivo van Doorn181d6902008-02-05 16:42:23 -0500111 * Queue handlers.
112 */
113void rt2x00queue_init_rx(struct rt2x00_dev *rt2x00dev);
114void rt2x00queue_init_tx(struct rt2x00_dev *rt2x00dev);
115int rt2x00queue_initialize(struct rt2x00_dev *rt2x00dev);
116void rt2x00queue_uninitialize(struct rt2x00_dev *rt2x00dev);
117int rt2x00queue_allocate(struct rt2x00_dev *rt2x00dev);
118void rt2x00queue_free(struct rt2x00_dev *rt2x00dev);
119
120/*
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700121 * Firmware handlers.
122 */
123#ifdef CONFIG_RT2X00_LIB_FIRMWARE
124int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev);
125void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev);
126#else
127static inline int rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev)
128{
129 return 0;
130}
131static inline void rt2x00lib_free_firmware(struct rt2x00_dev *rt2x00dev)
132{
133}
134#endif /* CONFIG_RT2X00_LIB_FIRMWARE */
135
136/*
137 * Debugfs handlers.
138 */
139#ifdef CONFIG_RT2X00_LIB_DEBUGFS
140void rt2x00debug_register(struct rt2x00_dev *rt2x00dev);
141void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev);
Ivo van Doorn4d8dd662007-11-27 21:49:29 +0100142void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb);
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700143#else
144static inline void rt2x00debug_register(struct rt2x00_dev *rt2x00dev)
145{
146}
147
148static inline void rt2x00debug_deregister(struct rt2x00_dev *rt2x00dev)
149{
150}
Ivo van Doorn4d8dd662007-11-27 21:49:29 +0100151
152static inline void rt2x00debug_dump_frame(struct rt2x00_dev *rt2x00dev,
John W. Linville2b1ea592007-12-04 17:24:35 -0500153 struct sk_buff *skb)
Ivo van Doorn4d8dd662007-11-27 21:49:29 +0100154{
155}
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700156#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
157
158/*
159 * RFkill handlers.
160 */
161#ifdef CONFIG_RT2X00_LIB_RFKILL
162int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev);
163void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev);
164int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev);
165void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev);
166#else
167static inline int rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
168{
Ivo van Doorn95ea3622007-09-25 17:57:13 -0700169 return 0;
170}
171
172static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
173{
174}
175
176static inline int rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
177{
178 return 0;
179}
180
181static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
182{
183}
184#endif /* CONFIG_RT2X00_LIB_RFKILL */
185
186#endif /* RT2X00LIB_H */