Commit d323655372590c533c275b1d798f9d1221efb5c6

Authored by Johannes Berg
Committed by John W. Linville
1 parent af8cdcd828

cfg80211: clean up includes

Trying to separate header files into net/wireless.h and
net/cfg80211.h has been a source of confusion. Remove
net/wireless.h (because there also is the linux/wireless.h)
and subsume everything into net/cfg80211.h -- except the
definitions for regulatory structures which get moved to
a new header net/regulatory.h.

The "new" net/cfg80211.h is now divided into sections.

There are no real changes in this patch but code shuffling
and some very minor documentation fixes.

I have also, to make things reflect reality, put in a
copyright line for Luis to net/regulatory.h since that
is probably exclusively written by him but was formerly
in a file that only had my copyright line.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

Showing 19 changed files with 690 additions and 637 deletions Side-by-side Diff

drivers/net/wireless/ath/ar9170/ar9170.h
... ... @@ -40,7 +40,7 @@
40 40  
41 41 #include <linux/completion.h>
42 42 #include <linux/spinlock.h>
43   -#include <net/wireless.h>
  43 +#include <net/cfg80211.h>
44 44 #include <net/mac80211.h>
45 45 #ifdef CONFIG_AR9170_LEDS
46 46 #include <linux/leds.h>
drivers/net/wireless/ath/ar9170/usb.h
... ... @@ -43,7 +43,7 @@
43 43 #include <linux/completion.h>
44 44 #include <linux/spinlock.h>
45 45 #include <linux/leds.h>
46   -#include <net/wireless.h>
  46 +#include <net/cfg80211.h>
47 47 #include <net/mac80211.h>
48 48 #include <linux/firmware.h>
49 49 #include "eeprom.h"
drivers/net/wireless/ath/ath9k/eeprom.h
... ... @@ -17,7 +17,7 @@
17 17 #ifndef EEPROM_H
18 18 #define EEPROM_H
19 19  
20   -#include <net/wireless.h>
  20 +#include <net/cfg80211.h>
21 21  
22 22 #define AH_USE_EEPROM 0x1
23 23  
drivers/net/wireless/ath/regd.c
... ... @@ -18,7 +18,6 @@
18 18 #include <linux/slab.h>
19 19 #include <net/cfg80211.h>
20 20 #include <net/mac80211.h>
21   -#include <net/wireless.h>
22 21 #include "regd.h"
23 22 #include "regd_common.h"
24 23  
drivers/net/wireless/ath/regd.h
... ... @@ -20,7 +20,6 @@
20 20 #include <linux/nl80211.h>
21 21  
22 22 #include <net/cfg80211.h>
23   -#include <net/wireless.h>
24 23  
25 24 #define NO_CTL 0xff
26 25 #define SD_NO_CTL 0xE0
drivers/net/wireless/rndis_wlan.c
... ... @@ -42,7 +42,6 @@
42 42 #include <linux/ctype.h>
43 43 #include <linux/spinlock.h>
44 44 #include <net/iw_handler.h>
45   -#include <net/wireless.h>
46 45 #include <net/cfg80211.h>
47 46 #include <linux/usb/usbnet.h>
48 47 #include <linux/usb/rndis_host.h>
include/net/cfg80211.h
1 1 #ifndef __NET_CFG80211_H
2 2 #define __NET_CFG80211_H
  3 +/*
  4 + * 802.11 device and configuration interface
  5 + *
  6 + * Copyright 2006-2009 Johannes Berg <johannes@sipsolutions.net>
  7 + *
  8 + * This program is free software; you can redistribute it and/or modify
  9 + * it under the terms of the GNU General Public License version 2 as
  10 + * published by the Free Software Foundation.
  11 + */
3 12  
  13 +#include <linux/netdevice.h>
  14 +#include <linux/debugfs.h>
  15 +#include <linux/list.h>
4 16 #include <linux/netlink.h>
5 17 #include <linux/skbuff.h>
6 18 #include <linux/nl80211.h>
7 19 #include <linux/if_ether.h>
8 20 #include <linux/ieee80211.h>
9   -#include <linux/wireless.h>
10   -#include <net/iw_handler.h>
11   -#include <net/genetlink.h>
  21 +#include <net/regulatory.h>
  22 +
12 23 /* remove once we remove the wext stuff */
  24 +#include <net/iw_handler.h>
  25 +#include <linux/wireless.h>
13 26  
  27 +
14 28 /*
15   - * 802.11 configuration in-kernel interface
  29 + * wireless hardware capability structures
  30 + */
  31 +
  32 +/**
  33 + * enum ieee80211_band - supported frequency bands
16 34 *
17   - * Copyright 2006, 2007 Johannes Berg <johannes@sipsolutions.net>
  35 + * The bands are assigned this way because the supported
  36 + * bitrates differ in these bands.
  37 + *
  38 + * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band
  39 + * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7)
18 40 */
  41 +enum ieee80211_band {
  42 + IEEE80211_BAND_2GHZ,
  43 + IEEE80211_BAND_5GHZ,
19 44  
  45 + /* keep last */
  46 + IEEE80211_NUM_BANDS
  47 +};
  48 +
20 49 /**
21   - * struct vif_params - describes virtual interface parameters
22   - * @mesh_id: mesh ID to use
23   - * @mesh_id_len: length of the mesh ID
  50 + * enum ieee80211_channel_flags - channel flags
  51 + *
  52 + * Channel flags set by the regulatory control code.
  53 + *
  54 + * @IEEE80211_CHAN_DISABLED: This channel is disabled.
  55 + * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
  56 + * on this channel.
  57 + * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
  58 + * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
  59 + * @IEEE80211_CHAN_NO_FAT_ABOVE: extension channel above this channel
  60 + * is not permitted.
  61 + * @IEEE80211_CHAN_NO_FAT_BELOW: extension channel below this channel
  62 + * is not permitted.
24 63 */
25   -struct vif_params {
26   - u8 *mesh_id;
27   - int mesh_id_len;
  64 +enum ieee80211_channel_flags {
  65 + IEEE80211_CHAN_DISABLED = 1<<0,
  66 + IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
  67 + IEEE80211_CHAN_NO_IBSS = 1<<2,
  68 + IEEE80211_CHAN_RADAR = 1<<3,
  69 + IEEE80211_CHAN_NO_FAT_ABOVE = 1<<4,
  70 + IEEE80211_CHAN_NO_FAT_BELOW = 1<<5,
28 71 };
29 72  
30   -/* Radiotap header iteration
31   - * implemented in net/wireless/radiotap.c
32   - * docs in Documentation/networking/radiotap-headers.txt
  73 +/**
  74 + * struct ieee80211_channel - channel definition
  75 + *
  76 + * This structure describes a single channel for use
  77 + * with cfg80211.
  78 + *
  79 + * @center_freq: center frequency in MHz
  80 + * @max_bandwidth: maximum allowed bandwidth for this channel, in MHz
  81 + * @hw_value: hardware-specific value for the channel
  82 + * @flags: channel flags from &enum ieee80211_channel_flags.
  83 + * @orig_flags: channel flags at registration time, used by regulatory
  84 + * code to support devices with additional restrictions
  85 + * @band: band this channel belongs to.
  86 + * @max_antenna_gain: maximum antenna gain in dBi
  87 + * @max_power: maximum transmission power (in dBm)
  88 + * @beacon_found: helper to regulatory code to indicate when a beacon
  89 + * has been found on this channel. Use regulatory_hint_found_beacon()
  90 + * to enable this, this is is useful only on 5 GHz band.
  91 + * @orig_mag: internal use
  92 + * @orig_mpwr: internal use
33 93 */
  94 +struct ieee80211_channel {
  95 + enum ieee80211_band band;
  96 + u16 center_freq;
  97 + u8 max_bandwidth;
  98 + u16 hw_value;
  99 + u32 flags;
  100 + int max_antenna_gain;
  101 + int max_power;
  102 + bool beacon_found;
  103 + u32 orig_flags;
  104 + int orig_mag, orig_mpwr;
  105 +};
  106 +
34 107 /**
35   - * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
36   - * @rtheader: pointer to the radiotap header we are walking through
37   - * @max_length: length of radiotap header in cpu byte ordering
38   - * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
39   - * @this_arg: pointer to current radiotap arg
40   - * @arg_index: internal next argument index
41   - * @arg: internal next argument pointer
42   - * @next_bitmap: internal pointer to next present u32
43   - * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  108 + * enum ieee80211_rate_flags - rate flags
  109 + *
  110 + * Hardware/specification flags for rates. These are structured
  111 + * in a way that allows using the same bitrate structure for
  112 + * different bands/PHY modes.
  113 + *
  114 + * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
  115 + * preamble on this bitrate; only relevant in 2.4GHz band and
  116 + * with CCK rates.
  117 + * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
  118 + * when used with 802.11a (on the 5 GHz band); filled by the
  119 + * core code when registering the wiphy.
  120 + * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
  121 + * when used with 802.11b (on the 2.4 GHz band); filled by the
  122 + * core code when registering the wiphy.
  123 + * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
  124 + * when used with 802.11g (on the 2.4 GHz band); filled by the
  125 + * core code when registering the wiphy.
  126 + * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
44 127 */
  128 +enum ieee80211_rate_flags {
  129 + IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
  130 + IEEE80211_RATE_MANDATORY_A = 1<<1,
  131 + IEEE80211_RATE_MANDATORY_B = 1<<2,
  132 + IEEE80211_RATE_MANDATORY_G = 1<<3,
  133 + IEEE80211_RATE_ERP_G = 1<<4,
  134 +};
45 135  
46   -struct ieee80211_radiotap_iterator {
47   - struct ieee80211_radiotap_header *rtheader;
48   - int max_length;
49   - int this_arg_index;
50   - u8 *this_arg;
  136 +/**
  137 + * struct ieee80211_rate - bitrate definition
  138 + *
  139 + * This structure describes a bitrate that an 802.11 PHY can
  140 + * operate with. The two values @hw_value and @hw_value_short
  141 + * are only for driver use when pointers to this structure are
  142 + * passed around.
  143 + *
  144 + * @flags: rate-specific flags
  145 + * @bitrate: bitrate in units of 100 Kbps
  146 + * @hw_value: driver/hardware value for this rate
  147 + * @hw_value_short: driver/hardware value for this rate when
  148 + * short preamble is used
  149 + */
  150 +struct ieee80211_rate {
  151 + u32 flags;
  152 + u16 bitrate;
  153 + u16 hw_value, hw_value_short;
  154 +};
51 155  
52   - int arg_index;
53   - u8 *arg;
54   - __le32 *next_bitmap;
55   - u32 bitmap_shifter;
  156 +/**
  157 + * struct ieee80211_sta_ht_cap - STA's HT capabilities
  158 + *
  159 + * This structure describes most essential parameters needed
  160 + * to describe 802.11n HT capabilities for an STA.
  161 + *
  162 + * @ht_supported: is HT supported by the STA
  163 + * @cap: HT capabilities map as described in 802.11n spec
  164 + * @ampdu_factor: Maximum A-MPDU length factor
  165 + * @ampdu_density: Minimum A-MPDU spacing
  166 + * @mcs: Supported MCS rates
  167 + */
  168 +struct ieee80211_sta_ht_cap {
  169 + u16 cap; /* use IEEE80211_HT_CAP_ */
  170 + bool ht_supported;
  171 + u8 ampdu_factor;
  172 + u8 ampdu_density;
  173 + struct ieee80211_mcs_info mcs;
56 174 };
57 175  
58   -extern int ieee80211_radiotap_iterator_init(
59   - struct ieee80211_radiotap_iterator *iterator,
60   - struct ieee80211_radiotap_header *radiotap_header,
61   - int max_length);
  176 +/**
  177 + * struct ieee80211_supported_band - frequency band definition
  178 + *
  179 + * This structure describes a frequency band a wiphy
  180 + * is able to operate in.
  181 + *
  182 + * @channels: Array of channels the hardware can operate in
  183 + * in this band.
  184 + * @band: the band this structure represents
  185 + * @n_channels: Number of channels in @channels
  186 + * @bitrates: Array of bitrates the hardware can operate with
  187 + * in this band. Must be sorted to give a valid "supported
  188 + * rates" IE, i.e. CCK rates first, then OFDM.
  189 + * @n_bitrates: Number of bitrates in @bitrates
  190 + */
  191 +struct ieee80211_supported_band {
  192 + struct ieee80211_channel *channels;
  193 + struct ieee80211_rate *bitrates;
  194 + enum ieee80211_band band;
  195 + int n_channels;
  196 + int n_bitrates;
  197 + struct ieee80211_sta_ht_cap ht_cap;
  198 +};
62 199  
63   -extern int ieee80211_radiotap_iterator_next(
64   - struct ieee80211_radiotap_iterator *iterator);
  200 +/*
  201 + * Wireless hardware/device configuration structures and methods
  202 + */
65 203  
  204 +/**
  205 + * struct vif_params - describes virtual interface parameters
  206 + * @mesh_id: mesh ID to use
  207 + * @mesh_id_len: length of the mesh ID
  208 + */
  209 +struct vif_params {
  210 + u8 *mesh_id;
  211 + int mesh_id_len;
  212 +};
66 213  
67   - /**
  214 +/**
68 215 * struct key_params - key information
69 216 *
70 217 * Information about a key
... ... @@ -347,92 +494,6 @@
347 494 u8 basic_rates_len;
348 495 };
349 496  
350   -/**
351   - * enum environment_cap - Environment parsed from country IE
352   - * @ENVIRON_ANY: indicates country IE applies to both indoor and
353   - * outdoor operation.
354   - * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation
355   - * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation
356   - */
357   -enum environment_cap {
358   - ENVIRON_ANY,
359   - ENVIRON_INDOOR,
360   - ENVIRON_OUTDOOR,
361   -};
362   -
363   -/**
364   - * struct regulatory_request - used to keep track of regulatory requests
365   - *
366   - * @wiphy_idx: this is set if this request's initiator is
367   - * %REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This
368   - * can be used by the wireless core to deal with conflicts
369   - * and potentially inform users of which devices specifically
370   - * cased the conflicts.
371   - * @initiator: indicates who sent this request, could be any of
372   - * of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*)
373   - * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
374   - * regulatory domain. We have a few special codes:
375   - * 00 - World regulatory domain
376   - * 99 - built by driver but a specific alpha2 cannot be determined
377   - * 98 - result of an intersection between two regulatory domains
378   - * @intersect: indicates whether the wireless core should intersect
379   - * the requested regulatory domain with the presently set regulatory
380   - * domain.
381   - * @country_ie_checksum: checksum of the last processed and accepted
382   - * country IE
383   - * @country_ie_env: lets us know if the AP is telling us we are outdoor,
384   - * indoor, or if it doesn't matter
385   - * @list: used to insert into the reg_requests_list linked list
386   - */
387   -struct regulatory_request {
388   - int wiphy_idx;
389   - enum nl80211_reg_initiator initiator;
390   - char alpha2[2];
391   - bool intersect;
392   - u32 country_ie_checksum;
393   - enum environment_cap country_ie_env;
394   - struct list_head list;
395   -};
396   -
397   -struct ieee80211_freq_range {
398   - u32 start_freq_khz;
399   - u32 end_freq_khz;
400   - u32 max_bandwidth_khz;
401   -};
402   -
403   -struct ieee80211_power_rule {
404   - u32 max_antenna_gain;
405   - u32 max_eirp;
406   -};
407   -
408   -struct ieee80211_reg_rule {
409   - struct ieee80211_freq_range freq_range;
410   - struct ieee80211_power_rule power_rule;
411   - u32 flags;
412   -};
413   -
414   -struct ieee80211_regdomain {
415   - u32 n_reg_rules;
416   - char alpha2[2];
417   - struct ieee80211_reg_rule reg_rules[];
418   -};
419   -
420   -#define MHZ_TO_KHZ(freq) ((freq) * 1000)
421   -#define KHZ_TO_MHZ(freq) ((freq) / 1000)
422   -#define DBI_TO_MBI(gain) ((gain) * 100)
423   -#define MBI_TO_DBI(gain) ((gain) / 100)
424   -#define DBM_TO_MBM(gain) ((gain) * 100)
425   -#define MBM_TO_DBM(gain) ((gain) / 100)
426   -
427   -#define REG_RULE(start, end, bw, gain, eirp, reg_flags) { \
428   - .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \
429   - .freq_range.end_freq_khz = MHZ_TO_KHZ(end), \
430   - .freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw), \
431   - .power_rule.max_antenna_gain = DBI_TO_MBI(gain), \
432   - .power_rule.max_eirp = DBM_TO_MBM(eirp), \
433   - .flags = reg_flags, \
434   - }
435   -
436 497 struct mesh_config {
437 498 /* Timeouts in ms */
438 499 /* Mesh plink management parameters */
... ... @@ -853,7 +914,396 @@
853 914 int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev);
854 915 };
855 916  
856   -/* temporary wext handlers */
  917 +/*
  918 + * wireless hardware and networking interfaces structures
  919 + * and registration/helper functions
  920 + */
  921 +
  922 +/**
  923 + * struct wiphy - wireless hardware description
  924 + * @idx: the wiphy index assigned to this item
  925 + * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
  926 + * @custom_regulatory: tells us the driver for this device
  927 + * has its own custom regulatory domain and cannot identify the
  928 + * ISO / IEC 3166 alpha2 it belongs to. When this is enabled
  929 + * we will disregard the first regulatory hint (when the
  930 + * initiator is %REGDOM_SET_BY_CORE).
  931 + * @strict_regulatory: tells us the driver for this device will ignore
  932 + * regulatory domain settings until it gets its own regulatory domain
  933 + * via its regulatory_hint(). After its gets its own regulatory domain
  934 + * it will only allow further regulatory domain settings to further
  935 + * enhance compliance. For example if channel 13 and 14 are disabled
  936 + * by this regulatory domain no user regulatory domain can enable these
  937 + * channels at a later time. This can be used for devices which do not
  938 + * have calibration information gauranteed for frequencies or settings
  939 + * outside of its regulatory domain.
  940 + * @reg_notifier: the driver's regulatory notification callback
  941 + * @regd: the driver's regulatory domain, if one was requested via
  942 + * the regulatory_hint() API. This can be used by the driver
  943 + * on the reg_notifier() if it chooses to ignore future
  944 + * regulatory domain changes caused by other drivers.
  945 + * @signal_type: signal type reported in &struct cfg80211_bss.
  946 + * @cipher_suites: supported cipher suites
  947 + * @n_cipher_suites: number of supported cipher suites
  948 + */
  949 +struct wiphy {
  950 + /* assign these fields before you register the wiphy */
  951 +
  952 + /* permanent MAC address */
  953 + u8 perm_addr[ETH_ALEN];
  954 +
  955 + /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
  956 + u16 interface_modes;
  957 +
  958 + bool custom_regulatory;
  959 + bool strict_regulatory;
  960 +
  961 + enum cfg80211_signal_type signal_type;
  962 +
  963 + int bss_priv_size;
  964 + u8 max_scan_ssids;
  965 + u16 max_scan_ie_len;
  966 +
  967 + int n_cipher_suites;
  968 + const u32 *cipher_suites;
  969 +
  970 + /* If multiple wiphys are registered and you're handed e.g.
  971 + * a regular netdev with assigned ieee80211_ptr, you won't
  972 + * know whether it points to a wiphy your driver has registered
  973 + * or not. Assign this to something global to your driver to
  974 + * help determine whether you own this wiphy or not. */
  975 + void *privid;
  976 +
  977 + struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
  978 +
  979 + /* Lets us get back the wiphy on the callback */
  980 + int (*reg_notifier)(struct wiphy *wiphy,
  981 + struct regulatory_request *request);
  982 +
  983 + /* fields below are read-only, assigned by cfg80211 */
  984 +
  985 + const struct ieee80211_regdomain *regd;
  986 +
  987 + /* the item in /sys/class/ieee80211/ points to this,
  988 + * you need use set_wiphy_dev() (see below) */
  989 + struct device dev;
  990 +
  991 + /* dir in debugfs: ieee80211/<wiphyname> */
  992 + struct dentry *debugfsdir;
  993 +
  994 + char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
  995 +};
  996 +
  997 +/**
  998 + * wiphy_priv - return priv from wiphy
  999 + *
  1000 + * @wiphy: the wiphy whose priv pointer to return
  1001 + */
  1002 +static inline void *wiphy_priv(struct wiphy *wiphy)
  1003 +{
  1004 + BUG_ON(!wiphy);
  1005 + return &wiphy->priv;
  1006 +}
  1007 +
  1008 +/**
  1009 + * set_wiphy_dev - set device pointer for wiphy
  1010 + *
  1011 + * @wiphy: The wiphy whose device to bind
  1012 + * @dev: The device to parent it to
  1013 + */
  1014 +static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
  1015 +{
  1016 + wiphy->dev.parent = dev;
  1017 +}
  1018 +
  1019 +/**
  1020 + * wiphy_dev - get wiphy dev pointer
  1021 + *
  1022 + * @wiphy: The wiphy whose device struct to look up
  1023 + */
  1024 +static inline struct device *wiphy_dev(struct wiphy *wiphy)
  1025 +{
  1026 + return wiphy->dev.parent;
  1027 +}
  1028 +
  1029 +/**
  1030 + * wiphy_name - get wiphy name
  1031 + *
  1032 + * @wiphy: The wiphy whose name to return
  1033 + */
  1034 +static inline const char *wiphy_name(struct wiphy *wiphy)
  1035 +{
  1036 + return dev_name(&wiphy->dev);
  1037 +}
  1038 +
  1039 +/**
  1040 + * wiphy_new - create a new wiphy for use with cfg80211
  1041 + *
  1042 + * @ops: The configuration operations for this device
  1043 + * @sizeof_priv: The size of the private area to allocate
  1044 + *
  1045 + * Create a new wiphy and associate the given operations with it.
  1046 + * @sizeof_priv bytes are allocated for private use.
  1047 + *
  1048 + * The returned pointer must be assigned to each netdev's
  1049 + * ieee80211_ptr for proper operation.
  1050 + */
  1051 +struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
  1052 +
  1053 +/**
  1054 + * wiphy_register - register a wiphy with cfg80211
  1055 + *
  1056 + * @wiphy: The wiphy to register.
  1057 + *
  1058 + * Returns a non-negative wiphy index or a negative error code.
  1059 + */
  1060 +extern int wiphy_register(struct wiphy *wiphy);
  1061 +
  1062 +/**
  1063 + * wiphy_unregister - deregister a wiphy from cfg80211
  1064 + *
  1065 + * @wiphy: The wiphy to unregister.
  1066 + *
  1067 + * After this call, no more requests can be made with this priv
  1068 + * pointer, but the call may sleep to wait for an outstanding
  1069 + * request that is being handled.
  1070 + */
  1071 +extern void wiphy_unregister(struct wiphy *wiphy);
  1072 +
  1073 +/**
  1074 + * wiphy_free - free wiphy
  1075 + *
  1076 + * @wiphy: The wiphy to free
  1077 + */
  1078 +extern void wiphy_free(struct wiphy *wiphy);
  1079 +
  1080 +/**
  1081 + * struct wireless_dev - wireless per-netdev state
  1082 + *
  1083 + * This structure must be allocated by the driver/stack
  1084 + * that uses the ieee80211_ptr field in struct net_device
  1085 + * (this is intentional so it can be allocated along with
  1086 + * the netdev.)
  1087 + *
  1088 + * @wiphy: pointer to hardware description
  1089 + * @iftype: interface type
  1090 + * @list: (private) Used to collect the interfaces
  1091 + * @netdev: (private) Used to reference back to the netdev
  1092 + * @current_bss: (private) Used by the internal configuration code
  1093 + * @bssid: (private) Used by the internal configuration code
  1094 + * @ssid: (private) Used by the internal configuration code
  1095 + * @ssid_len: (private) Used by the internal configuration code
  1096 + * @wext: (private) Used by the internal wireless extensions compat code
  1097 + * @wext_bssid: (private) Used by the internal wireless extensions compat code
  1098 + */
  1099 +struct wireless_dev {
  1100 + struct wiphy *wiphy;
  1101 + enum nl80211_iftype iftype;
  1102 +
  1103 + /* private to the generic wireless code */
  1104 + struct list_head list;
  1105 + struct net_device *netdev;
  1106 +
  1107 + /* currently used for IBSS - might be rearranged in the future */
  1108 + struct cfg80211_bss *current_bss;
  1109 + u8 bssid[ETH_ALEN];
  1110 + u8 ssid[IEEE80211_MAX_SSID_LEN];
  1111 + u8 ssid_len;
  1112 +
  1113 +#ifdef CONFIG_WIRELESS_EXT
  1114 + /* wext data */
  1115 + struct cfg80211_ibss_params wext;
  1116 + u8 wext_bssid[ETH_ALEN];
  1117 +#endif
  1118 +};
  1119 +
  1120 +/**
  1121 + * wdev_priv - return wiphy priv from wireless_dev
  1122 + *
  1123 + * @wdev: The wireless device whose wiphy's priv pointer to return
  1124 + */
  1125 +static inline void *wdev_priv(struct wireless_dev *wdev)
  1126 +{
  1127 + BUG_ON(!wdev);
  1128 + return wiphy_priv(wdev->wiphy);
  1129 +}
  1130 +
  1131 +/*
  1132 + * Utility functions
  1133 + */
  1134 +
  1135 +/**
  1136 + * ieee80211_channel_to_frequency - convert channel number to frequency
  1137 + */
  1138 +extern int ieee80211_channel_to_frequency(int chan);
  1139 +
  1140 +/**
  1141 + * ieee80211_frequency_to_channel - convert frequency to channel number
  1142 + */
  1143 +extern int ieee80211_frequency_to_channel(int freq);
  1144 +
  1145 +/*
  1146 + * Name indirection necessary because the ieee80211 code also has
  1147 + * a function named "ieee80211_get_channel", so if you include
  1148 + * cfg80211's header file you get cfg80211's version, if you try
  1149 + * to include both header files you'll (rightfully!) get a symbol
  1150 + * clash.
  1151 + */
  1152 +extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
  1153 + int freq);
  1154 +/**
  1155 + * ieee80211_get_channel - get channel struct from wiphy for specified frequency
  1156 + */
  1157 +static inline struct ieee80211_channel *
  1158 +ieee80211_get_channel(struct wiphy *wiphy, int freq)
  1159 +{
  1160 + return __ieee80211_get_channel(wiphy, freq);
  1161 +}
  1162 +
  1163 +/**
  1164 + * ieee80211_get_response_rate - get basic rate for a given rate
  1165 + *
  1166 + * @sband: the band to look for rates in
  1167 + * @basic_rates: bitmap of basic rates
  1168 + * @bitrate: the bitrate for which to find the basic rate
  1169 + *
  1170 + * This function returns the basic rate corresponding to a given
  1171 + * bitrate, that is the next lower bitrate contained in the basic
  1172 + * rate map, which is, for this function, given as a bitmap of
  1173 + * indices of rates in the band's bitrate table.
  1174 + */
  1175 +struct ieee80211_rate *
  1176 +ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
  1177 + u32 basic_rates, int bitrate);
  1178 +
  1179 +/*
  1180 + * Radiotap parsing functions -- for controlled injection support
  1181 + *
  1182 + * Implemented in net/wireless/radiotap.c
  1183 + * Documentation in Documentation/networking/radiotap-headers.txt
  1184 + */
  1185 +
  1186 +/**
  1187 + * struct ieee80211_radiotap_iterator - tracks walk thru present radiotap args
  1188 + * @rtheader: pointer to the radiotap header we are walking through
  1189 + * @max_length: length of radiotap header in cpu byte ordering
  1190 + * @this_arg_index: IEEE80211_RADIOTAP_... index of current arg
  1191 + * @this_arg: pointer to current radiotap arg
  1192 + * @arg_index: internal next argument index
  1193 + * @arg: internal next argument pointer
  1194 + * @next_bitmap: internal pointer to next present u32
  1195 + * @bitmap_shifter: internal shifter for curr u32 bitmap, b0 set == arg present
  1196 + */
  1197 +
  1198 +struct ieee80211_radiotap_iterator {
  1199 + struct ieee80211_radiotap_header *rtheader;
  1200 + int max_length;
  1201 + int this_arg_index;
  1202 + u8 *this_arg;
  1203 +
  1204 + int arg_index;
  1205 + u8 *arg;
  1206 + __le32 *next_bitmap;
  1207 + u32 bitmap_shifter;
  1208 +};
  1209 +
  1210 +extern int ieee80211_radiotap_iterator_init(
  1211 + struct ieee80211_radiotap_iterator *iterator,
  1212 + struct ieee80211_radiotap_header *radiotap_header,
  1213 + int max_length);
  1214 +
  1215 +extern int ieee80211_radiotap_iterator_next(
  1216 + struct ieee80211_radiotap_iterator *iterator);
  1217 +
  1218 +/*
  1219 + * Regulatory helper functions for wiphys
  1220 + */
  1221 +
  1222 +/**
  1223 + * regulatory_hint - driver hint to the wireless core a regulatory domain
  1224 + * @wiphy: the wireless device giving the hint (used only for reporting
  1225 + * conflicts)
  1226 + * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
  1227 + * should be in. If @rd is set this should be NULL. Note that if you
  1228 + * set this to NULL you should still set rd->alpha2 to some accepted
  1229 + * alpha2.
  1230 + *
  1231 + * Wireless drivers can use this function to hint to the wireless core
  1232 + * what it believes should be the current regulatory domain by
  1233 + * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
  1234 + * domain should be in or by providing a completely build regulatory domain.
  1235 + * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
  1236 + * for a regulatory domain structure for the respective country.
  1237 + *
  1238 + * The wiphy must have been registered to cfg80211 prior to this call.
  1239 + * For cfg80211 drivers this means you must first use wiphy_register(),
  1240 + * for mac80211 drivers you must first use ieee80211_register_hw().
  1241 + *
  1242 + * Drivers should check the return value, its possible you can get
  1243 + * an -ENOMEM.
  1244 + */
  1245 +extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
  1246 +
  1247 +/**
  1248 + * regulatory_hint_11d - hints a country IE as a regulatory domain
  1249 + * @wiphy: the wireless device giving the hint (used only for reporting
  1250 + * conflicts)
  1251 + * @country_ie: pointer to the country IE
  1252 + * @country_ie_len: length of the country IE
  1253 + *
  1254 + * We will intersect the rd with the what CRDA tells us should apply
  1255 + * for the alpha2 this country IE belongs to, this prevents APs from
  1256 + * sending us incorrect or outdated information against a country.
  1257 + */
  1258 +extern void regulatory_hint_11d(struct wiphy *wiphy,
  1259 + u8 *country_ie,
  1260 + u8 country_ie_len);
  1261 +/**
  1262 + * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
  1263 + * @wiphy: the wireless device we want to process the regulatory domain on
  1264 + * @regd: the custom regulatory domain to use for this wiphy
  1265 + *
  1266 + * Drivers can sometimes have custom regulatory domains which do not apply
  1267 + * to a specific country. Drivers can use this to apply such custom regulatory
  1268 + * domains. This routine must be called prior to wiphy registration. The
  1269 + * custom regulatory domain will be trusted completely and as such previous
  1270 + * default channel settings will be disregarded. If no rule is found for a
  1271 + * channel on the regulatory domain the channel will be disabled.
  1272 + */
  1273 +extern void wiphy_apply_custom_regulatory(
  1274 + struct wiphy *wiphy,
  1275 + const struct ieee80211_regdomain *regd);
  1276 +
  1277 +/**
  1278 + * freq_reg_info - get regulatory information for the given frequency
  1279 + * @wiphy: the wiphy for which we want to process this rule for
  1280 + * @center_freq: Frequency in KHz for which we want regulatory information for
  1281 + * @bandwidth: the bandwidth requirement you have in KHz, if you do not have one
  1282 + * you can set this to 0. If this frequency is allowed we then set
  1283 + * this value to the maximum allowed bandwidth.
  1284 + * @reg_rule: the regulatory rule which we have for this frequency
  1285 + *
  1286 + * Use this function to get the regulatory rule for a specific frequency on
  1287 + * a given wireless device. If the device has a specific regulatory domain
  1288 + * it wants to follow we respect that unless a country IE has been received
  1289 + * and processed already.
  1290 + *
  1291 + * Returns 0 if it was able to find a valid regulatory rule which does
  1292 + * apply to the given center_freq otherwise it returns non-zero. It will
  1293 + * also return -ERANGE if we determine the given center_freq does not even have
  1294 + * a regulatory rule for a frequency range in the center_freq's band. See
  1295 + * freq_in_rule_band() for our current definition of a band -- this is purely
  1296 + * subjective and right now its 802.11 specific.
  1297 + */
  1298 +extern int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 *bandwidth,
  1299 + const struct ieee80211_reg_rule **reg_rule);
  1300 +
  1301 +/*
  1302 + * Temporary wext handlers & helper functions
  1303 + *
  1304 + * In the future cfg80211 will simply assign the entire wext handler
  1305 + * structure to netdevs it manages, but we're not there yet.
  1306 + */
857 1307 int cfg80211_wext_giwname(struct net_device *dev,
858 1308 struct iw_request_info *info,
859 1309 char *name, char *extra);
860 1310  
... ... @@ -892,10 +1342,14 @@
892 1342 struct iw_request_info *info,
893 1343 struct sockaddr *ap_addr, char *extra);
894 1344  
895   -/* wext helper for now (to be removed) */
896 1345 struct ieee80211_channel *cfg80211_wext_freq(struct wiphy *wiphy,
897 1346 struct iw_freq *freq);
898 1347  
  1348 +/*
  1349 + * callbacks for asynchronous cfg80211 methods, notification
  1350 + * functions and BSS handling helpers
  1351 + */
  1352 +
899 1353 /**
900 1354 * cfg80211_scan_done - notify that scan finished
901 1355 *
... ... @@ -949,6 +1403,7 @@
949 1403 const u8 *meshid, size_t meshidlen,
950 1404 const u8 *meshcfg);
951 1405 void cfg80211_put_bss(struct cfg80211_bss *bss);
  1406 +
952 1407 /**
953 1408 * cfg80211_unlink_bss - unlink BSS from internal data structures
954 1409 * @wiphy: the wiphy
include/net/mac80211.h
... ... @@ -19,7 +19,6 @@
19 19 #include <linux/wireless.h>
20 20 #include <linux/device.h>
21 21 #include <linux/ieee80211.h>
22   -#include <net/wireless.h>
23 22 #include <net/cfg80211.h>
24 23  
25 24 /**
include/net/regulatory.h
  1 +#ifndef __NET_REGULATORY_H
  2 +#define __NET_REGULATORY_H
  3 +/*
  4 + * regulatory support structures
  5 + *
  6 + * Copyright 2008-2009 Luis R. Rodriguez <lrodriguez@atheros.com>
  7 + *
  8 + * This program is free software; you can redistribute it and/or modify
  9 + * it under the terms of the GNU General Public License version 2 as
  10 + * published by the Free Software Foundation.
  11 + */
  12 +
  13 +
  14 +/**
  15 + * enum environment_cap - Environment parsed from country IE
  16 + * @ENVIRON_ANY: indicates country IE applies to both indoor and
  17 + * outdoor operation.
  18 + * @ENVIRON_INDOOR: indicates country IE applies only to indoor operation
  19 + * @ENVIRON_OUTDOOR: indicates country IE applies only to outdoor operation
  20 + */
  21 +enum environment_cap {
  22 + ENVIRON_ANY,
  23 + ENVIRON_INDOOR,
  24 + ENVIRON_OUTDOOR,
  25 +};
  26 +
  27 +/**
  28 + * struct regulatory_request - used to keep track of regulatory requests
  29 + *
  30 + * @wiphy_idx: this is set if this request's initiator is
  31 + * %REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This
  32 + * can be used by the wireless core to deal with conflicts
  33 + * and potentially inform users of which devices specifically
  34 + * cased the conflicts.
  35 + * @initiator: indicates who sent this request, could be any of
  36 + * of those set in nl80211_reg_initiator (%NL80211_REGDOM_SET_BY_*)
  37 + * @alpha2: the ISO / IEC 3166 alpha2 country code of the requested
  38 + * regulatory domain. We have a few special codes:
  39 + * 00 - World regulatory domain
  40 + * 99 - built by driver but a specific alpha2 cannot be determined
  41 + * 98 - result of an intersection between two regulatory domains
  42 + * @intersect: indicates whether the wireless core should intersect
  43 + * the requested regulatory domain with the presently set regulatory
  44 + * domain.
  45 + * @country_ie_checksum: checksum of the last processed and accepted
  46 + * country IE
  47 + * @country_ie_env: lets us know if the AP is telling us we are outdoor,
  48 + * indoor, or if it doesn't matter
  49 + * @list: used to insert into the reg_requests_list linked list
  50 + */
  51 +struct regulatory_request {
  52 + int wiphy_idx;
  53 + enum nl80211_reg_initiator initiator;
  54 + char alpha2[2];
  55 + bool intersect;
  56 + u32 country_ie_checksum;
  57 + enum environment_cap country_ie_env;
  58 + struct list_head list;
  59 +};
  60 +
  61 +struct ieee80211_freq_range {
  62 + u32 start_freq_khz;
  63 + u32 end_freq_khz;
  64 + u32 max_bandwidth_khz;
  65 +};
  66 +
  67 +struct ieee80211_power_rule {
  68 + u32 max_antenna_gain;
  69 + u32 max_eirp;
  70 +};
  71 +
  72 +struct ieee80211_reg_rule {
  73 + struct ieee80211_freq_range freq_range;
  74 + struct ieee80211_power_rule power_rule;
  75 + u32 flags;
  76 +};
  77 +
  78 +struct ieee80211_regdomain {
  79 + u32 n_reg_rules;
  80 + char alpha2[2];
  81 + struct ieee80211_reg_rule reg_rules[];
  82 +};
  83 +
  84 +#define MHZ_TO_KHZ(freq) ((freq) * 1000)
  85 +#define KHZ_TO_MHZ(freq) ((freq) / 1000)
  86 +#define DBI_TO_MBI(gain) ((gain) * 100)
  87 +#define MBI_TO_DBI(gain) ((gain) / 100)
  88 +#define DBM_TO_MBM(gain) ((gain) * 100)
  89 +#define MBM_TO_DBM(gain) ((gain) / 100)
  90 +
  91 +#define REG_RULE(start, end, bw, gain, eirp, reg_flags) \
  92 +{ \
  93 + .freq_range.start_freq_khz = MHZ_TO_KHZ(start), \
  94 + .freq_range.end_freq_khz = MHZ_TO_KHZ(end), \
  95 + .freq_range.max_bandwidth_khz = MHZ_TO_KHZ(bw), \
  96 + .power_rule.max_antenna_gain = DBI_TO_MBI(gain),\
  97 + .power_rule.max_eirp = DBM_TO_MBM(eirp), \
  98 + .flags = reg_flags, \
  99 +}
  100 +
  101 +#endif
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 <linux/ieee80211.h>
14   -#include <net/cfg80211.h>
15   -
16   -/**
17   - * enum ieee80211_band - supported frequency bands
18   - *
19   - * The bands are assigned this way because the supported
20   - * bitrates differ in these bands.
21   - *
22   - * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band
23   - * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7)
24   - */
25   -enum ieee80211_band {
26   - IEEE80211_BAND_2GHZ,
27   - IEEE80211_BAND_5GHZ,
28   -
29   - /* keep last */
30   - IEEE80211_NUM_BANDS
31   -};
32   -
33   -/**
34   - * enum ieee80211_channel_flags - channel flags
35   - *
36   - * Channel flags set by the regulatory control code.
37   - *
38   - * @IEEE80211_CHAN_DISABLED: This channel is disabled.
39   - * @IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted
40   - * on this channel.
41   - * @IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel.
42   - * @IEEE80211_CHAN_RADAR: Radar detection is required on this channel.
43   - * @IEEE80211_CHAN_NO_FAT_ABOVE: extension channel above this channel
44   - * is not permitted.
45   - * @IEEE80211_CHAN_NO_FAT_BELOW: extension channel below this channel
46   - * is not permitted.
47   - */
48   -enum ieee80211_channel_flags {
49   - IEEE80211_CHAN_DISABLED = 1<<0,
50   - IEEE80211_CHAN_PASSIVE_SCAN = 1<<1,
51   - IEEE80211_CHAN_NO_IBSS = 1<<2,
52   - IEEE80211_CHAN_RADAR = 1<<3,
53   - IEEE80211_CHAN_NO_FAT_ABOVE = 1<<4,
54   - IEEE80211_CHAN_NO_FAT_BELOW = 1<<5,
55   -};
56   -
57   -/**
58   - * struct ieee80211_channel - channel definition
59   - *
60   - * This structure describes a single channel for use
61   - * with cfg80211.
62   - *
63   - * @center_freq: center frequency in MHz
64   - * @max_bandwidth: maximum allowed bandwidth for this channel, in MHz
65   - * @hw_value: hardware-specific value for the channel
66   - * @flags: channel flags from &enum ieee80211_channel_flags.
67   - * @orig_flags: channel flags at registration time, used by regulatory
68   - * code to support devices with additional restrictions
69   - * @band: band this channel belongs to.
70   - * @max_antenna_gain: maximum antenna gain in dBi
71   - * @max_power: maximum transmission power (in dBm)
72   - * @beacon_found: helper to regulatory code to indicate when a beacon
73   - * has been found on this channel. Use regulatory_hint_found_beacon()
74   - * to enable this, this is is useful only on 5 GHz band.
75   - * @orig_mag: internal use
76   - * @orig_mpwr: internal use
77   - */
78   -struct ieee80211_channel {
79   - enum ieee80211_band band;
80   - u16 center_freq;
81   - u8 max_bandwidth;
82   - u16 hw_value;
83   - u32 flags;
84   - int max_antenna_gain;
85   - int max_power;
86   - bool beacon_found;
87   - u32 orig_flags;
88   - int orig_mag, orig_mpwr;
89   -};
90   -
91   -/**
92   - * enum ieee80211_rate_flags - rate flags
93   - *
94   - * Hardware/specification flags for rates. These are structured
95   - * in a way that allows using the same bitrate structure for
96   - * different bands/PHY modes.
97   - *
98   - * @IEEE80211_RATE_SHORT_PREAMBLE: Hardware can send with short
99   - * preamble on this bitrate; only relevant in 2.4GHz band and
100   - * with CCK rates.
101   - * @IEEE80211_RATE_MANDATORY_A: This bitrate is a mandatory rate
102   - * when used with 802.11a (on the 5 GHz band); filled by the
103   - * core code when registering the wiphy.
104   - * @IEEE80211_RATE_MANDATORY_B: This bitrate is a mandatory rate
105   - * when used with 802.11b (on the 2.4 GHz band); filled by the
106   - * core code when registering the wiphy.
107   - * @IEEE80211_RATE_MANDATORY_G: This bitrate is a mandatory rate
108   - * when used with 802.11g (on the 2.4 GHz band); filled by the
109   - * core code when registering the wiphy.
110   - * @IEEE80211_RATE_ERP_G: This is an ERP rate in 802.11g mode.
111   - */
112   -enum ieee80211_rate_flags {
113   - IEEE80211_RATE_SHORT_PREAMBLE = 1<<0,
114   - IEEE80211_RATE_MANDATORY_A = 1<<1,
115   - IEEE80211_RATE_MANDATORY_B = 1<<2,
116   - IEEE80211_RATE_MANDATORY_G = 1<<3,
117   - IEEE80211_RATE_ERP_G = 1<<4,
118   -};
119   -
120   -/**
121   - * struct ieee80211_rate - bitrate definition
122   - *
123   - * This structure describes a bitrate that an 802.11 PHY can
124   - * operate with. The two values @hw_value and @hw_value_short
125   - * are only for driver use when pointers to this structure are
126   - * passed around.
127   - *
128   - * @flags: rate-specific flags
129   - * @bitrate: bitrate in units of 100 Kbps
130   - * @hw_value: driver/hardware value for this rate
131   - * @hw_value_short: driver/hardware value for this rate when
132   - * short preamble is used
133   - */
134   -struct ieee80211_rate {
135   - u32 flags;
136   - u16 bitrate;
137   - u16 hw_value, hw_value_short;
138   -};
139   -
140   -/**
141   - * struct ieee80211_sta_ht_cap - STA's HT capabilities
142   - *
143   - * This structure describes most essential parameters needed
144   - * to describe 802.11n HT capabilities for an STA.
145   - *
146   - * @ht_supported: is HT supported by the STA
147   - * @cap: HT capabilities map as described in 802.11n spec
148   - * @ampdu_factor: Maximum A-MPDU length factor
149   - * @ampdu_density: Minimum A-MPDU spacing
150   - * @mcs: Supported MCS rates
151   - */
152   -struct ieee80211_sta_ht_cap {
153   - u16 cap; /* use IEEE80211_HT_CAP_ */
154   - bool ht_supported;
155   - u8 ampdu_factor;
156   - u8 ampdu_density;
157   - struct ieee80211_mcs_info mcs;
158   -};
159   -
160   -/**
161   - * struct ieee80211_supported_band - frequency band definition
162   - *
163   - * This structure describes a frequency band a wiphy
164   - * is able to operate in.
165   - *
166   - * @channels: Array of channels the hardware can operate in
167   - * in this band.
168   - * @band: the band this structure represents
169   - * @n_channels: Number of channels in @channels
170   - * @bitrates: Array of bitrates the hardware can operate with
171   - * in this band. Must be sorted to give a valid "supported
172   - * rates" IE, i.e. CCK rates first, then OFDM.
173   - * @n_bitrates: Number of bitrates in @bitrates
174   - */
175   -struct ieee80211_supported_band {
176   - struct ieee80211_channel *channels;
177   - struct ieee80211_rate *bitrates;
178   - enum ieee80211_band band;
179   - int n_channels;
180   - int n_bitrates;
181   - struct ieee80211_sta_ht_cap ht_cap;
182   -};
183   -
184   -/**
185   - * struct wiphy - wireless hardware description
186   - * @idx: the wiphy index assigned to this item
187   - * @class_dev: the class device representing /sys/class/ieee80211/<wiphy-name>
188   - * @custom_regulatory: tells us the driver for this device
189   - * has its own custom regulatory domain and cannot identify the
190   - * ISO / IEC 3166 alpha2 it belongs to. When this is enabled
191   - * we will disregard the first regulatory hint (when the
192   - * initiator is %REGDOM_SET_BY_CORE).
193   - * @strict_regulatory: tells us the driver for this device will ignore
194   - * regulatory domain settings until it gets its own regulatory domain
195   - * via its regulatory_hint(). After its gets its own regulatory domain
196   - * it will only allow further regulatory domain settings to further
197   - * enhance compliance. For example if channel 13 and 14 are disabled
198   - * by this regulatory domain no user regulatory domain can enable these
199   - * channels at a later time. This can be used for devices which do not
200   - * have calibration information gauranteed for frequencies or settings
201   - * outside of its regulatory domain.
202   - * @reg_notifier: the driver's regulatory notification callback
203   - * @regd: the driver's regulatory domain, if one was requested via
204   - * the regulatory_hint() API. This can be used by the driver
205   - * on the reg_notifier() if it chooses to ignore future
206   - * regulatory domain changes caused by other drivers.
207   - * @signal_type: signal type reported in &struct cfg80211_bss.
208   - * @cipher_suites: supported cipher suites
209   - * @n_cipher_suites: number of supported cipher suites
210   - */
211   -struct wiphy {
212   - /* assign these fields before you register the wiphy */
213   -
214   - /* permanent MAC address */
215   - u8 perm_addr[ETH_ALEN];
216   -
217   - /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */
218   - u16 interface_modes;
219   -
220   - bool custom_regulatory;
221   - bool strict_regulatory;
222   -
223   - enum cfg80211_signal_type signal_type;
224   -
225   - int bss_priv_size;
226   - u8 max_scan_ssids;
227   - u16 max_scan_ie_len;
228   -
229   - int n_cipher_suites;
230   - const u32 *cipher_suites;
231   -
232   - /* If multiple wiphys are registered and you're handed e.g.
233   - * a regular netdev with assigned ieee80211_ptr, you won't
234   - * know whether it points to a wiphy your driver has registered
235   - * or not. Assign this to something global to your driver to
236   - * help determine whether you own this wiphy or not. */
237   - void *privid;
238   -
239   - struct ieee80211_supported_band *bands[IEEE80211_NUM_BANDS];
240   -
241   - /* Lets us get back the wiphy on the callback */
242   - int (*reg_notifier)(struct wiphy *wiphy,
243   - struct regulatory_request *request);
244   -
245   - /* fields below are read-only, assigned by cfg80211 */
246   -
247   - const struct ieee80211_regdomain *regd;
248   -
249   - /* the item in /sys/class/ieee80211/ points to this,
250   - * you need use set_wiphy_dev() (see below) */
251   - struct device dev;
252   -
253   - /* dir in debugfs: ieee80211/<wiphyname> */
254   - struct dentry *debugfsdir;
255   -
256   - char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
257   -};
258   -
259   -/** struct wireless_dev - wireless per-netdev state
260   - *
261   - * This structure must be allocated by the driver/stack
262   - * that uses the ieee80211_ptr field in struct net_device
263   - * (this is intentional so it can be allocated along with
264   - * the netdev.)
265   - *
266   - * @wiphy: pointer to hardware description
267   - * @iftype: interface type
268   - * @list: (private)
269   - * @netdev (private)
270   - */
271   -struct wireless_dev {
272   - struct wiphy *wiphy;
273   - enum nl80211_iftype iftype;
274   -
275   - /* private to the generic wireless code */
276   - struct list_head list;
277   - struct net_device *netdev;
278   -
279   - /* currently used for IBSS - might be rearranged in the future */
280   - struct cfg80211_bss *current_bss;
281   - u8 bssid[ETH_ALEN];
282   - u8 ssid[IEEE80211_MAX_SSID_LEN];
283   - u8 ssid_len;
284   -
285   -#ifdef CONFIG_WIRELESS_EXT
286   - /* wext data */
287   - struct cfg80211_ibss_params wext;
288   - u8 wext_bssid[ETH_ALEN];
289   -#endif
290   -};
291   -
292   -/**
293   - * wiphy_priv - return priv from wiphy
294   - */
295   -static inline void *wiphy_priv(struct wiphy *wiphy)
296   -{
297   - BUG_ON(!wiphy);
298   - return &wiphy->priv;
299   -}
300   -
301   -/**
302   - * set_wiphy_dev - set device pointer for wiphy
303   - */
304   -static inline void set_wiphy_dev(struct wiphy *wiphy, struct device *dev)
305   -{
306   - wiphy->dev.parent = dev;
307   -}
308   -
309   -/**
310   - * wiphy_dev - get wiphy dev pointer
311   - */
312   -static inline struct device *wiphy_dev(struct wiphy *wiphy)
313   -{
314   - return wiphy->dev.parent;
315   -}
316   -
317   -/**
318   - * wiphy_name - get wiphy name
319   - */
320   -static inline const char *wiphy_name(struct wiphy *wiphy)
321   -{
322   - return dev_name(&wiphy->dev);
323   -}
324   -
325   -/**
326   - * wdev_priv - return wiphy priv from wireless_dev
327   - */
328   -static inline void *wdev_priv(struct wireless_dev *wdev)
329   -{
330   - BUG_ON(!wdev);
331   - return wiphy_priv(wdev->wiphy);
332   -}
333   -
334   -/**
335   - * wiphy_new - create a new wiphy for use with cfg80211
336   - *
337   - * create a new wiphy and associate the given operations with it.
338   - * @sizeof_priv bytes are allocated for private use.
339   - *
340   - * the returned pointer must be assigned to each netdev's
341   - * ieee80211_ptr for proper operation.
342   - */
343   -struct wiphy *wiphy_new(struct cfg80211_ops *ops, int sizeof_priv);
344   -
345   -/**
346   - * wiphy_register - register a wiphy with cfg80211
347   - *
348   - * register the given wiphy
349   - *
350   - * Returns a non-negative wiphy index or a negative error code.
351   - */
352   -extern int wiphy_register(struct wiphy *wiphy);
353   -
354   -/**
355   - * wiphy_unregister - deregister a wiphy from cfg80211
356   - *
357   - * unregister a device with the given priv pointer.
358   - * After this call, no more requests can be made with this priv
359   - * pointer, but the call may sleep to wait for an outstanding
360   - * request that is being handled.
361   - */
362   -extern void wiphy_unregister(struct wiphy *wiphy);
363   -
364   -/**
365   - * wiphy_free - free wiphy
366   - */
367   -extern void wiphy_free(struct wiphy *wiphy);
368   -
369   -/**
370   - * ieee80211_channel_to_frequency - convert channel number to frequency
371   - */
372   -extern int ieee80211_channel_to_frequency(int chan);
373   -
374   -/**
375   - * ieee80211_frequency_to_channel - convert frequency to channel number
376   - */
377   -extern int ieee80211_frequency_to_channel(int freq);
378   -
379   -/*
380   - * Name indirection necessary because the ieee80211 code also has
381   - * a function named "ieee80211_get_channel", so if you include
382   - * cfg80211's header file you get cfg80211's version, if you try
383   - * to include both header files you'll (rightfully!) get a symbol
384   - * clash.
385   - */
386   -extern struct ieee80211_channel *__ieee80211_get_channel(struct wiphy *wiphy,
387   - int freq);
388   -/**
389   - * ieee80211_get_channel - get channel struct from wiphy for specified frequency
390   - */
391   -static inline struct ieee80211_channel *
392   -ieee80211_get_channel(struct wiphy *wiphy, int freq)
393   -{
394   - return __ieee80211_get_channel(wiphy, freq);
395   -}
396   -
397   -/**
398   - * ieee80211_get_response_rate - get basic rate for a given rate
399   - *
400   - * @sband: the band to look for rates in
401   - * @basic_rates: bitmap of basic rates
402   - * @bitrate: the bitrate for which to find the basic rate
403   - *
404   - * This function returns the basic rate corresponding to a given
405   - * bitrate, that is the next lower bitrate contained in the basic
406   - * rate map, which is, for this function, given as a bitmap of
407   - * indices of rates in the band's bitrate table.
408   - */
409   -struct ieee80211_rate *
410   -ieee80211_get_response_rate(struct ieee80211_supported_band *sband,
411   - u32 basic_rates, int bitrate);
412   -
413   -/**
414   - * regulatory_hint - driver hint to the wireless core a regulatory domain
415   - * @wiphy: the wireless device giving the hint (used only for reporting
416   - * conflicts)
417   - * @alpha2: the ISO/IEC 3166 alpha2 the driver claims its regulatory domain
418   - * should be in. If @rd is set this should be NULL. Note that if you
419   - * set this to NULL you should still set rd->alpha2 to some accepted
420   - * alpha2.
421   - *
422   - * Wireless drivers can use this function to hint to the wireless core
423   - * what it believes should be the current regulatory domain by
424   - * giving it an ISO/IEC 3166 alpha2 country code it knows its regulatory
425   - * domain should be in or by providing a completely build regulatory domain.
426   - * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried
427   - * for a regulatory domain structure for the respective country.
428   - *
429   - * The wiphy must have been registered to cfg80211 prior to this call.
430   - * For cfg80211 drivers this means you must first use wiphy_register(),
431   - * for mac80211 drivers you must first use ieee80211_register_hw().
432   - *
433   - * Drivers should check the return value, its possible you can get
434   - * an -ENOMEM.
435   - */
436   -extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2);
437   -
438   -/**
439   - * regulatory_hint_11d - hints a country IE as a regulatory domain
440   - * @wiphy: the wireless device giving the hint (used only for reporting
441   - * conflicts)
442   - * @country_ie: pointer to the country IE
443   - * @country_ie_len: length of the country IE
444   - *
445   - * We will intersect the rd with the what CRDA tells us should apply
446   - * for the alpha2 this country IE belongs to, this prevents APs from
447   - * sending us incorrect or outdated information against a country.
448   - */
449   -extern void regulatory_hint_11d(struct wiphy *wiphy,
450   - u8 *country_ie,
451   - u8 country_ie_len);
452   -/**
453   - * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain
454   - * @wiphy: the wireless device we want to process the regulatory domain on
455   - * @regd: the custom regulatory domain to use for this wiphy
456   - *
457   - * Drivers can sometimes have custom regulatory domains which do not apply
458   - * to a specific country. Drivers can use this to apply such custom regulatory
459   - * domains. This routine must be called prior to wiphy registration. The
460   - * custom regulatory domain will be trusted completely and as such previous
461   - * default channel settings will be disregarded. If no rule is found for a
462   - * channel on the regulatory domain the channel will be disabled.
463   - */
464   -extern void wiphy_apply_custom_regulatory(
465   - struct wiphy *wiphy,
466   - const struct ieee80211_regdomain *regd);
467   -
468   -/**
469   - * freq_reg_info - get regulatory information for the given frequency
470   - * @wiphy: the wiphy for which we want to process this rule for
471   - * @center_freq: Frequency in KHz for which we want regulatory information for
472   - * @bandwidth: the bandwidth requirement you have in KHz, if you do not have one
473   - * you can set this to 0. If this frequency is allowed we then set
474   - * this value to the maximum allowed bandwidth.
475   - * @reg_rule: the regulatory rule which we have for this frequency
476   - *
477   - * Use this function to get the regulatory rule for a specific frequency on
478   - * a given wireless device. If the device has a specific regulatory domain
479   - * it wants to follow we respect that unless a country IE has been received
480   - * and processed already.
481   - *
482   - * Returns 0 if it was able to find a valid regulatory rule which does
483   - * apply to the given center_freq otherwise it returns non-zero. It will
484   - * also return -ERANGE if we determine the given center_freq does not even have
485   - * a regulatory rule for a frequency range in the center_freq's band. See
486   - * freq_in_rule_band() for our current definition of a band -- this is purely
487   - * subjective and right now its 802.11 specific.
488   - */
489   -extern int freq_reg_info(struct wiphy *wiphy, u32 center_freq, u32 *bandwidth,
490   - const struct ieee80211_reg_rule **reg_rule);
491   -
492   -#endif /* __NET_WIRELESS_H */
... ... @@ -14,7 +14,6 @@
14 14 */
15 15  
16 16 #include <linux/ieee80211.h>
17   -#include <net/wireless.h>
18 17 #include <net/mac80211.h>
19 18 #include "ieee80211_i.h"
20 19 #include "rate.h"
net/mac80211/ieee80211_i.h
... ... @@ -24,7 +24,6 @@
24 24 #include <linux/spinlock.h>
25 25 #include <linux/etherdevice.h>
26 26 #include <net/cfg80211.h>
27   -#include <net/wireless.h>
28 27 #include <net/iw_handler.h>
29 28 #include <net/mac80211.h>
30 29 #include "key.h"
net/mac80211/spectmgmt.c
... ... @@ -15,7 +15,7 @@
15 15 */
16 16  
17 17 #include <linux/ieee80211.h>
18   -#include <net/wireless.h>
  18 +#include <net/cfg80211.h>
19 19 #include <net/mac80211.h>
20 20 #include "ieee80211_i.h"
21 21 #include "sta_info.h"
... ... @@ -14,7 +14,6 @@
14 14 #include <linux/device.h>
15 15 #include <net/genetlink.h>
16 16 #include <net/cfg80211.h>
17   -#include <net/wireless.h>
18 17 #include "nl80211.h"
19 18 #include "core.h"
20 19 #include "sysfs.h"
... ... @@ -11,7 +11,6 @@
11 11 #include <linux/kref.h>
12 12 #include <linux/rbtree.h>
13 13 #include <net/genetlink.h>
14   -#include <net/wireless.h>
15 14 #include <net/cfg80211.h>
16 15 #include "reg.h"
17 16  
... ... @@ -7,7 +7,6 @@
7 7 #include <linux/etherdevice.h>
8 8 #include <linux/if_arp.h>
9 9 #include <net/cfg80211.h>
10   -#include <net/wireless.h>
11 10 #include "nl80211.h"
12 11  
13 12  
... ... @@ -37,7 +37,6 @@
37 37 #include <linux/random.h>
38 38 #include <linux/nl80211.h>
39 39 #include <linux/platform_device.h>
40   -#include <net/wireless.h>
41 40 #include <net/cfg80211.h>
42 41 #include "core.h"
43 42 #include "reg.h"
1 1 /*
2 2 * Wireless utility functions
3 3 *
4   - * Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
  4 + * Copyright 2007-2009 Johannes Berg <johannes@sipsolutions.net>
5 5 */
6   -#include <net/wireless.h>
7   -#include <asm/bitops.h>
  6 +#include <linux/bitops.h>
  7 +#include <net/cfg80211.h>
8 8 #include "core.h"
9 9  
10 10 struct ieee80211_rate *
net/wireless/wext-compat.c
... ... @@ -12,7 +12,6 @@
12 12 #include <linux/nl80211.h>
13 13 #include <linux/if_arp.h>
14 14 #include <net/iw_handler.h>
15   -#include <net/wireless.h>
16 15 #include <net/cfg80211.h>
17 16 #include "core.h"
18 17