kmemtrace: SLOB hooks.
[linux-2.6/kmemtrace.git] / include / net / wireless.h
blob667b4080d30fe27eee5949a4c9e846ea6b3384ef
1 #ifndef __NET_WIRELESS_H
2 #define __NET_WIRELESS_H
4 /*
5 * 802.11 device management
7 * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
8 */
10 #include <linux/netdevice.h>
11 #include <linux/debugfs.h>
12 #include <linux/list.h>
13 #include <net/cfg80211.h>
15 /**
16 * enum ieee80211_band - supported frequency bands
18 * The bands are assigned this way because the supported
19 * bitrates differ in these bands.
21 * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band
22 * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7)
24 enum ieee80211_band {
25 IEEE80211_BAND_2GHZ,
26 IEEE80211_BAND_5GHZ,
28 /* keep last */
29 IEEE80211_NUM_BANDS
32 /**
33 * enum ieee80211_channel_flags - channel flags
35 * Channel flags set by the regulatory control code.
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.
43 enum ieee80211_channel_flags {
44 IEEE80211_CHAN_DISABLED = 1<<0,
45 IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
46 IEEE80211_CHAN_NO_IBSS = 1<<2,
47 IEEE80211_CHAN_RADAR = 1<<3,
50 /**
51 * struct ieee80211_channel - channel definition
53 * This structure describes a single channel for use
54 * with cfg80211.
56 * @center_freq: center frequency in MHz
57 * @hw_value: hardware-specific value for the channel
58 * @flags: channel flags from &enum ieee80211_channel_flags.
59 * @orig_flags: channel flags at registration time, used by regulatory
60 * code to support devices with additional restrictions
61 * @band: band this channel belongs to.
62 * @max_antenna_gain: maximum antenna gain in dBi
63 * @max_power: maximum transmission power (in dBm)
64 * @orig_mag: internal use
65 * @orig_mpwr: internal use
67 struct ieee80211_channel {
68 enum ieee80211_band band;
69 u16 center_freq;
70 u16 hw_value;
71 u32 flags;
72 int max_antenna_gain;
73 int max_power;
74 u32 orig_flags;
75 int orig_mag, orig_mpwr;
78 /**
79 * enum ieee80211_rate_flags - rate flags
81 * Hardware/specification flags for rates. These are structured
82 * in a way that allows using the same bitrate structure for
83 * different bands/PHY modes.
85 * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
86 * preamble on this bitrate; only relevant in 2.4GHz band and
87 * with CCK rates.
88 * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
89 * when used with 802.11a (on the 5 GHz band); filled by the
90 * core code when registering the wiphy.
91 * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
92 * when used with 802.11b (on the 2.4 GHz band); filled by the
93 * core code when registering the wiphy.
94 * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
95 * when used with 802.11g (on the 2.4 GHz band); filled by the
96 * core code when registering the wiphy.
97 * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
99 enum ieee80211_rate_flags {
100 IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
101 IEEE80211_RATE_MANDATORY_A = 1<<1,
102 IEEE80211_RATE_MANDATORY_B = 1<<2,
103 IEEE80211_RATE_MANDATORY_G = 1<<3,
104 IEEE80211_RATE_ERP_G = 1<<4,
108 * struct ieee80211_rate - bitrate definition
110 * This structure describes a bitrate that an 802.11 PHY can
111 * operate with. The two values @hw_value and @hw_value_short
112 * are only for driver use when pointers to this structure are
113 * passed around.
115 * @flags: rate-specific flags
116 * @bitrate: bitrate in units of 100 Kbps
117 * @hw_value: driver/hardware value for this rate
118 * @hw_value_short: driver/hardware value for this rate when
119 * short preamble is used
121 struct ieee80211_rate {
122 u32 flags;
123 u16 bitrate;
124 u16 hw_value, hw_value_short;
128 * struct ieee80211_ht_info - describing STA's HT capabilities
130 * This structure describes most essential parameters needed
131 * to describe 802.11n HT capabilities for an STA.
133 * @ht_supported: is HT supported by STA, 0: no, 1: yes
134 * @cap: HT capabilities map as described in 802.11n spec
135 * @ampdu_factor: Maximum A-MPDU length factor
136 * @ampdu_density: Minimum A-MPDU spacing
137 * @supp_mcs_set: Supported MCS set as described in 802.11n spec
139 struct ieee80211_ht_info {
140 u16 cap; /* use IEEE80211_HT_CAP_ */
141 u8 ht_supported;
142 u8 ampdu_factor;
143 u8 ampdu_density;
144 u8 supp_mcs_set[16];
148 * struct ieee80211_supported_band - frequency band definition
150 * This structure describes a frequency band a wiphy
151 * is able to operate in.
153 * @channels: Array of channels the hardware can operate in
154 * in this band.
155 * @band: the band this structure represents
156 * @n_channels: Number of channels in @channels
157 * @bitrates: Array of bitrates the hardware can operate with
158 * in this band. Must be sorted to give a valid "supported
159 * rates" IE, i.e. CCK rates first, then OFDM.
160 * @n_bitrates: Number of bitrates in @bitrates
162 struct ieee80211_supported_band {
163 struct ieee80211_channel *channels;
164 struct ieee80211_rate *bitrates;
165 enum ieee80211_band band;
166 int n_channels;
167 int n_bitrates;
168 struct ieee80211_ht_info ht_info;
172 * struct wiphy - wireless hardware description
173 * @idx: the wiphy index assigned to this item
174 * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
176 struct wiphy {
177 /* assign these fields before you register the wiphy */
179 /* permanent MAC address */
180 u8 perm_addr[ETH_ALEN];
182 /* If multiple wiphys are registered and you're handed e.g.
183 * a regular netdev with assigned ieee80211_ptr, you won't
184 * know whether it points to a wiphy your driver has registered
185 * or not. Assign this to something global to your driver to
186 * help determine whether you own this wiphy or not. */
187 void *privid;
189 struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
191 /* fields below are read-only, assigned by cfg80211 */
193 /* the item in /sys/class/ieee80211/ points to this,
194 * you need use set_wiphy_dev() (see below) */
195 struct device dev;
197 /* dir in debugfs: ieee80211/<wiphyname> */
198 struct dentry *debugfsdir;
200 char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
203 /** struct wireless_dev - wireless per-netdev state
205 * This structure must be allocated by the driver/stack
206 * that uses the ieee80211_ptr field in struct net_device
207 * (this is intentional so it can be allocated along with
208 * the netdev.)
210 * @wiphy: pointer to hardware description
212 struct wireless_dev {
213 struct wiphy *wiphy;
215 /* private to the generic wireless code */
216 struct list_head list;
217 struct net_device *netdev;
221 * wiphy_priv - return priv from wiphy
223 static inline void *wiphy_priv(struct wiphy *wiphy)
225 BUG_ON(!wiphy);
226 return &wiphy->priv;
230 * set_wiphy_dev - set device pointer for wiphy
232 static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
234 wiphy->dev.parent = dev;
238 * wiphy_dev - get wiphy dev pointer
240 static inline struct device *wiphy_dev(struct wiphy *wiphy)
242 return wiphy->dev.parent;
246 * wiphy_name - get wiphy name
248 static inline char *wiphy_name(struct wiphy *wiphy)
250 return wiphy->dev.bus_id;
254 * wdev_priv - return wiphy priv from wireless_dev
256 static inline void *wdev_priv(struct wireless_dev *wdev)
258 BUG_ON(!wdev);
259 return wiphy_priv(wdev->wiphy);
263 * wiphy_new - create a new wiphy for use with cfg80211
265 * create a new wiphy and associate the given operations with it.
266 * @sizeof_priv bytes are allocated for private use.
268 * the returned pointer must be assigned to each netdev's
269 * ieee80211_ptr for proper operation.
271 struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
274 * wiphy_register - register a wiphy with cfg80211
276 * register the given wiphy
278 * Returns a non-negative wiphy index or a negative error code.
280 extern int wiphy_register(struct wiphy *wiphy);
283 * wiphy_unregister - deregister a wiphy from cfg80211
285 * unregister a device with the given priv pointer.
286 * After this call, no more requests can be made with this priv
287 * pointer, but the call may sleep to wait for an outstanding
288 * request that is being handled.
290 extern void wiphy_unregister(struct wiphy *wiphy);
293 * wiphy_free - free wiphy
295 extern void wiphy_free(struct wiphy *wiphy);
298 * ieee80211_channel_to_frequency - convert channel number to frequency
300 extern int ieee80211_channel_to_frequency(int chan);
303 * ieee80211_frequency_to_channel - convert frequency to channel number
305 extern int ieee80211_frequency_to_channel(int freq);
308 * Name indirection necessary because the ieee80211 code also has
309 * a function named "ieee80211_get_channel", so if you include
310 * cfg80211's header file you get cfg80211's version, if you try
311 * to include both header files you'll (rightfully!) get a symbol
312 * clash.
314 extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
315 int freq);
318 * ieee80211_get_channel - get channel struct from wiphy for specified frequency
320 static inline struct ieee80211_channel *
321 ieee80211_get_channel(struct wiphy *wiphy, int freq)
323 return __ieee80211_get_channel(wiphy, freq);
325 #endif /* __NET_WIRELESS_H */