aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHolger Schurig <hs4233@mail.mn-solutions.de>2007-10-09 08:15:19 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:55:21 -0400
commite56188ac4163cb276b7650949c1e8e20fb2f9c73 (patch)
treef6bc3bc3ac8c9fc8e1f6b30f2aa8d3241430331f /drivers/net
parent314a886f08d689cdcf10bd8e4777a3d9f483bb53 (diff)
[PATCH] libertas: clean up scan debug messages
* make scan debug output cleaner * change some LBS_DEB_ASSOC messages to LBS_DEB_SCAN, which is more correct * move helper functions together * print function return value in the tracing code at one central location Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de> Acked-By: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/libertas/join.c2
-rw-r--r--drivers/net/wireless/libertas/scan.c221
2 files changed, 155 insertions, 68 deletions
diff --git a/drivers/net/wireless/libertas/join.c b/drivers/net/wireless/libertas/join.c
index 8dcff00574f..dc24a05c944 100644
--- a/drivers/net/wireless/libertas/join.c
+++ b/drivers/net/wireless/libertas/join.c
@@ -800,8 +800,6 @@ int libertas_ret_80211_associate(wlan_private * priv,
800 netif_wake_queue(priv->mesh_dev); 800 netif_wake_queue(priv->mesh_dev);
801 } 801 }
802 802
803 lbs_deb_join("ASSOC_RESP: Associated \n");
804
805 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN); 803 memcpy(wrqu.ap_addr.sa_data, adapter->curbssparams.bssid, ETH_ALEN);
806 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 804 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
807 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL); 805 wireless_send_event(priv->dev, SIOCGIWAP, &wrqu, NULL);
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index dcce354e904..ad1e67d984c 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -65,6 +65,15 @@
65static const u8 zeromac[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 65static const u8 zeromac[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
66static const u8 bcastmac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; 66static const u8 bcastmac[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
67 67
68
69
70
71/*********************************************************************/
72/* */
73/* Misc helper functions */
74/* */
75/*********************************************************************/
76
68static inline void clear_bss_descriptor (struct bss_descriptor * bss) 77static inline void clear_bss_descriptor (struct bss_descriptor * bss)
69{ 78{
70 /* Don't blow away ->list, just BSS data */ 79 /* Don't blow away ->list, just BSS data */
@@ -165,7 +174,7 @@ static int is_network_compatible(wlan_adapter * adapter,
165{ 174{
166 int matched = 0; 175 int matched = 0;
167 176
168 lbs_deb_enter(LBS_DEB_ASSOC); 177 lbs_deb_enter(LBS_DEB_SCAN);
169 178
170 if (bss->mode != mode) 179 if (bss->mode != mode)
171 goto done; 180 goto done;
@@ -214,13 +223,41 @@ static int is_network_compatible(wlan_adapter * adapter,
214 (bss->capability & WLAN_CAPABILITY_PRIVACY)); 223 (bss->capability & WLAN_CAPABILITY_PRIVACY));
215 224
216done: 225done:
217 lbs_deb_leave(LBS_DEB_SCAN); 226 lbs_deb_leave_args(LBS_DEB_SCAN, "matched: %d", matched);
218 return matched; 227 return matched;
219} 228}
220 229
221/** 230/**
231 * @brief Compare two SSIDs
232 *
233 * @param ssid1 A pointer to ssid to compare
234 * @param ssid2 A pointer to ssid to compare
235 *
236 * @return 0--ssid is same, otherwise is different
237 */
238int libertas_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len)
239{
240 if (ssid1_len != ssid2_len)
241 return -1;
242
243 return memcmp(ssid1, ssid2, ssid1_len);
244}
245
246
247
248
249/*********************************************************************/
250/* */
251/* Main scanning support */
252/* */
253/*********************************************************************/
254
255
256/**
222 * @brief Create a channel list for the driver to scan based on region info 257 * @brief Create a channel list for the driver to scan based on region info
223 * 258 *
259 * Only used from wlan_scan_setup_scan_config()
260 *
224 * Use the driver region/band information to construct a comprehensive list 261 * Use the driver region/band information to construct a comprehensive list
225 * of channels to scan. This routine is used for any scan that is not 262 * of channels to scan. This routine is used for any scan that is not
226 * provided a specific channel list to scan. 263 * provided a specific channel list to scan.
@@ -248,6 +285,8 @@ static void wlan_scan_create_channel_list(wlan_private * priv,
248 int nextchan; 285 int nextchan;
249 u8 scantype; 286 u8 scantype;
250 287
288 lbs_deb_enter_args(LBS_DEB_SCAN, "filteredscan %d", filteredscan);
289
251 chanidx = 0; 290 chanidx = 0;
252 291
253 /* Set the default scan type to the user specified type, will later 292 /* Set the default scan type to the user specified type, will later
@@ -384,6 +423,8 @@ wlan_scan_setup_scan_config(wlan_private * priv,
384 int channel; 423 int channel;
385 int radiotype; 424 int radiotype;
386 425
426 lbs_deb_enter(LBS_DEB_SCAN);
427
387 pscancfgout = kzalloc(MAX_SCAN_CFG_ALLOC, GFP_KERNEL); 428 pscancfgout = kzalloc(MAX_SCAN_CFG_ALLOC, GFP_KERNEL);
388 if (pscancfgout == NULL) 429 if (pscancfgout == NULL)
389 goto out; 430 goto out;
@@ -481,13 +522,12 @@ wlan_scan_setup_scan_config(wlan_private * priv,
481 522
482 if (!puserscanin || !puserscanin->chanlist[0].channumber) { 523 if (!puserscanin || !puserscanin->chanlist[0].channumber) {
483 /* Create a default channel scan list */ 524 /* Create a default channel scan list */
484 lbs_deb_scan("Scan: Creating full region channel list\n"); 525 lbs_deb_scan("creating full region channel list\n");
485 wlan_scan_create_channel_list(priv, pscanchanlist, 526 wlan_scan_create_channel_list(priv, pscanchanlist,
486 *pfilteredscan); 527 *pfilteredscan);
487 goto out; 528 goto out;
488 } 529 }
489 530
490 lbs_deb_scan("Scan: Using supplied channel list\n");
491 for (chanidx = 0; 531 for (chanidx = 0;
492 chanidx < WLAN_IOCTL_USER_SCAN_CHAN_MAX 532 chanidx < WLAN_IOCTL_USER_SCAN_CHAN_MAX
493 && puserscanin->chanlist[chanidx].channumber; chanidx++) { 533 && puserscanin->chanlist[chanidx].channumber; chanidx++) {
@@ -529,7 +569,7 @@ wlan_scan_setup_scan_config(wlan_private * priv,
529 (puserscanin->chanlist[0].channumber == 569 (puserscanin->chanlist[0].channumber ==
530 priv->adapter->curbssparams.channel)) { 570 priv->adapter->curbssparams.channel)) {
531 *pscancurrentonly = 1; 571 *pscancurrentonly = 1;
532 lbs_deb_scan("Scan: Scanning current channel only"); 572 lbs_deb_scan("scanning current channel only");
533 } 573 }
534 574
535out: 575out:
@@ -539,6 +579,8 @@ out:
539/** 579/**
540 * @brief Construct and send multiple scan config commands to the firmware 580 * @brief Construct and send multiple scan config commands to the firmware
541 * 581 *
582 * Only used from wlan_scan_networks()
583 *
542 * Previous routines have created a wlan_scan_cmd_config with any requested 584 * Previous routines have created a wlan_scan_cmd_config with any requested
543 * TLVs. This function splits the channel TLV into maxchanperscan lists 585 * TLVs. This function splits the channel TLV into maxchanperscan lists
544 * and sends the portion of the channel TLV along with the other TLVs 586 * and sends the portion of the channel TLV along with the other TLVs
@@ -576,12 +618,14 @@ static int wlan_scan_channel_list(wlan_private * priv,
576 int scanned = 0; 618 int scanned = 0;
577 union iwreq_data wrqu; 619 union iwreq_data wrqu;
578 620
579 lbs_deb_enter(LBS_DEB_ASSOC); 621 lbs_deb_enter_args(LBS_DEB_SCAN, "maxchanperscan %d, filteredscan %d, "
622 "full_scan %d", maxchanperscan, filteredscan, full_scan);
580 623
581 if (!pscancfgout || !pchantlvout || !pscanchanlist) { 624 if (!pscancfgout || !pchantlvout || !pscanchanlist) {
582 lbs_deb_scan("Scan: Null detect: %p, %p, %p\n", 625 lbs_deb_scan("pscancfgout, pchantlvout or "
583 pscancfgout, pchantlvout, pscanchanlist); 626 "pscanchanlist is NULL\n");
584 return -1; 627 ret = -1;
628 goto out;
585 } 629 }
586 630
587 pchantlvout->header.type = cpu_to_le16(TLV_TYPE_CHANLIST); 631 pchantlvout->header.type = cpu_to_le16(TLV_TYPE_CHANLIST);
@@ -613,9 +657,10 @@ static int wlan_scan_channel_list(wlan_private * priv,
613 while (tlvidx < maxchanperscan && ptmpchan->channumber 657 while (tlvidx < maxchanperscan && ptmpchan->channumber
614 && !doneearly && scanned < 2) { 658 && !doneearly && scanned < 2) {
615 659
616 lbs_deb_scan("Scan: Chan(%3d), Radio(%d), mode(%d,%d), " 660 lbs_deb_scan("channel %d, radio %d, passive %d, "
617 "Dur(%d)\n", 661 "dischanflt %d, maxscantime %d\n",
618 ptmpchan->channumber, ptmpchan->radiotype, 662 ptmpchan->channumber,
663 ptmpchan->radiotype,
619 ptmpchan->chanscanmode.passivescan, 664 ptmpchan->chanscanmode.passivescan,
620 ptmpchan->chanscanmode.disablechanfilt, 665 ptmpchan->chanscanmode.disablechanfilt,
621 ptmpchan->maxscantime); 666 ptmpchan->maxscantime);
@@ -700,20 +745,25 @@ done:
700 wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); 745 wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL);
701 } 746 }
702 747
748out:
703 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 749 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
704 return ret; 750 return ret;
705} 751}
706 752
707static void 753/*
708clear_selected_scan_list_entries(wlan_adapter * adapter, 754 * Only used from wlan_scan_networks()
709 const struct wlan_ioctl_user_scan_cfg * scan_cfg) 755*/
756static void clear_selected_scan_list_entries(wlan_adapter *adapter,
757 const struct wlan_ioctl_user_scan_cfg *scan_cfg)
710{ 758{
711 struct bss_descriptor * bss; 759 struct bss_descriptor *bss;
712 struct bss_descriptor * safe; 760 struct bss_descriptor *safe;
713 u32 clear_ssid_flag = 0, clear_bssid_flag = 0; 761 u32 clear_ssid_flag = 0, clear_bssid_flag = 0;
714 762
763 lbs_deb_enter(LBS_DEB_SCAN);
764
715 if (!scan_cfg) 765 if (!scan_cfg)
716 return; 766 goto out;
717 767
718 if (scan_cfg->clear_ssid && scan_cfg->ssid_len) 768 if (scan_cfg->clear_ssid && scan_cfg->ssid_len)
719 clear_ssid_flag = 1; 769 clear_ssid_flag = 1;
@@ -725,7 +775,7 @@ clear_selected_scan_list_entries(wlan_adapter * adapter,
725 } 775 }
726 776
727 if (!clear_ssid_flag && !clear_bssid_flag) 777 if (!clear_ssid_flag && !clear_bssid_flag)
728 return; 778 goto out;
729 779
730 mutex_lock(&adapter->lock); 780 mutex_lock(&adapter->lock);
731 list_for_each_entry_safe (bss, safe, &adapter->network_list, list) { 781 list_for_each_entry_safe (bss, safe, &adapter->network_list, list) {
@@ -748,12 +798,16 @@ clear_selected_scan_list_entries(wlan_adapter * adapter,
748 } 798 }
749 } 799 }
750 mutex_unlock(&adapter->lock); 800 mutex_unlock(&adapter->lock);
801out:
802 lbs_deb_leave(LBS_DEB_SCAN);
751} 803}
752 804
753 805
754/** 806/**
755 * @brief Internal function used to start a scan based on an input config 807 * @brief Internal function used to start a scan based on an input config
756 * 808 *
809 * Also used from debugfs
810 *
757 * Use the input user scan configuration information when provided in 811 * Use the input user scan configuration information when provided in
758 * order to send the appropriate scan commands to firmware to populate or 812 * order to send the appropriate scan commands to firmware to populate or
759 * update the internal driver scan table 813 * update the internal driver scan table
@@ -761,6 +815,7 @@ clear_selected_scan_list_entries(wlan_adapter * adapter,
761 * @param priv A pointer to wlan_private structure 815 * @param priv A pointer to wlan_private structure
762 * @param puserscanin Pointer to the input configuration for the requested 816 * @param puserscanin Pointer to the input configuration for the requested
763 * scan. 817 * scan.
818 * @param full_scan ???
764 * 819 *
765 * @return 0 or < 0 if error 820 * @return 0 or < 0 if error
766 */ 821 */
@@ -782,7 +837,7 @@ int wlan_scan_networks(wlan_private * priv,
782 DECLARE_MAC_BUF(mac); 837 DECLARE_MAC_BUF(mac);
783#endif 838#endif
784 839
785 lbs_deb_enter(LBS_DEB_SCAN); 840 lbs_deb_enter_args(LBS_DEB_SCAN, "full_scan %d", full_scan);
786 841
787 /* Cancel any partial outstanding partial scans if this scan 842 /* Cancel any partial outstanding partial scans if this scan
788 * is a full scan. 843 * is a full scan.
@@ -833,8 +888,9 @@ int wlan_scan_networks(wlan_private * priv,
833#ifdef CONFIG_LIBERTAS_DEBUG 888#ifdef CONFIG_LIBERTAS_DEBUG
834 /* Dump the scan table */ 889 /* Dump the scan table */
835 mutex_lock(&adapter->lock); 890 mutex_lock(&adapter->lock);
891 lbs_deb_scan("The scan table contains:\n");
836 list_for_each_entry (iter_bss, &adapter->network_list, list) { 892 list_for_each_entry (iter_bss, &adapter->network_list, list) {
837 lbs_deb_scan("Scan:(%02d) %s, RSSI[%03d], SSID[%s]\n", 893 lbs_deb_scan("scan %02d, %s, RSSI, %d, SSID '%s'\n",
838 i++, print_mac(mac, iter_bss->bssid), (s32) iter_bss->rssi, 894 i++, print_mac(mac, iter_bss->bssid), (s32) iter_bss->rssi,
839 escape_essid(iter_bss->ssid, iter_bss->ssid_len)); 895 escape_essid(iter_bss->ssid, iter_bss->ssid_len));
840 } 896 }
@@ -886,7 +942,7 @@ static int libertas_process_bss(struct bss_descriptor * bss,
886 u16 beaconsize = 0; 942 u16 beaconsize = 0;
887 int ret; 943 int ret;
888 944
889 lbs_deb_enter(LBS_DEB_ASSOC); 945 lbs_deb_enter(LBS_DEB_SCAN);
890 946
891 if (*bytesleft >= sizeof(beaconsize)) { 947 if (*bytesleft >= sizeof(beaconsize)) {
892 /* Extract & convert beacon size from the command buffer */ 948 /* Extract & convert beacon size from the command buffer */
@@ -898,7 +954,8 @@ static int libertas_process_bss(struct bss_descriptor * bss,
898 if (beaconsize == 0 || beaconsize > *bytesleft) { 954 if (beaconsize == 0 || beaconsize > *bytesleft) {
899 *pbeaconinfo += *bytesleft; 955 *pbeaconinfo += *bytesleft;
900 *bytesleft = 0; 956 *bytesleft = 0;
901 return -1; 957 ret = -1;
958 goto done;
902 } 959 }
903 960
904 /* Initialize the current working beacon pointer for this BSS iteration */ 961 /* Initialize the current working beacon pointer for this BSS iteration */
@@ -915,7 +972,8 @@ static int libertas_process_bss(struct bss_descriptor * bss,
915 972
916 if ((end - pos) < 12) { 973 if ((end - pos) < 12) {
917 lbs_deb_scan("process_bss: Not enough bytes left\n"); 974 lbs_deb_scan("process_bss: Not enough bytes left\n");
918 return -1; 975 ret = -1;
976 goto done;
919 } 977 }
920 978
921 /* 979 /*
@@ -1091,38 +1149,26 @@ done:
1091} 1149}
1092 1150
1093/** 1151/**
1094 * @brief Compare two SSIDs
1095 *
1096 * @param ssid1 A pointer to ssid to compare
1097 * @param ssid2 A pointer to ssid to compare
1098 *
1099 * @return 0--ssid is same, otherwise is different
1100 */
1101int libertas_ssid_cmp(u8 *ssid1, u8 ssid1_len, u8 *ssid2, u8 ssid2_len)
1102{
1103 if (ssid1_len != ssid2_len)
1104 return -1;
1105
1106 return memcmp(ssid1, ssid2, ssid1_len);
1107}
1108
1109/**
1110 * @brief This function finds a specific compatible BSSID in the scan list 1152 * @brief This function finds a specific compatible BSSID in the scan list
1111 * 1153 *
1154 * Used in association code
1155 *
1112 * @param adapter A pointer to wlan_adapter 1156 * @param adapter A pointer to wlan_adapter
1113 * @param bssid BSSID to find in the scan list 1157 * @param bssid BSSID to find in the scan list
1114 * @param mode Network mode: Infrastructure or IBSS 1158 * @param mode Network mode: Infrastructure or IBSS
1115 * 1159 *
1116 * @return index in BSSID list, or error return code (< 0) 1160 * @return index in BSSID list, or error return code (< 0)
1117 */ 1161 */
1118struct bss_descriptor * libertas_find_bssid_in_list(wlan_adapter * adapter, 1162struct bss_descriptor *libertas_find_bssid_in_list(wlan_adapter * adapter,
1119 u8 * bssid, u8 mode) 1163 u8 * bssid, u8 mode)
1120{ 1164{
1121 struct bss_descriptor * iter_bss; 1165 struct bss_descriptor * iter_bss;
1122 struct bss_descriptor * found_bss = NULL; 1166 struct bss_descriptor * found_bss = NULL;
1123 1167
1168 lbs_deb_enter(LBS_DEB_SCAN);
1169
1124 if (!bssid) 1170 if (!bssid)
1125 return NULL; 1171 goto out;
1126 1172
1127 lbs_deb_hex(LBS_DEB_SCAN, "looking for", 1173 lbs_deb_hex(LBS_DEB_SCAN, "looking for",
1128 bssid, ETH_ALEN); 1174 bssid, ETH_ALEN);
@@ -1149,12 +1195,16 @@ struct bss_descriptor * libertas_find_bssid_in_list(wlan_adapter * adapter,
1149 } 1195 }
1150 mutex_unlock(&adapter->lock); 1196 mutex_unlock(&adapter->lock);
1151 1197
1198out:
1199 lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss);
1152 return found_bss; 1200 return found_bss;
1153} 1201}
1154 1202
1155/** 1203/**
1156 * @brief This function finds ssid in ssid list. 1204 * @brief This function finds ssid in ssid list.
1157 * 1205 *
1206 * Used in association code
1207 *
1158 * @param adapter A pointer to wlan_adapter 1208 * @param adapter A pointer to wlan_adapter
1159 * @param ssid SSID to find in the list 1209 * @param ssid SSID to find in the list
1160 * @param bssid BSSID to qualify the SSID selection (if provided) 1210 * @param bssid BSSID to qualify the SSID selection (if provided)
@@ -1171,6 +1221,8 @@ struct bss_descriptor * libertas_find_ssid_in_list(wlan_adapter * adapter,
1171 struct bss_descriptor * found_bss = NULL; 1221 struct bss_descriptor * found_bss = NULL;
1172 struct bss_descriptor * tmp_oldest = NULL; 1222 struct bss_descriptor * tmp_oldest = NULL;
1173 1223
1224 lbs_deb_enter(LBS_DEB_SCAN);
1225
1174 mutex_lock(&adapter->lock); 1226 mutex_lock(&adapter->lock);
1175 1227
1176 list_for_each_entry (iter_bss, &adapter->network_list, list) { 1228 list_for_each_entry (iter_bss, &adapter->network_list, list) {
@@ -1215,6 +1267,7 @@ struct bss_descriptor * libertas_find_ssid_in_list(wlan_adapter * adapter,
1215 1267
1216out: 1268out:
1217 mutex_unlock(&adapter->lock); 1269 mutex_unlock(&adapter->lock);
1270 lbs_deb_leave_args(LBS_DEB_SCAN, "found_bss %p", found_bss);
1218 return found_bss; 1271 return found_bss;
1219} 1272}
1220 1273
@@ -1235,6 +1288,8 @@ static struct bss_descriptor * libertas_find_best_ssid_in_list(wlan_adapter * ad
1235 struct bss_descriptor * iter_bss; 1288 struct bss_descriptor * iter_bss;
1236 struct bss_descriptor * best_bss = NULL; 1289 struct bss_descriptor * best_bss = NULL;
1237 1290
1291 lbs_deb_enter(LBS_DEB_SCAN);
1292
1238 mutex_lock(&adapter->lock); 1293 mutex_lock(&adapter->lock);
1239 1294
1240 list_for_each_entry (iter_bss, &adapter->network_list, list) { 1295 list_for_each_entry (iter_bss, &adapter->network_list, list) {
@@ -1259,12 +1314,15 @@ static struct bss_descriptor * libertas_find_best_ssid_in_list(wlan_adapter * ad
1259 } 1314 }
1260 1315
1261 mutex_unlock(&adapter->lock); 1316 mutex_unlock(&adapter->lock);
1317 lbs_deb_leave_args(LBS_DEB_SCAN, "best_bss %p", best_bss);
1262 return best_bss; 1318 return best_bss;
1263} 1319}
1264 1320
1265/** 1321/**
1266 * @brief Find the AP with specific ssid in the scan list 1322 * @brief Find the AP with specific ssid in the scan list
1267 * 1323 *
1324 * Used from association worker.
1325 *
1268 * @param priv A pointer to wlan_private structure 1326 * @param priv A pointer to wlan_private structure
1269 * @param pSSID A pointer to AP's ssid 1327 * @param pSSID A pointer to AP's ssid
1270 * 1328 *
@@ -1277,11 +1335,11 @@ int libertas_find_best_network_ssid(wlan_private * priv,
1277 int ret = -1; 1335 int ret = -1;
1278 struct bss_descriptor * found; 1336 struct bss_descriptor * found;
1279 1337
1280 lbs_deb_enter(LBS_DEB_ASSOC); 1338 lbs_deb_enter(LBS_DEB_SCAN);
1281 1339
1282 wlan_scan_networks(priv, NULL, 1); 1340 wlan_scan_networks(priv, NULL, 1);
1283 if (adapter->surpriseremoved) 1341 if (adapter->surpriseremoved)
1284 return -1; 1342 goto out;
1285 1343
1286 wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending); 1344 wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending);
1287 1345
@@ -1293,6 +1351,7 @@ int libertas_find_best_network_ssid(wlan_private * priv,
1293 ret = 0; 1351 ret = 0;
1294 } 1352 }
1295 1353
1354out:
1296 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret); 1355 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
1297 return ret; 1356 return ret;
1298} 1357}
@@ -1327,10 +1386,17 @@ int libertas_set_scan(struct net_device *dev, struct iw_request_info *info,
1327 return 0; 1386 return 0;
1328} 1387}
1329 1388
1389
1330/** 1390/**
1331 * @brief Send a scan command for all available channels filtered on a spec 1391 * @brief Send a scan command for all available channels filtered on a spec
1332 * 1392 *
1393 * Used in association code and from debugfs
1394 *
1333 * @param priv A pointer to wlan_private structure 1395 * @param priv A pointer to wlan_private structure
1396 * @param ssid A pointer to the SSID to scan for
1397 * @param ssid_len Length of the SSID
1398 * @param clear_ssid Should existing scan results with this SSID
1399 * be cleared?
1334 * @param prequestedssid A pointer to AP's ssid 1400 * @param prequestedssid A pointer to AP's ssid
1335 * @param keeppreviousscan Flag used to save/clear scan table before scan 1401 * @param keeppreviousscan Flag used to save/clear scan table before scan
1336 * 1402 *
@@ -1343,7 +1409,8 @@ int libertas_send_specific_ssid_scan(wlan_private * priv,
1343 struct wlan_ioctl_user_scan_cfg scancfg; 1409 struct wlan_ioctl_user_scan_cfg scancfg;
1344 int ret = 0; 1410 int ret = 0;
1345 1411
1346 lbs_deb_enter(LBS_DEB_ASSOC); 1412 lbs_deb_enter_args(LBS_DEB_SCAN, "SSID '%s', clear %d",
1413 escape_essid(ssid, ssid_len), clear_ssid);
1347 1414
1348 if (!ssid_len) 1415 if (!ssid_len)
1349 goto out; 1416 goto out;
@@ -1354,15 +1421,26 @@ int libertas_send_specific_ssid_scan(wlan_private * priv,
1354 scancfg.clear_ssid = clear_ssid; 1421 scancfg.clear_ssid = clear_ssid;
1355 1422
1356 wlan_scan_networks(priv, &scancfg, 1); 1423 wlan_scan_networks(priv, &scancfg, 1);
1357 if (adapter->surpriseremoved) 1424 if (adapter->surpriseremoved) {
1358 return -1; 1425 ret = -1;
1426 goto out;
1427 }
1359 wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending); 1428 wait_event_interruptible(adapter->cmd_pending, !adapter->nr_cmd_pending);
1360 1429
1361out: 1430out:
1362 lbs_deb_leave(LBS_DEB_ASSOC); 1431 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", ret);
1363 return ret; 1432 return ret;
1364} 1433}
1365 1434
1435
1436
1437
1438/*********************************************************************/
1439/* */
1440/* Support for Wireless Extensions */
1441/* */
1442/*********************************************************************/
1443
1366#define MAX_CUSTOM_LEN 64 1444#define MAX_CUSTOM_LEN 64
1367 1445
1368static inline char *libertas_translate_scan(wlan_private *priv, 1446static inline char *libertas_translate_scan(wlan_private *priv,
@@ -1379,10 +1457,13 @@ static inline char *libertas_translate_scan(wlan_private *priv,
1379#define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI)) 1457#define RSSI_DIFF ((u8)(PERFECT_RSSI - WORST_RSSI))
1380 u8 rssi; 1458 u8 rssi;
1381 1459
1460 lbs_deb_enter(LBS_DEB_SCAN);
1461
1382 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, bss->channel); 1462 cfp = libertas_find_cfp_by_band_and_channel(adapter, 0, bss->channel);
1383 if (!cfp) { 1463 if (!cfp) {
1384 lbs_deb_scan("Invalid channel number %d\n", bss->channel); 1464 lbs_deb_scan("Invalid channel number %d\n", bss->channel);
1385 return NULL; 1465 start = NULL;
1466 goto out;
1386 } 1467 }
1387 1468
1388 /* First entry *MUST* be the AP BSSID */ 1469 /* First entry *MUST* be the AP BSSID */
@@ -1510,11 +1591,13 @@ static inline char *libertas_translate_scan(wlan_private *priv,
1510 start = iwe_stream_add_point(start, stop, &iwe, custom); 1591 start = iwe_stream_add_point(start, stop, &iwe, custom);
1511 } 1592 }
1512 1593
1594out:
1595 lbs_deb_leave_args(LBS_DEB_SCAN, "start %p", start);
1513 return start; 1596 return start;
1514} 1597}
1515 1598
1516/** 1599/**
1517 * @brief Retrieve the scan table entries via wireless tools IOCTL call 1600 * @brief Handle Retrieve scan table ioctl
1518 * 1601 *
1519 * @param dev A pointer to net_device structure 1602 * @param dev A pointer to net_device structure
1520 * @param info A pointer to iw_request_info structure 1603 * @param info A pointer to iw_request_info structure
@@ -1535,7 +1618,7 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1535 struct bss_descriptor * iter_bss; 1618 struct bss_descriptor * iter_bss;
1536 struct bss_descriptor * safe; 1619 struct bss_descriptor * safe;
1537 1620
1538 lbs_deb_enter(LBS_DEB_ASSOC); 1621 lbs_deb_enter(LBS_DEB_SCAN);
1539 1622
1540 /* Update RSSI if current BSS is a locally created ad-hoc BSS */ 1623 /* Update RSSI if current BSS is a locally created ad-hoc BSS */
1541 if ((adapter->mode == IW_MODE_ADHOC) && adapter->adhoccreate) { 1624 if ((adapter->mode == IW_MODE_ADHOC) && adapter->adhoccreate) {
@@ -1577,19 +1660,27 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1577 dwrq->length = (ev - extra); 1660 dwrq->length = (ev - extra);
1578 dwrq->flags = 0; 1661 dwrq->flags = 0;
1579 1662
1580 lbs_deb_leave(LBS_DEB_ASSOC); 1663 lbs_deb_leave_args(LBS_DEB_SCAN, "ret %d", err);
1581 return err; 1664 return err;
1582} 1665}
1583 1666
1667
1668
1669
1670/*********************************************************************/
1671/* */
1672/* Command execution */
1673/* */
1674/*********************************************************************/
1675
1676
1584/** 1677/**
1585 * @brief Prepare a scan command to be sent to the firmware 1678 * @brief Prepare a scan command to be sent to the firmware
1586 * 1679 *
1587 * Use the wlan_scan_cmd_config sent to the command processing module in 1680 * Called from libertas_prepare_and_send_command() in cmd.c
1588 * the libertas_prepare_and_send_command to configure a cmd_ds_802_11_scan command
1589 * struct to send to firmware.
1590 * 1681 *
1591 * The fixed fields specifying the BSS type and BSSID filters as well as a 1682 * Sends a fixed lenght data part (specifying the BSS type and BSSID filters)
1592 * variable number/length of TLVs are sent in the command to firmware. 1683 * as well as a variable number/length of TLVs to the firmware.
1593 * 1684 *
1594 * @param priv A pointer to wlan_private structure 1685 * @param priv A pointer to wlan_private structure
1595 * @param cmd A pointer to cmd_ds_command structure to be sent to 1686 * @param cmd A pointer to cmd_ds_command structure to be sent to
@@ -1598,18 +1689,14 @@ int libertas_get_scan(struct net_device *dev, struct iw_request_info *info,
1598 * to set the fields/TLVs for the command sent to firmware 1689 * to set the fields/TLVs for the command sent to firmware
1599 * 1690 *
1600 * @return 0 or -1 1691 * @return 0 or -1
1601 *
1602 * @sa wlan_scan_create_channel_list
1603 */ 1692 */
1604int libertas_cmd_80211_scan(wlan_private * priv, 1693int libertas_cmd_80211_scan(wlan_private * priv,
1605 struct cmd_ds_command *cmd, void *pdata_buf) 1694 struct cmd_ds_command *cmd, void *pdata_buf)
1606{ 1695{
1607 struct cmd_ds_802_11_scan *pscan = &cmd->params.scan; 1696 struct cmd_ds_802_11_scan *pscan = &cmd->params.scan;
1608 struct wlan_scan_cmd_config *pscancfg; 1697 struct wlan_scan_cmd_config *pscancfg = pdata_buf;
1609
1610 lbs_deb_enter(LBS_DEB_ASSOC);
1611 1698
1612 pscancfg = pdata_buf; 1699 lbs_deb_enter(LBS_DEB_SCAN);
1613 1700
1614 /* Set fixed field variables in scan command */ 1701 /* Set fixed field variables in scan command */
1615 pscan->bsstype = pscancfg->bsstype; 1702 pscan->bsstype = pscancfg->bsstype;
@@ -1622,11 +1709,11 @@ int libertas_cmd_80211_scan(wlan_private * priv,
1622 cmd->size = cpu_to_le16(sizeof(pscan->bsstype) + ETH_ALEN 1709 cmd->size = cpu_to_le16(sizeof(pscan->bsstype) + ETH_ALEN
1623 + pscancfg->tlvbufferlen + S_DS_GEN); 1710 + pscancfg->tlvbufferlen + S_DS_GEN);
1624 1711
1625 lbs_deb_scan("SCAN_CMD: command=%x, size=%x, seqnum=%x\n", 1712 lbs_deb_scan("SCAN_CMD: command 0x%04x, size %d, seqnum %d\n",
1626 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size), 1713 le16_to_cpu(cmd->command), le16_to_cpu(cmd->size),
1627 le16_to_cpu(cmd->seqnum)); 1714 le16_to_cpu(cmd->seqnum));
1628 1715
1629 lbs_deb_leave(LBS_DEB_ASSOC); 1716 lbs_deb_leave(LBS_DEB_SCAN);
1630 return 0; 1717 return 0;
1631} 1718}
1632 1719
@@ -1645,6 +1732,8 @@ static inline int is_same_network(struct bss_descriptor *src,
1645/** 1732/**
1646 * @brief This function handles the command response of scan 1733 * @brief This function handles the command response of scan
1647 * 1734 *
1735 * Called from handle_cmd_response() in cmdrespc.
1736 *
1648 * The response buffer for the scan command has the following 1737 * The response buffer for the scan command has the following
1649 * memory layout: 1738 * memory layout:
1650 * 1739 *
@@ -1679,7 +1768,7 @@ int libertas_ret_80211_scan(wlan_private * priv, struct cmd_ds_command *resp)
1679 int tlvbufsize; 1768 int tlvbufsize;
1680 int ret; 1769 int ret;
1681 1770
1682 lbs_deb_enter(LBS_DEB_ASSOC); 1771 lbs_deb_enter(LBS_DEB_SCAN);
1683 1772
1684 /* Prune old entries from scan table */ 1773 /* Prune old entries from scan table */
1685 list_for_each_entry_safe (iter_bss, safe, &adapter->network_list, list) { 1774 list_for_each_entry_safe (iter_bss, safe, &adapter->network_list, list) {