aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/sta_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/mwifiex/sta_ioctl.c')
-rw-r--r--drivers/net/wireless/mwifiex/sta_ioctl.c1081
1 files changed, 163 insertions, 918 deletions
diff --git a/drivers/net/wireless/mwifiex/sta_ioctl.c b/drivers/net/wireless/mwifiex/sta_ioctl.c
index b163507b1fe..e7adaab3522 100644
--- a/drivers/net/wireless/mwifiex/sta_ioctl.c
+++ b/drivers/net/wireless/mwifiex/sta_ioctl.c
@@ -33,9 +33,8 @@
33 * size, and the calling function must ensure enough memory is 33 * size, and the calling function must ensure enough memory is
34 * available. 34 * available.
35 */ 35 */
36static int 36int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
37mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist, 37 struct net_device *dev)
38 struct net_device *dev)
39{ 38{
40 int i = 0; 39 int i = 0;
41 struct netdev_hw_addr *ha; 40 struct netdev_hw_addr *ha;
@@ -47,216 +46,51 @@ mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
47} 46}
48 47
49/* 48/*
50 * Allocate and fills a wait queue with proper parameters.
51 *
52 * This function needs to be called before an IOCTL request can be made.
53 * It can handle the following wait options:
54 * MWIFIEX_NO_WAIT - Waiting is disabled
55 * MWIFIEX_IOCTL_WAIT - Waiting is done on IOCTL wait queue
56 * MWIFIEX_CMD_WAIT - Waiting is done on command wait queue
57 * MWIFIEX_WSTATS_WAIT - Waiting is done on stats wait queue
58 */
59struct mwifiex_wait_queue *
60mwifiex_alloc_fill_wait_queue(struct mwifiex_private *priv,
61 u8 wait_option)
62{
63 struct mwifiex_wait_queue *wait = NULL;
64
65 wait = (struct mwifiex_wait_queue *)
66 kzalloc(sizeof(struct mwifiex_wait_queue), GFP_ATOMIC);
67 if (!wait) {
68 dev_err(priv->adapter->dev, "%s: fail to alloc buffer\n",
69 __func__);
70 return wait;
71 }
72
73 wait->bss_index = priv->bss_index;
74
75 switch (wait_option) {
76 case MWIFIEX_NO_WAIT:
77 wait->enabled = 0;
78 break;
79 case MWIFIEX_IOCTL_WAIT:
80 priv->ioctl_wait_q_woken = false;
81 wait->start_time = jiffies;
82 wait->wait = &priv->ioctl_wait_q;
83 wait->condition = &priv->ioctl_wait_q_woken;
84 wait->enabled = 1;
85 break;
86 case MWIFIEX_CMD_WAIT:
87 priv->cmd_wait_q_woken = false;
88 wait->start_time = jiffies;
89 wait->wait = &priv->cmd_wait_q;
90 wait->condition = &priv->cmd_wait_q_woken;
91 wait->enabled = 1;
92 break;
93 case MWIFIEX_WSTATS_WAIT:
94 priv->w_stats_wait_q_woken = false;
95 wait->start_time = jiffies;
96 wait->wait = &priv->w_stats_wait_q;
97 wait->condition = &priv->w_stats_wait_q_woken;
98 wait->enabled = 1;
99 break;
100 }
101
102 return wait;
103}
104
105/*
106 * Wait queue completion handler. 49 * Wait queue completion handler.
107 * 50 *
108 * This function waits on a particular wait queue. 51 * This function waits on a cmd wait queue. It also cancels the pending
109 * For NO_WAIT option, it returns immediately. It also cancels the 52 * request after waking up, in case of errors.
110 * pending IOCTL request after waking up, in case of errors.
111 */ 53 */
112static void 54int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter)
113mwifiex_wait_ioctl_complete(struct mwifiex_private *priv,
114 struct mwifiex_wait_queue *wait,
115 u8 wait_option)
116{ 55{
117 bool cancel_flag = false; 56 bool cancel_flag = false;
57 int status = adapter->cmd_wait_q.status;
118 58
119 switch (wait_option) { 59 dev_dbg(adapter->dev, "cmd pending\n");
120 case MWIFIEX_NO_WAIT: 60 atomic_inc(&adapter->cmd_pending);
121 break;
122 case MWIFIEX_IOCTL_WAIT:
123 wait_event_interruptible(priv->ioctl_wait_q,
124 priv->ioctl_wait_q_woken);
125 if (!priv->ioctl_wait_q_woken)
126 cancel_flag = true;
127 break;
128 case MWIFIEX_CMD_WAIT:
129 wait_event_interruptible(priv->cmd_wait_q,
130 priv->cmd_wait_q_woken);
131 if (!priv->cmd_wait_q_woken)
132 cancel_flag = true;
133 break;
134 case MWIFIEX_WSTATS_WAIT:
135 wait_event_interruptible(priv->w_stats_wait_q,
136 priv->w_stats_wait_q_woken);
137 if (!priv->w_stats_wait_q_woken)
138 cancel_flag = true;
139 break;
140 }
141 if (cancel_flag) {
142 mwifiex_cancel_pending_ioctl(priv->adapter, wait);
143 dev_dbg(priv->adapter->dev, "cmd: IOCTL cancel: wait=%p, wait_option=%d\n",
144 wait, wait_option);
145 }
146 61
147 return; 62 /* Status pending, wake up main process */
148} 63 queue_work(adapter->workqueue, &adapter->main_work);
149
150/*
151 * The function waits for the request to complete and issues the
152 * completion handler, if required.
153 */
154int mwifiex_request_ioctl(struct mwifiex_private *priv,
155 struct mwifiex_wait_queue *wait,
156 int status, u8 wait_option)
157{
158 switch (status) {
159 case -EINPROGRESS:
160 dev_dbg(priv->adapter->dev, "cmd: IOCTL pending: wait=%p, wait_option=%d\n",
161 wait, wait_option);
162 atomic_inc(&priv->adapter->ioctl_pending);
163 /* Status pending, wake up main process */
164 queue_work(priv->adapter->workqueue, &priv->adapter->main_work);
165
166 /* Wait for completion */
167 if (wait_option) {
168 mwifiex_wait_ioctl_complete(priv, wait, wait_option);
169 status = wait->status;
170 }
171 break;
172 case 0:
173 case -1:
174 case -EBUSY:
175 default:
176 break;
177 }
178 return status;
179}
180EXPORT_SYMBOL_GPL(mwifiex_request_ioctl);
181 64
182/* 65 /* Wait for completion */
183 * IOCTL request handler to set/get MAC address. 66 wait_event_interruptible(adapter->cmd_wait_q.wait,
184 * 67 adapter->cmd_wait_q.condition);
185 * This function prepares the correct firmware command and 68 if (!adapter->cmd_wait_q.condition)
186 * issues it to get the extended version information. 69 cancel_flag = true;
187 */
188static int mwifiex_bss_ioctl_mac_address(struct mwifiex_private *priv,
189 struct mwifiex_wait_queue *wait,
190 u8 action, u8 *mac)
191{
192 int ret = 0;
193 70
194 if ((action == HostCmd_ACT_GEN_GET) && mac) { 71 if (cancel_flag) {
195 memcpy(mac, priv->curr_addr, ETH_ALEN); 72 mwifiex_cancel_pending_ioctl(adapter);
196 return 0; 73 dev_dbg(adapter->dev, "cmd cancel\n");
197 } 74 }
75 adapter->cmd_wait_q.status = 0;
198 76
199 /* Send request to firmware */
200 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_MAC_ADDRESS,
201 action, 0, wait, mac);
202 if (!ret)
203 ret = -EINPROGRESS;
204
205 return ret;
206}
207
208/*
209 * Sends IOCTL request to set MAC address.
210 *
211 * This function allocates the IOCTL request buffer, fills it
212 * with requisite parameters and calls the IOCTL handler.
213 */
214int mwifiex_request_set_mac_address(struct mwifiex_private *priv)
215{
216 struct mwifiex_wait_queue *wait = NULL;
217 int status = 0;
218 u8 wait_option = MWIFIEX_CMD_WAIT;
219
220 /* Allocate wait buffer */
221 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
222 if (!wait)
223 return -ENOMEM;
224
225 status = mwifiex_bss_ioctl_mac_address(priv, wait, HostCmd_ACT_GEN_SET,
226 NULL);
227
228 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
229 if (!status)
230 memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN);
231 else
232 dev_err(priv->adapter->dev, "set mac address failed: status=%d"
233 " error_code=%#x\n", status, wait->status);
234
235 kfree(wait);
236 return status; 77 return status;
237} 78}
238 79
239/* 80/*
240 * IOCTL request handler to set multicast list.
241 *
242 * This function prepares the correct firmware command and 81 * This function prepares the correct firmware command and
243 * issues it to set the multicast list. 82 * issues it to set the multicast list.
244 * 83 *
245 * This function can be used to enable promiscuous mode, or enable all 84 * This function can be used to enable promiscuous mode, or enable all
246 * multicast packets, or to enable selective multicast. 85 * multicast packets, or to enable selective multicast.
247 */ 86 */
248static int 87int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
249mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv, 88 struct mwifiex_multicast_list *mcast_list)
250 struct mwifiex_wait_queue *wait,
251 u16 action,
252 struct mwifiex_multicast_list *mcast_list)
253{ 89{
254 int ret = 0; 90 int ret = 0;
255 u16 old_pkt_filter; 91 u16 old_pkt_filter;
256 92
257 old_pkt_filter = priv->curr_pkt_filter; 93 old_pkt_filter = priv->curr_pkt_filter;
258 if (action == HostCmd_ACT_GEN_GET)
259 return -1;
260 94
261 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) { 95 if (mcast_list->mode == MWIFIEX_PROMISC_MODE) {
262 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n"); 96 dev_dbg(priv->adapter->dev, "info: Enable Promiscuous mode\n");
@@ -281,16 +115,15 @@ mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv,
281 /* Set multicast addresses to firmware */ 115 /* Set multicast addresses to firmware */
282 if (old_pkt_filter == priv->curr_pkt_filter) { 116 if (old_pkt_filter == priv->curr_pkt_filter) {
283 /* Send request to firmware */ 117 /* Send request to firmware */
284 ret = mwifiex_prepare_cmd(priv, 118 ret = mwifiex_send_cmd_async(priv,
285 HostCmd_CMD_MAC_MULTICAST_ADR, 119 HostCmd_CMD_MAC_MULTICAST_ADR,
286 action, 0, wait, mcast_list); 120 HostCmd_ACT_GEN_SET, 0,
287 if (!ret) 121 mcast_list);
288 ret = -EINPROGRESS;
289 } else { 122 } else {
290 /* Send request to firmware */ 123 /* Send request to firmware */
291 ret = mwifiex_prepare_cmd(priv, 124 ret = mwifiex_send_cmd_async(priv,
292 HostCmd_CMD_MAC_MULTICAST_ADR, 125 HostCmd_CMD_MAC_MULTICAST_ADR,
293 action, 0, NULL, 126 HostCmd_ACT_GEN_SET, 0,
294 mcast_list); 127 mcast_list);
295 } 128 }
296 } 129 }
@@ -300,101 +133,21 @@ mwifiex_bss_ioctl_multicast_list(struct mwifiex_private *priv,
300 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n", 133 "info: old_pkt_filter=%#x, curr_pkt_filter=%#x\n",
301 old_pkt_filter, priv->curr_pkt_filter); 134 old_pkt_filter, priv->curr_pkt_filter);
302 if (old_pkt_filter != priv->curr_pkt_filter) { 135 if (old_pkt_filter != priv->curr_pkt_filter) {
303 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, action, 136 ret = mwifiex_send_cmd_async(priv, HostCmd_CMD_MAC_CONTROL,
304 0, wait, &priv->curr_pkt_filter); 137 HostCmd_ACT_GEN_SET,
305 if (!ret) 138 0, &priv->curr_pkt_filter);
306 ret = -EINPROGRESS;
307 } 139 }
308 140
309 return ret; 141 return ret;
310} 142}
311 143
312/* 144/*
313 * Sends IOCTL request to set multicast list.
314 *
315 * This function allocates the IOCTL request buffer, fills it
316 * with requisite parameters and calls the IOCTL handler.
317 */
318void
319mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
320 struct net_device *dev)
321{
322 struct mwifiex_wait_queue *wait = NULL;
323 struct mwifiex_multicast_list mcast_list;
324 u8 wait_option = MWIFIEX_NO_WAIT;
325 int status = 0;
326
327 /* Allocate wait buffer */
328 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
329 if (!wait)
330 return;
331
332 if (dev->flags & IFF_PROMISC) {
333 mcast_list.mode = MWIFIEX_PROMISC_MODE;
334 } else if (dev->flags & IFF_ALLMULTI ||
335 netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) {
336 mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
337 } else {
338 mcast_list.mode = MWIFIEX_MULTICAST_MODE;
339 if (netdev_mc_count(dev))
340 mcast_list.num_multicast_addr =
341 mwifiex_copy_mcast_addr(&mcast_list, dev);
342 }
343 status = mwifiex_bss_ioctl_multicast_list(priv, wait,
344 HostCmd_ACT_GEN_SET,
345 &mcast_list);
346
347 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
348 if (wait && status != -EINPROGRESS)
349 kfree(wait);
350
351 return;
352}
353
354/*
355 * IOCTL request handler to disconnect from a BSS/IBSS.
356 */
357static int mwifiex_bss_ioctl_stop(struct mwifiex_private *priv,
358 struct mwifiex_wait_queue *wait, u8 *mac)
359{
360 return mwifiex_deauthenticate(priv, wait, mac);
361}
362
363/*
364 * Sends IOCTL request to disconnect from a BSS.
365 *
366 * This function allocates the IOCTL request buffer, fills it
367 * with requisite parameters and calls the IOCTL handler.
368 */
369int mwifiex_disconnect(struct mwifiex_private *priv, u8 wait_option, u8 *mac)
370{
371 struct mwifiex_wait_queue *wait = NULL;
372 int status = 0;
373
374 /* Allocate wait buffer */
375 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
376 if (!wait)
377 return -ENOMEM;
378
379 status = mwifiex_bss_ioctl_stop(priv, wait, mac);
380
381 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
382
383 kfree(wait);
384 return status;
385}
386EXPORT_SYMBOL_GPL(mwifiex_disconnect);
387
388/*
389 * IOCTL request handler to join a BSS/IBSS.
390 *
391 * In Ad-Hoc mode, the IBSS is created if not found in scan list. 145 * In Ad-Hoc mode, the IBSS is created if not found in scan list.
392 * In both Ad-Hoc and infra mode, an deauthentication is performed 146 * In both Ad-Hoc and infra mode, an deauthentication is performed
393 * first. 147 * first.
394 */ 148 */
395static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv, 149int mwifiex_bss_start(struct mwifiex_private *priv,
396 struct mwifiex_wait_queue *wait, 150 struct mwifiex_ssid_bssid *ssid_bssid)
397 struct mwifiex_ssid_bssid *ssid_bssid)
398{ 151{
399 int ret = 0; 152 int ret = 0;
400 struct mwifiex_adapter *adapter = priv->adapter; 153 struct mwifiex_adapter *adapter = priv->adapter;
@@ -406,7 +159,7 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
406 159
407 if (priv->bss_mode == NL80211_IFTYPE_STATION) { 160 if (priv->bss_mode == NL80211_IFTYPE_STATION) {
408 /* Infra mode */ 161 /* Infra mode */
409 ret = mwifiex_deauthenticate(priv, NULL, NULL); 162 ret = mwifiex_deauthenticate(priv, NULL);
410 if (ret) 163 if (ret)
411 return ret; 164 return ret;
412 165
@@ -427,7 +180,7 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
427 /* Clear any past association response stored for 180 /* Clear any past association response stored for
428 * application retrieval */ 181 * application retrieval */
429 priv->assoc_rsp_size = 0; 182 priv->assoc_rsp_size = 0;
430 ret = mwifiex_associate(priv, wait, &adapter->scan_table[i]); 183 ret = mwifiex_associate(priv, &adapter->scan_table[i]);
431 if (ret) 184 if (ret)
432 return ret; 185 return ret;
433 } else { 186 } else {
@@ -441,7 +194,7 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
441 194
442 /* Exit Adhoc mode first */ 195 /* Exit Adhoc mode first */
443 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n"); 196 dev_dbg(adapter->dev, "info: Sending Adhoc Stop\n");
444 ret = mwifiex_deauthenticate(priv, NULL, NULL); 197 ret = mwifiex_deauthenticate(priv, NULL);
445 if (ret) 198 if (ret)
446 return ret; 199 return ret;
447 200
@@ -460,75 +213,39 @@ static int mwifiex_bss_ioctl_start(struct mwifiex_private *priv,
460 if (i >= 0) { 213 if (i >= 0) {
461 dev_dbg(adapter->dev, "info: network found in scan" 214 dev_dbg(adapter->dev, "info: network found in scan"
462 " list. Joining...\n"); 215 " list. Joining...\n");
463 ret = mwifiex_adhoc_join(priv, wait, 216 ret = mwifiex_adhoc_join(priv, &adapter->scan_table[i]);
464 &adapter->scan_table[i]);
465 if (ret) 217 if (ret)
466 return ret; 218 return ret;
467 } else { /* i >= 0 */ 219 } else {
468 dev_dbg(adapter->dev, "info: Network not found in " 220 dev_dbg(adapter->dev, "info: Network not found in "
469 "the list, creating adhoc with ssid = %s\n", 221 "the list, creating adhoc with ssid = %s\n",
470 ssid_bssid->ssid.ssid); 222 ssid_bssid->ssid.ssid);
471 ret = mwifiex_adhoc_start(priv, wait, 223 ret = mwifiex_adhoc_start(priv, &ssid_bssid->ssid);
472 &ssid_bssid->ssid);
473 if (ret) 224 if (ret)
474 return ret; 225 return ret;
475 } 226 }
476 } 227 }
477 228
478 if (!ret)
479 ret = -EINPROGRESS;
480
481 return ret; 229 return ret;
482} 230}
483 231
484/* 232/*
485 * Sends IOCTL request to connect with a BSS.
486 *
487 * This function allocates the IOCTL request buffer, fills it
488 * with requisite parameters and calls the IOCTL handler.
489 */
490int mwifiex_bss_start(struct mwifiex_private *priv, u8 wait_option,
491 struct mwifiex_ssid_bssid *ssid_bssid)
492{
493 struct mwifiex_wait_queue *wait = NULL;
494 struct mwifiex_ssid_bssid tmp_ssid_bssid;
495 int status = 0;
496
497 /* Stop the O.S. TX queue if needed */
498 if (!netif_queue_stopped(priv->netdev))
499 netif_stop_queue(priv->netdev);
500
501 /* Allocate wait buffer */
502 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
503 if (!wait)
504 return -ENOMEM;
505
506 if (ssid_bssid)
507 memcpy(&tmp_ssid_bssid, ssid_bssid,
508 sizeof(struct mwifiex_ssid_bssid));
509 status = mwifiex_bss_ioctl_start(priv, wait, &tmp_ssid_bssid);
510
511 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
512
513 kfree(wait);
514 return status;
515}
516
517/*
518 * IOCTL request handler to set host sleep configuration. 233 * IOCTL request handler to set host sleep configuration.
519 * 234 *
520 * This function prepares the correct firmware command and 235 * This function prepares the correct firmware command and
521 * issues it. 236 * issues it.
522 */ 237 */
523static int 238int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
524mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv, 239 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg)
525 struct mwifiex_wait_queue *wait, 240
526 u16 action, struct mwifiex_ds_hs_cfg *hs_cfg)
527{ 241{
528 struct mwifiex_adapter *adapter = priv->adapter; 242 struct mwifiex_adapter *adapter = priv->adapter;
529 int status = 0; 243 int status = 0;
530 u32 prev_cond = 0; 244 u32 prev_cond = 0;
531 245
246 if (!hs_cfg)
247 return -ENOMEM;
248
532 switch (action) { 249 switch (action) {
533 case HostCmd_ACT_GEN_SET: 250 case HostCmd_ACT_GEN_SET:
534 if (adapter->pps_uapsd_mode) { 251 if (adapter->pps_uapsd_mode) {
@@ -561,12 +278,16 @@ mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv,
561 status = -1; 278 status = -1;
562 break; 279 break;
563 } 280 }
564 status = mwifiex_prepare_cmd(priv, 281 if (cmd_type == MWIFIEX_SYNC_CMD)
565 HostCmd_CMD_802_11_HS_CFG_ENH, 282 status = mwifiex_send_cmd_sync(priv,
566 HostCmd_ACT_GEN_SET, 283 HostCmd_CMD_802_11_HS_CFG_ENH,
567 0, wait, &adapter->hs_cfg); 284 HostCmd_ACT_GEN_SET, 0,
568 if (!status) 285 &adapter->hs_cfg);
569 status = -EINPROGRESS; 286 else
287 status = mwifiex_send_cmd_async(priv,
288 HostCmd_CMD_802_11_HS_CFG_ENH,
289 HostCmd_ACT_GEN_SET, 0,
290 &adapter->hs_cfg);
570 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL) 291 if (hs_cfg->conditions == HOST_SLEEP_CFG_CANCEL)
571 /* Restore previous condition */ 292 /* Restore previous condition */
572 adapter->hs_cfg.conditions = 293 adapter->hs_cfg.conditions =
@@ -592,53 +313,20 @@ mwifiex_pm_ioctl_hs_cfg(struct mwifiex_private *priv,
592} 313}
593 314
594/* 315/*
595 * Sends IOCTL request to set Host Sleep parameters.
596 *
597 * This function allocates the IOCTL request buffer, fills it
598 * with requisite parameters and calls the IOCTL handler.
599 */
600int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
601 u8 wait_option,
602 struct mwifiex_ds_hs_cfg *hscfg)
603{
604 int ret = 0;
605 struct mwifiex_wait_queue *wait = NULL;
606
607 if (!hscfg)
608 return -ENOMEM;
609
610 /* Allocate wait buffer */
611 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
612 if (!wait)
613 return -ENOMEM;
614
615 ret = mwifiex_pm_ioctl_hs_cfg(priv, wait, action, hscfg);
616
617 ret = mwifiex_request_ioctl(priv, wait, ret, wait_option);
618
619 if (wait && (ret != -EINPROGRESS))
620 kfree(wait);
621 return ret;
622}
623
624/*
625 * Sends IOCTL request to cancel the existing Host Sleep configuration. 316 * Sends IOCTL request to cancel the existing Host Sleep configuration.
626 * 317 *
627 * This function allocates the IOCTL request buffer, fills it 318 * This function allocates the IOCTL request buffer, fills it
628 * with requisite parameters and calls the IOCTL handler. 319 * with requisite parameters and calls the IOCTL handler.
629 */ 320 */
630int mwifiex_cancel_hs(struct mwifiex_private *priv, u8 wait_option) 321int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type)
631{ 322{
632 int ret = 0;
633 struct mwifiex_ds_hs_cfg hscfg; 323 struct mwifiex_ds_hs_cfg hscfg;
634 324
635 /* Cancel Host Sleep */
636 hscfg.conditions = HOST_SLEEP_CFG_CANCEL; 325 hscfg.conditions = HOST_SLEEP_CFG_CANCEL;
637 hscfg.is_invoke_hostcmd = true; 326 hscfg.is_invoke_hostcmd = true;
638 ret = mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
639 wait_option, &hscfg);
640 327
641 return ret; 328 return mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET,
329 cmd_type, &hscfg);
642} 330}
643EXPORT_SYMBOL_GPL(mwifiex_cancel_hs); 331EXPORT_SYMBOL_GPL(mwifiex_cancel_hs);
644 332
@@ -657,7 +345,6 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
657 return true; 345 return true;
658 } 346 }
659 347
660 /* Enable Host Sleep */
661 adapter->hs_activate_wait_q_woken = false; 348 adapter->hs_activate_wait_q_woken = false;
662 349
663 memset(&hscfg, 0, sizeof(struct mwifiex_hs_config_param)); 350 memset(&hscfg, 0, sizeof(struct mwifiex_hs_config_param));
@@ -665,8 +352,8 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
665 352
666 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter, 353 if (mwifiex_set_hs_params(mwifiex_get_priv(adapter,
667 MWIFIEX_BSS_ROLE_STA), 354 MWIFIEX_BSS_ROLE_STA),
668 HostCmd_ACT_GEN_SET, 355 HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD,
669 MWIFIEX_IOCTL_WAIT, &hscfg)) { 356 &hscfg)) {
670 dev_err(adapter->dev, "IOCTL request HS enable failed\n"); 357 dev_err(adapter->dev, "IOCTL request HS enable failed\n");
671 return false; 358 return false;
672 } 359 }
@@ -679,69 +366,6 @@ int mwifiex_enable_hs(struct mwifiex_adapter *adapter)
679EXPORT_SYMBOL_GPL(mwifiex_enable_hs); 366EXPORT_SYMBOL_GPL(mwifiex_enable_hs);
680 367
681/* 368/*
682 * IOCTL request handler to get signal information.
683 *
684 * This function prepares the correct firmware command and
685 * issues it to get the signal (RSSI) information.
686 *
687 * This only works in the connected mode.
688 */
689static int mwifiex_get_info_signal(struct mwifiex_private *priv,
690 struct mwifiex_wait_queue *wait,
691 struct mwifiex_ds_get_signal *signal)
692{
693 int ret = 0;
694
695 if (!wait) {
696 dev_err(priv->adapter->dev, "WAIT information is not present\n");
697 return -1;
698 }
699
700 /* Signal info can be obtained only if connected */
701 if (!priv->media_connected) {
702 dev_dbg(priv->adapter->dev,
703 "info: Can not get signal in disconnected state\n");
704 return -1;
705 }
706
707 /* Send request to firmware */
708 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_RSSI_INFO,
709 HostCmd_ACT_GEN_GET, 0, wait, signal);
710
711 if (!ret)
712 ret = -EINPROGRESS;
713
714 return ret;
715}
716
717/*
718 * IOCTL request handler to get statistics.
719 *
720 * This function prepares the correct firmware command and
721 * issues it to get the statistics (RSSI) information.
722 */
723static int mwifiex_get_info_stats(struct mwifiex_private *priv,
724 struct mwifiex_wait_queue *wait,
725 struct mwifiex_ds_get_stats *log)
726{
727 int ret = 0;
728
729 if (!wait) {
730 dev_err(priv->adapter->dev, "MWIFIEX IOCTL information is not present\n");
731 return -1;
732 }
733
734 /* Send request to firmware */
735 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_GET_LOG,
736 HostCmd_ACT_GEN_GET, 0, wait, log);
737
738 if (!ret)
739 ret = -EINPROGRESS;
740
741 return ret;
742}
743
744/*
745 * IOCTL request handler to get BSS information. 369 * IOCTL request handler to get BSS information.
746 * 370 *
747 * This function collates the information from different driver structures 371 * This function collates the information from different driver structures
@@ -757,23 +381,17 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
757 if (!info) 381 if (!info)
758 return -1; 382 return -1;
759 383
760 /* Get current BSS info */
761 bss_desc = &priv->curr_bss_params.bss_descriptor; 384 bss_desc = &priv->curr_bss_params.bss_descriptor;
762 385
763 /* BSS mode */
764 info->bss_mode = priv->bss_mode; 386 info->bss_mode = priv->bss_mode;
765 387
766 /* SSID */
767 memcpy(&info->ssid, &bss_desc->ssid, 388 memcpy(&info->ssid, &bss_desc->ssid,
768 sizeof(struct mwifiex_802_11_ssid)); 389 sizeof(struct mwifiex_802_11_ssid));
769 390
770 /* BSSID */
771 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN); 391 memcpy(&info->bssid, &bss_desc->mac_address, ETH_ALEN);
772 392
773 /* Channel */
774 info->bss_chan = bss_desc->channel; 393 info->bss_chan = bss_desc->channel;
775 394
776 /* Region code */
777 info->region_code = adapter->region_code; 395 info->region_code = adapter->region_code;
778 396
779 /* Scan table index if connected */ 397 /* Scan table index if connected */
@@ -787,20 +405,15 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
787 info->scan_table_idx = tbl_idx; 405 info->scan_table_idx = tbl_idx;
788 } 406 }
789 407
790 /* Connection status */
791 info->media_connected = priv->media_connected; 408 info->media_connected = priv->media_connected;
792 409
793 /* Tx power information */
794 info->max_power_level = priv->max_tx_power_level; 410 info->max_power_level = priv->max_tx_power_level;
795 info->min_power_level = priv->min_tx_power_level; 411 info->min_power_level = priv->min_tx_power_level;
796 412
797 /* AdHoc state */
798 info->adhoc_state = priv->adhoc_state; 413 info->adhoc_state = priv->adhoc_state;
799 414
800 /* Last beacon NF */
801 info->bcn_nf_last = priv->bcn_nf_last; 415 info->bcn_nf_last = priv->bcn_nf_last;
802 416
803 /* wep status */
804 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED) 417 if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_ENABLED)
805 info->wep_status = true; 418 info->wep_status = true;
806 else 419 else
@@ -813,90 +426,20 @@ int mwifiex_get_bss_info(struct mwifiex_private *priv,
813} 426}
814 427
815/* 428/*
816 * IOCTL request handler to get extended version information. 429 * The function sets band configurations.
817 * 430 *
818 * This function prepares the correct firmware command and 431 * it performs extra checks to make sure the Ad-Hoc
819 * issues it to get the extended version information.
820 */
821static int mwifiex_get_info_ver_ext(struct mwifiex_private *priv,
822 struct mwifiex_wait_queue *wait,
823 struct mwifiex_ver_ext *ver_ext)
824{
825 int ret = 0;
826
827 /* Send request to firmware */
828 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_VERSION_EXT,
829 HostCmd_ACT_GEN_GET, 0, wait, ver_ext);
830 if (!ret)
831 ret = -EINPROGRESS;
832
833 return ret;
834}
835
836/*
837 * IOCTL request handler to set/get SNMP MIB parameters.
838 *
839 * This function prepares the correct firmware command and
840 * issues it.
841 *
842 * Currently the following parameters are supported -
843 * Set/get RTS Threshold
844 * Set/get fragmentation threshold
845 * Set/get retry count
846 */
847int mwifiex_snmp_mib_ioctl(struct mwifiex_private *priv,
848 struct mwifiex_wait_queue *wait,
849 u32 cmd_oid, u16 action, u32 *value)
850{
851 int ret = 0;
852
853 if (!value)
854 return -1;
855
856 /* Send request to firmware */
857 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_SNMP_MIB,
858 action, cmd_oid, wait, value);
859
860 if (!ret)
861 ret = -EINPROGRESS;
862
863 return ret;
864}
865
866/*
867 * IOCTL request handler to set/get band configurations.
868 *
869 * For SET operation, it performs extra checks to make sure the Ad-Hoc
870 * band and channel are compatible. Otherwise it returns an error. 432 * band and channel are compatible. Otherwise it returns an error.
871 * 433 *
872 * For GET operation, this function retrieves the following information -
873 * - Infra bands
874 * - Ad-hoc band
875 * - Ad-hoc channel
876 * - Secondary channel offset
877 */ 434 */
878int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *priv, 435int mwifiex_set_radio_band_cfg(struct mwifiex_private *priv,
879 u16 action, 436 struct mwifiex_ds_band_cfg *radio_cfg)
880 struct mwifiex_ds_band_cfg *radio_cfg)
881{ 437{
882 struct mwifiex_adapter *adapter = priv->adapter; 438 struct mwifiex_adapter *adapter = priv->adapter;
883 u8 infra_band = 0; 439 u8 infra_band = 0;
884 u8 adhoc_band = 0; 440 u8 adhoc_band = 0;
885 u32 adhoc_channel = 0; 441 u32 adhoc_channel = 0;
886 442
887 if (action == HostCmd_ACT_GEN_GET) {
888 /* Infra Bands */
889 radio_cfg->config_bands = adapter->config_bands;
890 /* Adhoc Band */
891 radio_cfg->adhoc_start_band = adapter->adhoc_start_band;
892 /* Adhoc channel */
893 radio_cfg->adhoc_channel = priv->adhoc_channel;
894 /* Secondary channel offset */
895 radio_cfg->sec_chan_offset = adapter->chan_offset;
896 return 0;
897 }
898
899 /* For action = SET */
900 infra_band = (u8) radio_cfg->config_bands; 443 infra_band = (u8) radio_cfg->config_bands;
901 adhoc_band = (u8) radio_cfg->adhoc_start_band; 444 adhoc_band = (u8) radio_cfg->adhoc_start_band;
902 adhoc_channel = radio_cfg->adhoc_channel; 445 adhoc_channel = radio_cfg->adhoc_channel;
@@ -950,8 +493,8 @@ int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *priv,
950 * This function performs validity checking on channel/frequency 493 * This function performs validity checking on channel/frequency
951 * compatibility and returns failure if not valid. 494 * compatibility and returns failure if not valid.
952 */ 495 */
953int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action, 496int mwifiex_bss_set_channel(struct mwifiex_private *priv,
954 struct mwifiex_chan_freq_power *chan) 497 struct mwifiex_chan_freq_power *chan)
955{ 498{
956 struct mwifiex_adapter *adapter = priv->adapter; 499 struct mwifiex_adapter *adapter = priv->adapter;
957 struct mwifiex_chan_freq_power *cfp = NULL; 500 struct mwifiex_chan_freq_power *cfp = NULL;
@@ -959,16 +502,6 @@ int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action,
959 if (!chan) 502 if (!chan)
960 return -1; 503 return -1;
961 504
962 if (action == HostCmd_ACT_GEN_GET) {
963 cfp = mwifiex_get_cfp_by_band_and_channel_from_cfg80211(priv,
964 priv->curr_bss_params.band,
965 (u16) priv->curr_bss_params.bss_descriptor.
966 channel);
967 chan->channel = cfp->channel;
968 chan->freq = cfp->freq;
969
970 return 0;
971 }
972 if (!chan->channel && !chan->freq) 505 if (!chan->channel && !chan->freq)
973 return -1; 506 return -1;
974 if (adapter->adhoc_start_band & BAND_AN) 507 if (adapter->adhoc_start_band & BAND_AN)
@@ -1024,27 +557,19 @@ int mwifiex_bss_ioctl_channel(struct mwifiex_private *priv, u16 action,
1024 * issues it to set or get the ad-hoc channel. 557 * issues it to set or get the ad-hoc channel.
1025 */ 558 */
1026static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv, 559static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
1027 struct mwifiex_wait_queue *wait,
1028 u16 action, u16 *channel) 560 u16 action, u16 *channel)
1029{ 561{
1030 int ret = 0;
1031
1032 if (action == HostCmd_ACT_GEN_GET) { 562 if (action == HostCmd_ACT_GEN_GET) {
1033 if (!priv->media_connected) { 563 if (!priv->media_connected) {
1034 *channel = priv->adhoc_channel; 564 *channel = priv->adhoc_channel;
1035 return ret; 565 return 0;
1036 } 566 }
1037 } else { 567 } else {
1038 priv->adhoc_channel = (u8) *channel; 568 priv->adhoc_channel = (u8) *channel;
1039 } 569 }
1040 570
1041 /* Send request to firmware */ 571 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_RF_CHANNEL,
1042 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_RF_CHANNEL, 572 action, 0, channel);
1043 action, 0, wait, channel);
1044 if (!ret)
1045 ret = -EINPROGRESS;
1046
1047 return ret;
1048} 573}
1049 574
1050/* 575/*
@@ -1054,11 +579,9 @@ static int mwifiex_bss_ioctl_ibss_channel(struct mwifiex_private *priv,
1054 * these are provided, just the best BSS (best RSSI) is returned. 579 * these are provided, just the best BSS (best RSSI) is returned.
1055 */ 580 */
1056int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv, 581int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv,
1057 struct mwifiex_wait_queue *wait,
1058 struct mwifiex_ssid_bssid *ssid_bssid) 582 struct mwifiex_ssid_bssid *ssid_bssid)
1059{ 583{
1060 struct mwifiex_adapter *adapter = priv->adapter; 584 struct mwifiex_adapter *adapter = priv->adapter;
1061 int ret = 0;
1062 struct mwifiex_bssdescriptor *bss_desc; 585 struct mwifiex_bssdescriptor *bss_desc;
1063 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; 586 u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 };
1064 u8 mac[ETH_ALEN]; 587 u8 mac[ETH_ALEN];
@@ -1087,10 +610,10 @@ int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *priv,
1087 bss_desc = &adapter->scan_table[i]; 610 bss_desc = &adapter->scan_table[i];
1088 memcpy(ssid_bssid->bssid, bss_desc->mac_address, ETH_ALEN); 611 memcpy(ssid_bssid->bssid, bss_desc->mac_address, ETH_ALEN);
1089 } else { 612 } else {
1090 ret = mwifiex_find_best_network(priv, ssid_bssid); 613 return mwifiex_find_best_network(priv, ssid_bssid);
1091 } 614 }
1092 615
1093 return ret; 616 return 0;
1094} 617}
1095 618
1096/* 619/*
@@ -1114,10 +637,7 @@ int
1114mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel) 637mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1115{ 638{
1116 int ret = 0; 639 int ret = 0;
1117 int status = 0;
1118 struct mwifiex_bss_info bss_info; 640 struct mwifiex_bss_info bss_info;
1119 struct mwifiex_wait_queue *wait = NULL;
1120 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1121 struct mwifiex_ssid_bssid ssid_bssid; 641 struct mwifiex_ssid_bssid ssid_bssid;
1122 u16 curr_chan = 0; 642 u16 curr_chan = 0;
1123 643
@@ -1127,19 +647,10 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1127 if (mwifiex_get_bss_info(priv, &bss_info)) 647 if (mwifiex_get_bss_info(priv, &bss_info))
1128 return -1; 648 return -1;
1129 649
1130 /* Allocate wait buffer */
1131 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1132 if (!wait)
1133 return -ENOMEM;
1134
1135 /* Get current channel */ 650 /* Get current channel */
1136 status = mwifiex_bss_ioctl_ibss_channel(priv, wait, HostCmd_ACT_GEN_GET, 651 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_GET,
1137 &curr_chan); 652 &curr_chan);
1138 653
1139 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1140 ret = -1;
1141 goto done;
1142 }
1143 if (curr_chan == channel) { 654 if (curr_chan == channel) {
1144 ret = 0; 655 ret = 0;
1145 goto done; 656 goto done;
@@ -1154,23 +665,13 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1154 665
1155 /* Do disonnect */ 666 /* Do disonnect */
1156 memset(&ssid_bssid, 0, ETH_ALEN); 667 memset(&ssid_bssid, 0, ETH_ALEN);
1157 status = mwifiex_bss_ioctl_stop(priv, wait, ssid_bssid.bssid); 668 ret = mwifiex_deauthenticate(priv, ssid_bssid.bssid);
1158
1159 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1160 ret = -1;
1161 goto done;
1162 }
1163 669
1164 status = mwifiex_bss_ioctl_ibss_channel(priv, wait, HostCmd_ACT_GEN_SET, 670 ret = mwifiex_bss_ioctl_ibss_channel(priv, HostCmd_ACT_GEN_SET,
1165 (u16 *) &channel); 671 (u16 *) &channel);
1166
1167 if (mwifiex_request_ioctl(priv, wait, status, wait_option)) {
1168 ret = -1;
1169 goto done;
1170 }
1171 672
1172 /* Do specific SSID scanning */ 673 /* Do specific SSID scanning */
1173 if (mwifiex_request_scan(priv, wait_option, &bss_info.ssid)) { 674 if (mwifiex_request_scan(priv, &bss_info.ssid)) {
1174 ret = -1; 675 ret = -1;
1175 goto done; 676 goto done;
1176 } 677 }
@@ -1179,13 +680,8 @@ mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel)
1179 memcpy(&ssid_bssid.ssid, &bss_info.ssid, 680 memcpy(&ssid_bssid.ssid, &bss_info.ssid,
1180 sizeof(struct mwifiex_802_11_ssid)); 681 sizeof(struct mwifiex_802_11_ssid));
1181 682
1182 status = mwifiex_bss_ioctl_start(priv, wait, &ssid_bssid); 683 ret = mwifiex_bss_start(priv, &ssid_bssid);
1183
1184 if (mwifiex_request_ioctl(priv, wait, status, wait_option))
1185 ret = -1;
1186
1187done: 684done:
1188 kfree(wait);
1189 return ret; 685 return ret;
1190} 686}
1191 687
@@ -1198,11 +694,9 @@ done:
1198 * for the band. 694 * for the band.
1199 */ 695 */
1200static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv, 696static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1201 struct mwifiex_wait_queue *wait,
1202 struct mwifiex_rate_cfg *rate_cfg) 697 struct mwifiex_rate_cfg *rate_cfg)
1203{ 698{
1204 struct mwifiex_adapter *adapter = priv->adapter; 699 struct mwifiex_adapter *adapter = priv->adapter;
1205 int ret = 0;
1206 700
1207 rate_cfg->is_rate_auto = priv->is_data_rate_auto; 701 rate_cfg->is_rate_auto = priv->is_data_rate_auto;
1208 if (!priv->media_connected) { 702 if (!priv->media_connected) {
@@ -1241,15 +735,12 @@ static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1241 break; 735 break;
1242 } 736 }
1243 } else { 737 } else {
1244 /* Send request to firmware */ 738 return mwifiex_send_cmd_sync(priv,
1245 ret = mwifiex_prepare_cmd(priv, 739 HostCmd_CMD_802_11_TX_RATE_QUERY,
1246 HostCmd_CMD_802_11_TX_RATE_QUERY, 740 HostCmd_ACT_GEN_GET, 0, NULL);
1247 HostCmd_ACT_GEN_GET, 0, wait, NULL);
1248 if (!ret)
1249 ret = -EINPROGRESS;
1250 } 741 }
1251 742
1252 return ret; 743 return 0;
1253} 744}
1254 745
1255/* 746/*
@@ -1261,7 +752,6 @@ static int mwifiex_rate_ioctl_get_rate_value(struct mwifiex_private *priv,
1261 * The function also performs validation checking on the supplied value. 752 * The function also performs validation checking on the supplied value.
1262 */ 753 */
1263static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv, 754static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1264 struct mwifiex_wait_queue *wait,
1265 struct mwifiex_rate_cfg *rate_cfg) 755 struct mwifiex_rate_cfg *rate_cfg)
1266{ 756{
1267 u8 rates[MWIFIEX_SUPPORTED_RATES]; 757 u8 rates[MWIFIEX_SUPPORTED_RATES];
@@ -1299,8 +789,7 @@ static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1299 } 789 }
1300 memset(bitmap_rates, 0, sizeof(bitmap_rates)); 790 memset(bitmap_rates, 0, sizeof(bitmap_rates));
1301 791
1302 rate_index = 792 rate_index = mwifiex_data_rate_to_index(rate_cfg->rate);
1303 mwifiex_data_rate_to_index(adapter, rate_cfg->rate);
1304 793
1305 /* Only allow b/g rates to be set */ 794 /* Only allow b/g rates to be set */
1306 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 && 795 if (rate_index >= MWIFIEX_RATE_INDEX_HRDSSS0 &&
@@ -1315,11 +804,8 @@ static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1315 } 804 }
1316 } 805 }
1317 806
1318 /* Send request to firmware */ 807 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TX_RATE_CFG,
1319 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TX_RATE_CFG, 808 HostCmd_ACT_GEN_SET, 0, bitmap_rates);
1320 HostCmd_ACT_GEN_SET, 0, wait, bitmap_rates);
1321 if (!ret)
1322 ret = -EINPROGRESS;
1323 809
1324 return ret; 810 return ret;
1325} 811}
@@ -1331,7 +817,6 @@ static int mwifiex_rate_ioctl_set_rate_value(struct mwifiex_private *priv,
1331 * rate index. 817 * rate index.
1332 */ 818 */
1333static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv, 819static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
1334 struct mwifiex_wait_queue *wait,
1335 struct mwifiex_rate_cfg *rate_cfg) 820 struct mwifiex_rate_cfg *rate_cfg)
1336{ 821{
1337 int status = 0; 822 int status = 0;
@@ -1340,11 +825,9 @@ static int mwifiex_rate_ioctl_cfg(struct mwifiex_private *priv,
1340 return -1; 825 return -1;
1341 826
1342 if (rate_cfg->action == HostCmd_ACT_GEN_GET) 827 if (rate_cfg->action == HostCmd_ACT_GEN_GET)
1343 status = mwifiex_rate_ioctl_get_rate_value( 828 status = mwifiex_rate_ioctl_get_rate_value(priv, rate_cfg);
1344 priv, wait, rate_cfg);
1345 else 829 else
1346 status = mwifiex_rate_ioctl_set_rate_value( 830 status = mwifiex_rate_ioctl_set_rate_value(priv, rate_cfg);
1347 priv, wait, rate_cfg);
1348 831
1349 return status; 832 return status;
1350} 833}
@@ -1359,30 +842,21 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
1359 struct mwifiex_rate_cfg *rate) 842 struct mwifiex_rate_cfg *rate)
1360{ 843{
1361 int ret = 0; 844 int ret = 0;
1362 struct mwifiex_wait_queue *wait = NULL;
1363 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1364
1365 /* Allocate wait buffer */
1366 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1367 if (!wait)
1368 return -ENOMEM;
1369 845
1370 memset(rate, 0, sizeof(struct mwifiex_rate_cfg)); 846 memset(rate, 0, sizeof(struct mwifiex_rate_cfg));
1371 rate->action = HostCmd_ACT_GEN_GET; 847 rate->action = HostCmd_ACT_GEN_GET;
1372 ret = mwifiex_rate_ioctl_cfg(priv, wait, rate); 848 ret = mwifiex_rate_ioctl_cfg(priv, rate);
1373 849
1374 ret = mwifiex_request_ioctl(priv, wait, ret, wait_option);
1375 if (!ret) { 850 if (!ret) {
1376 if (rate && rate->is_rate_auto) 851 if (rate && rate->is_rate_auto)
1377 rate->rate = mwifiex_index_to_data_rate(priv->adapter, 852 rate->rate = mwifiex_index_to_data_rate(priv->tx_rate,
1378 priv->tx_rate, priv->tx_htinfo); 853 priv->tx_htinfo);
1379 else if (rate) 854 else if (rate)
1380 rate->rate = priv->data_rate; 855 rate->rate = priv->data_rate;
1381 } else { 856 } else {
1382 ret = -1; 857 ret = -1;
1383 } 858 }
1384 859
1385 kfree(wait);
1386 return ret; 860 return ret;
1387} 861}
1388 862
@@ -1398,9 +872,8 @@ int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
1398 * - Modulation class HTBW20 872 * - Modulation class HTBW20
1399 * - Modulation class HTBW40 873 * - Modulation class HTBW40
1400 */ 874 */
1401static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv, 875int mwifiex_set_tx_power(struct mwifiex_private *priv,
1402 struct mwifiex_wait_queue *wait, 876 struct mwifiex_power_cfg *power_cfg)
1403 struct mwifiex_power_cfg *power_cfg)
1404{ 877{
1405 int ret = 0; 878 int ret = 0;
1406 struct host_cmd_ds_txpwr_cfg *txp_cfg = NULL; 879 struct host_cmd_ds_txpwr_cfg *txp_cfg = NULL;
@@ -1472,13 +945,10 @@ static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv,
1472 pg->power_max = (s8) dbm; 945 pg->power_max = (s8) dbm;
1473 pg->ht_bandwidth = HT_BW_40; 946 pg->ht_bandwidth = HT_BW_40;
1474 } 947 }
1475 /* Send request to firmware */ 948 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_TXPWR_CFG,
1476 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_TXPWR_CFG, 949 HostCmd_ACT_GEN_SET, 0, buf);
1477 HostCmd_ACT_GEN_SET, 0, wait, buf);
1478 if (!ret)
1479 ret = -EINPROGRESS;
1480 kfree(buf);
1481 950
951 kfree(buf);
1482 return ret; 952 return ret;
1483} 953}
1484 954
@@ -1488,33 +958,23 @@ static int mwifiex_power_ioctl_set_power(struct mwifiex_private *priv,
1488 * This function prepares the correct firmware command and 958 * This function prepares the correct firmware command and
1489 * issues it. 959 * issues it.
1490 */ 960 */
1491static int mwifiex_pm_ioctl_ps_mode(struct mwifiex_private *priv, 961int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode)
1492 struct mwifiex_wait_queue *wait,
1493 u32 *ps_mode, u16 action)
1494{ 962{
1495 int ret = 0; 963 int ret = 0;
1496 struct mwifiex_adapter *adapter = priv->adapter; 964 struct mwifiex_adapter *adapter = priv->adapter;
1497 u16 sub_cmd; 965 u16 sub_cmd;
1498 966
1499 if (action == HostCmd_ACT_GEN_SET) { 967 if (*ps_mode)
1500 if (*ps_mode) 968 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP;
1501 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_PSP; 969 else
1502 else 970 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
1503 adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM; 971 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS;
1504 sub_cmd = (*ps_mode) ? EN_AUTO_PS : DIS_AUTO_PS; 972 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1505 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH, 973 sub_cmd, BITMAP_STA_PS, NULL);
1506 sub_cmd, BITMAP_STA_PS, wait, NULL); 974 if ((!ret) && (sub_cmd == DIS_AUTO_PS))
1507 if ((!ret) && (sub_cmd == DIS_AUTO_PS)) 975 ret = mwifiex_send_cmd_async(priv,
1508 ret = mwifiex_prepare_cmd(priv, 976 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS,
1509 HostCmd_CMD_802_11_PS_MODE_ENH, GET_PS, 977 0, NULL);
1510 0, NULL, NULL);
1511 } else {
1512 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_PS_MODE_ENH,
1513 GET_PS, 0, wait, NULL);
1514 }
1515
1516 if (!ret)
1517 ret = -EINPROGRESS;
1518 978
1519 return ret; 979 return ret;
1520} 980}
@@ -1600,20 +1060,13 @@ static int mwifiex_set_wapi_ie(struct mwifiex_private *priv,
1600 * This function prepares the correct firmware command and 1060 * This function prepares the correct firmware command and
1601 * issues it. 1061 * issues it.
1602 */ 1062 */
1603static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_adapter *adapter, 1063static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_private *priv,
1604 struct mwifiex_wait_queue *wait,
1605 struct mwifiex_ds_encrypt_key *encrypt_key) 1064 struct mwifiex_ds_encrypt_key *encrypt_key)
1606{ 1065{
1607 int ret = 0;
1608 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1609 1066
1610 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1067 return mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_KEY_MATERIAL,
1611 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, 1068 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1612 wait, encrypt_key); 1069 encrypt_key);
1613 if (!ret)
1614 ret = -EINPROGRESS;
1615
1616 return ret;
1617} 1070}
1618 1071
1619/* 1072/*
@@ -1622,12 +1075,10 @@ static int mwifiex_sec_ioctl_set_wapi_key(struct mwifiex_adapter *adapter,
1622 * This function prepares the correct firmware command and 1075 * This function prepares the correct firmware command and
1623 * issues it, after validation checks. 1076 * issues it, after validation checks.
1624 */ 1077 */
1625static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter, 1078static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_private *priv,
1626 struct mwifiex_wait_queue *wait,
1627 struct mwifiex_ds_encrypt_key *encrypt_key) 1079 struct mwifiex_ds_encrypt_key *encrypt_key)
1628{ 1080{
1629 int ret = 0; 1081 int ret = 0;
1630 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1631 struct mwifiex_wep_key *wep_key = NULL; 1082 struct mwifiex_wep_key *wep_key = NULL;
1632 int index; 1083 int index;
1633 1084
@@ -1641,7 +1092,7 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1641 /* Copy the required key as the current key */ 1092 /* Copy the required key as the current key */
1642 wep_key = &priv->wep_key[index]; 1093 wep_key = &priv->wep_key[index];
1643 if (!wep_key->key_length) { 1094 if (!wep_key->key_length) {
1644 dev_err(adapter->dev, 1095 dev_err(priv->adapter->dev,
1645 "key not set, so cannot enable it\n"); 1096 "key not set, so cannot enable it\n");
1646 return -1; 1097 return -1;
1647 } 1098 }
@@ -1649,7 +1100,6 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1649 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED; 1100 priv->sec_info.wep_status = MWIFIEX_802_11_WEP_ENABLED;
1650 } else { 1101 } else {
1651 wep_key = &priv->wep_key[index]; 1102 wep_key = &priv->wep_key[index];
1652 /* Cleanup */
1653 memset(wep_key, 0, sizeof(struct mwifiex_wep_key)); 1103 memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
1654 /* Copy the key in the driver */ 1104 /* Copy the key in the driver */
1655 memcpy(wep_key->key_material, 1105 memcpy(wep_key->key_material,
@@ -1661,8 +1111,9 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1661 } 1111 }
1662 if (wep_key->key_length) { 1112 if (wep_key->key_length) {
1663 /* Send request to firmware */ 1113 /* Send request to firmware */
1664 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1114 ret = mwifiex_send_cmd_async(priv,
1665 HostCmd_ACT_GEN_SET, 0, NULL, NULL); 1115 HostCmd_CMD_802_11_KEY_MATERIAL,
1116 HostCmd_ACT_GEN_SET, 0, NULL);
1666 if (ret) 1117 if (ret)
1667 return ret; 1118 return ret;
1668 } 1119 }
@@ -1671,12 +1122,9 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1671 else 1122 else
1672 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE; 1123 priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
1673 1124
1674 /* Send request to firmware */ 1125 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
1675 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_MAC_CONTROL, 1126 HostCmd_ACT_GEN_SET, 0,
1676 HostCmd_ACT_GEN_SET, 0, wait, 1127 &priv->curr_pkt_filter);
1677 &priv->curr_pkt_filter);
1678 if (!ret)
1679 ret = -EINPROGRESS;
1680 1128
1681 return ret; 1129 return ret;
1682} 1130}
@@ -1691,18 +1139,16 @@ static int mwifiex_sec_ioctl_set_wep_key(struct mwifiex_adapter *adapter,
1691 * 1139 *
1692 * This function can also be used to disable a currently set key. 1140 * This function can also be used to disable a currently set key.
1693 */ 1141 */
1694static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter, 1142static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_private *priv,
1695 struct mwifiex_wait_queue *wait,
1696 struct mwifiex_ds_encrypt_key *encrypt_key) 1143 struct mwifiex_ds_encrypt_key *encrypt_key)
1697{ 1144{
1698 int ret = 0; 1145 int ret = 0;
1699 struct mwifiex_private *priv = adapter->priv[wait->bss_index];
1700 u8 remove_key = false; 1146 u8 remove_key = false;
1701 struct host_cmd_ds_802_11_key_material *ibss_key; 1147 struct host_cmd_ds_802_11_key_material *ibss_key;
1702 1148
1703 /* Current driver only supports key length of up to 32 bytes */ 1149 /* Current driver only supports key length of up to 32 bytes */
1704 if (encrypt_key->key_len > MWIFIEX_MAX_KEY_LENGTH) { 1150 if (encrypt_key->key_len > WLAN_MAX_KEY_LEN) {
1705 dev_err(adapter->dev, "key length too long\n"); 1151 dev_err(priv->adapter->dev, "key length too long\n");
1706 return -1; 1152 return -1;
1707 } 1153 }
1708 1154
@@ -1713,9 +1159,10 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1713 */ 1159 */
1714 /* Send the key as PTK to firmware */ 1160 /* Send the key as PTK to firmware */
1715 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST; 1161 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1716 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1162 ret = mwifiex_send_cmd_async(priv,
1717 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, 1163 HostCmd_CMD_802_11_KEY_MATERIAL,
1718 NULL, encrypt_key); 1164 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1165 encrypt_key);
1719 if (ret) 1166 if (ret)
1720 return ret; 1167 return ret;
1721 1168
@@ -1729,8 +1176,7 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1729 sizeof(ibss_key->key_param_set.key_len)); 1176 sizeof(ibss_key->key_param_set.key_len));
1730 ibss_key->key_param_set.key_type_id 1177 ibss_key->key_param_set.key_type_id
1731 = cpu_to_le16(KEY_TYPE_ID_TKIP); 1178 = cpu_to_le16(KEY_TYPE_ID_TKIP);
1732 ibss_key->key_param_set.key_info 1179 ibss_key->key_param_set.key_info = cpu_to_le16(KEY_ENABLED);
1733 = cpu_to_le16(KEY_INFO_TKIP_ENABLED);
1734 1180
1735 /* Send the key as GTK to firmware */ 1181 /* Send the key as GTK to firmware */
1736 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST; 1182 encrypt_key->key_index = ~MWIFIEX_KEY_INDEX_UNICAST;
@@ -1740,19 +1186,15 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1740 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST; 1186 encrypt_key->key_index = MWIFIEX_KEY_INDEX_UNICAST;
1741 1187
1742 if (remove_key) 1188 if (remove_key)
1743 /* Send request to firmware */ 1189 ret = mwifiex_send_cmd_sync(priv,
1744 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1190 HostCmd_CMD_802_11_KEY_MATERIAL,
1745 HostCmd_ACT_GEN_SET, 1191 HostCmd_ACT_GEN_SET, !(KEY_INFO_ENABLED),
1746 !(KEY_INFO_ENABLED), 1192 encrypt_key);
1747 wait, encrypt_key);
1748 else 1193 else
1749 /* Send request to firmware */ 1194 ret = mwifiex_send_cmd_sync(priv,
1750 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_KEY_MATERIAL, 1195 HostCmd_CMD_802_11_KEY_MATERIAL,
1751 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED, 1196 HostCmd_ACT_GEN_SET, KEY_INFO_ENABLED,
1752 wait, encrypt_key); 1197 encrypt_key);
1753
1754 if (!ret)
1755 ret = -EINPROGRESS;
1756 1198
1757 return ret; 1199 return ret;
1758} 1200}
@@ -1765,21 +1207,16 @@ static int mwifiex_sec_ioctl_set_wpa_key(struct mwifiex_adapter *adapter,
1765 */ 1207 */
1766static int 1208static int
1767mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv, 1209mwifiex_sec_ioctl_encrypt_key(struct mwifiex_private *priv,
1768 struct mwifiex_wait_queue *wait,
1769 struct mwifiex_ds_encrypt_key *encrypt_key) 1210 struct mwifiex_ds_encrypt_key *encrypt_key)
1770{ 1211{
1771 int status = 0; 1212 int status = 0;
1772 struct mwifiex_adapter *adapter = priv->adapter;
1773 1213
1774 if (encrypt_key->is_wapi_key) 1214 if (encrypt_key->is_wapi_key)
1775 status = mwifiex_sec_ioctl_set_wapi_key(adapter, wait, 1215 status = mwifiex_sec_ioctl_set_wapi_key(priv, encrypt_key);
1776 encrypt_key);
1777 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104) 1216 else if (encrypt_key->key_len > WLAN_KEY_LEN_WEP104)
1778 status = mwifiex_sec_ioctl_set_wpa_key(adapter, wait, 1217 status = mwifiex_sec_ioctl_set_wpa_key(priv, encrypt_key);
1779 encrypt_key);
1780 else 1218 else
1781 status = mwifiex_sec_ioctl_set_wep_key(adapter, wait, 1219 status = mwifiex_sec_ioctl_set_wep_key(priv, encrypt_key);
1782 encrypt_key);
1783 return status; 1220 return status;
1784} 1221}
1785 1222
@@ -1807,94 +1244,30 @@ mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,
1807} 1244}
1808 1245
1809/* 1246/*
1810 * Sends IOCTL request to set Tx power. It can be set to either auto
1811 * or a fixed value.
1812 *
1813 * This function allocates the IOCTL request buffer, fills it
1814 * with requisite parameters and calls the IOCTL handler.
1815 */
1816int
1817mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm)
1818{
1819 struct mwifiex_power_cfg power_cfg;
1820 struct mwifiex_wait_queue *wait = NULL;
1821 int status = 0;
1822 int ret = 0;
1823
1824 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1825 if (!wait)
1826 return -ENOMEM;
1827
1828 if (type == NL80211_TX_POWER_FIXED) {
1829 power_cfg.is_power_auto = 0;
1830 power_cfg.power_level = dbm;
1831 } else {
1832 power_cfg.is_power_auto = 1;
1833 }
1834 status = mwifiex_power_ioctl_set_power(priv, wait, &power_cfg);
1835
1836 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
1837
1838 kfree(wait);
1839 return ret;
1840}
1841
1842/*
1843 * Sends IOCTL request to get scan table.
1844 *
1845 * This function allocates the IOCTL request buffer, fills it
1846 * with requisite parameters and calls the IOCTL handler.
1847 */
1848int mwifiex_get_scan_table(struct mwifiex_private *priv, u8 wait_option,
1849 struct mwifiex_scan_resp *scan_resp)
1850{
1851 struct mwifiex_wait_queue *wait = NULL;
1852 struct mwifiex_scan_resp scan;
1853 int status = 0;
1854
1855 /* Allocate wait buffer */
1856 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1857 if (!wait)
1858 return -ENOMEM;
1859
1860 status = mwifiex_scan_networks(priv, wait, HostCmd_ACT_GEN_GET,
1861 NULL, &scan);
1862
1863 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1864 if (!status) {
1865 if (scan_resp)
1866 memcpy(scan_resp, &scan,
1867 sizeof(struct mwifiex_scan_resp));
1868 }
1869
1870 if (wait && (status != -EINPROGRESS))
1871 kfree(wait);
1872 return status;
1873}
1874
1875/*
1876 * Sends IOCTL request to get signal information. 1247 * Sends IOCTL request to get signal information.
1877 * 1248 *
1878 * This function allocates the IOCTL request buffer, fills it 1249 * This function allocates the IOCTL request buffer, fills it
1879 * with requisite parameters and calls the IOCTL handler. 1250 * with requisite parameters and calls the IOCTL handler.
1880 */ 1251 */
1881int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option, 1252int mwifiex_get_signal_info(struct mwifiex_private *priv,
1882 struct mwifiex_ds_get_signal *signal) 1253 struct mwifiex_ds_get_signal *signal)
1883{ 1254{
1884 struct mwifiex_ds_get_signal info; 1255 struct mwifiex_ds_get_signal info;
1885 struct mwifiex_wait_queue *wait = NULL;
1886 int status = 0; 1256 int status = 0;
1887 1257
1888 /* Allocate wait buffer */ 1258 memset(&info, 0, sizeof(struct mwifiex_ds_get_signal));
1889 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1890 if (!wait)
1891 return -ENOMEM;
1892
1893 info.selector = ALL_RSSI_INFO_MASK; 1259 info.selector = ALL_RSSI_INFO_MASK;
1894 1260
1895 status = mwifiex_get_info_signal(priv, wait, &info); 1261 /* Signal info can be obtained only if connected */
1262 if (!priv->media_connected) {
1263 dev_dbg(priv->adapter->dev,
1264 "info: Can not get signal in disconnected state\n");
1265 return -1;
1266 }
1267
1268 status = mwifiex_send_cmd_sync(priv, HostCmd_CMD_RSSI_INFO,
1269 HostCmd_ACT_GEN_GET, 0, signal);
1896 1270
1897 status = mwifiex_request_ioctl(priv, wait, status, wait_option);
1898 if (!status) { 1271 if (!status) {
1899 if (signal) 1272 if (signal)
1900 memcpy(signal, &info, 1273 memcpy(signal, &info,
@@ -1905,8 +1278,6 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option,
1905 priv->w_stats.qual.noise = info.bcn_nf_avg; 1278 priv->w_stats.qual.noise = info.bcn_nf_avg;
1906 } 1279 }
1907 1280
1908 if (wait && (status != -EINPROGRESS))
1909 kfree(wait);
1910 return status; 1281 return status;
1911} 1282}
1912 1283
@@ -1919,14 +1290,7 @@ int mwifiex_get_signal_info(struct mwifiex_private *priv, u8 wait_option,
1919int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key, 1290int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1920 int key_len, u8 key_index, int disable) 1291 int key_len, u8 key_index, int disable)
1921{ 1292{
1922 struct mwifiex_wait_queue *wait = NULL;
1923 struct mwifiex_ds_encrypt_key encrypt_key; 1293 struct mwifiex_ds_encrypt_key encrypt_key;
1924 int status = 0;
1925 int ret = 0;
1926
1927 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1928 if (!wait)
1929 return -ENOMEM;
1930 1294
1931 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key)); 1295 memset(&encrypt_key, 0, sizeof(struct mwifiex_ds_encrypt_key));
1932 encrypt_key.key_len = key_len; 1296 encrypt_key.key_len = key_len;
@@ -1938,41 +1302,7 @@ int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1938 encrypt_key.key_disable = true; 1302 encrypt_key.key_disable = true;
1939 } 1303 }
1940 1304
1941 status = mwifiex_sec_ioctl_encrypt_key(priv, wait, &encrypt_key); 1305 return mwifiex_sec_ioctl_encrypt_key(priv, &encrypt_key);
1942
1943 if (mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT))
1944 ret = -EFAULT;
1945
1946 kfree(wait);
1947 return ret;
1948}
1949
1950/*
1951 * Sends IOCTL request to set power management parameters.
1952 *
1953 * This function allocates the IOCTL request buffer, fills it
1954 * with requisite parameters and calls the IOCTL handler.
1955 */
1956int
1957mwifiex_drv_set_power(struct mwifiex_private *priv, bool power_on)
1958{
1959 int ret = 0;
1960 int status = 0;
1961 struct mwifiex_wait_queue *wait = NULL;
1962 u32 ps_mode;
1963
1964 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
1965 if (!wait)
1966 return -ENOMEM;
1967
1968 ps_mode = power_on;
1969 status = mwifiex_pm_ioctl_ps_mode(priv, wait, &ps_mode,
1970 HostCmd_ACT_GEN_SET);
1971
1972 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
1973
1974 kfree(wait);
1975 return ret;
1976} 1306}
1977 1307
1978/* 1308/*
@@ -1985,27 +1315,13 @@ int
1985mwifiex_get_ver_ext(struct mwifiex_private *priv) 1315mwifiex_get_ver_ext(struct mwifiex_private *priv)
1986{ 1316{
1987 struct mwifiex_ver_ext ver_ext; 1317 struct mwifiex_ver_ext ver_ext;
1988 struct mwifiex_wait_queue *wait = NULL;
1989 int status = 0;
1990 int ret = 0;
1991 u8 wait_option = MWIFIEX_IOCTL_WAIT;
1992 1318
1993 /* Allocate wait buffer */
1994 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
1995 if (!wait)
1996 return -ENOMEM;
1997
1998 /* get fw version */
1999 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext)); 1319 memset(&ver_ext, 0, sizeof(struct host_cmd_ds_version_ext));
2000 status = mwifiex_get_info_ver_ext(priv, wait, &ver_ext); 1320 if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_VERSION_EXT,
2001 1321 HostCmd_ACT_GEN_GET, 0, &ver_ext))
2002 ret = mwifiex_request_ioctl(priv, wait, status, wait_option); 1322 return -1;
2003
2004 if (ret)
2005 ret = -1;
2006 1323
2007 kfree(wait); 1324 return 0;
2008 return ret;
2009} 1325}
2010 1326
2011/* 1327/*
@@ -2019,21 +1335,12 @@ mwifiex_get_stats_info(struct mwifiex_private *priv,
2019 struct mwifiex_ds_get_stats *log) 1335 struct mwifiex_ds_get_stats *log)
2020{ 1336{
2021 int ret = 0; 1337 int ret = 0;
2022 int status = 0;
2023 struct mwifiex_wait_queue *wait = NULL;
2024 struct mwifiex_ds_get_stats get_log; 1338 struct mwifiex_ds_get_stats get_log;
2025 u8 wait_option = MWIFIEX_IOCTL_WAIT;
2026
2027 /* Allocate wait buffer */
2028 wait = mwifiex_alloc_fill_wait_queue(priv, wait_option);
2029 if (!wait)
2030 return -ENOMEM;
2031 1339
2032 memset(&get_log, 0, sizeof(struct mwifiex_ds_get_stats)); 1340 memset(&get_log, 0, sizeof(struct mwifiex_ds_get_stats));
2033 status = mwifiex_get_info_stats(priv, wait, &get_log); 1341 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_GET_LOG,
1342 HostCmd_ACT_GEN_GET, 0, &get_log);
2034 1343
2035 /* Send IOCTL request to MWIFIEX */
2036 ret = mwifiex_request_ioctl(priv, wait, status, wait_option);
2037 if (!ret) { 1344 if (!ret) {
2038 if (log) 1345 if (log)
2039 memcpy(log, &get_log, sizeof(struct 1346 memcpy(log, &get_log, sizeof(struct
@@ -2043,7 +1350,6 @@ mwifiex_get_stats_info(struct mwifiex_private *priv,
2043 priv->w_stats.discard.misc = get_log.ack_failure; 1350 priv->w_stats.discard.misc = get_log.ack_failure;
2044 } 1351 }
2045 1352
2046 kfree(wait);
2047 return ret; 1353 return ret;
2048} 1354}
2049 1355
@@ -2061,11 +1367,9 @@ mwifiex_get_stats_info(struct mwifiex_private *priv,
2061 * - CAU 1367 * - CAU
2062 */ 1368 */
2063static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv, 1369static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
2064 struct mwifiex_wait_queue *wait,
2065 struct mwifiex_ds_reg_rw *reg_rw, 1370 struct mwifiex_ds_reg_rw *reg_rw,
2066 u16 action) 1371 u16 action)
2067{ 1372{
2068 int ret = 0;
2069 u16 cmd_no; 1373 u16 cmd_no;
2070 1374
2071 switch (le32_to_cpu(reg_rw->type)) { 1375 switch (le32_to_cpu(reg_rw->type)) {
@@ -2088,13 +1392,8 @@ static int mwifiex_reg_mem_ioctl_reg_rw(struct mwifiex_private *priv,
2088 return -1; 1392 return -1;
2089 } 1393 }
2090 1394
2091 /* Send request to firmware */ 1395 return mwifiex_send_cmd_sync(priv, cmd_no, action, 0, reg_rw);
2092 ret = mwifiex_prepare_cmd(priv, cmd_no, action, 0, wait, reg_rw);
2093
2094 if (!ret)
2095 ret = -EINPROGRESS;
2096 1396
2097 return ret;
2098} 1397}
2099 1398
2100/* 1399/*
@@ -2107,25 +1406,13 @@ int
2107mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type, 1406mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
2108 u32 reg_offset, u32 reg_value) 1407 u32 reg_offset, u32 reg_value)
2109{ 1408{
2110 int ret = 0;
2111 int status = 0;
2112 struct mwifiex_wait_queue *wait = NULL;
2113 struct mwifiex_ds_reg_rw reg_rw; 1409 struct mwifiex_ds_reg_rw reg_rw;
2114 1410
2115 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2116 if (!wait)
2117 return -ENOMEM;
2118
2119 reg_rw.type = cpu_to_le32(reg_type); 1411 reg_rw.type = cpu_to_le32(reg_type);
2120 reg_rw.offset = cpu_to_le32(reg_offset); 1412 reg_rw.offset = cpu_to_le32(reg_offset);
2121 reg_rw.value = cpu_to_le32(reg_value); 1413 reg_rw.value = cpu_to_le32(reg_value);
2122 status = mwifiex_reg_mem_ioctl_reg_rw(priv, wait, &reg_rw,
2123 HostCmd_ACT_GEN_SET);
2124
2125 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2126 1414
2127 kfree(wait); 1415 return mwifiex_reg_mem_ioctl_reg_rw(priv, &reg_rw, HostCmd_ACT_GEN_SET);
2128 return ret;
2129} 1416}
2130 1417
2131/* 1418/*
@@ -2139,50 +1426,18 @@ mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
2139 u32 reg_offset, u32 *value) 1426 u32 reg_offset, u32 *value)
2140{ 1427{
2141 int ret = 0; 1428 int ret = 0;
2142 int status = 0;
2143 struct mwifiex_wait_queue *wait = NULL;
2144 struct mwifiex_ds_reg_rw reg_rw; 1429 struct mwifiex_ds_reg_rw reg_rw;
2145 1430
2146 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2147 if (!wait)
2148 return -ENOMEM;
2149
2150 reg_rw.type = cpu_to_le32(reg_type); 1431 reg_rw.type = cpu_to_le32(reg_type);
2151 reg_rw.offset = cpu_to_le32(reg_offset); 1432 reg_rw.offset = cpu_to_le32(reg_offset);
2152 status = mwifiex_reg_mem_ioctl_reg_rw(priv, wait, &reg_rw, 1433 ret = mwifiex_reg_mem_ioctl_reg_rw(priv, &reg_rw, HostCmd_ACT_GEN_GET);
2153 HostCmd_ACT_GEN_GET);
2154 1434
2155 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT);
2156 if (ret) 1435 if (ret)
2157 goto done; 1436 goto done;
2158 1437
2159 *value = le32_to_cpu(reg_rw.value); 1438 *value = le32_to_cpu(reg_rw.value);
2160 1439
2161done: 1440done:
2162 kfree(wait);
2163 return ret;
2164}
2165
2166/*
2167 * IOCTL request handler to read EEPROM.
2168 *
2169 * This function prepares the correct firmware command and
2170 * issues it.
2171 */
2172static int
2173mwifiex_reg_mem_ioctl_read_eeprom(struct mwifiex_private *priv,
2174 struct mwifiex_wait_queue *wait,
2175 struct mwifiex_ds_read_eeprom *rd_eeprom)
2176{
2177 int ret = 0;
2178
2179 /* Send request to firmware */
2180 ret = mwifiex_prepare_cmd(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
2181 HostCmd_ACT_GEN_GET, 0, wait, rd_eeprom);
2182
2183 if (!ret)
2184 ret = -EINPROGRESS;
2185
2186 return ret; 1441 return ret;
2187} 1442}
2188 1443
@@ -2197,25 +1452,17 @@ mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
2197 u8 *value) 1452 u8 *value)
2198{ 1453{
2199 int ret = 0; 1454 int ret = 0;
2200 int status = 0;
2201 struct mwifiex_wait_queue *wait = NULL;
2202 struct mwifiex_ds_read_eeprom rd_eeprom; 1455 struct mwifiex_ds_read_eeprom rd_eeprom;
2203 1456
2204 wait = mwifiex_alloc_fill_wait_queue(priv, MWIFIEX_IOCTL_WAIT);
2205 if (!wait)
2206 return -ENOMEM;
2207
2208 rd_eeprom.offset = cpu_to_le16((u16) offset); 1457 rd_eeprom.offset = cpu_to_le16((u16) offset);
2209 rd_eeprom.byte_count = cpu_to_le16((u16) bytes); 1458 rd_eeprom.byte_count = cpu_to_le16((u16) bytes);
2210 status = mwifiex_reg_mem_ioctl_read_eeprom(priv, wait, &rd_eeprom);
2211 1459
2212 ret = mwifiex_request_ioctl(priv, wait, status, MWIFIEX_IOCTL_WAIT); 1460 /* Send request to firmware */
2213 if (ret) 1461 ret = mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_EEPROM_ACCESS,
2214 goto done; 1462 HostCmd_ACT_GEN_GET, 0, &rd_eeprom);
2215 1463
2216 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA); 1464 if (!ret)
2217done: 1465 memcpy(value, rd_eeprom.value, MAX_EEPROM_DATA);
2218 kfree(wait);
2219 return ret; 1466 return ret;
2220} 1467}
2221 1468
@@ -2344,7 +1591,6 @@ int
2344mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len) 1591mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
2345{ 1592{
2346 struct mwifiex_ds_misc_gen_ie gen_ie; 1593 struct mwifiex_ds_misc_gen_ie gen_ie;
2347 int status = 0;
2348 1594
2349 if (ie_len > IW_CUSTOM_MAX) 1595 if (ie_len > IW_CUSTOM_MAX)
2350 return -EFAULT; 1596 return -EFAULT;
@@ -2352,8 +1598,7 @@ mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len)
2352 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE; 1598 gen_ie.type = MWIFIEX_IE_TYPE_GEN_IE;
2353 gen_ie.len = ie_len; 1599 gen_ie.len = ie_len;
2354 memcpy(gen_ie.ie_data, ie, ie_len); 1600 memcpy(gen_ie.ie_data, ie, ie_len);
2355 status = mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET); 1601 if (mwifiex_misc_ioctl_gen_ie(priv, &gen_ie, HostCmd_ACT_GEN_SET))
2356 if (status)
2357 return -EFAULT; 1602 return -EFAULT;
2358 1603
2359 return 0; 1604 return 0;