aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/scan.c
diff options
context:
space:
mode:
authorAmitkumar Karwar <akarwar@marvell.com>2011-04-13 20:27:06 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-04-14 15:35:11 -0400
commit600f5d909a54a8dccf8c8c23898fc2e91bc0953e (patch)
treedad2709218946398c370647f16d0dd6f2f9a1919 /drivers/net/wireless/mwifiex/scan.c
parent3a9dddea89eb2132ba919fe04cb3b44a3b1e6db7 (diff)
mwifiex: cleanup ioctl wait queue and abstraction layer
1) remove mwifiex_alloc_fill_wait_queue() and mwifiex_request_ioctl() 2) avoid dynamic allocation of wait queue 3) remove unnecessary mwifiex_error_code macros that were used mainly by the wait queue status code 4) remove some abstraction functions 5) split mwifiex_prepare_cmd() to mwifiex_send_cmd_async() and mwifiex_send_sync() to handle asynchronous and synchronous commands respectively Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/scan.c')
-rw-r--r--drivers/net/wireless/mwifiex/scan.c126
1 files changed, 34 insertions, 92 deletions
diff --git a/drivers/net/wireless/mwifiex/scan.c b/drivers/net/wireless/mwifiex/scan.c
index 6bb52d0e6cfa..12fe021536d1 100644
--- a/drivers/net/wireless/mwifiex/scan.c
+++ b/drivers/net/wireless/mwifiex/scan.c
@@ -178,9 +178,8 @@ mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
178 * with requisite parameters and calls the IOCTL handler. 178 * with requisite parameters and calls the IOCTL handler.
179 */ 179 */
180int mwifiex_find_best_bss(struct mwifiex_private *priv, 180int mwifiex_find_best_bss(struct mwifiex_private *priv,
181 u8 wait_option, struct mwifiex_ssid_bssid *ssid_bssid) 181 struct mwifiex_ssid_bssid *ssid_bssid)
182{ 182{
183 struct mwifiex_wait_queue *wait = NULL;
184 struct mwifiex_ssid_bssid tmp_ssid_bssid; 183 struct mwifiex_ssid_bssid tmp_ssid_bssid;
185 int ret = 0; 184 int ret = 0;
186 u8 *mac = NULL; 185 u8 *mac = NULL;
@@ -188,14 +187,9 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
188 if (!ssid_bssid) 187 if (!ssid_bssid)
189 return -1; 188 return -1;
190 189
191 /* Allocate wait request buffer */
192 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
193 if (!wait)
194 return -ENOMEM;
195
196 memcpy(&tmp_ssid_bssid, ssid_bssid, 190 memcpy(&tmp_ssid_bssid, ssid_bssid,
197 sizeof(struct mwifiex_ssid_bssid)); 191 sizeof(struct mwifiex_ssid_bssid));
198 ret = mwifiex_bss_ioctl_find_bss(priv, wait, &tmp_ssid_bssid); 192 ret = mwifiex_bss_ioctl_find_bss(priv, &tmp_ssid_bssid);
199 193
200 if (!ret) { 194 if (!ret) {
201 memcpy(ssid_bssid, &tmp_ssid_bssid, 195 memcpy(ssid_bssid, &tmp_ssid_bssid,
@@ -205,7 +199,6 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
205 " %pM\n", ssid_bssid->ssid.ssid, mac); 199 " %pM\n", ssid_bssid->ssid.ssid, mac);
206 } 200 }
207 201
208 kfree(wait);
209 return ret; 202 return ret;
210} 203}
211 204
@@ -221,22 +214,14 @@ int mwifiex_find_best_bss(struct mwifiex_private *priv,
221int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv, 214int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
222 struct mwifiex_user_scan_cfg *scan_req) 215 struct mwifiex_user_scan_cfg *scan_req)
223{ 216{
224 struct mwifiex_wait_queue *wait = NULL;
225 int status = 0; 217 int status = 0;
226 u8 wait_option = MWIFIEX_IOCTL_WAIT;
227
228 /* Allocate an IOCTL request buffer */
229 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
230 if (!wait)
231 return -ENOMEM;
232 218
233 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_SET, 219 priv->adapter->cmd_wait_q.condition = false;
234 scan_req, NULL);
235 220
236 status = mwifiex_request_ioctl(priv, wait, status, wait_option); 221 status = mwifiex_scan_networks(priv, scan_req);
222 if (!status)
223 status = mwifiex_wait_queue_complete(priv->adapter);
237 224
238 if (wait && (status != -EINPROGRESS))
239 kfree(wait);
240 return status; 225 return status;
241} 226}
242 227
@@ -674,7 +659,7 @@ mwifiex_scan_create_channel_list(struct mwifiex_private *priv,
674 * along with the other TLVs, to the firmware. 659 * along with the other TLVs, to the firmware.
675 */ 660 */
676static int 661static int
677mwifiex_scan_channel_list(struct mwifiex_private *priv, void *wait_buf, 662mwifiex_scan_channel_list(struct mwifiex_private *priv,
678 u32 max_chan_per_scan, u8 filtered_scan, 663 u32 max_chan_per_scan, u8 filtered_scan,
679 struct mwifiex_scan_cmd_config *scan_cfg_out, 664 struct mwifiex_scan_cmd_config *scan_cfg_out,
680 struct mwifiex_ie_types_chan_list_param_set 665 struct mwifiex_ie_types_chan_list_param_set
@@ -808,9 +793,9 @@ mwifiex_scan_channel_list(struct mwifiex_private *priv, void *wait_buf,
808 793
809 /* Send the scan command to the firmware with the specified 794 /* Send the scan command to the firmware with the specified
810 cfg */ 795 cfg */
811 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SCAN, 796 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_802_11_SCAN,
812 HostCmd_ACT_GEN_SET, 797 HostCmd_ACT_GEN_SET, 0,
813 0, wait_buf, scan_cfg_out); 798 scan_cfg_out);
814 if (ret) 799 if (ret)
815 break; 800 break;
816 } 801 }
@@ -2271,9 +2256,7 @@ mwifiex_scan_delete_ssid_table_entry(struct mwifiex_private *priv,
2271 * update the internal driver scan table. 2256 * update the internal driver scan table.
2272 */ 2257 */
2273int mwifiex_scan_networks(struct mwifiex_private *priv, 2258int mwifiex_scan_networks(struct mwifiex_private *priv,
2274 void *wait_buf, u16 action, 2259 const struct mwifiex_user_scan_cfg *user_scan_in)
2275 const struct mwifiex_user_scan_cfg *user_scan_in,
2276 struct mwifiex_scan_resp *scan_resp)
2277{ 2260{
2278 int ret = 0; 2261 int ret = 0;
2279 struct mwifiex_adapter *adapter = priv->adapter; 2262 struct mwifiex_adapter *adapter = priv->adapter;
@@ -2288,18 +2271,7 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2288 u8 max_chan_per_scan; 2271 u8 max_chan_per_scan;
2289 unsigned long flags; 2272 unsigned long flags;
2290 2273
2291 if (action == HostCmd_ACT_GEN_GET) { 2274 if (adapter->scan_processing) {
2292 if (scan_resp) {
2293 scan_resp->scan_table = (u8 *) adapter->scan_table;
2294 scan_resp->num_in_scan_table =
2295 adapter->num_in_scan_table;
2296 } else {
2297 ret = -1;
2298 }
2299 return ret;
2300 }
2301
2302 if (adapter->scan_processing && action == HostCmd_ACT_GEN_SET) {
2303 dev_dbg(adapter->dev, "cmd: Scan already in process...\n"); 2275 dev_dbg(adapter->dev, "cmd: Scan already in process...\n");
2304 return ret; 2276 return ret;
2305 } 2277 }
@@ -2308,7 +2280,7 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2308 adapter->scan_processing = true; 2280 adapter->scan_processing = true;
2309 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); 2281 spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
2310 2282
2311 if (priv->scan_block && action == HostCmd_ACT_GEN_SET) { 2283 if (priv->scan_block) {
2312 dev_dbg(adapter->dev, 2284 dev_dbg(adapter->dev,
2313 "cmd: Scan is blocked during association...\n"); 2285 "cmd: Scan is blocked during association...\n");
2314 return ret; 2286 return ret;
@@ -2348,9 +2320,9 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2348 adapter->bcn_buf_end = adapter->bcn_buf; 2320 adapter->bcn_buf_end = adapter->bcn_buf;
2349 } 2321 }
2350 2322
2351 ret = mwifiex_scan_channel_list(priv, wait_buf, max_chan_per_scan, 2323 ret = mwifiex_scan_channel_list(priv, max_chan_per_scan, filtered_scan,
2352 filtered_scan, &scan_cfg_out->config, 2324 &scan_cfg_out->config, chan_list_out,
2353 chan_list_out, scan_chan_list); 2325 scan_chan_list);
2354 2326
2355 /* Get scan command from scan_pending_q and put to cmd_pending_q */ 2327 /* Get scan command from scan_pending_q and put to cmd_pending_q */
2356 if (!ret) { 2328 if (!ret) {
@@ -2367,7 +2339,6 @@ int mwifiex_scan_networks(struct mwifiex_private *priv,
2367 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, 2339 spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
2368 flags); 2340 flags);
2369 } 2341 }
2370 ret = -EINPROGRESS;
2371 } else { 2342 } else {
2372 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); 2343 spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
2373 adapter->scan_processing = true; 2344 adapter->scan_processing = true;
@@ -2437,11 +2408,10 @@ int mwifiex_cmd_802_11_scan(struct mwifiex_private *priv,
2437 * .-------------------------------------------------------------. 2408 * .-------------------------------------------------------------.
2438 */ 2409 */
2439int mwifiex_ret_802_11_scan(struct mwifiex_private *priv, 2410int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2440 struct host_cmd_ds_command *resp, void *wq_buf) 2411 struct host_cmd_ds_command *resp)
2441{ 2412{
2442 int ret = 0; 2413 int ret = 0;
2443 struct mwifiex_adapter *adapter = priv->adapter; 2414 struct mwifiex_adapter *adapter = priv->adapter;
2444 struct mwifiex_wait_queue *wait_queue = NULL;
2445 struct cmd_ctrl_node *cmd_node = NULL; 2415 struct cmd_ctrl_node *cmd_node = NULL;
2446 struct host_cmd_ds_802_11_scan_rsp *scan_rsp = NULL; 2416 struct host_cmd_ds_802_11_scan_rsp *scan_rsp = NULL;
2447 struct mwifiex_bssdescriptor *bss_new_entry = NULL; 2417 struct mwifiex_bssdescriptor *bss_new_entry = NULL;
@@ -2653,13 +2623,9 @@ int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
2653 mwifiex_process_scan_results(priv); 2623 mwifiex_process_scan_results(priv);
2654 2624
2655 /* Need to indicate IOCTL complete */ 2625 /* Need to indicate IOCTL complete */
2656 wait_queue = (struct mwifiex_wait_queue *) wq_buf; 2626 if (adapter->curr_cmd->wait_q_enabled) {
2657 if (wait_queue) { 2627 adapter->cmd_wait_q.status = 0;
2658 wait_queue->status = MWIFIEX_ERROR_NO_ERROR; 2628 mwifiex_complete_cmd(adapter);
2659
2660 /* Indicate ioctl complete */
2661 mwifiex_ioctl_complete(adapter,
2662 (struct mwifiex_wait_queue *) wait_queue, 0);
2663 } 2629 }
2664 if (priv->report_scan_result) 2630 if (priv->report_scan_result)
2665 priv->report_scan_result = false; 2631 priv->report_scan_result = false;
@@ -2853,6 +2819,7 @@ mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
2853 struct mwifiex_adapter *adapter = priv->adapter; 2819 struct mwifiex_adapter *adapter = priv->adapter;
2854 unsigned long flags; 2820 unsigned long flags;
2855 2821
2822 cmd_node->wait_q_enabled = true;
2856 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); 2823 spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
2857 list_add_tail(&cmd_node->list, &adapter->scan_pending_q); 2824 list_add_tail(&cmd_node->list, &adapter->scan_pending_q);
2858 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); 2825 spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
@@ -2899,9 +2866,7 @@ int mwifiex_find_best_network(struct mwifiex_private *priv,
2899 * firmware, filtered on a specific SSID. 2866 * firmware, filtered on a specific SSID.
2900 */ 2867 */
2901static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv, 2868static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2902 void *wait_buf, u16 action, 2869 struct mwifiex_802_11_ssid *req_ssid)
2903 struct mwifiex_802_11_ssid *req_ssid,
2904 struct mwifiex_scan_resp *scan_resp)
2905{ 2870{
2906 struct mwifiex_adapter *adapter = priv->adapter; 2871 struct mwifiex_adapter *adapter = priv->adapter;
2907 int ret = 0; 2872 int ret = 0;
@@ -2910,24 +2875,12 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2910 if (!req_ssid) 2875 if (!req_ssid)
2911 return -1; 2876 return -1;
2912 2877
2913 if (action == HostCmd_ACT_GEN_GET) { 2878 if (adapter->scan_processing) {
2914 if (scan_resp) {
2915 scan_resp->scan_table =
2916 (u8 *) &priv->curr_bss_params.bss_descriptor;
2917 scan_resp->num_in_scan_table =
2918 adapter->num_in_scan_table;
2919 } else {
2920 ret = -1;
2921 }
2922 return ret;
2923 }
2924
2925 if (adapter->scan_processing && action == HostCmd_ACT_GEN_SET) {
2926 dev_dbg(adapter->dev, "cmd: Scan already in process...\n"); 2879 dev_dbg(adapter->dev, "cmd: Scan already in process...\n");
2927 return ret; 2880 return ret;
2928 } 2881 }
2929 2882
2930 if (priv->scan_block && action == HostCmd_ACT_GEN_SET) { 2883 if (priv->scan_block) {
2931 dev_dbg(adapter->dev, 2884 dev_dbg(adapter->dev,
2932 "cmd: Scan is blocked during association...\n"); 2885 "cmd: Scan is blocked during association...\n");
2933 return ret; 2886 return ret;
@@ -2945,7 +2898,7 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2945 req_ssid->ssid_len); 2898 req_ssid->ssid_len);
2946 scan_cfg->keep_previous_scan = true; 2899 scan_cfg->keep_previous_scan = true;
2947 2900
2948 ret = mwifiex_scan_networks(priv, wait_buf, action, scan_cfg, NULL); 2901 ret = mwifiex_scan_networks(priv, scan_cfg);
2949 2902
2950 kfree(scan_cfg); 2903 kfree(scan_cfg);
2951 return ret; 2904 return ret;
@@ -2960,12 +2913,10 @@ static int mwifiex_scan_specific_ssid(struct mwifiex_private *priv,
2960 * Scan command can be issued for both normal scan and specific SSID 2913 * Scan command can be issued for both normal scan and specific SSID
2961 * scan, depending upon whether an SSID is provided or not. 2914 * scan, depending upon whether an SSID is provided or not.
2962 */ 2915 */
2963int mwifiex_request_scan(struct mwifiex_private *priv, u8 wait_option, 2916int mwifiex_request_scan(struct mwifiex_private *priv,
2964 struct mwifiex_802_11_ssid *req_ssid) 2917 struct mwifiex_802_11_ssid *req_ssid)
2965{ 2918{
2966 int ret = 0; 2919 int ret = 0;
2967 struct mwifiex_wait_queue *wait = NULL;
2968 int status = 0;
2969 2920
2970 if (down_interruptible(&priv->async_sem)) { 2921 if (down_interruptible(&priv->async_sem)) {
2971 dev_err(priv->adapter->dev, "%s: acquire semaphore\n", 2922 dev_err(priv->adapter->dev, "%s: acquire semaphore\n",
@@ -2974,32 +2925,23 @@ int mwifiex_request_scan(struct mwifiex_private *priv, u8 wait_option,
2974 } 2925 }
2975 priv->scan_pending_on_block = true; 2926 priv->scan_pending_on_block = true;
2976 2927
2977 /* Allocate wait request buffer */ 2928 priv->adapter->cmd_wait_q.condition = false;
2978 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
2979 if (!wait) {
2980 ret = -1;
2981 goto done;
2982 }
2983 2929
2984 if (req_ssid && req_ssid->ssid_len != 0) 2930 if (req_ssid && req_ssid->ssid_len != 0)
2985 /* Specific SSID scan */ 2931 /* Specific SSID scan */
2986 status = mwifiex_scan_specific_ssid(priv, wait, 2932 ret = mwifiex_scan_specific_ssid(priv, req_ssid);
2987 HostCmd_ACT_GEN_SET,
2988 req_ssid, NULL);
2989 else 2933 else
2990 /* Normal scan */ 2934 /* Normal scan */
2991 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_SET, 2935 ret = mwifiex_scan_networks(priv, NULL);
2992 NULL, NULL); 2936
2993 status = mwifiex_request_ioctl(priv, wait, status, wait_option); 2937 if (!ret)
2994 if (status == -1) 2938 ret = mwifiex_wait_queue_complete(priv->adapter);
2995 ret = -1; 2939
2996done:
2997 if ((wait) && (status != -EINPROGRESS))
2998 kfree(wait);
2999 if (ret == -1) { 2940 if (ret == -1) {
3000 priv->scan_pending_on_block = false; 2941 priv->scan_pending_on_block = false;
3001 up(&priv->async_sem); 2942 up(&priv->async_sem);
3002 } 2943 }
2944
3003 return ret; 2945 return ret;
3004} 2946}
3005 2947