Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetoot...
[deliverable/linux.git] / drivers / net / wireless / mwifiex / main.c
1 /*
2 * Marvell Wireless LAN device driver: major functions
3 *
4 * Copyright (C) 2011-2014, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
17 * this warranty disclaimer.
18 */
19
20 #include "main.h"
21 #include "wmm.h"
22 #include "cfg80211.h"
23 #include "11n.h"
24
25 #define VERSION "1.0"
26
27 const char driver_version[] = "mwifiex " VERSION " (%s) ";
28 static char *cal_data_cfg;
29 module_param(cal_data_cfg, charp, 0);
30
31 static unsigned short driver_mode;
32 module_param(driver_mode, ushort, 0);
33 MODULE_PARM_DESC(driver_mode,
34 "station=0x1(default), ap-sta=0x3, station-p2p=0x5, ap-sta-p2p=0x7");
35
36 /*
37 * This function registers the device and performs all the necessary
38 * initializations.
39 *
40 * The following initialization operations are performed -
41 * - Allocate adapter structure
42 * - Save interface specific operations table in adapter
43 * - Call interface specific initialization routine
44 * - Allocate private structures
45 * - Set default adapter structure parameters
46 * - Initialize locks
47 *
48 * In case of any errors during inittialization, this function also ensures
49 * proper cleanup before exiting.
50 */
51 static int mwifiex_register(void *card, struct mwifiex_if_ops *if_ops,
52 void **padapter)
53 {
54 struct mwifiex_adapter *adapter;
55 int i;
56
57 adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL);
58 if (!adapter)
59 return -ENOMEM;
60
61 *padapter = adapter;
62 adapter->card = card;
63
64 /* Save interface specific operations in adapter */
65 memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops));
66
67 /* card specific initialization has been deferred until now .. */
68 if (adapter->if_ops.init_if)
69 if (adapter->if_ops.init_if(adapter))
70 goto error;
71
72 adapter->priv_num = 0;
73
74 for (i = 0; i < MWIFIEX_MAX_BSS_NUM; i++) {
75 /* Allocate memory for private structure */
76 adapter->priv[i] =
77 kzalloc(sizeof(struct mwifiex_private), GFP_KERNEL);
78 if (!adapter->priv[i])
79 goto error;
80
81 adapter->priv[i]->adapter = adapter;
82 adapter->priv_num++;
83 }
84 mwifiex_init_lock_list(adapter);
85
86 setup_timer(&adapter->cmd_timer, mwifiex_cmd_timeout_func,
87 (unsigned long)adapter);
88
89 return 0;
90
91 error:
92 dev_dbg(adapter->dev, "info: leave mwifiex_register with error\n");
93
94 for (i = 0; i < adapter->priv_num; i++)
95 kfree(adapter->priv[i]);
96
97 kfree(adapter);
98
99 return -1;
100 }
101
102 /*
103 * This function unregisters the device and performs all the necessary
104 * cleanups.
105 *
106 * The following cleanup operations are performed -
107 * - Free the timers
108 * - Free beacon buffers
109 * - Free private structures
110 * - Free adapter structure
111 */
112 static int mwifiex_unregister(struct mwifiex_adapter *adapter)
113 {
114 s32 i;
115
116 if (adapter->if_ops.cleanup_if)
117 adapter->if_ops.cleanup_if(adapter);
118
119 del_timer_sync(&adapter->cmd_timer);
120
121 /* Free private structures */
122 for (i = 0; i < adapter->priv_num; i++) {
123 if (adapter->priv[i]) {
124 mwifiex_free_curr_bcn(adapter->priv[i]);
125 kfree(adapter->priv[i]);
126 }
127 }
128
129 vfree(adapter->chan_stats);
130 kfree(adapter);
131 return 0;
132 }
133
134 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter)
135 {
136 unsigned long flags;
137
138 spin_lock_irqsave(&adapter->main_proc_lock, flags);
139 if (adapter->mwifiex_processing) {
140 adapter->more_task_flag = true;
141 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
142 } else {
143 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
144 queue_work(adapter->workqueue, &adapter->main_work);
145 }
146 }
147 EXPORT_SYMBOL_GPL(mwifiex_queue_main_work);
148
149 static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter)
150 {
151 unsigned long flags;
152
153 spin_lock_irqsave(&adapter->rx_proc_lock, flags);
154 if (adapter->rx_processing) {
155 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
156 } else {
157 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
158 queue_work(adapter->rx_workqueue, &adapter->rx_work);
159 }
160 }
161
162 static int mwifiex_process_rx(struct mwifiex_adapter *adapter)
163 {
164 unsigned long flags;
165 struct sk_buff *skb;
166 struct mwifiex_rxinfo *rx_info;
167
168 spin_lock_irqsave(&adapter->rx_proc_lock, flags);
169 if (adapter->rx_processing || adapter->rx_locked) {
170 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
171 goto exit_rx_proc;
172 } else {
173 adapter->rx_processing = true;
174 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
175 }
176
177 /* Check for Rx data */
178 while ((skb = skb_dequeue(&adapter->rx_data_q))) {
179 atomic_dec(&adapter->rx_pending);
180 if ((adapter->delay_main_work ||
181 adapter->iface_type == MWIFIEX_USB) &&
182 (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) {
183 if (adapter->if_ops.submit_rem_rx_urbs)
184 adapter->if_ops.submit_rem_rx_urbs(adapter);
185 adapter->delay_main_work = false;
186 mwifiex_queue_main_work(adapter);
187 }
188 rx_info = MWIFIEX_SKB_RXCB(skb);
189 if (rx_info->buf_type == MWIFIEX_TYPE_AGGR_DATA) {
190 if (adapter->if_ops.deaggr_pkt)
191 adapter->if_ops.deaggr_pkt(adapter, skb);
192 dev_kfree_skb_any(skb);
193 } else {
194 mwifiex_handle_rx_packet(adapter, skb);
195 }
196 }
197 spin_lock_irqsave(&adapter->rx_proc_lock, flags);
198 adapter->rx_processing = false;
199 spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);
200
201 exit_rx_proc:
202 return 0;
203 }
204
205 /*
206 * The main process.
207 *
208 * This function is the main procedure of the driver and handles various driver
209 * operations. It runs in a loop and provides the core functionalities.
210 *
211 * The main responsibilities of this function are -
212 * - Ensure concurrency control
213 * - Handle pending interrupts and call interrupt handlers
214 * - Wake up the card if required
215 * - Handle command responses and call response handlers
216 * - Handle events and call event handlers
217 * - Execute pending commands
218 * - Transmit pending data packets
219 */
220 int mwifiex_main_process(struct mwifiex_adapter *adapter)
221 {
222 int ret = 0;
223 unsigned long flags;
224
225 spin_lock_irqsave(&adapter->main_proc_lock, flags);
226
227 /* Check if already processing */
228 if (adapter->mwifiex_processing || adapter->main_locked) {
229 adapter->more_task_flag = true;
230 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
231 goto exit_main_proc;
232 } else {
233 adapter->mwifiex_processing = true;
234 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
235 }
236 process_start:
237 do {
238 if ((adapter->hw_status == MWIFIEX_HW_STATUS_CLOSING) ||
239 (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY))
240 break;
241
242 /* For non-USB interfaces, If we process interrupts first, it
243 * would increase RX pending even further. Avoid this by
244 * checking if rx_pending has crossed high threshold and
245 * schedule rx work queue and then process interrupts.
246 * For USB interface, there are no interrupts. We already have
247 * HIGH_RX_PENDING check in usb.c
248 */
249 if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING &&
250 adapter->iface_type != MWIFIEX_USB) {
251 adapter->delay_main_work = true;
252 mwifiex_queue_rx_work(adapter);
253 break;
254 }
255
256 /* Handle pending interrupt if any */
257 if (adapter->int_status) {
258 if (adapter->hs_activated)
259 mwifiex_process_hs_config(adapter);
260 if (adapter->if_ops.process_int_status)
261 adapter->if_ops.process_int_status(adapter);
262 }
263
264 if (adapter->rx_work_enabled && adapter->data_received)
265 mwifiex_queue_rx_work(adapter);
266
267 /* Need to wake up the card ? */
268 if ((adapter->ps_state == PS_STATE_SLEEP) &&
269 (adapter->pm_wakeup_card_req &&
270 !adapter->pm_wakeup_fw_try) &&
271 (is_command_pending(adapter) ||
272 !skb_queue_empty(&adapter->tx_data_q) ||
273 !mwifiex_wmm_lists_empty(adapter))) {
274 adapter->pm_wakeup_fw_try = true;
275 mod_timer(&adapter->wakeup_timer, jiffies + (HZ*3));
276 adapter->if_ops.wakeup(adapter);
277 continue;
278 }
279
280 if (IS_CARD_RX_RCVD(adapter)) {
281 adapter->data_received = false;
282 adapter->pm_wakeup_fw_try = false;
283 del_timer(&adapter->wakeup_timer);
284 if (adapter->ps_state == PS_STATE_SLEEP)
285 adapter->ps_state = PS_STATE_AWAKE;
286 } else {
287 /* We have tried to wakeup the card already */
288 if (adapter->pm_wakeup_fw_try)
289 break;
290 if (adapter->ps_state != PS_STATE_AWAKE ||
291 adapter->tx_lock_flag)
292 break;
293
294 if ((!adapter->scan_chan_gap_enabled &&
295 adapter->scan_processing) || adapter->data_sent ||
296 (mwifiex_wmm_lists_empty(adapter) &&
297 skb_queue_empty(&adapter->tx_data_q))) {
298 if (adapter->cmd_sent || adapter->curr_cmd ||
299 (!is_command_pending(adapter)))
300 break;
301 }
302 }
303
304 /* Check for event */
305 if (adapter->event_received) {
306 adapter->event_received = false;
307 mwifiex_process_event(adapter);
308 }
309
310 /* Check for Cmd Resp */
311 if (adapter->cmd_resp_received) {
312 adapter->cmd_resp_received = false;
313 mwifiex_process_cmdresp(adapter);
314
315 /* call mwifiex back when init_fw is done */
316 if (adapter->hw_status == MWIFIEX_HW_STATUS_INIT_DONE) {
317 adapter->hw_status = MWIFIEX_HW_STATUS_READY;
318 mwifiex_init_fw_complete(adapter);
319 }
320 }
321
322 /* Check if we need to confirm Sleep Request
323 received previously */
324 if (adapter->ps_state == PS_STATE_PRE_SLEEP) {
325 if (!adapter->cmd_sent && !adapter->curr_cmd)
326 mwifiex_check_ps_cond(adapter);
327 }
328
329 /* * The ps_state may have been changed during processing of
330 * Sleep Request event.
331 */
332 if ((adapter->ps_state == PS_STATE_SLEEP) ||
333 (adapter->ps_state == PS_STATE_PRE_SLEEP) ||
334 (adapter->ps_state == PS_STATE_SLEEP_CFM) ||
335 adapter->tx_lock_flag){
336 continue;
337 }
338
339 if (!adapter->cmd_sent && !adapter->curr_cmd) {
340 if (mwifiex_exec_next_cmd(adapter) == -1) {
341 ret = -1;
342 break;
343 }
344 }
345
346 if ((adapter->scan_chan_gap_enabled ||
347 !adapter->scan_processing) &&
348 !adapter->data_sent &&
349 !skb_queue_empty(&adapter->tx_data_q)) {
350 mwifiex_process_tx_queue(adapter);
351 if (adapter->hs_activated) {
352 adapter->is_hs_configured = false;
353 mwifiex_hs_activated_event
354 (mwifiex_get_priv
355 (adapter, MWIFIEX_BSS_ROLE_ANY),
356 false);
357 }
358 }
359
360 if ((adapter->scan_chan_gap_enabled ||
361 !adapter->scan_processing) &&
362 !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter)) {
363 mwifiex_wmm_process_tx(adapter);
364 if (adapter->hs_activated) {
365 adapter->is_hs_configured = false;
366 mwifiex_hs_activated_event
367 (mwifiex_get_priv
368 (adapter, MWIFIEX_BSS_ROLE_ANY),
369 false);
370 }
371 }
372
373 if (adapter->delay_null_pkt && !adapter->cmd_sent &&
374 !adapter->curr_cmd && !is_command_pending(adapter) &&
375 (mwifiex_wmm_lists_empty(adapter) &&
376 skb_queue_empty(&adapter->tx_data_q))) {
377 if (!mwifiex_send_null_packet
378 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA),
379 MWIFIEX_TxPD_POWER_MGMT_NULL_PACKET |
380 MWIFIEX_TxPD_POWER_MGMT_LAST_PACKET)) {
381 adapter->delay_null_pkt = false;
382 adapter->ps_state = PS_STATE_SLEEP;
383 }
384 break;
385 }
386 } while (true);
387
388 spin_lock_irqsave(&adapter->main_proc_lock, flags);
389 if (adapter->more_task_flag) {
390 adapter->more_task_flag = false;
391 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
392 goto process_start;
393 }
394 adapter->mwifiex_processing = false;
395 spin_unlock_irqrestore(&adapter->main_proc_lock, flags);
396
397 exit_main_proc:
398 if (adapter->hw_status == MWIFIEX_HW_STATUS_CLOSING)
399 mwifiex_shutdown_drv(adapter);
400 return ret;
401 }
402 EXPORT_SYMBOL_GPL(mwifiex_main_process);
403
404 /*
405 * This function frees the adapter structure.
406 *
407 * Additionally, this closes the netlink socket, frees the timers
408 * and private structures.
409 */
410 static void mwifiex_free_adapter(struct mwifiex_adapter *adapter)
411 {
412 if (!adapter) {
413 pr_err("%s: adapter is NULL\n", __func__);
414 return;
415 }
416
417 mwifiex_unregister(adapter);
418 pr_debug("info: %s: free adapter\n", __func__);
419 }
420
421 /*
422 * This function cancels all works in the queue and destroys
423 * the main workqueue.
424 */
425 static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter)
426 {
427 flush_workqueue(adapter->workqueue);
428 destroy_workqueue(adapter->workqueue);
429 adapter->workqueue = NULL;
430
431 if (adapter->rx_workqueue) {
432 flush_workqueue(adapter->rx_workqueue);
433 destroy_workqueue(adapter->rx_workqueue);
434 adapter->rx_workqueue = NULL;
435 }
436 }
437
438 /*
439 * This function gets firmware and initializes it.
440 *
441 * The main initialization steps followed are -
442 * - Download the correct firmware to card
443 * - Issue the init commands to firmware
444 */
445 static void mwifiex_fw_dpc(const struct firmware *firmware, void *context)
446 {
447 int ret;
448 char fmt[64];
449 struct mwifiex_private *priv;
450 struct mwifiex_adapter *adapter = context;
451 struct mwifiex_fw_image fw;
452 struct semaphore *sem = adapter->card_sem;
453 bool init_failed = false;
454 struct wireless_dev *wdev;
455
456 if (!firmware) {
457 dev_err(adapter->dev,
458 "Failed to get firmware %s\n", adapter->fw_name);
459 goto err_dnld_fw;
460 }
461
462 memset(&fw, 0, sizeof(struct mwifiex_fw_image));
463 adapter->firmware = firmware;
464 fw.fw_buf = (u8 *) adapter->firmware->data;
465 fw.fw_len = adapter->firmware->size;
466
467 if (adapter->if_ops.dnld_fw)
468 ret = adapter->if_ops.dnld_fw(adapter, &fw);
469 else
470 ret = mwifiex_dnld_fw(adapter, &fw);
471 if (ret == -1)
472 goto err_dnld_fw;
473
474 dev_notice(adapter->dev, "WLAN FW is active\n");
475
476 if (cal_data_cfg) {
477 if ((request_firmware(&adapter->cal_data, cal_data_cfg,
478 adapter->dev)) < 0)
479 dev_err(adapter->dev,
480 "Cal data request_firmware() failed\n");
481 }
482
483 /* enable host interrupt after fw dnld is successful */
484 if (adapter->if_ops.enable_int) {
485 if (adapter->if_ops.enable_int(adapter))
486 goto err_dnld_fw;
487 }
488
489 adapter->init_wait_q_woken = false;
490 ret = mwifiex_init_fw(adapter);
491 if (ret == -1) {
492 goto err_init_fw;
493 } else if (!ret) {
494 adapter->hw_status = MWIFIEX_HW_STATUS_READY;
495 goto done;
496 }
497 /* Wait for mwifiex_init to complete */
498 wait_event_interruptible(adapter->init_wait_q,
499 adapter->init_wait_q_woken);
500 if (adapter->hw_status != MWIFIEX_HW_STATUS_READY)
501 goto err_init_fw;
502
503 priv = adapter->priv[MWIFIEX_BSS_ROLE_STA];
504 if (mwifiex_register_cfg80211(adapter)) {
505 dev_err(adapter->dev, "cannot register with cfg80211\n");
506 goto err_init_fw;
507 }
508
509 if (mwifiex_init_channel_scan_gap(adapter)) {
510 dev_err(adapter->dev, "could not init channel stats table\n");
511 goto err_init_fw;
512 }
513
514 if (driver_mode) {
515 driver_mode &= MWIFIEX_DRIVER_MODE_BITMASK;
516 driver_mode |= MWIFIEX_DRIVER_MODE_STA;
517 }
518
519 rtnl_lock();
520 /* Create station interface by default */
521 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM,
522 NL80211_IFTYPE_STATION, NULL, NULL);
523 if (IS_ERR(wdev)) {
524 dev_err(adapter->dev, "cannot create default STA interface\n");
525 rtnl_unlock();
526 goto err_add_intf;
527 }
528
529 if (driver_mode & MWIFIEX_DRIVER_MODE_UAP) {
530 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM,
531 NL80211_IFTYPE_AP, NULL, NULL);
532 if (IS_ERR(wdev)) {
533 dev_err(adapter->dev, "cannot create AP interface\n");
534 rtnl_unlock();
535 goto err_add_intf;
536 }
537 }
538
539 if (driver_mode & MWIFIEX_DRIVER_MODE_P2P) {
540 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM,
541 NL80211_IFTYPE_P2P_CLIENT, NULL,
542 NULL);
543 if (IS_ERR(wdev)) {
544 dev_err(adapter->dev,
545 "cannot create p2p client interface\n");
546 rtnl_unlock();
547 goto err_add_intf;
548 }
549 }
550 rtnl_unlock();
551
552 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1);
553 dev_notice(adapter->dev, "driver_version = %s\n", fmt);
554 goto done;
555
556 err_add_intf:
557 wiphy_unregister(adapter->wiphy);
558 wiphy_free(adapter->wiphy);
559 err_init_fw:
560 if (adapter->if_ops.disable_int)
561 adapter->if_ops.disable_int(adapter);
562 err_dnld_fw:
563 pr_debug("info: %s: unregister device\n", __func__);
564 if (adapter->if_ops.unregister_dev)
565 adapter->if_ops.unregister_dev(adapter);
566
567 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
568 pr_debug("info: %s: shutdown mwifiex\n", __func__);
569 adapter->init_wait_q_woken = false;
570
571 if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS)
572 wait_event_interruptible(adapter->init_wait_q,
573 adapter->init_wait_q_woken);
574 }
575 adapter->surprise_removed = true;
576 mwifiex_terminate_workqueue(adapter);
577 init_failed = true;
578 done:
579 if (adapter->cal_data) {
580 release_firmware(adapter->cal_data);
581 adapter->cal_data = NULL;
582 }
583 if (adapter->firmware) {
584 release_firmware(adapter->firmware);
585 adapter->firmware = NULL;
586 }
587 if (init_failed)
588 mwifiex_free_adapter(adapter);
589 up(sem);
590 return;
591 }
592
593 /*
594 * This function initializes the hardware and gets firmware.
595 */
596 static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter)
597 {
598 int ret;
599
600 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name,
601 adapter->dev, GFP_KERNEL, adapter,
602 mwifiex_fw_dpc);
603 if (ret < 0)
604 dev_err(adapter->dev,
605 "request_firmware_nowait() returned error %d\n", ret);
606 return ret;
607 }
608
609 /*
610 * CFG802.11 network device handler for open.
611 *
612 * Starts the data queue.
613 */
614 static int
615 mwifiex_open(struct net_device *dev)
616 {
617 netif_carrier_off(dev);
618
619 return 0;
620 }
621
622 /*
623 * CFG802.11 network device handler for close.
624 */
625 static int
626 mwifiex_close(struct net_device *dev)
627 {
628 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
629
630 if (priv->scan_request) {
631 dev_dbg(priv->adapter->dev, "aborting scan on ndo_stop\n");
632 cfg80211_scan_done(priv->scan_request, 1);
633 priv->scan_request = NULL;
634 priv->scan_aborting = true;
635 }
636
637 return 0;
638 }
639
640 /*
641 * Add buffer into wmm tx queue and queue work to transmit it.
642 */
643 int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb)
644 {
645 struct netdev_queue *txq;
646 int index = mwifiex_1d_to_wmm_queue[skb->priority];
647
648 if (atomic_inc_return(&priv->wmm_tx_pending[index]) >= MAX_TX_PENDING) {
649 txq = netdev_get_tx_queue(priv->netdev, index);
650 if (!netif_tx_queue_stopped(txq)) {
651 netif_tx_stop_queue(txq);
652 dev_dbg(priv->adapter->dev, "stop queue: %d\n", index);
653 }
654 }
655
656 atomic_inc(&priv->adapter->tx_pending);
657 mwifiex_wmm_add_buf_txqueue(priv, skb);
658
659 mwifiex_queue_main_work(priv->adapter);
660
661 return 0;
662 }
663
664 struct sk_buff *
665 mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
666 struct sk_buff *skb, u8 flag, u64 *cookie)
667 {
668 struct sk_buff *orig_skb = skb;
669 struct mwifiex_txinfo *tx_info, *orig_tx_info;
670
671 skb = skb_clone(skb, GFP_ATOMIC);
672 if (skb) {
673 unsigned long flags;
674 int id;
675
676 spin_lock_irqsave(&priv->ack_status_lock, flags);
677 id = idr_alloc(&priv->ack_status_frames, orig_skb,
678 1, 0xff, GFP_ATOMIC);
679 spin_unlock_irqrestore(&priv->ack_status_lock, flags);
680
681 if (id >= 0) {
682 tx_info = MWIFIEX_SKB_TXCB(skb);
683 tx_info->ack_frame_id = id;
684 tx_info->flags |= flag;
685 orig_tx_info = MWIFIEX_SKB_TXCB(orig_skb);
686 orig_tx_info->ack_frame_id = id;
687 orig_tx_info->flags |= flag;
688
689 if (flag == MWIFIEX_BUF_FLAG_ACTION_TX_STATUS && cookie)
690 orig_tx_info->cookie = *cookie;
691
692 } else if (skb_shared(skb)) {
693 kfree_skb(orig_skb);
694 } else {
695 kfree_skb(skb);
696 skb = orig_skb;
697 }
698 } else {
699 /* couldn't clone -- lose tx status ... */
700 skb = orig_skb;
701 }
702
703 return skb;
704 }
705
706 /*
707 * CFG802.11 network device handler for data transmission.
708 */
709 static int
710 mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
711 {
712 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
713 struct sk_buff *new_skb;
714 struct mwifiex_txinfo *tx_info;
715 bool multicast;
716
717 dev_dbg(priv->adapter->dev, "data: %lu BSS(%d-%d): Data <= kernel\n",
718 jiffies, priv->bss_type, priv->bss_num);
719
720 if (priv->adapter->surprise_removed) {
721 kfree_skb(skb);
722 priv->stats.tx_dropped++;
723 return 0;
724 }
725 if (!skb->len || (skb->len > ETH_FRAME_LEN)) {
726 dev_err(priv->adapter->dev, "Tx: bad skb len %d\n", skb->len);
727 kfree_skb(skb);
728 priv->stats.tx_dropped++;
729 return 0;
730 }
731 if (skb_headroom(skb) < MWIFIEX_MIN_DATA_HEADER_LEN) {
732 dev_dbg(priv->adapter->dev,
733 "data: Tx: insufficient skb headroom %d\n",
734 skb_headroom(skb));
735 /* Insufficient skb headroom - allocate a new skb */
736 new_skb =
737 skb_realloc_headroom(skb, MWIFIEX_MIN_DATA_HEADER_LEN);
738 if (unlikely(!new_skb)) {
739 dev_err(priv->adapter->dev, "Tx: cannot alloca new_skb\n");
740 kfree_skb(skb);
741 priv->stats.tx_dropped++;
742 return 0;
743 }
744 kfree_skb(skb);
745 skb = new_skb;
746 dev_dbg(priv->adapter->dev, "info: new skb headroomd %d\n",
747 skb_headroom(skb));
748 }
749
750 tx_info = MWIFIEX_SKB_TXCB(skb);
751 memset(tx_info, 0, sizeof(*tx_info));
752 tx_info->bss_num = priv->bss_num;
753 tx_info->bss_type = priv->bss_type;
754 tx_info->pkt_len = skb->len;
755
756 multicast = is_multicast_ether_addr(skb->data);
757
758 if (unlikely(!multicast && skb->sk &&
759 skb_shinfo(skb)->tx_flags & SKBTX_WIFI_STATUS &&
760 priv->adapter->fw_api_ver == MWIFIEX_FW_V15))
761 skb = mwifiex_clone_skb_for_tx_status(priv,
762 skb,
763 MWIFIEX_BUF_FLAG_EAPOL_TX_STATUS, NULL);
764
765 /* Record the current time the packet was queued; used to
766 * determine the amount of time the packet was queued in
767 * the driver before it was sent to the firmware.
768 * The delay is then sent along with the packet to the
769 * firmware for aggregate delay calculation for stats and
770 * MSDU lifetime expiry.
771 */
772 __net_timestamp(skb);
773
774 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) &&
775 priv->bss_type == MWIFIEX_BSS_TYPE_STA &&
776 !ether_addr_equal_unaligned(priv->cfg_bssid, skb->data)) {
777 if (priv->adapter->auto_tdls && priv->check_tdls_tx)
778 mwifiex_tdls_check_tx(priv, skb);
779 }
780
781 mwifiex_queue_tx_pkt(priv, skb);
782
783 return 0;
784 }
785
786 /*
787 * CFG802.11 network device handler for setting MAC address.
788 */
789 static int
790 mwifiex_set_mac_address(struct net_device *dev, void *addr)
791 {
792 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
793 struct sockaddr *hw_addr = addr;
794 int ret;
795
796 memcpy(priv->curr_addr, hw_addr->sa_data, ETH_ALEN);
797
798 /* Send request to firmware */
799 ret = mwifiex_send_cmd(priv, HostCmd_CMD_802_11_MAC_ADDRESS,
800 HostCmd_ACT_GEN_SET, 0, NULL, true);
801
802 if (!ret)
803 memcpy(priv->netdev->dev_addr, priv->curr_addr, ETH_ALEN);
804 else
805 dev_err(priv->adapter->dev,
806 "set mac address failed: ret=%d\n", ret);
807
808 memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);
809
810 return ret;
811 }
812
813 /*
814 * CFG802.11 network device handler for setting multicast list.
815 */
816 static void mwifiex_set_multicast_list(struct net_device *dev)
817 {
818 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
819 struct mwifiex_multicast_list mcast_list;
820
821 if (dev->flags & IFF_PROMISC) {
822 mcast_list.mode = MWIFIEX_PROMISC_MODE;
823 } else if (dev->flags & IFF_ALLMULTI ||
824 netdev_mc_count(dev) > MWIFIEX_MAX_MULTICAST_LIST_SIZE) {
825 mcast_list.mode = MWIFIEX_ALL_MULTI_MODE;
826 } else {
827 mcast_list.mode = MWIFIEX_MULTICAST_MODE;
828 mcast_list.num_multicast_addr =
829 mwifiex_copy_mcast_addr(&mcast_list, dev);
830 }
831 mwifiex_request_set_multicast_list(priv, &mcast_list);
832 }
833
834 /*
835 * CFG802.11 network device handler for transmission timeout.
836 */
837 static void
838 mwifiex_tx_timeout(struct net_device *dev)
839 {
840 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
841
842 priv->num_tx_timeout++;
843 priv->tx_timeout_cnt++;
844 dev_err(priv->adapter->dev,
845 "%lu : Tx timeout(#%d), bss_type-num = %d-%d\n",
846 jiffies, priv->tx_timeout_cnt, priv->bss_type, priv->bss_num);
847 mwifiex_set_trans_start(dev);
848
849 if (priv->tx_timeout_cnt > TX_TIMEOUT_THRESHOLD &&
850 priv->adapter->if_ops.card_reset) {
851 dev_err(priv->adapter->dev,
852 "tx_timeout_cnt exceeds threshold. Triggering card reset!\n");
853 priv->adapter->if_ops.card_reset(priv->adapter);
854 }
855 }
856
857 void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter)
858 {
859 void *p;
860 char drv_version[64];
861 struct usb_card_rec *cardp;
862 struct sdio_mmc_card *sdio_card;
863 struct mwifiex_private *priv;
864 int i, idx;
865 struct netdev_queue *txq;
866 struct mwifiex_debug_info *debug_info;
867
868 if (adapter->drv_info_dump) {
869 vfree(adapter->drv_info_dump);
870 adapter->drv_info_size = 0;
871 }
872
873 dev_info(adapter->dev, "=== DRIVER INFO DUMP START===\n");
874
875 adapter->drv_info_dump = vzalloc(MWIFIEX_DRV_INFO_SIZE_MAX);
876
877 if (!adapter->drv_info_dump)
878 return;
879
880 p = (char *)(adapter->drv_info_dump);
881 p += sprintf(p, "driver_name = " "\"mwifiex\"\n");
882
883 mwifiex_drv_get_driver_version(adapter, drv_version,
884 sizeof(drv_version) - 1);
885 p += sprintf(p, "driver_version = %s\n", drv_version);
886
887 if (adapter->iface_type == MWIFIEX_USB) {
888 cardp = (struct usb_card_rec *)adapter->card;
889 p += sprintf(p, "tx_cmd_urb_pending = %d\n",
890 atomic_read(&cardp->tx_cmd_urb_pending));
891 p += sprintf(p, "tx_data_urb_pending = %d\n",
892 atomic_read(&cardp->tx_data_urb_pending));
893 p += sprintf(p, "rx_cmd_urb_pending = %d\n",
894 atomic_read(&cardp->rx_cmd_urb_pending));
895 p += sprintf(p, "rx_data_urb_pending = %d\n",
896 atomic_read(&cardp->rx_data_urb_pending));
897 }
898
899 p += sprintf(p, "tx_pending = %d\n",
900 atomic_read(&adapter->tx_pending));
901 p += sprintf(p, "rx_pending = %d\n",
902 atomic_read(&adapter->rx_pending));
903
904 if (adapter->iface_type == MWIFIEX_SDIO) {
905 sdio_card = (struct sdio_mmc_card *)adapter->card;
906 p += sprintf(p, "\nmp_rd_bitmap=0x%x curr_rd_port=0x%x\n",
907 sdio_card->mp_rd_bitmap, sdio_card->curr_rd_port);
908 p += sprintf(p, "mp_wr_bitmap=0x%x curr_wr_port=0x%x\n",
909 sdio_card->mp_wr_bitmap, sdio_card->curr_wr_port);
910 }
911
912 for (i = 0; i < adapter->priv_num; i++) {
913 if (!adapter->priv[i] || !adapter->priv[i]->netdev)
914 continue;
915 priv = adapter->priv[i];
916 p += sprintf(p, "\n[interface : \"%s\"]\n",
917 priv->netdev->name);
918 p += sprintf(p, "wmm_tx_pending[0] = %d\n",
919 atomic_read(&priv->wmm_tx_pending[0]));
920 p += sprintf(p, "wmm_tx_pending[1] = %d\n",
921 atomic_read(&priv->wmm_tx_pending[1]));
922 p += sprintf(p, "wmm_tx_pending[2] = %d\n",
923 atomic_read(&priv->wmm_tx_pending[2]));
924 p += sprintf(p, "wmm_tx_pending[3] = %d\n",
925 atomic_read(&priv->wmm_tx_pending[3]));
926 p += sprintf(p, "media_state=\"%s\"\n", !priv->media_connected ?
927 "Disconnected" : "Connected");
928 p += sprintf(p, "carrier %s\n", (netif_carrier_ok(priv->netdev)
929 ? "on" : "off"));
930 for (idx = 0; idx < priv->netdev->num_tx_queues; idx++) {
931 txq = netdev_get_tx_queue(priv->netdev, idx);
932 p += sprintf(p, "tx queue %d:%s ", idx,
933 netif_tx_queue_stopped(txq) ?
934 "stopped" : "started");
935 }
936 p += sprintf(p, "\n%s: num_tx_timeout = %d\n",
937 priv->netdev->name, priv->num_tx_timeout);
938 }
939
940 if (adapter->iface_type == MWIFIEX_SDIO) {
941 p += sprintf(p, "\n=== SDIO register DUMP===\n");
942 if (adapter->if_ops.reg_dump)
943 p += adapter->if_ops.reg_dump(adapter, p);
944 }
945
946 p += sprintf(p, "\n=== MORE DEBUG INFORMATION\n");
947 debug_info = kzalloc(sizeof(*debug_info), GFP_KERNEL);
948 if (debug_info) {
949 for (i = 0; i < adapter->priv_num; i++) {
950 if (!adapter->priv[i] || !adapter->priv[i]->netdev)
951 continue;
952 priv = adapter->priv[i];
953 mwifiex_get_debug_info(priv, debug_info);
954 p += mwifiex_debug_info_to_buffer(priv, p, debug_info);
955 break;
956 }
957 kfree(debug_info);
958 }
959
960 adapter->drv_info_size = p - adapter->drv_info_dump;
961 dev_info(adapter->dev, "=== DRIVER INFO DUMP END===\n");
962 }
963 EXPORT_SYMBOL_GPL(mwifiex_dump_drv_info);
964
965 /*
966 * CFG802.11 network device handler for statistics retrieval.
967 */
968 static struct net_device_stats *mwifiex_get_stats(struct net_device *dev)
969 {
970 struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
971
972 return &priv->stats;
973 }
974
975 static u16
976 mwifiex_netdev_select_wmm_queue(struct net_device *dev, struct sk_buff *skb,
977 void *accel_priv, select_queue_fallback_t fallback)
978 {
979 skb->priority = cfg80211_classify8021d(skb, NULL);
980 return mwifiex_1d_to_wmm_queue[skb->priority];
981 }
982
983 /* Network device handlers */
984 static const struct net_device_ops mwifiex_netdev_ops = {
985 .ndo_open = mwifiex_open,
986 .ndo_stop = mwifiex_close,
987 .ndo_start_xmit = mwifiex_hard_start_xmit,
988 .ndo_set_mac_address = mwifiex_set_mac_address,
989 .ndo_tx_timeout = mwifiex_tx_timeout,
990 .ndo_get_stats = mwifiex_get_stats,
991 .ndo_set_rx_mode = mwifiex_set_multicast_list,
992 .ndo_select_queue = mwifiex_netdev_select_wmm_queue,
993 };
994
995 /*
996 * This function initializes the private structure parameters.
997 *
998 * The following wait queues are initialized -
999 * - IOCTL wait queue
1000 * - Command wait queue
1001 * - Statistics wait queue
1002 *
1003 * ...and the following default parameters are set -
1004 * - Current key index : Set to 0
1005 * - Rate index : Set to auto
1006 * - Media connected : Set to disconnected
1007 * - Adhoc link sensed : Set to false
1008 * - Nick name : Set to null
1009 * - Number of Tx timeout : Set to 0
1010 * - Device address : Set to current address
1011 * - Rx histogram statistc : Set to 0
1012 *
1013 * In addition, the CFG80211 work queue is also created.
1014 */
1015 void mwifiex_init_priv_params(struct mwifiex_private *priv,
1016 struct net_device *dev)
1017 {
1018 dev->netdev_ops = &mwifiex_netdev_ops;
1019 dev->destructor = free_netdev;
1020 /* Initialize private structure */
1021 priv->current_key_index = 0;
1022 priv->media_connected = false;
1023 memset(priv->mgmt_ie, 0,
1024 sizeof(struct mwifiex_ie) * MAX_MGMT_IE_INDEX);
1025 priv->beacon_idx = MWIFIEX_AUTO_IDX_MASK;
1026 priv->proberesp_idx = MWIFIEX_AUTO_IDX_MASK;
1027 priv->assocresp_idx = MWIFIEX_AUTO_IDX_MASK;
1028 priv->gen_idx = MWIFIEX_AUTO_IDX_MASK;
1029 priv->num_tx_timeout = 0;
1030 ether_addr_copy(priv->curr_addr, priv->adapter->perm_addr);
1031 memcpy(dev->dev_addr, priv->curr_addr, ETH_ALEN);
1032
1033 if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA ||
1034 GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP) {
1035 priv->hist_data = kmalloc(sizeof(*priv->hist_data), GFP_KERNEL);
1036 if (priv->hist_data)
1037 mwifiex_hist_data_reset(priv);
1038 }
1039 }
1040
1041 /*
1042 * This function check if command is pending.
1043 */
1044 int is_command_pending(struct mwifiex_adapter *adapter)
1045 {
1046 unsigned long flags;
1047 int is_cmd_pend_q_empty;
1048
1049 spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
1050 is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q);
1051 spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
1052
1053 return !is_cmd_pend_q_empty;
1054 }
1055
1056 /*
1057 * This is the RX work queue function.
1058 *
1059 * It handles the RX operations.
1060 */
1061 static void mwifiex_rx_work_queue(struct work_struct *work)
1062 {
1063 struct mwifiex_adapter *adapter =
1064 container_of(work, struct mwifiex_adapter, rx_work);
1065
1066 if (adapter->surprise_removed)
1067 return;
1068 mwifiex_process_rx(adapter);
1069 }
1070
1071 /*
1072 * This is the main work queue function.
1073 *
1074 * It handles the main process, which in turn handles the complete
1075 * driver operations.
1076 */
1077 static void mwifiex_main_work_queue(struct work_struct *work)
1078 {
1079 struct mwifiex_adapter *adapter =
1080 container_of(work, struct mwifiex_adapter, main_work);
1081
1082 if (adapter->surprise_removed)
1083 return;
1084 mwifiex_main_process(adapter);
1085 }
1086
1087 /*
1088 * This function adds the card.
1089 *
1090 * This function follows the following major steps to set up the device -
1091 * - Initialize software. This includes probing the card, registering
1092 * the interface operations table, and allocating/initializing the
1093 * adapter structure
1094 * - Set up the netlink socket
1095 * - Create and start the main work queue
1096 * - Register the device
1097 * - Initialize firmware and hardware
1098 * - Add logical interfaces
1099 */
1100 int
1101 mwifiex_add_card(void *card, struct semaphore *sem,
1102 struct mwifiex_if_ops *if_ops, u8 iface_type)
1103 {
1104 struct mwifiex_adapter *adapter;
1105
1106 if (down_interruptible(sem))
1107 goto exit_sem_err;
1108
1109 if (mwifiex_register(card, if_ops, (void **)&adapter)) {
1110 pr_err("%s: software init failed\n", __func__);
1111 goto err_init_sw;
1112 }
1113
1114 adapter->iface_type = iface_type;
1115 adapter->card_sem = sem;
1116
1117 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING;
1118 adapter->surprise_removed = false;
1119 init_waitqueue_head(&adapter->init_wait_q);
1120 adapter->is_suspended = false;
1121 adapter->hs_activated = false;
1122 init_waitqueue_head(&adapter->hs_activate_wait_q);
1123 init_waitqueue_head(&adapter->cmd_wait_q.wait);
1124 adapter->cmd_wait_q.status = 0;
1125 adapter->scan_wait_q_woken = false;
1126
1127 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) {
1128 adapter->rx_work_enabled = true;
1129 pr_notice("rx work enabled, cpus %d\n", num_possible_cpus());
1130 }
1131
1132 adapter->workqueue =
1133 alloc_workqueue("MWIFIEX_WORK_QUEUE",
1134 WQ_HIGHPRI | WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
1135 if (!adapter->workqueue)
1136 goto err_kmalloc;
1137
1138 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue);
1139
1140 if (adapter->rx_work_enabled) {
1141 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE",
1142 WQ_HIGHPRI |
1143 WQ_MEM_RECLAIM |
1144 WQ_UNBOUND, 1);
1145 if (!adapter->rx_workqueue)
1146 goto err_kmalloc;
1147
1148 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue);
1149 }
1150
1151 /* Register the device. Fill up the private data structure with relevant
1152 information from the card. */
1153 if (adapter->if_ops.register_dev(adapter)) {
1154 pr_err("%s: failed to register mwifiex device\n", __func__);
1155 goto err_registerdev;
1156 }
1157
1158 if (mwifiex_init_hw_fw(adapter)) {
1159 pr_err("%s: firmware init failed\n", __func__);
1160 goto err_init_fw;
1161 }
1162
1163 return 0;
1164
1165 err_init_fw:
1166 pr_debug("info: %s: unregister device\n", __func__);
1167 if (adapter->if_ops.unregister_dev)
1168 adapter->if_ops.unregister_dev(adapter);
1169 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) {
1170 pr_debug("info: %s: shutdown mwifiex\n", __func__);
1171 adapter->init_wait_q_woken = false;
1172
1173 if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS)
1174 wait_event_interruptible(adapter->init_wait_q,
1175 adapter->init_wait_q_woken);
1176 }
1177 err_registerdev:
1178 adapter->surprise_removed = true;
1179 mwifiex_terminate_workqueue(adapter);
1180 err_kmalloc:
1181 mwifiex_free_adapter(adapter);
1182
1183 err_init_sw:
1184 up(sem);
1185
1186 exit_sem_err:
1187 return -1;
1188 }
1189 EXPORT_SYMBOL_GPL(mwifiex_add_card);
1190
1191 /*
1192 * This function removes the card.
1193 *
1194 * This function follows the following major steps to remove the device -
1195 * - Stop data traffic
1196 * - Shutdown firmware
1197 * - Remove the logical interfaces
1198 * - Terminate the work queue
1199 * - Unregister the device
1200 * - Free the adapter structure
1201 */
1202 int mwifiex_remove_card(struct mwifiex_adapter *adapter, struct semaphore *sem)
1203 {
1204 struct mwifiex_private *priv = NULL;
1205 int i;
1206
1207 if (down_interruptible(sem))
1208 goto exit_sem_err;
1209
1210 if (!adapter)
1211 goto exit_remove;
1212
1213 /* We can no longer handle interrupts once we start doing the teardown
1214 * below. */
1215 if (adapter->if_ops.disable_int)
1216 adapter->if_ops.disable_int(adapter);
1217
1218 adapter->surprise_removed = true;
1219
1220 mwifiex_terminate_workqueue(adapter);
1221
1222 /* Stop data */
1223 for (i = 0; i < adapter->priv_num; i++) {
1224 priv = adapter->priv[i];
1225 if (priv && priv->netdev) {
1226 mwifiex_stop_net_dev_queue(priv->netdev, adapter);
1227 if (netif_carrier_ok(priv->netdev))
1228 netif_carrier_off(priv->netdev);
1229 }
1230 }
1231
1232 dev_dbg(adapter->dev, "cmd: calling mwifiex_shutdown_drv...\n");
1233 adapter->init_wait_q_woken = false;
1234
1235 if (mwifiex_shutdown_drv(adapter) == -EINPROGRESS)
1236 wait_event_interruptible(adapter->init_wait_q,
1237 adapter->init_wait_q_woken);
1238 dev_dbg(adapter->dev, "cmd: mwifiex_shutdown_drv done\n");
1239 if (atomic_read(&adapter->rx_pending) ||
1240 atomic_read(&adapter->tx_pending) ||
1241 atomic_read(&adapter->cmd_pending)) {
1242 dev_err(adapter->dev, "rx_pending=%d, tx_pending=%d, "
1243 "cmd_pending=%d\n",
1244 atomic_read(&adapter->rx_pending),
1245 atomic_read(&adapter->tx_pending),
1246 atomic_read(&adapter->cmd_pending));
1247 }
1248
1249 for (i = 0; i < adapter->priv_num; i++) {
1250 priv = adapter->priv[i];
1251
1252 if (!priv)
1253 continue;
1254
1255 rtnl_lock();
1256 if (priv->netdev &&
1257 priv->wdev.iftype != NL80211_IFTYPE_UNSPECIFIED)
1258 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev);
1259 rtnl_unlock();
1260 }
1261
1262 wiphy_unregister(adapter->wiphy);
1263 wiphy_free(adapter->wiphy);
1264
1265 /* Unregister device */
1266 dev_dbg(adapter->dev, "info: unregister device\n");
1267 if (adapter->if_ops.unregister_dev)
1268 adapter->if_ops.unregister_dev(adapter);
1269 /* Free adapter structure */
1270 dev_dbg(adapter->dev, "info: free adapter\n");
1271 mwifiex_free_adapter(adapter);
1272
1273 exit_remove:
1274 up(sem);
1275 exit_sem_err:
1276 return 0;
1277 }
1278 EXPORT_SYMBOL_GPL(mwifiex_remove_card);
1279
1280 /*
1281 * This function initializes the module.
1282 *
1283 * The debug FS is also initialized if configured.
1284 */
1285 static int
1286 mwifiex_init_module(void)
1287 {
1288 #ifdef CONFIG_DEBUG_FS
1289 mwifiex_debugfs_init();
1290 #endif
1291 return 0;
1292 }
1293
1294 /*
1295 * This function cleans up the module.
1296 *
1297 * The debug FS is removed if available.
1298 */
1299 static void
1300 mwifiex_cleanup_module(void)
1301 {
1302 #ifdef CONFIG_DEBUG_FS
1303 mwifiex_debugfs_remove();
1304 #endif
1305 }
1306
1307 module_init(mwifiex_init_module);
1308 module_exit(mwifiex_cleanup_module);
1309
1310 MODULE_AUTHOR("Marvell International Ltd.");
1311 MODULE_DESCRIPTION("Marvell WiFi-Ex Driver version " VERSION);
1312 MODULE_VERSION(VERSION);
1313 MODULE_LICENSE("GPL v2");
This page took 0.057357 seconds and 6 git commands to generate.