]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/linux-26-headers/include/net/wireless.h
update
[l4.git] / l4 / pkg / linux-26-headers / include / net / wireless.h
1 #ifndef __NET_WIRELESS_H
2 #define __NET_WIRELESS_H
3
4 /*
5  * 802.11 device management
6  *
7  * Copyright 2007       Johannes Berg <johannes@sipsolutions.net>
8  */
9
10 #include <linux/netdevice.h>
11 #include <linux/debugfs.h>
12 #include <linux/list.h>
13 #include <net/cfg80211.h>
14
15 /**
16  * enum ieee80211_band - supported frequency bands
17  *
18  * The bands are assigned this way because the supported
19  * bitrates differ in these bands.
20  *
21  * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band
22  * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7)
23  */
24 enum ieee80211_band {
25         IEEE80211_BAND_2GHZ,
26         IEEE80211_BAND_5GHZ,
27
28         /* keep last */
29         IEEE80211_NUM_BANDS
30 };
31
32 /**
33  * enum ieee80211_channel_flags - channel flags
34  *
35  * Channel flags set by the regulatory control code.
36  *
37  * @IEEE80211_CHAN_DISABLED: This channel is disabled.
38  * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
39  *      on this channel.
40  * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
41  * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
42  * @IEEE80211_CHAN_NO_FAT_ABOVE: extension channel above this channel
43  *      is not permitted.
44  * @IEEE80211_CHAN_NO_FAT_BELOW: extension channel below this channel
45  *      is not permitted.
46  */
47 enum ieee80211_channel_flags {
48         IEEE80211_CHAN_DISABLED         = 1<<0,
49         IEEE80211_CHAN_PASSIVE_SCAN     = 1<<1,
50         IEEE80211_CHAN_NO_IBSS          = 1<<2,
51         IEEE80211_CHAN_RADAR            = 1<<3,
52         IEEE80211_CHAN_NO_FAT_ABOVE     = 1<<4,
53         IEEE80211_CHAN_NO_FAT_BELOW     = 1<<5,
54 };
55
56 /**
57  * struct ieee80211_channel - channel definition
58  *
59  * This structure describes a single channel for use
60  * with cfg80211.
61  *
62  * @center_freq: center frequency in MHz
63  * @hw_value: hardware-specific value for the channel
64  * @flags: channel flags from &enum ieee80211_channel_flags.
65  * @orig_flags: channel flags at registration time, used by regulatory
66  *      code to support devices with additional restrictions
67  * @band: band this channel belongs to.
68  * @max_antenna_gain: maximum antenna gain in dBi
69  * @max_power: maximum transmission power (in dBm)
70  * @orig_mag: internal use
71  * @orig_mpwr: internal use
72  */
73 struct ieee80211_channel {
74         enum ieee80211_band band;
75         u16 center_freq;
76         u16 hw_value;
77         u32 flags;
78         int max_antenna_gain;
79         int max_power;
80         u32 orig_flags;
81         int orig_mag, orig_mpwr;
82 };
83
84 /**
85  * enum ieee80211_rate_flags - rate flags
86  *
87  * Hardware/specification flags for rates. These are structured
88  * in a way that allows using the same bitrate structure for
89  * different bands/PHY modes.
90  *
91  * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
92  *      preamble on this bitrate; only relevant in 2.4GHz band and
93  *      with CCK rates.
94  * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
95  *      when used with 802.11a (on the 5 GHz band); filled by the
96  *      core code when registering the wiphy.
97  * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
98  *      when used with 802.11b (on the 2.4 GHz band); filled by the
99  *      core code when registering the wiphy.
100  * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
101  *      when used with 802.11g (on the 2.4 GHz band); filled by the
102  *      core code when registering the wiphy.
103  * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
104  */
105 enum ieee80211_rate_flags {
106         IEEE80211_RATE_SHORT_PREAMBLE   = 1<<0,
107         IEEE80211_RATE_MANDATORY_A      = 1<<1,
108         IEEE80211_RATE_MANDATORY_B      = 1<<2,
109         IEEE80211_RATE_MANDATORY_G      = 1<<3,
110         IEEE80211_RATE_ERP_G            = 1<<4,
111 };
112
113 /**
114  * struct ieee80211_rate - bitrate definition
115  *
116  * This structure describes a bitrate that an 802.11 PHY can
117  * operate with. The two values @hw_value and @hw_value_short
118  * are only for driver use when pointers to this structure are
119  * passed around.
120  *
121  * @flags: rate-specific flags
122  * @bitrate: bitrate in units of 100 Kbps
123  * @hw_value: driver/hardware value for this rate
124  * @hw_value_short: driver/hardware value for this rate when
125  *      short preamble is used
126  */
127 struct ieee80211_rate {
128         u32 flags;
129         u16 bitrate;
130         u16 hw_value, hw_value_short;
131 };
132
133 /**
134  * struct ieee80211_ht_info - describing STA's HT capabilities
135  *
136  * This structure describes most essential parameters needed
137  * to describe 802.11n HT capabilities for an STA.
138  *
139  * @ht_supported: is HT supported by STA, 0: no, 1: yes
140  * @cap: HT capabilities map as described in 802.11n spec
141  * @ampdu_factor: Maximum A-MPDU length factor
142  * @ampdu_density: Minimum A-MPDU spacing
143  * @supp_mcs_set: Supported MCS set as described in 802.11n spec
144  */
145 struct ieee80211_ht_info {
146         u16 cap; /* use IEEE80211_HT_CAP_ */
147         u8 ht_supported;
148         u8 ampdu_factor;
149         u8 ampdu_density;
150         u8 supp_mcs_set[16];
151 };
152
153 /**
154  * struct ieee80211_supported_band - frequency band definition
155  *
156  * This structure describes a frequency band a wiphy
157  * is able to operate in.
158  *
159  * @channels: Array of channels the hardware can operate in
160  *      in this band.
161  * @band: the band this structure represents
162  * @n_channels: Number of channels in @channels
163  * @bitrates: Array of bitrates the hardware can operate with
164  *      in this band. Must be sorted to give a valid "supported
165  *      rates" IE, i.e. CCK rates first, then OFDM.
166  * @n_bitrates: Number of bitrates in @bitrates
167  */
168 struct ieee80211_supported_band {
169         struct ieee80211_channel *channels;
170         struct ieee80211_rate *bitrates;
171         enum ieee80211_band band;
172         int n_channels;
173         int n_bitrates;
174         struct ieee80211_ht_info ht_info;
175 };
176
177 /**
178  * struct wiphy - wireless hardware description
179  * @idx: the wiphy index assigned to this item
180  * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
181  */
182 struct wiphy {
183         /* assign these fields before you register the wiphy */
184
185         /* permanent MAC address */
186         u8 perm_addr[ETH_ALEN];
187
188         /* If multiple wiphys are registered and you're handed e.g.
189          * a regular netdev with assigned ieee80211_ptr, you won't
190          * know whether it points to a wiphy your driver has registered
191          * or not. Assign this to something global to your driver to
192          * help determine whether you own this wiphy or not. */
193         void *privid;
194
195         struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
196
197         /* fields below are read-only, assigned by cfg80211 */
198
199         /* the item in /sys/class/ieee80211/ points to this,
200          * you need use set_wiphy_dev() (see below) */
201         struct device dev;
202
203         /* dir in debugfs: ieee80211/<wiphyname> */
204         struct dentry *debugfsdir;
205
206         char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
207 };
208
209 /** struct wireless_dev - wireless per-netdev state
210  *
211  * This structure must be allocated by the driver/stack
212  * that uses the ieee80211_ptr field in struct net_device
213  * (this is intentional so it can be allocated along with
214  * the netdev.)
215  *
216  * @wiphy: pointer to hardware description
217  */
218 struct wireless_dev {
219         struct wiphy *wiphy;
220
221         /* private to the generic wireless code */
222         struct list_head list;
223         struct net_device *netdev;
224 };
225
226 /**
227  * wiphy_priv - return priv from wiphy
228  */
229 static inline void *wiphy_priv(struct wiphy *wiphy)
230 {
231         BUG_ON(!wiphy);
232         return &wiphy->priv;
233 }
234
235 /**
236  * set_wiphy_dev - set device pointer for wiphy
237  */
238 static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
239 {
240         wiphy->dev.parent = dev;
241 }
242
243 /**
244  * wiphy_dev - get wiphy dev pointer
245  */
246 static inline struct device *wiphy_dev(struct wiphy *wiphy)
247 {
248         return wiphy->dev.parent;
249 }
250
251 /**
252  * wiphy_name - get wiphy name
253  */
254 static inline char *wiphy_name(struct wiphy *wiphy)
255 {
256         return wiphy->dev.bus_id;
257 }
258
259 /**
260  * wdev_priv - return wiphy priv from wireless_dev
261  */
262 static inline void *wdev_priv(struct wireless_dev *wdev)
263 {
264         BUG_ON(!wdev);
265         return wiphy_priv(wdev->wiphy);
266 }
267
268 /**
269  * wiphy_new - create a new wiphy for use with cfg80211
270  *
271  * create a new wiphy and associate the given operations with it.
272  * @sizeof_priv bytes are allocated for private use.
273  *
274  * the returned pointer must be assigned to each netdev's
275  * ieee80211_ptr for proper operation.
276  */
277 struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
278
279 /**
280  * wiphy_register - register a wiphy with cfg80211
281  *
282  * register the given wiphy
283  *
284  * Returns a non-negative wiphy index or a negative error code.
285  */
286 extern int wiphy_register(struct wiphy *wiphy);
287
288 /**
289  * wiphy_unregister - deregister a wiphy from cfg80211
290  *
291  * unregister a device with the given priv pointer.
292  * After this call, no more requests can be made with this priv
293  * pointer, but the call may sleep to wait for an outstanding
294  * request that is being handled.
295  */
296 extern void wiphy_unregister(struct wiphy *wiphy);
297
298 /**
299  * wiphy_free - free wiphy
300  */
301 extern void wiphy_free(struct wiphy *wiphy);
302
303 /**
304  * ieee80211_channel_to_frequency - convert channel number to frequency
305  */
306 extern int ieee80211_channel_to_frequency(int chan);
307
308 /**
309  * ieee80211_frequency_to_channel - convert frequency to channel number
310  */
311 extern int ieee80211_frequency_to_channel(int freq);
312
313 /*
314  * Name indirection necessary because the ieee80211 code also has
315  * a function named "ieee80211_get_channel", so if you include
316  * cfg80211's header file you get cfg80211's version, if you try
317  * to include both header files you'll (rightfully!) get a symbol
318  * clash.
319  */
320 extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
321                                                          int freq);
322
323 /**
324  * ieee80211_get_channel - get channel struct from wiphy for specified frequency
325  */
326 static inline struct ieee80211_channel *
327 ieee80211_get_channel(struct wiphy *wiphy, int freq)
328 {
329         return __ieee80211_get_channel(wiphy, freq);
330 }
331 #endif /* __NET_WIRELESS_H */