diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-03-03 06:18:59 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-03-06 17:19:46 -0500 |
commit | f137e05468f2a648aba11377dc824d788683dff4 (patch) | |
tree | 7a436a12e5e605bcdf5903cde16ed34244b69be2 /drivers | |
parent | fa62f99cf80af9c65bfc0f731d780e03e3ce6ede (diff) |
libertas: clean up scan.c, remove zeromac and bcastmac
Should be purely cosmetic apart from the removal of the two pointless
MAC addresses.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/libertas/scan.c | 415 |
1 files changed, 181 insertions, 234 deletions
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c index 9f9c7d9c8bd2..99f11a56d84e 100644 --- a/drivers/net/wireless/libertas/scan.c +++ b/drivers/net/wireless/libertas/scan.c | |||
@@ -61,9 +61,6 @@ | |||
61 | //! Scan time specified in the channel TLV for each channel for active scans | 61 | //! Scan time specified in the channel TLV for each channel for active scans |
62 | #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 | 62 | #define MRVDRV_ACTIVE_SCAN_CHAN_TIME 100 |
63 | 63 | ||
64 | static const u8 zeromac[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | ||
65 | static const u8 bcastmac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; | ||
66 | |||
67 | static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy, | 64 | static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy, |
68 | struct cmd_header *resp); | 65 | struct cmd_header *resp); |
69 | 66 | ||
@@ -90,7 +87,7 @@ static void lbs_unset_basic_rate_flags(u8 *rates, size_t len) | |||
90 | } | 87 | } |
91 | 88 | ||
92 | 89 | ||
93 | static inline void clear_bss_descriptor (struct bss_descriptor * bss) | 90 | static inline void clear_bss_descriptor(struct bss_descriptor *bss) |
94 | { | 91 | { |
95 | /* Don't blow away ->list, just BSS data */ | 92 | /* Don't blow away ->list, just BSS data */ |
96 | memset(bss, 0, offsetof(struct bss_descriptor, list)); | 93 | memset(bss, 0, offsetof(struct bss_descriptor, list)); |
@@ -104,7 +101,8 @@ static inline void clear_bss_descriptor (struct bss_descriptor * bss) | |||
104 | * | 101 | * |
105 | * @return 0: ssid is same, otherwise is different | 102 | * @return 0: ssid is same, otherwise is different |
106 | */ | 103 | */ |
107 | int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len) | 104 | int lbs_ssid_cmp(uint8_t *ssid1, uint8_t ssid1_len, uint8_t *ssid2, |
105 | uint8_t ssid2_len) | ||
108 | { | 106 | { |
109 | if (ssid1_len != ssid2_len) | 107 | if (ssid1_len != ssid2_len) |
110 | return -1; | 108 | return -1; |
@@ -113,73 +111,66 @@ int lbs_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len) | |||
113 | } | 111 | } |
114 | 112 | ||
115 | static inline int match_bss_no_security(struct lbs_802_11_security *secinfo, | 113 | static inline int match_bss_no_security(struct lbs_802_11_security *secinfo, |
116 | struct bss_descriptor * match_bss) | 114 | struct bss_descriptor *match_bss) |
117 | { | 115 | { |
118 | if ( !secinfo->wep_enabled | 116 | if (!secinfo->wep_enabled && !secinfo->WPAenabled |
119 | && !secinfo->WPAenabled | ||
120 | && !secinfo->WPA2enabled | 117 | && !secinfo->WPA2enabled |
121 | && match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC | 118 | && match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC |
122 | && match_bss->rsn_ie[0] != MFIE_TYPE_RSN | 119 | && match_bss->rsn_ie[0] != MFIE_TYPE_RSN |
123 | && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { | 120 | && !(match_bss->capability & WLAN_CAPABILITY_PRIVACY)) |
124 | return 1; | 121 | return 1; |
125 | } | 122 | else |
126 | return 0; | 123 | return 0; |
127 | } | 124 | } |
128 | 125 | ||
129 | static inline int match_bss_static_wep(struct lbs_802_11_security *secinfo, | 126 | static inline int match_bss_static_wep(struct lbs_802_11_security *secinfo, |
130 | struct bss_descriptor * match_bss) | 127 | struct bss_descriptor *match_bss) |
131 | { | 128 | { |
132 | if ( secinfo->wep_enabled | 129 | if (secinfo->wep_enabled && !secinfo->WPAenabled |
133 | && !secinfo->WPAenabled | 130 | && !secinfo->WPA2enabled |
134 | && !secinfo->WPA2enabled | 131 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) |
135 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { | ||
136 | return 1; | 132 | return 1; |
137 | } | 133 | else |
138 | return 0; | 134 | return 0; |
139 | } | 135 | } |
140 | 136 | ||
141 | static inline int match_bss_wpa(struct lbs_802_11_security *secinfo, | 137 | static inline int match_bss_wpa(struct lbs_802_11_security *secinfo, |
142 | struct bss_descriptor * match_bss) | 138 | struct bss_descriptor *match_bss) |
143 | { | 139 | { |
144 | if ( !secinfo->wep_enabled | 140 | if (!secinfo->wep_enabled && secinfo->WPAenabled |
145 | && secinfo->WPAenabled | 141 | && (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC) |
146 | && (match_bss->wpa_ie[0] == MFIE_TYPE_GENERIC) | 142 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
147 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G | 143 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */ |
148 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { | 144 | ) |
149 | */ | ||
150 | ) { | ||
151 | return 1; | 145 | return 1; |
152 | } | 146 | else |
153 | return 0; | 147 | return 0; |
154 | } | 148 | } |
155 | 149 | ||
156 | static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo, | 150 | static inline int match_bss_wpa2(struct lbs_802_11_security *secinfo, |
157 | struct bss_descriptor * match_bss) | 151 | struct bss_descriptor *match_bss) |
158 | { | 152 | { |
159 | if ( !secinfo->wep_enabled | 153 | if (!secinfo->wep_enabled && secinfo->WPA2enabled |
160 | && secinfo->WPA2enabled | 154 | && (match_bss->rsn_ie[0] == MFIE_TYPE_RSN) |
161 | && (match_bss->rsn_ie[0] == MFIE_TYPE_RSN) | 155 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G |
162 | /* privacy bit may NOT be set in some APs like LinkSys WRT54G | 156 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY) */ |
163 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { | 157 | ) |
164 | */ | ||
165 | ) { | ||
166 | return 1; | 158 | return 1; |
167 | } | 159 | else |
168 | return 0; | 160 | return 0; |
169 | } | 161 | } |
170 | 162 | ||
171 | static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo, | 163 | static inline int match_bss_dynamic_wep(struct lbs_802_11_security *secinfo, |
172 | struct bss_descriptor * match_bss) | 164 | struct bss_descriptor *match_bss) |
173 | { | 165 | { |
174 | if ( !secinfo->wep_enabled | 166 | if (!secinfo->wep_enabled && !secinfo->WPAenabled |
175 | && !secinfo->WPAenabled | 167 | && !secinfo->WPA2enabled |
176 | && !secinfo->WPA2enabled | 168 | && (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC) |
177 | && (match_bss->wpa_ie[0] != MFIE_TYPE_GENERIC) | 169 | && (match_bss->rsn_ie[0] != MFIE_TYPE_RSN) |
178 | && (match_bss->rsn_ie[0] != MFIE_TYPE_RSN) | 170 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) |
179 | && (match_bss->capability & WLAN_CAPABILITY_PRIVACY)) { | ||
180 | return 1; | 171 | return 1; |
181 | } | 172 | else |
182 | return 0; | 173 | return 0; |
183 | } | 174 | } |
184 | 175 | ||
185 | static inline int is_same_network(struct bss_descriptor *src, | 176 | static inline int is_same_network(struct bss_descriptor *src, |
@@ -214,7 +205,7 @@ static inline int is_same_network(struct bss_descriptor *src, | |||
214 | * @return Index in scantable, or error code if negative | 205 | * @return Index in scantable, or error code if negative |
215 | */ | 206 | */ |
216 | static int is_network_compatible(struct lbs_private *priv, | 207 | static int is_network_compatible(struct lbs_private *priv, |
217 | struct bss_descriptor * bss, u8 mode) | 208 | struct bss_descriptor *bss, uint8_t mode) |
218 | { | 209 | { |
219 | int matched = 0; | 210 | int matched = 0; |
220 | 211 | ||
@@ -228,43 +219,39 @@ static int is_network_compatible(struct lbs_private *priv, | |||
228 | } else if ((matched = match_bss_static_wep(&priv->secinfo, bss))) { | 219 | } else if ((matched = match_bss_static_wep(&priv->secinfo, bss))) { |
229 | goto done; | 220 | goto done; |
230 | } else if ((matched = match_bss_wpa(&priv->secinfo, bss))) { | 221 | } else if ((matched = match_bss_wpa(&priv->secinfo, bss))) { |
231 | lbs_deb_scan( | 222 | lbs_deb_scan("is_network_compatible() WPA: wpa_ie 0x%x " |
232 | "is_network_compatible() WPA: wpa_ie 0x%x " | 223 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " |
233 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " | 224 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], |
234 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], | 225 | priv->secinfo.wep_enabled ? "e" : "d", |
235 | priv->secinfo.wep_enabled ? "e" : "d", | 226 | priv->secinfo.WPAenabled ? "e" : "d", |
236 | priv->secinfo.WPAenabled ? "e" : "d", | 227 | priv->secinfo.WPA2enabled ? "e" : "d", |
237 | priv->secinfo.WPA2enabled ? "e" : "d", | 228 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
238 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); | ||
239 | goto done; | 229 | goto done; |
240 | } else if ((matched = match_bss_wpa2(&priv->secinfo, bss))) { | 230 | } else if ((matched = match_bss_wpa2(&priv->secinfo, bss))) { |
241 | lbs_deb_scan( | 231 | lbs_deb_scan("is_network_compatible() WPA2: wpa_ie 0x%x " |
242 | "is_network_compatible() WPA2: wpa_ie 0x%x " | 232 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " |
243 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s " | 233 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], |
244 | "privacy 0x%x\n", bss->wpa_ie[0], bss->rsn_ie[0], | 234 | priv->secinfo.wep_enabled ? "e" : "d", |
245 | priv->secinfo.wep_enabled ? "e" : "d", | 235 | priv->secinfo.WPAenabled ? "e" : "d", |
246 | priv->secinfo.WPAenabled ? "e" : "d", | 236 | priv->secinfo.WPA2enabled ? "e" : "d", |
247 | priv->secinfo.WPA2enabled ? "e" : "d", | 237 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
248 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); | ||
249 | goto done; | 238 | goto done; |
250 | } else if ((matched = match_bss_dynamic_wep(&priv->secinfo, bss))) { | 239 | } else if ((matched = match_bss_dynamic_wep(&priv->secinfo, bss))) { |
251 | lbs_deb_scan( | 240 | lbs_deb_scan("is_network_compatible() dynamic WEP: " |
252 | "is_network_compatible() dynamic WEP: " | 241 | "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n", |
253 | "wpa_ie 0x%x wpa2_ie 0x%x privacy 0x%x\n", | 242 | bss->wpa_ie[0], bss->rsn_ie[0], |
254 | bss->wpa_ie[0], bss->rsn_ie[0], | 243 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
255 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); | ||
256 | goto done; | 244 | goto done; |
257 | } | 245 | } |
258 | 246 | ||
259 | /* bss security settings don't match those configured on card */ | 247 | /* bss security settings don't match those configured on card */ |
260 | lbs_deb_scan( | 248 | lbs_deb_scan("is_network_compatible() FAILED: wpa_ie 0x%x " |
261 | "is_network_compatible() FAILED: wpa_ie 0x%x " | 249 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n", |
262 | "wpa2_ie 0x%x WEP %s WPA %s WPA2 %s privacy 0x%x\n", | 250 | bss->wpa_ie[0], bss->rsn_ie[0], |
263 | bss->wpa_ie[0], bss->rsn_ie[0], | 251 | priv->secinfo.wep_enabled ? "e" : "d", |
264 | priv->secinfo.wep_enabled ? "e" : "d", | 252 | priv->secinfo.WPAenabled ? "e" : "d", |
265 | priv->secinfo.WPAenabled ? "e" : "d", | 253 | priv->secinfo.WPA2enabled ? "e" : "d", |
266 | priv->secinfo.WPA2enabled ? "e" : "d", | 254 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); |
267 | (bss->capability & WLAN_CAPABILITY_PRIVACY)); | ||
268 | 255 | ||
269 | done: | 256 | done: |
270 | lbs_deb_leave_args(LBS_DEB_SCAN, "matched: %d", matched); | 257 | lbs_deb_leave_args(LBS_DEB_SCAN, "matched: %d", matched); |
@@ -311,16 +298,15 @@ void lbs_scan_worker(struct work_struct *work) | |||
311 | * @return void | 298 | * @return void |
312 | */ | 299 | */ |
313 | static int lbs_scan_create_channel_list(struct lbs_private *priv, | 300 | static int lbs_scan_create_channel_list(struct lbs_private *priv, |
314 | struct chanscanparamset * scanchanlist, | 301 | struct chanscanparamset *scanchanlist, |
315 | u8 filteredscan) | 302 | uint8_t filteredscan) |
316 | { | 303 | { |
317 | |||
318 | struct region_channel *scanregion; | 304 | struct region_channel *scanregion; |
319 | struct chan_freq_power *cfp; | 305 | struct chan_freq_power *cfp; |
320 | int rgnidx; | 306 | int rgnidx; |
321 | int chanidx; | 307 | int chanidx; |
322 | int nextchan; | 308 | int nextchan; |
323 | u8 scantype; | 309 | uint8_t scantype; |
324 | 310 | ||
325 | chanidx = 0; | 311 | chanidx = 0; |
326 | 312 | ||
@@ -331,9 +317,8 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv, | |||
331 | scantype = CMD_SCAN_TYPE_ACTIVE; | 317 | scantype = CMD_SCAN_TYPE_ACTIVE; |
332 | 318 | ||
333 | for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) { | 319 | for (rgnidx = 0; rgnidx < ARRAY_SIZE(priv->region_channel); rgnidx++) { |
334 | if (priv->enable11d && | 320 | if (priv->enable11d && (priv->connect_status != LBS_CONNECTED) |
335 | (priv->connect_status != LBS_CONNECTED) && | 321 | && (priv->mesh_connect_status != LBS_CONNECTED)) { |
336 | (priv->mesh_connect_status != LBS_CONNECTED)) { | ||
337 | /* Scan all the supported chan for the first scan */ | 322 | /* Scan all the supported chan for the first scan */ |
338 | if (!priv->universal_channel[rgnidx].valid) | 323 | if (!priv->universal_channel[rgnidx].valid) |
339 | continue; | 324 | continue; |
@@ -348,45 +333,30 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv, | |||
348 | scanregion = &priv->region_channel[rgnidx]; | 333 | scanregion = &priv->region_channel[rgnidx]; |
349 | } | 334 | } |
350 | 335 | ||
351 | for (nextchan = 0; | 336 | for (nextchan = 0; nextchan < scanregion->nrcfp; nextchan++, chanidx++) { |
352 | nextchan < scanregion->nrcfp; nextchan++, chanidx++) { | 337 | struct chanscanparamset *chan = &scanchanlist[chanidx]; |
353 | 338 | ||
354 | cfp = scanregion->CFP + nextchan; | 339 | cfp = scanregion->CFP + nextchan; |
355 | 340 | ||
356 | if (priv->enable11d) { | 341 | if (priv->enable11d) |
357 | scantype = | 342 | scantype = lbs_get_scan_type_11d(cfp->channel, |
358 | lbs_get_scan_type_11d(cfp->channel, | 343 | &priv->parsed_region_chan); |
359 | &priv-> | ||
360 | parsed_region_chan); | ||
361 | } | ||
362 | 344 | ||
363 | switch (scanregion->band) { | 345 | if (scanregion->band == BAND_B || scanregion->band == BAND_G) |
364 | case BAND_B: | 346 | chan->radiotype = CMD_SCAN_RADIO_TYPE_BG; |
365 | case BAND_G: | ||
366 | default: | ||
367 | scanchanlist[chanidx].radiotype = | ||
368 | CMD_SCAN_RADIO_TYPE_BG; | ||
369 | break; | ||
370 | } | ||
371 | 347 | ||
372 | if (scantype == CMD_SCAN_TYPE_PASSIVE) { | 348 | if (scantype == CMD_SCAN_TYPE_PASSIVE) { |
373 | scanchanlist[chanidx].maxscantime = | 349 | chan->maxscantime = cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME); |
374 | cpu_to_le16(MRVDRV_PASSIVE_SCAN_CHAN_TIME); | 350 | chan->chanscanmode.passivescan = 1; |
375 | scanchanlist[chanidx].chanscanmode.passivescan = | ||
376 | 1; | ||
377 | } else { | 351 | } else { |
378 | scanchanlist[chanidx].maxscantime = | 352 | chan->maxscantime = cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME); |
379 | cpu_to_le16(MRVDRV_ACTIVE_SCAN_CHAN_TIME); | 353 | chan->chanscanmode.passivescan = 0; |
380 | scanchanlist[chanidx].chanscanmode.passivescan = | ||
381 | 0; | ||
382 | } | 354 | } |
383 | 355 | ||
384 | scanchanlist[chanidx].channumber = cfp->channel; | 356 | chan->channumber = cfp->channel; |
385 | 357 | ||
386 | if (filteredscan) { | 358 | if (filteredscan) |
387 | scanchanlist[chanidx].chanscanmode. | 359 | chan->chanscanmode.disablechanfilt = 1; |
388 | disablechanfilt = 1; | ||
389 | } | ||
390 | } | 360 | } |
391 | } | 361 | } |
392 | return chanidx; | 362 | return chanidx; |
@@ -400,11 +370,11 @@ static int lbs_scan_create_channel_list(struct lbs_private *priv, | |||
400 | * length 06 00 | 370 | * length 06 00 |
401 | * ssid 4d 4e 54 45 53 54 | 371 | * ssid 4d 4e 54 45 53 54 |
402 | */ | 372 | */ |
403 | static int lbs_scan_add_ssid_tlv(u8 *tlv, | 373 | static int lbs_scan_add_ssid_tlv(uint8_t *tlv, |
404 | const struct lbs_ioctl_user_scan_cfg *user_cfg) | 374 | const struct lbs_ioctl_user_scan_cfg *user_cfg) |
405 | { | 375 | { |
406 | struct mrvlietypes_ssidparamset *ssid_tlv = | 376 | struct mrvlietypes_ssidparamset *ssid_tlv = (void *)tlv; |
407 | (struct mrvlietypes_ssidparamset *)tlv; | 377 | |
408 | ssid_tlv->header.type = cpu_to_le16(TLV_TYPE_SSID); | 378 | ssid_tlv->header.type = cpu_to_le16(TLV_TYPE_SSID); |
409 | ssid_tlv->header.len = cpu_to_le16(user_cfg->ssid_len); | 379 | ssid_tlv->header.len = cpu_to_le16(user_cfg->ssid_len); |
410 | memcpy(ssid_tlv->ssid, user_cfg->ssid, user_cfg->ssid_len); | 380 | memcpy(ssid_tlv->ssid, user_cfg->ssid, user_cfg->ssid_len); |
@@ -437,13 +407,12 @@ static int lbs_scan_add_ssid_tlv(u8 *tlv, | |||
437 | * channel 13 00 0d 00 00 00 64 00 | 407 | * channel 13 00 0d 00 00 00 64 00 |
438 | * | 408 | * |
439 | */ | 409 | */ |
440 | static int lbs_scan_add_chanlist_tlv(u8 *tlv, | 410 | static int lbs_scan_add_chanlist_tlv(uint8_t *tlv, |
441 | struct chanscanparamset *chan_list, | 411 | struct chanscanparamset *chan_list, |
442 | int chan_count) | 412 | int chan_count) |
443 | { | 413 | { |
444 | size_t size = sizeof(struct chanscanparamset) * chan_count; | 414 | size_t size = sizeof(struct chanscanparamset) *chan_count; |
445 | struct mrvlietypes_chanlistparamset *chan_tlv = | 415 | struct mrvlietypes_chanlistparamset *chan_tlv = (void *)tlv; |
446 | (struct mrvlietypes_chanlistparamset *) tlv; | ||
447 | 416 | ||
448 | chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); | 417 | chan_tlv->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); |
449 | memcpy(chan_tlv->chanscanparam, chan_list, size); | 418 | memcpy(chan_tlv->chanscanparam, chan_list, size); |
@@ -462,11 +431,10 @@ static int lbs_scan_add_chanlist_tlv(u8 *tlv, | |||
462 | * The rates are in lbs_bg_rates[], but for the 802.11b | 431 | * The rates are in lbs_bg_rates[], but for the 802.11b |
463 | * rates the high bit isn't set. | 432 | * rates the high bit isn't set. |
464 | */ | 433 | */ |
465 | static int lbs_scan_add_rates_tlv(u8 *tlv) | 434 | static int lbs_scan_add_rates_tlv(uint8_t *tlv) |
466 | { | 435 | { |
467 | int i; | 436 | int i; |
468 | struct mrvlietypes_ratesparamset *rate_tlv = | 437 | struct mrvlietypes_ratesparamset *rate_tlv = (void *)tlv; |
469 | (struct mrvlietypes_ratesparamset *) tlv; | ||
470 | 438 | ||
471 | rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES); | 439 | rate_tlv->header.type = cpu_to_le16(TLV_TYPE_RATES); |
472 | tlv += sizeof(rate_tlv->header); | 440 | tlv += sizeof(rate_tlv->header); |
@@ -554,14 +522,14 @@ out: | |||
554 | * @return 0 or < 0 if error | 522 | * @return 0 or < 0 if error |
555 | */ | 523 | */ |
556 | int lbs_scan_networks(struct lbs_private *priv, | 524 | int lbs_scan_networks(struct lbs_private *priv, |
557 | const struct lbs_ioctl_user_scan_cfg *user_cfg, | 525 | const struct lbs_ioctl_user_scan_cfg *user_cfg, |
558 | int full_scan) | 526 | int full_scan) |
559 | { | 527 | { |
560 | int ret = -ENOMEM; | 528 | int ret = -ENOMEM; |
561 | struct chanscanparamset *chan_list; | 529 | struct chanscanparamset *chan_list; |
562 | struct chanscanparamset *curr_chans; | 530 | struct chanscanparamset *curr_chans; |
563 | int chan_count; | 531 | int chan_count; |
564 | u8 bsstype = CMD_BSS_TYPE_ANY; | 532 | uint8_t bsstype = CMD_BSS_TYPE_ANY; |
565 | int numchannels = MRVDRV_CHANNELS_PER_SCAN_CMD; | 533 | int numchannels = MRVDRV_CHANNELS_PER_SCAN_CMD; |
566 | int filteredscan = 0; | 534 | int filteredscan = 0; |
567 | union iwreq_data wrqu; | 535 | union iwreq_data wrqu; |
@@ -571,8 +539,7 @@ int lbs_scan_networks(struct lbs_private *priv, | |||
571 | DECLARE_MAC_BUF(mac); | 539 | DECLARE_MAC_BUF(mac); |
572 | #endif | 540 | #endif |
573 | 541 | ||
574 | lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", | 542 | lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan); |
575 | full_scan); | ||
576 | 543 | ||
577 | /* Cancel any partial outstanding partial scans if this scan | 544 | /* Cancel any partial outstanding partial scans if this scan |
578 | * is a full scan. | 545 | * is a full scan. |
@@ -584,26 +551,24 @@ int lbs_scan_networks(struct lbs_private *priv, | |||
584 | if (user_cfg) { | 551 | if (user_cfg) { |
585 | if (user_cfg->bsstype) | 552 | if (user_cfg->bsstype) |
586 | bsstype = user_cfg->bsstype; | 553 | bsstype = user_cfg->bsstype; |
587 | if (compare_ether_addr(user_cfg->bssid, &zeromac[0]) != 0) { | 554 | if (!is_zero_ether_addr(user_cfg->bssid)) { |
588 | numchannels = MRVDRV_MAX_CHANNELS_PER_SCAN; | 555 | numchannels = MRVDRV_MAX_CHANNELS_PER_SCAN; |
589 | filteredscan = 1; | 556 | filteredscan = 1; |
590 | } | 557 | } |
591 | } | 558 | } |
592 | lbs_deb_scan("numchannels %d, bsstype %d, " | 559 | lbs_deb_scan("numchannels %d, bsstype %d, filteredscan %d\n", |
593 | "filteredscan %d\n", | 560 | numchannels, bsstype, filteredscan); |
594 | numchannels, bsstype, filteredscan); | ||
595 | 561 | ||
596 | /* Create list of channels to scan */ | 562 | /* Create list of channels to scan */ |
597 | chan_list = kzalloc(sizeof(struct chanscanparamset) * | 563 | chan_list = kzalloc(sizeof(struct chanscanparamset) * |
598 | LBS_IOCTL_USER_SCAN_CHAN_MAX, GFP_KERNEL); | 564 | LBS_IOCTL_USER_SCAN_CHAN_MAX, GFP_KERNEL); |
599 | if (!chan_list) { | 565 | if (!chan_list) { |
600 | lbs_pr_alert("SCAN: chan_list empty\n"); | 566 | lbs_pr_alert("SCAN: chan_list empty\n"); |
601 | goto out; | 567 | goto out; |
602 | } | 568 | } |
603 | 569 | ||
604 | /* We want to scan all channels */ | 570 | /* We want to scan all channels */ |
605 | chan_count = lbs_scan_create_channel_list(priv, chan_list, | 571 | chan_count = lbs_scan_create_channel_list(priv, chan_list, filteredscan); |
606 | filteredscan); | ||
607 | 572 | ||
608 | netif_stop_queue(priv->dev); | 573 | netif_stop_queue(priv->dev); |
609 | netif_carrier_off(priv->dev); | 574 | netif_carrier_off(priv->dev); |
@@ -630,9 +595,9 @@ int lbs_scan_networks(struct lbs_private *priv, | |||
630 | while (chan_count) { | 595 | while (chan_count) { |
631 | int to_scan = min(numchannels, chan_count); | 596 | int to_scan = min(numchannels, chan_count); |
632 | lbs_deb_scan("scanning %d of %d channels\n", | 597 | lbs_deb_scan("scanning %d of %d channels\n", |
633 | to_scan, chan_count); | 598 | to_scan, chan_count); |
634 | ret = lbs_do_scan(priv, bsstype, curr_chans, | 599 | ret = lbs_do_scan(priv, bsstype, curr_chans, |
635 | to_scan, user_cfg); | 600 | to_scan, user_cfg); |
636 | if (ret) { | 601 | if (ret) { |
637 | lbs_pr_err("SCAN_CMD failed\n"); | 602 | lbs_pr_err("SCAN_CMD failed\n"); |
638 | goto out2; | 603 | goto out2; |
@@ -641,8 +606,7 @@ int lbs_scan_networks(struct lbs_private *priv, | |||
641 | chan_count -= to_scan; | 606 | chan_count -= to_scan; |
642 | 607 | ||
643 | /* somehow schedule the next part of the scan */ | 608 | /* somehow schedule the next part of the scan */ |
644 | if (chan_count && | 609 | if (chan_count && !full_scan && |
645 | !full_scan && | ||
646 | !priv->surpriseremoved) { | 610 | !priv->surpriseremoved) { |
647 | /* -1 marks just that we're currently scanning */ | 611 | /* -1 marks just that we're currently scanning */ |
648 | if (priv->scan_channel < 0) | 612 | if (priv->scan_channel < 0) |
@@ -651,7 +615,7 @@ int lbs_scan_networks(struct lbs_private *priv, | |||
651 | priv->scan_channel += to_scan; | 615 | priv->scan_channel += to_scan; |
652 | cancel_delayed_work(&priv->scan_work); | 616 | cancel_delayed_work(&priv->scan_work); |
653 | queue_delayed_work(priv->work_thread, &priv->scan_work, | 617 | queue_delayed_work(priv->work_thread, &priv->scan_work, |
654 | msecs_to_jiffies(300)); | 618 | msecs_to_jiffies(300)); |
655 | /* skip over GIWSCAN event */ | 619 | /* skip over GIWSCAN event */ |
656 | goto out; | 620 | goto out; |
657 | } | 621 | } |
@@ -666,8 +630,8 @@ int lbs_scan_networks(struct lbs_private *priv, | |||
666 | lbs_deb_scan("scan table:\n"); | 630 | lbs_deb_scan("scan table:\n"); |
667 | list_for_each_entry(iter, &priv->network_list, list) | 631 | list_for_each_entry(iter, &priv->network_list, list) |
668 | lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", | 632 | lbs_deb_scan("%02d: BSSID %s, RSSI %d, SSID '%s'\n", |
669 | i++, print_mac(mac, iter->bssid), (s32) iter->rssi, | 633 | i++, print_mac(mac, iter->bssid), (int)iter->rssi, |
670 | escape_essid(iter->ssid, iter->ssid_len)); | 634 | escape_essid(iter->ssid, iter->ssid_len)); |
671 | mutex_unlock(&priv->lock); | 635 | mutex_unlock(&priv->lock); |
672 | #endif | 636 | #endif |
673 | 637 | ||
@@ -712,7 +676,7 @@ out: | |||
712 | * @return 0 or -1 | 676 | * @return 0 or -1 |
713 | */ | 677 | */ |
714 | static int lbs_process_bss(struct bss_descriptor *bss, | 678 | static int lbs_process_bss(struct bss_descriptor *bss, |
715 | u8 ** pbeaconinfo, int *bytesleft) | 679 | uint8_t **pbeaconinfo, int *bytesleft) |
716 | { | 680 | { |
717 | struct ieeetypes_fhparamset *pFH; | 681 | struct ieeetypes_fhparamset *pFH; |
718 | struct ieeetypes_dsparamset *pDS; | 682 | struct ieeetypes_dsparamset *pDS; |
@@ -720,9 +684,9 @@ static int lbs_process_bss(struct bss_descriptor *bss, | |||
720 | struct ieeetypes_ibssparamset *pibss; | 684 | struct ieeetypes_ibssparamset *pibss; |
721 | DECLARE_MAC_BUF(mac); | 685 | DECLARE_MAC_BUF(mac); |
722 | struct ieeetypes_countryinfoset *pcountryinfo; | 686 | struct ieeetypes_countryinfoset *pcountryinfo; |
723 | u8 *pos, *end, *p; | 687 | uint8_t *pos, *end, *p; |
724 | u8 n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0; | 688 | uint8_t n_ex_rates = 0, got_basic_rates = 0, n_basic_rates = 0; |
725 | u16 beaconsize = 0; | 689 | uint16_t beaconsize = 0; |
726 | int ret; | 690 | int ret; |
727 | 691 | ||
728 | lbs_deb_enter(LBS_DEB_SCAN); | 692 | lbs_deb_enter(LBS_DEB_SCAN); |
@@ -794,12 +758,11 @@ static int lbs_process_bss(struct bss_descriptor *bss, | |||
794 | 758 | ||
795 | /* process variable IE */ | 759 | /* process variable IE */ |
796 | while (pos <= end - 2) { | 760 | while (pos <= end - 2) { |
797 | struct ieee80211_info_element * elem = | 761 | struct ieee80211_info_element * elem = (void *)pos; |
798 | (struct ieee80211_info_element *) pos; | ||
799 | 762 | ||
800 | if (pos + elem->len > end) { | 763 | if (pos + elem->len > end) { |
801 | lbs_deb_scan("process_bss: error in processing IE, " | 764 | lbs_deb_scan("process_bss: error in processing IE, " |
802 | "bytes left < IE length\n"); | 765 | "bytes left < IE length\n"); |
803 | break; | 766 | break; |
804 | } | 767 | } |
805 | 768 | ||
@@ -813,7 +776,7 @@ static int lbs_process_bss(struct bss_descriptor *bss, | |||
813 | break; | 776 | break; |
814 | 777 | ||
815 | case MFIE_TYPE_RATES: | 778 | case MFIE_TYPE_RATES: |
816 | n_basic_rates = min_t(u8, MAX_RATES, elem->len); | 779 | n_basic_rates = min_t(uint8_t, MAX_RATES, elem->len); |
817 | memcpy(bss->rates, elem->data, n_basic_rates); | 780 | memcpy(bss->rates, elem->data, n_basic_rates); |
818 | got_basic_rates = 1; | 781 | got_basic_rates = 1; |
819 | lbs_deb_scan("got RATES IE\n"); | 782 | lbs_deb_scan("got RATES IE\n"); |
@@ -854,19 +817,16 @@ static int lbs_process_bss(struct bss_descriptor *bss, | |||
854 | lbs_deb_scan("got COUNTRY IE\n"); | 817 | lbs_deb_scan("got COUNTRY IE\n"); |
855 | if (pcountryinfo->len < sizeof(pcountryinfo->countrycode) | 818 | if (pcountryinfo->len < sizeof(pcountryinfo->countrycode) |
856 | || pcountryinfo->len > 254) { | 819 | || pcountryinfo->len > 254) { |
857 | lbs_deb_scan("process_bss: 11D- Err " | 820 | lbs_deb_scan("process_bss: 11D- Err CountryInfo len %d, min %zd, max 254\n", |
858 | "CountryInfo len %d, min %zd, max 254\n", | 821 | pcountryinfo->len, sizeof(pcountryinfo->countrycode)); |
859 | pcountryinfo->len, | ||
860 | sizeof(pcountryinfo->countrycode)); | ||
861 | ret = -1; | 822 | ret = -1; |
862 | goto done; | 823 | goto done; |
863 | } | 824 | } |
864 | 825 | ||
865 | memcpy(&bss->countryinfo, | 826 | memcpy(&bss->countryinfo, pcountryinfo, pcountryinfo->len + 2); |
866 | pcountryinfo, pcountryinfo->len + 2); | ||
867 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: 11d countryinfo", | 827 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: 11d countryinfo", |
868 | (u8 *) pcountryinfo, | 828 | (uint8_t *) pcountryinfo, |
869 | (u32) (pcountryinfo->len + 2)); | 829 | (int) (pcountryinfo->len + 2)); |
870 | break; | 830 | break; |
871 | 831 | ||
872 | case MFIE_TYPE_RATES_EX: | 832 | case MFIE_TYPE_RATES_EX: |
@@ -890,26 +850,19 @@ static int lbs_process_bss(struct bss_descriptor *bss, | |||
890 | 850 | ||
891 | case MFIE_TYPE_GENERIC: | 851 | case MFIE_TYPE_GENERIC: |
892 | if (elem->len >= 4 && | 852 | if (elem->len >= 4 && |
893 | elem->data[0] == 0x00 && | 853 | elem->data[0] == 0x00 && elem->data[1] == 0x50 && |
894 | elem->data[1] == 0x50 && | 854 | elem->data[2] == 0xf2 && elem->data[3] == 0x01) { |
895 | elem->data[2] == 0xf2 && | 855 | bss->wpa_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN); |
896 | elem->data[3] == 0x01) { | ||
897 | bss->wpa_ie_len = min(elem->len + 2, | ||
898 | MAX_WPA_IE_LEN); | ||
899 | memcpy(bss->wpa_ie, elem, bss->wpa_ie_len); | 856 | memcpy(bss->wpa_ie, elem, bss->wpa_ie_len); |
900 | lbs_deb_scan("got WPA IE\n"); | 857 | lbs_deb_scan("got WPA IE\n"); |
901 | lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie, | 858 | lbs_deb_hex(LBS_DEB_SCAN, "WPA IE", bss->wpa_ie, elem->len); |
902 | elem->len); | ||
903 | } else if (elem->len >= MARVELL_MESH_IE_LENGTH && | 859 | } else if (elem->len >= MARVELL_MESH_IE_LENGTH && |
904 | elem->data[0] == 0x00 && | 860 | elem->data[0] == 0x00 && elem->data[1] == 0x50 && |
905 | elem->data[1] == 0x50 && | 861 | elem->data[2] == 0x43 && elem->data[3] == 0x04) { |
906 | elem->data[2] == 0x43 && | ||
907 | elem->data[3] == 0x04) { | ||
908 | lbs_deb_scan("got mesh IE\n"); | 862 | lbs_deb_scan("got mesh IE\n"); |
909 | bss->mesh = 1; | 863 | bss->mesh = 1; |
910 | } else { | 864 | } else { |
911 | lbs_deb_scan("got generiec IE: " | 865 | lbs_deb_scan("got generic IE: %02x:%02x:%02x:%02x, len %d\n", |
912 | "%02x:%02x:%02x:%02x, len %d\n", | ||
913 | elem->data[0], elem->data[1], | 866 | elem->data[0], elem->data[1], |
914 | elem->data[2], elem->data[3], | 867 | elem->data[2], elem->data[3], |
915 | elem->len); | 868 | elem->len); |
@@ -921,12 +874,12 @@ static int lbs_process_bss(struct bss_descriptor *bss, | |||
921 | bss->rsn_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN); | 874 | bss->rsn_ie_len = min(elem->len + 2, MAX_WPA_IE_LEN); |
922 | memcpy(bss->rsn_ie, elem, bss->rsn_ie_len); | 875 | memcpy(bss->rsn_ie, elem, bss->rsn_ie_len); |
923 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: RSN_IE", | 876 | lbs_deb_hex(LBS_DEB_SCAN, "process_bss: RSN_IE", |
924 | bss->rsn_ie, elem->len); | 877 | bss->rsn_ie, elem->len); |
925 | break; | 878 | break; |
926 | 879 | ||
927 | default: | 880 | default: |
928 | lbs_deb_scan("got IE 0x%04x, len %d\n", | 881 | lbs_deb_scan("got IE 0x%04x, len %d\n", |
929 | elem->id, elem->len); | 882 | elem->id, elem->len); |
930 | break; | 883 | break; |
931 | } | 884 | } |
932 | 885 | ||
@@ -956,18 +909,17 @@ done: | |||
956 | * @return index in BSSID list, or error return code (< 0) | 909 | * @return index in BSSID list, or error return code (< 0) |
957 | */ | 910 | */ |
958 | struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv, | 911 | struct bss_descriptor *lbs_find_bssid_in_list(struct lbs_private *priv, |
959 | u8 * bssid, u8 mode) | 912 | uint8_t *bssid, uint8_t mode) |
960 | { | 913 | { |
961 | struct bss_descriptor * iter_bss; | 914 | struct bss_descriptor *iter_bss; |
962 | struct bss_descriptor * found_bss = NULL; | 915 | struct bss_descriptor *found_bss = NULL; |
963 | 916 | ||
964 | lbs_deb_enter(LBS_DEB_SCAN); | 917 | lbs_deb_enter(LBS_DEB_SCAN); |
965 | 918 | ||
966 | if (!bssid) | 919 | if (!bssid) |
967 | goto out; | 920 | goto out; |
968 | 921 | ||
969 | lbs_deb_hex(LBS_DEB_SCAN, "looking for", | 922 | lbs_deb_hex(LBS_DEB_SCAN, "looking for", bssid, ETH_ALEN); |
970 | bssid, ETH_ALEN); | ||
971 | 923 | ||
972 | /* Look through the scan table for a compatible match. The loop will | 924 | /* Look through the scan table for a compatible match. The loop will |
973 | * continue past a matched bssid that is not compatible in case there | 925 | * continue past a matched bssid that is not compatible in case there |
@@ -1009,10 +961,11 @@ out: | |||
1009 | * @return index in BSSID list | 961 | * @return index in BSSID list |
1010 | */ | 962 | */ |
1011 | struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv, | 963 | struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv, |
1012 | u8 *ssid, u8 ssid_len, u8 * bssid, u8 mode, | 964 | uint8_t *ssid, uint8_t ssid_len, |
1013 | int channel) | 965 | uint8_t *bssid, uint8_t mode, |
966 | int channel) | ||
1014 | { | 967 | { |
1015 | u8 bestrssi = 0; | 968 | uint8_t bestrssi = 0; |
1016 | struct bss_descriptor * iter_bss = NULL; | 969 | struct bss_descriptor * iter_bss = NULL; |
1017 | struct bss_descriptor * found_bss = NULL; | 970 | struct bss_descriptor * found_bss = NULL; |
1018 | struct bss_descriptor * tmp_oldest = NULL; | 971 | struct bss_descriptor * tmp_oldest = NULL; |
@@ -1027,7 +980,7 @@ struct bss_descriptor *lbs_find_ssid_in_list(struct lbs_private *priv, | |||
1027 | tmp_oldest = iter_bss; | 980 | tmp_oldest = iter_bss; |
1028 | 981 | ||
1029 | if (lbs_ssid_cmp(iter_bss->ssid, iter_bss->ssid_len, | 982 | if (lbs_ssid_cmp(iter_bss->ssid, iter_bss->ssid_len, |
1030 | ssid, ssid_len) != 0) | 983 | ssid, ssid_len) != 0) |
1031 | continue; /* ssid doesn't match */ | 984 | continue; /* ssid doesn't match */ |
1032 | if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0) | 985 | if (bssid && compare_ether_addr(iter_bss->bssid, bssid) != 0) |
1033 | continue; /* bssid doesn't match */ | 986 | continue; /* bssid doesn't match */ |
@@ -1077,13 +1030,12 @@ out: | |||
1077 | * | 1030 | * |
1078 | * @return index in BSSID list | 1031 | * @return index in BSSID list |
1079 | */ | 1032 | */ |
1080 | static struct bss_descriptor *lbs_find_best_ssid_in_list( | 1033 | static struct bss_descriptor *lbs_find_best_ssid_in_list(struct lbs_private *priv, |
1081 | struct lbs_private *priv, | 1034 | uint8_t mode) |
1082 | u8 mode) | ||
1083 | { | 1035 | { |
1084 | u8 bestrssi = 0; | 1036 | uint8_t bestrssi = 0; |
1085 | struct bss_descriptor * iter_bss; | 1037 | struct bss_descriptor *iter_bss; |
1086 | struct bss_descriptor * best_bss = NULL; | 1038 | struct bss_descriptor *best_bss = NULL; |
1087 | 1039 | ||
1088 | lbs_deb_enter(LBS_DEB_SCAN); | 1040 | lbs_deb_enter(LBS_DEB_SCAN); |
1089 | 1041 | ||
@@ -1125,11 +1077,12 @@ static struct bss_descriptor *lbs_find_best_ssid_in_list( | |||
1125 | * | 1077 | * |
1126 | * @return 0--success, otherwise--fail | 1078 | * @return 0--success, otherwise--fail |
1127 | */ | 1079 | */ |
1128 | int lbs_find_best_network_ssid(struct lbs_private *priv, | 1080 | int lbs_find_best_network_ssid(struct lbs_private *priv, uint8_t *out_ssid, |
1129 | u8 *out_ssid, u8 *out_ssid_len, u8 preferred_mode, u8 *out_mode) | 1081 | uint8_t *out_ssid_len, uint8_t preferred_mode, |
1082 | uint8_t *out_mode) | ||
1130 | { | 1083 | { |
1131 | int ret = -1; | 1084 | int ret = -1; |
1132 | struct bss_descriptor * found; | 1085 | struct bss_descriptor *found; |
1133 | 1086 | ||
1134 | lbs_deb_enter(LBS_DEB_SCAN); | 1087 | lbs_deb_enter(LBS_DEB_SCAN); |
1135 | 1088 | ||
@@ -1164,14 +1117,14 @@ out: | |||
1164 | * | 1117 | * |
1165 | * @return 0-success, otherwise fail | 1118 | * @return 0-success, otherwise fail |
1166 | */ | 1119 | */ |
1167 | int lbs_send_specific_ssid_scan(struct lbs_private *priv, | 1120 | int lbs_send_specific_ssid_scan(struct lbs_private *priv, uint8_t *ssid, |
1168 | u8 *ssid, u8 ssid_len, u8 clear_ssid) | 1121 | uint8_t ssid_len, uint8_t clear_ssid) |
1169 | { | 1122 | { |
1170 | struct lbs_ioctl_user_scan_cfg scancfg; | 1123 | struct lbs_ioctl_user_scan_cfg scancfg; |
1171 | int ret = 0; | 1124 | int ret = 0; |
1172 | 1125 | ||
1173 | lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s', clear %d", | 1126 | lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s', clear %d", |
1174 | escape_essid(ssid, ssid_len), clear_ssid); | 1127 | escape_essid(ssid, ssid_len), clear_ssid); |
1175 | 1128 | ||
1176 | if (!ssid_len) | 1129 | if (!ssid_len) |
1177 | goto out; | 1130 | goto out; |
@@ -1205,17 +1158,17 @@ out: | |||
1205 | #define MAX_CUSTOM_LEN 64 | 1158 | #define MAX_CUSTOM_LEN 64 |
1206 | 1159 | ||
1207 | static inline char *lbs_translate_scan(struct lbs_private *priv, | 1160 | static inline char *lbs_translate_scan(struct lbs_private *priv, |
1208 | char *start, char *stop, | 1161 | char *start, char *stop, |
1209 | struct bss_descriptor *bss) | 1162 | struct bss_descriptor *bss) |
1210 | { | 1163 | { |
1211 | struct chan_freq_power *cfp; | 1164 | struct chan_freq_power *cfp; |
1212 | char *current_val; /* For rates */ | 1165 | char *current_val; /* For rates */ |
1213 | struct iw_event iwe; /* Temporary buffer */ | 1166 | struct iw_event iwe; /* Temporary buffer */ |
1214 | int j; | 1167 | int j; |
1215 | #define PERFECT_RSSI ((u8)50) | 1168 | #define PERFECT_RSSI ((uint8_t)50) |
1216 | #define WORST_RSSI ((u8)0) | 1169 | #define WORST_RSSI ((uint8_t)0) |
1217 | #define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI)) | 1170 | #define RSSI_DIFF ((uint8_t)(PERFECT_RSSI - WORST_RSSI)) |
1218 | u8 rssi; | 1171 | uint8_t rssi; |
1219 | 1172 | ||
1220 | lbs_deb_enter(LBS_DEB_SCAN); | 1173 | lbs_deb_enter(LBS_DEB_SCAN); |
1221 | 1174 | ||
@@ -1235,7 +1188,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv, | |||
1235 | /* SSID */ | 1188 | /* SSID */ |
1236 | iwe.cmd = SIOCGIWESSID; | 1189 | iwe.cmd = SIOCGIWESSID; |
1237 | iwe.u.data.flags = 1; | 1190 | iwe.u.data.flags = 1; |
1238 | iwe.u.data.length = min((u32) bss->ssid_len, (u32) IW_ESSID_MAX_SIZE); | 1191 | iwe.u.data.length = min((uint32_t) bss->ssid_len, (uint32_t) IW_ESSID_MAX_SIZE); |
1239 | start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); | 1192 | start = iwe_stream_add_point(start, stop, &iwe, bss->ssid); |
1240 | 1193 | ||
1241 | /* Mode */ | 1194 | /* Mode */ |
@@ -1256,28 +1209,26 @@ static inline char *lbs_translate_scan(struct lbs_private *priv, | |||
1256 | 1209 | ||
1257 | rssi = iwe.u.qual.level - MRVDRV_NF_DEFAULT_SCAN_VALUE; | 1210 | rssi = iwe.u.qual.level - MRVDRV_NF_DEFAULT_SCAN_VALUE; |
1258 | iwe.u.qual.qual = | 1211 | iwe.u.qual.qual = |
1259 | (100 * RSSI_DIFF * RSSI_DIFF - (PERFECT_RSSI - rssi) * | 1212 | (100 * RSSI_DIFF * RSSI_DIFF - (PERFECT_RSSI - rssi) * |
1260 | (15 * (RSSI_DIFF) + 62 * (PERFECT_RSSI - rssi))) / | 1213 | (15 * (RSSI_DIFF) + 62 * (PERFECT_RSSI - rssi))) / |
1261 | (RSSI_DIFF * RSSI_DIFF); | 1214 | (RSSI_DIFF * RSSI_DIFF); |
1262 | if (iwe.u.qual.qual > 100) | 1215 | if (iwe.u.qual.qual > 100) |
1263 | iwe.u.qual.qual = 100; | 1216 | iwe.u.qual.qual = 100; |
1264 | 1217 | ||
1265 | if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { | 1218 | if (priv->NF[TYPE_BEACON][TYPE_NOAVG] == 0) { |
1266 | iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; | 1219 | iwe.u.qual.noise = MRVDRV_NF_DEFAULT_SCAN_VALUE; |
1267 | } else { | 1220 | } else { |
1268 | iwe.u.qual.noise = | 1221 | iwe.u.qual.noise = CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]); |
1269 | CAL_NF(priv->NF[TYPE_BEACON][TYPE_NOAVG]); | ||
1270 | } | 1222 | } |
1271 | 1223 | ||
1272 | /* Locally created ad-hoc BSSs won't have beacons if this is the | 1224 | /* Locally created ad-hoc BSSs won't have beacons if this is the |
1273 | * only station in the adhoc network; so get signal strength | 1225 | * only station in the adhoc network; so get signal strength |
1274 | * from receive statistics. | 1226 | * from receive statistics. |
1275 | */ | 1227 | */ |
1276 | if ((priv->mode == IW_MODE_ADHOC) | 1228 | if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate |
1277 | && priv->adhoccreate | ||
1278 | && !lbs_ssid_cmp(priv->curbssparams.ssid, | 1229 | && !lbs_ssid_cmp(priv->curbssparams.ssid, |
1279 | priv->curbssparams.ssid_len, | 1230 | priv->curbssparams.ssid_len, |
1280 | bss->ssid, bss->ssid_len)) { | 1231 | bss->ssid, bss->ssid_len)) { |
1281 | int snr, nf; | 1232 | int snr, nf; |
1282 | snr = priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | 1233 | snr = priv->SNR[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; |
1283 | nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; | 1234 | nf = priv->NF[TYPE_RXPD][TYPE_AVG] / AVG_SCALE; |
@@ -1308,14 +1259,13 @@ static inline char *lbs_translate_scan(struct lbs_private *priv, | |||
1308 | current_val = iwe_stream_add_value(start, current_val, | 1259 | current_val = iwe_stream_add_value(start, current_val, |
1309 | stop, &iwe, IW_EV_PARAM_LEN); | 1260 | stop, &iwe, IW_EV_PARAM_LEN); |
1310 | } | 1261 | } |
1311 | if ((bss->mode == IW_MODE_ADHOC) | 1262 | if ((bss->mode == IW_MODE_ADHOC) && priv->adhoccreate |
1312 | && !lbs_ssid_cmp(priv->curbssparams.ssid, | 1263 | && !lbs_ssid_cmp(priv->curbssparams.ssid, |
1313 | priv->curbssparams.ssid_len, | 1264 | priv->curbssparams.ssid_len, |
1314 | bss->ssid, bss->ssid_len) | 1265 | bss->ssid, bss->ssid_len)) { |
1315 | && priv->adhoccreate) { | ||
1316 | iwe.u.bitrate.value = 22 * 500000; | 1266 | iwe.u.bitrate.value = 22 * 500000; |
1317 | current_val = iwe_stream_add_value(start, current_val, | 1267 | current_val = iwe_stream_add_value(start, current_val, |
1318 | stop, &iwe, IW_EV_PARAM_LEN); | 1268 | stop, &iwe, IW_EV_PARAM_LEN); |
1319 | } | 1269 | } |
1320 | /* Check if we added any event */ | 1270 | /* Check if we added any event */ |
1321 | if((current_val - start) > IW_EV_LCP_LEN) | 1271 | if((current_val - start) > IW_EV_LCP_LEN) |
@@ -1344,8 +1294,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv, | |||
1344 | char *p = custom; | 1294 | char *p = custom; |
1345 | 1295 | ||
1346 | iwe.cmd = IWEVCUSTOM; | 1296 | iwe.cmd = IWEVCUSTOM; |
1347 | p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), | 1297 | p += snprintf(p, MAX_CUSTOM_LEN, "mesh-type: olpc"); |
1348 | "mesh-type: olpc"); | ||
1349 | iwe.u.data.length = p - custom; | 1298 | iwe.u.data.length = p - custom; |
1350 | if (iwe.u.data.length) | 1299 | if (iwe.u.data.length) |
1351 | start = iwe_stream_add_point(start, stop, &iwe, custom); | 1300 | start = iwe_stream_add_point(start, stop, &iwe, custom); |
@@ -1368,7 +1317,7 @@ out: | |||
1368 | * @return 0 --success, otherwise fail | 1317 | * @return 0 --success, otherwise fail |
1369 | */ | 1318 | */ |
1370 | int lbs_set_scan(struct net_device *dev, struct iw_request_info *info, | 1319 | int lbs_set_scan(struct net_device *dev, struct iw_request_info *info, |
1371 | struct iw_param *wrqu, char *extra) | 1320 | struct iw_param *wrqu, char *extra) |
1372 | { | 1321 | { |
1373 | struct lbs_private *priv = dev->priv; | 1322 | struct lbs_private *priv = dev->priv; |
1374 | 1323 | ||
@@ -1392,7 +1341,7 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info, | |||
1392 | 1341 | ||
1393 | if (!delayed_work_pending(&priv->scan_work)) | 1342 | if (!delayed_work_pending(&priv->scan_work)) |
1394 | queue_delayed_work(priv->work_thread, &priv->scan_work, | 1343 | queue_delayed_work(priv->work_thread, &priv->scan_work, |
1395 | msecs_to_jiffies(50)); | 1344 | msecs_to_jiffies(50)); |
1396 | /* set marker that currently a scan is taking place */ | 1345 | /* set marker that currently a scan is taking place */ |
1397 | priv->scan_channel = -1; | 1346 | priv->scan_channel = -1; |
1398 | 1347 | ||
@@ -1415,15 +1364,15 @@ int lbs_set_scan(struct net_device *dev, struct iw_request_info *info, | |||
1415 | * @return 0 --success, otherwise fail | 1364 | * @return 0 --success, otherwise fail |
1416 | */ | 1365 | */ |
1417 | int lbs_get_scan(struct net_device *dev, struct iw_request_info *info, | 1366 | int lbs_get_scan(struct net_device *dev, struct iw_request_info *info, |
1418 | struct iw_point *dwrq, char *extra) | 1367 | struct iw_point *dwrq, char *extra) |
1419 | { | 1368 | { |
1420 | #define SCAN_ITEM_SIZE 128 | 1369 | #define SCAN_ITEM_SIZE 128 |
1421 | struct lbs_private *priv = dev->priv; | 1370 | struct lbs_private *priv = dev->priv; |
1422 | int err = 0; | 1371 | int err = 0; |
1423 | char *ev = extra; | 1372 | char *ev = extra; |
1424 | char *stop = ev + dwrq->length; | 1373 | char *stop = ev + dwrq->length; |
1425 | struct bss_descriptor * iter_bss; | 1374 | struct bss_descriptor *iter_bss; |
1426 | struct bss_descriptor * safe; | 1375 | struct bss_descriptor *safe; |
1427 | 1376 | ||
1428 | lbs_deb_enter(LBS_DEB_SCAN); | 1377 | lbs_deb_enter(LBS_DEB_SCAN); |
1429 | 1378 | ||
@@ -1432,14 +1381,13 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1432 | return -EAGAIN; | 1381 | return -EAGAIN; |
1433 | 1382 | ||
1434 | /* Update RSSI if current BSS is a locally created ad-hoc BSS */ | 1383 | /* Update RSSI if current BSS is a locally created ad-hoc BSS */ |
1435 | if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate) { | 1384 | if ((priv->mode == IW_MODE_ADHOC) && priv->adhoccreate) |
1436 | lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, | 1385 | lbs_prepare_and_send_command(priv, CMD_802_11_RSSI, 0, |
1437 | CMD_OPTION_WAITFORRSP, 0, NULL); | 1386 | CMD_OPTION_WAITFORRSP, 0, NULL); |
1438 | } | ||
1439 | 1387 | ||
1440 | mutex_lock(&priv->lock); | 1388 | mutex_lock(&priv->lock); |
1441 | list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) { | 1389 | list_for_each_entry_safe (iter_bss, safe, &priv->network_list, list) { |
1442 | char * next_ev; | 1390 | char *next_ev; |
1443 | unsigned long stale_time; | 1391 | unsigned long stale_time; |
1444 | 1392 | ||
1445 | if (stop - ev < SCAN_ITEM_SIZE) { | 1393 | if (stop - ev < SCAN_ITEM_SIZE) { |
@@ -1454,8 +1402,7 @@ int lbs_get_scan(struct net_device *dev, struct iw_request_info *info, | |||
1454 | /* Prune old an old scan result */ | 1402 | /* Prune old an old scan result */ |
1455 | stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; | 1403 | stale_time = iter_bss->last_scanned + DEFAULT_MAX_SCAN_AGE; |
1456 | if (time_after(jiffies, stale_time)) { | 1404 | if (time_after(jiffies, stale_time)) { |
1457 | list_move_tail (&iter_bss->list, | 1405 | list_move_tail(&iter_bss->list, &priv->network_free_list); |
1458 | &priv->network_free_list); | ||
1459 | clear_bss_descriptor(iter_bss); | 1406 | clear_bss_descriptor(iter_bss); |
1460 | continue; | 1407 | continue; |
1461 | } | 1408 | } |
@@ -1515,8 +1462,8 @@ static int lbs_ret_80211_scan(struct lbs_private *priv, unsigned long dummy, | |||
1515 | struct cmd_header *resp) | 1462 | struct cmd_header *resp) |
1516 | { | 1463 | { |
1517 | struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; | 1464 | struct cmd_ds_802_11_scan_rsp *scanresp = (void *)resp; |
1518 | struct bss_descriptor * iter_bss; | 1465 | struct bss_descriptor *iter_bss; |
1519 | struct bss_descriptor * safe; | 1466 | struct bss_descriptor *safe; |
1520 | uint8_t *bssinfo; | 1467 | uint8_t *bssinfo; |
1521 | uint16_t scanrespsize; | 1468 | uint16_t scanrespsize; |
1522 | int bytesleft; | 1469 | int bytesleft; |