libertas: rework event subscription
[linux-2.6] / drivers / net / wireless / libertas / scan.h
1 /**
2   * Interface for the wlan network scan routines
3   *
4   * Driver interface functions and type declarations for the scan module
5   * implemented in scan.c.
6   */
7 #ifndef _LBS_SCAN_H
8 #define _LBS_SCAN_H
9
10 #include <net/ieee80211.h>
11 #include "hostcmd.h"
12
13 struct lbs_adapter;
14
15 /**
16  *  @brief Maximum number of channels that can be sent in a setuserscan ioctl
17  *
18  *  @sa lbs_ioctl_user_scan_cfg
19  */
20 #define LBS_IOCTL_USER_SCAN_CHAN_MAX  50
21
22 //! Infrastructure BSS scan type in lbs_scan_cmd_config
23 #define LBS_SCAN_BSS_TYPE_BSS         1
24
25 //! Adhoc BSS scan type in lbs_scan_cmd_config
26 #define LBS_SCAN_BSS_TYPE_IBSS        2
27
28 //! Adhoc or Infrastructure BSS scan type in lbs_scan_cmd_config, no filter
29 #define LBS_SCAN_BSS_TYPE_ANY         3
30
31 /**
32  * @brief Structure used internally in the wlan driver to configure a scan.
33  *
34  * Sent to the command processing module to configure the firmware
35  *   scan command prepared by lbs_cmd_80211_scan.
36  *
37  * @sa lbs_scan_networks
38  *
39  */
40 struct lbs_scan_cmd_config {
41     /**
42      *  @brief BSS type to be sent in the firmware command
43      *
44      *  Field can be used to restrict the types of networks returned in the
45      *    scan.  valid settings are:
46      *
47      *   - LBS_SCAN_BSS_TYPE_BSS  (infrastructure)
48      *   - LBS_SCAN_BSS_TYPE_IBSS (adhoc)
49      *   - LBS_SCAN_BSS_TYPE_ANY  (unrestricted, adhoc and infrastructure)
50      */
51         u8 bsstype;
52
53     /**
54      *  @brief Specific BSSID used to filter scan results in the firmware
55      */
56         u8 bssid[ETH_ALEN];
57
58     /**
59      *  @brief length of TLVs sent in command starting at tlvBuffer
60      */
61         int tlvbufferlen;
62
63     /**
64      *  @brief SSID TLV(s) and ChanList TLVs to be sent in the firmware command
65      *
66      *  @sa TLV_TYPE_CHANLIST, mrvlietypes_chanlistparamset_t
67      *  @sa TLV_TYPE_SSID, mrvlietypes_ssidparamset_t
68      */
69         u8 tlvbuffer[1];        //!< SSID TLV(s) and ChanList TLVs are stored here
70 };
71
72 /**
73  *  @brief IOCTL channel sub-structure sent in lbs_ioctl_user_scan_cfg
74  *
75  *  Multiple instances of this structure are included in the IOCTL command
76  *   to configure a instance of a scan on the specific channel.
77  */
78 struct lbs_ioctl_user_scan_chan {
79         u8 channumber;          //!< channel Number to scan
80         u8 radiotype;           //!< Radio type: 'B/G' band = 0, 'A' band = 1
81         u8 scantype;            //!< Scan type: Active = 0, Passive = 1
82         u16 scantime;           //!< Scan duration in milliseconds; if 0 default used
83 };
84
85 /**
86  *  @brief IOCTL input structure to configure an immediate scan cmd to firmware
87  *
88  *  Used in the setuserscan (LBS_SET_USER_SCAN) private ioctl.  Specifies
89  *   a number of parameters to be used in general for the scan as well
90  *   as a channel list (lbs_ioctl_user_scan_chan) for each scan period
91  *   desired.
92  *
93  *  @sa lbs_set_user_scan_ioctl
94  */
95 struct lbs_ioctl_user_scan_cfg {
96     /**
97      *  @brief BSS type to be sent in the firmware command
98      *
99      *  Field can be used to restrict the types of networks returned in the
100      *    scan.  valid settings are:
101      *
102      *   - LBS_SCAN_BSS_TYPE_BSS  (infrastructure)
103      *   - LBS_SCAN_BSS_TYPE_IBSS (adhoc)
104      *   - LBS_SCAN_BSS_TYPE_ANY  (unrestricted, adhoc and infrastructure)
105      */
106         u8 bsstype;
107
108     /**
109      *  @brief Configure the number of probe requests for active chan scans
110      */
111         u8 numprobes;
112
113         /**
114          *  @brief BSSID filter sent in the firmware command to limit the results
115          */
116         u8 bssid[ETH_ALEN];
117
118         /* Clear existing scan results matching this BSSID */
119         u8 clear_bssid;
120
121         /**
122          *  @brief SSID filter sent in the firmware command to limit the results
123          */
124         char ssid[IW_ESSID_MAX_SIZE];
125         u8 ssid_len;
126
127         /* Clear existing scan results matching this SSID */
128         u8 clear_ssid;
129
130     /**
131      *  @brief Variable number (fixed maximum) of channels to scan up
132      */
133         struct lbs_ioctl_user_scan_chan chanlist[LBS_IOCTL_USER_SCAN_CHAN_MAX];
134 };
135
136 /**
137  *  @brief Structure used to store information for each beacon/probe response
138  */
139 struct bss_descriptor {
140         u8 bssid[ETH_ALEN];
141
142         u8 ssid[IW_ESSID_MAX_SIZE + 1];
143         u8 ssid_len;
144
145         u16 capability;
146
147         /* receive signal strength in dBm */
148         long rssi;
149
150         u32 channel;
151
152         u16 beaconperiod;
153
154         u32 atimwindow;
155
156         /* IW_MODE_AUTO, IW_MODE_ADHOC, IW_MODE_INFRA */
157         u8 mode;
158
159         /* zero-terminated array of supported data rates */
160         u8 rates[MAX_RATES + 1];
161
162         unsigned long last_scanned;
163
164         union ieeetypes_phyparamset phyparamset;
165         union IEEEtypes_ssparamset ssparamset;
166
167         struct ieeetypes_countryinfofullset countryinfo;
168
169         u8 wpa_ie[MAX_WPA_IE_LEN];
170         size_t wpa_ie_len;
171         u8 rsn_ie[MAX_WPA_IE_LEN];
172         size_t rsn_ie_len;
173
174         u8 mesh;
175
176         struct list_head list;
177 };
178
179 int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len);
180
181 struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_adapter *adapter,
182                 u8 *ssid, u8 ssid_len, u8 *bssid, u8 mode,
183                 int channel);
184
185 struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_adapter *adapter,
186         u8 *bssid, u8 mode);
187
188 int lbs_find_best_network_ssid(struct lbs_private *priv, u8 *out_ssid,
189                         u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode);
190
191 int lbs_send_specific_ssid_scan(struct lbs_private *priv, u8 *ssid,
192                                 u8 ssid_len, u8 clear_ssid);
193
194 int lbs_cmd_80211_scan(struct lbs_private *priv,
195                                 struct cmd_ds_command *cmd,
196                                 void *pdata_buf);
197
198 int lbs_ret_80211_scan(struct lbs_private *priv,
199                                 struct cmd_ds_command *resp);
200
201 int lbs_scan_networks(struct lbs_private *priv,
202         const struct lbs_ioctl_user_scan_cfg *puserscanin,
203                 int full_scan);
204
205 struct ifreq;
206
207 struct iw_point;
208 struct iw_param;
209 struct iw_request_info;
210 int lbs_get_scan(struct net_device *dev, struct iw_request_info *info,
211                          struct iw_point *dwrq, char *extra);
212 int lbs_set_scan(struct net_device *dev, struct iw_request_info *info,
213                          struct iw_param *vwrq, char *extra);
214
215 void lbs_scan_worker(struct work_struct *work);
216
217 #endif