Lines Matching refs:adapter
69 struct mwifiex_adapter *adapter; in mwifiex_register() local
72 adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL); in mwifiex_register()
73 if (!adapter) in mwifiex_register()
76 *padapter = adapter; in mwifiex_register()
77 adapter->dev = dev; in mwifiex_register()
78 adapter->card = card; in mwifiex_register()
81 memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops)); in mwifiex_register()
82 adapter->debug_mask = debug_mask; in mwifiex_register()
85 if (adapter->if_ops.init_if) in mwifiex_register()
86 if (adapter->if_ops.init_if(adapter)) in mwifiex_register()
89 adapter->priv_num = 0; in mwifiex_register()
93 adapter->priv[i] = in mwifiex_register()
95 if (!adapter->priv[i]) in mwifiex_register()
98 adapter->priv[i]->adapter = adapter; in mwifiex_register()
99 adapter->priv_num++; in mwifiex_register()
101 mwifiex_init_lock_list(adapter); in mwifiex_register()
103 timer_setup(&adapter->cmd_timer, mwifiex_cmd_timeout_func, 0); in mwifiex_register()
108 mwifiex_dbg(adapter, ERROR, in mwifiex_register()
111 for (i = 0; i < adapter->priv_num; i++) in mwifiex_register()
112 kfree(adapter->priv[i]); in mwifiex_register()
114 kfree(adapter); in mwifiex_register()
129 static int mwifiex_unregister(struct mwifiex_adapter *adapter) in mwifiex_unregister() argument
133 if (adapter->if_ops.cleanup_if) in mwifiex_unregister()
134 adapter->if_ops.cleanup_if(adapter); in mwifiex_unregister()
136 del_timer_sync(&adapter->cmd_timer); in mwifiex_unregister()
139 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_unregister()
140 if (adapter->priv[i]) { in mwifiex_unregister()
141 mwifiex_free_curr_bcn(adapter->priv[i]); in mwifiex_unregister()
142 kfree(adapter->priv[i]); in mwifiex_unregister()
146 if (adapter->nd_info) { in mwifiex_unregister()
147 for (i = 0 ; i < adapter->nd_info->n_matches ; i++) in mwifiex_unregister()
148 kfree(adapter->nd_info->matches[i]); in mwifiex_unregister()
149 kfree(adapter->nd_info); in mwifiex_unregister()
150 adapter->nd_info = NULL; in mwifiex_unregister()
153 kfree(adapter->regd); in mwifiex_unregister()
155 kfree(adapter); in mwifiex_unregister()
159 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) in mwifiex_queue_main_work() argument
163 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
164 if (adapter->mwifiex_processing) { in mwifiex_queue_main_work()
165 adapter->more_task_flag = true; in mwifiex_queue_main_work()
166 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
168 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
169 queue_work(adapter->workqueue, &adapter->main_work); in mwifiex_queue_main_work()
174 static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) in mwifiex_queue_rx_work() argument
176 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
177 if (adapter->rx_processing) { in mwifiex_queue_rx_work()
178 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
180 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
181 queue_work(adapter->rx_workqueue, &adapter->rx_work); in mwifiex_queue_rx_work()
185 static int mwifiex_process_rx(struct mwifiex_adapter *adapter) in mwifiex_process_rx() argument
190 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
191 if (adapter->rx_processing || adapter->rx_locked) { in mwifiex_process_rx()
192 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
195 adapter->rx_processing = true; in mwifiex_process_rx()
196 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
200 while ((skb = skb_dequeue(&adapter->rx_data_q))) { in mwifiex_process_rx()
201 atomic_dec(&adapter->rx_pending); in mwifiex_process_rx()
202 if ((adapter->delay_main_work || in mwifiex_process_rx()
203 adapter->iface_type == MWIFIEX_USB) && in mwifiex_process_rx()
204 (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) { in mwifiex_process_rx()
205 if (adapter->if_ops.submit_rem_rx_urbs) in mwifiex_process_rx()
206 adapter->if_ops.submit_rem_rx_urbs(adapter); in mwifiex_process_rx()
207 adapter->delay_main_work = false; in mwifiex_process_rx()
208 mwifiex_queue_main_work(adapter); in mwifiex_process_rx()
212 if (adapter->if_ops.deaggr_pkt) in mwifiex_process_rx()
213 adapter->if_ops.deaggr_pkt(adapter, skb); in mwifiex_process_rx()
216 mwifiex_handle_rx_packet(adapter, skb); in mwifiex_process_rx()
219 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
220 adapter->rx_processing = false; in mwifiex_process_rx()
221 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
242 int mwifiex_main_process(struct mwifiex_adapter *adapter) in mwifiex_main_process() argument
247 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
250 if (adapter->mwifiex_processing || adapter->main_locked) { in mwifiex_main_process()
251 adapter->more_task_flag = true; in mwifiex_main_process()
252 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
255 adapter->mwifiex_processing = true; in mwifiex_main_process()
256 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
260 if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY) in mwifiex_main_process()
270 if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING && in mwifiex_main_process()
271 adapter->iface_type != MWIFIEX_USB) { in mwifiex_main_process()
272 adapter->delay_main_work = true; in mwifiex_main_process()
273 mwifiex_queue_rx_work(adapter); in mwifiex_main_process()
278 if (adapter->int_status) { in mwifiex_main_process()
279 if (adapter->hs_activated) in mwifiex_main_process()
280 mwifiex_process_hs_config(adapter); in mwifiex_main_process()
281 if (adapter->if_ops.process_int_status) in mwifiex_main_process()
282 adapter->if_ops.process_int_status(adapter); in mwifiex_main_process()
285 if (adapter->rx_work_enabled && adapter->data_received) in mwifiex_main_process()
286 mwifiex_queue_rx_work(adapter); in mwifiex_main_process()
289 if ((adapter->ps_state == PS_STATE_SLEEP) && in mwifiex_main_process()
290 (adapter->pm_wakeup_card_req && in mwifiex_main_process()
291 !adapter->pm_wakeup_fw_try) && in mwifiex_main_process()
292 (is_command_pending(adapter) || in mwifiex_main_process()
293 !skb_queue_empty(&adapter->tx_data_q) || in mwifiex_main_process()
294 !mwifiex_bypass_txlist_empty(adapter) || in mwifiex_main_process()
295 !mwifiex_wmm_lists_empty(adapter))) { in mwifiex_main_process()
296 adapter->pm_wakeup_fw_try = true; in mwifiex_main_process()
297 mod_timer(&adapter->wakeup_timer, jiffies + (HZ*3)); in mwifiex_main_process()
298 adapter->if_ops.wakeup(adapter); in mwifiex_main_process()
302 if (IS_CARD_RX_RCVD(adapter)) { in mwifiex_main_process()
303 adapter->data_received = false; in mwifiex_main_process()
304 adapter->pm_wakeup_fw_try = false; in mwifiex_main_process()
305 del_timer(&adapter->wakeup_timer); in mwifiex_main_process()
306 if (adapter->ps_state == PS_STATE_SLEEP) in mwifiex_main_process()
307 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_main_process()
310 if (adapter->pm_wakeup_fw_try) in mwifiex_main_process()
312 if (adapter->ps_state == PS_STATE_PRE_SLEEP) in mwifiex_main_process()
313 mwifiex_check_ps_cond(adapter); in mwifiex_main_process()
315 if (adapter->ps_state != PS_STATE_AWAKE) in mwifiex_main_process()
317 if (adapter->tx_lock_flag) { in mwifiex_main_process()
318 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_main_process()
319 if (!adapter->usb_mc_setup) in mwifiex_main_process()
325 if ((!adapter->scan_chan_gap_enabled && in mwifiex_main_process()
326 adapter->scan_processing) || adapter->data_sent || in mwifiex_main_process()
328 (mwifiex_get_priv(adapter, in mwifiex_main_process()
330 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
331 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
332 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
333 if (adapter->cmd_sent || adapter->curr_cmd || in mwifiex_main_process()
335 (mwifiex_get_priv(adapter, in mwifiex_main_process()
337 (!is_command_pending(adapter))) in mwifiex_main_process()
343 if (adapter->event_received) { in mwifiex_main_process()
344 adapter->event_received = false; in mwifiex_main_process()
345 mwifiex_process_event(adapter); in mwifiex_main_process()
349 if (adapter->cmd_resp_received) { in mwifiex_main_process()
350 adapter->cmd_resp_received = false; in mwifiex_main_process()
351 mwifiex_process_cmdresp(adapter); in mwifiex_main_process()
354 if (adapter->hw_status == MWIFIEX_HW_STATUS_INIT_DONE) { in mwifiex_main_process()
355 adapter->hw_status = MWIFIEX_HW_STATUS_READY; in mwifiex_main_process()
356 mwifiex_init_fw_complete(adapter); in mwifiex_main_process()
362 if (adapter->ps_state == PS_STATE_PRE_SLEEP) in mwifiex_main_process()
363 mwifiex_check_ps_cond(adapter); in mwifiex_main_process()
368 if ((adapter->ps_state == PS_STATE_SLEEP) || in mwifiex_main_process()
369 (adapter->ps_state == PS_STATE_PRE_SLEEP) || in mwifiex_main_process()
370 (adapter->ps_state == PS_STATE_SLEEP_CFM)) { in mwifiex_main_process()
374 if (adapter->tx_lock_flag) { in mwifiex_main_process()
375 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_main_process()
376 if (!adapter->usb_mc_setup) in mwifiex_main_process()
382 if (!adapter->cmd_sent && !adapter->curr_cmd && in mwifiex_main_process()
384 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
385 if (mwifiex_exec_next_cmd(adapter) == -1) { in mwifiex_main_process()
394 if (adapter->iface_type == MWIFIEX_USB && in mwifiex_main_process()
395 adapter->usb_mc_setup) in mwifiex_main_process()
398 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
399 !adapter->scan_processing) && in mwifiex_main_process()
400 !adapter->data_sent && in mwifiex_main_process()
401 !skb_queue_empty(&adapter->tx_data_q)) { in mwifiex_main_process()
402 mwifiex_process_tx_queue(adapter); in mwifiex_main_process()
403 if (adapter->hs_activated) { in mwifiex_main_process()
405 &adapter->work_flags); in mwifiex_main_process()
408 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
413 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
414 !adapter->scan_processing) && in mwifiex_main_process()
415 !adapter->data_sent && in mwifiex_main_process()
416 !mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
418 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
419 mwifiex_process_bypass_tx(adapter); in mwifiex_main_process()
420 if (adapter->hs_activated) { in mwifiex_main_process()
422 &adapter->work_flags); in mwifiex_main_process()
425 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
430 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
431 !adapter->scan_processing) && in mwifiex_main_process()
432 !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
434 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
435 mwifiex_wmm_process_tx(adapter); in mwifiex_main_process()
436 if (adapter->hs_activated) { in mwifiex_main_process()
438 &adapter->work_flags); in mwifiex_main_process()
441 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
446 if (adapter->delay_null_pkt && !adapter->cmd_sent && in mwifiex_main_process()
447 !adapter->curr_cmd && !is_command_pending(adapter) && in mwifiex_main_process()
448 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
449 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
450 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
452 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_main_process()
455 adapter->delay_null_pkt = false; in mwifiex_main_process()
456 adapter->ps_state = PS_STATE_SLEEP; in mwifiex_main_process()
462 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
463 if (adapter->more_task_flag) { in mwifiex_main_process()
464 adapter->more_task_flag = false; in mwifiex_main_process()
465 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
468 adapter->mwifiex_processing = false; in mwifiex_main_process()
469 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
481 static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) in mwifiex_free_adapter() argument
483 if (!adapter) { in mwifiex_free_adapter()
488 mwifiex_unregister(adapter); in mwifiex_free_adapter()
496 static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) in mwifiex_terminate_workqueue() argument
498 if (adapter->workqueue) { in mwifiex_terminate_workqueue()
499 flush_workqueue(adapter->workqueue); in mwifiex_terminate_workqueue()
500 destroy_workqueue(adapter->workqueue); in mwifiex_terminate_workqueue()
501 adapter->workqueue = NULL; in mwifiex_terminate_workqueue()
504 if (adapter->rx_workqueue) { in mwifiex_terminate_workqueue()
505 flush_workqueue(adapter->rx_workqueue); in mwifiex_terminate_workqueue()
506 destroy_workqueue(adapter->rx_workqueue); in mwifiex_terminate_workqueue()
507 adapter->rx_workqueue = NULL; in mwifiex_terminate_workqueue()
522 struct mwifiex_adapter *adapter = context; in _mwifiex_fw_dpc() local
526 struct completion *fw_done = adapter->fw_done; in _mwifiex_fw_dpc()
529 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
530 "Failed to get firmware %s\n", adapter->fw_name); in _mwifiex_fw_dpc()
535 adapter->firmware = firmware; in _mwifiex_fw_dpc()
536 fw.fw_buf = (u8 *) adapter->firmware->data; in _mwifiex_fw_dpc()
537 fw.fw_len = adapter->firmware->size; in _mwifiex_fw_dpc()
539 if (adapter->if_ops.dnld_fw) { in _mwifiex_fw_dpc()
540 ret = adapter->if_ops.dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
542 ret = mwifiex_dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
548 mwifiex_dbg(adapter, MSG, "WLAN FW is active\n"); in _mwifiex_fw_dpc()
551 if ((request_firmware(&adapter->cal_data, cal_data_cfg, in _mwifiex_fw_dpc()
552 adapter->dev)) < 0) in _mwifiex_fw_dpc()
553 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
558 if (adapter->if_ops.enable_int) { in _mwifiex_fw_dpc()
559 if (adapter->if_ops.enable_int(adapter)) in _mwifiex_fw_dpc()
563 adapter->init_wait_q_woken = false; in _mwifiex_fw_dpc()
564 ret = mwifiex_init_fw(adapter); in _mwifiex_fw_dpc()
568 adapter->hw_status = MWIFIEX_HW_STATUS_READY; in _mwifiex_fw_dpc()
572 if (!adapter->mfg_mode) { in _mwifiex_fw_dpc()
573 wait_event_interruptible(adapter->init_wait_q, in _mwifiex_fw_dpc()
574 adapter->init_wait_q_woken); in _mwifiex_fw_dpc()
575 if (adapter->hw_status != MWIFIEX_HW_STATUS_READY) in _mwifiex_fw_dpc()
579 if (!adapter->wiphy) { in _mwifiex_fw_dpc()
580 if (mwifiex_register_cfg80211(adapter)) { in _mwifiex_fw_dpc()
581 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
587 if (mwifiex_init_channel_scan_gap(adapter)) { in _mwifiex_fw_dpc()
588 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
600 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
603 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
610 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
613 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
621 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
624 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
632 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); in _mwifiex_fw_dpc()
633 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); in _mwifiex_fw_dpc()
634 adapter->is_up = true; in _mwifiex_fw_dpc()
638 vfree(adapter->chan_stats); in _mwifiex_fw_dpc()
640 wiphy_unregister(adapter->wiphy); in _mwifiex_fw_dpc()
641 wiphy_free(adapter->wiphy); in _mwifiex_fw_dpc()
643 if (adapter->if_ops.disable_int) in _mwifiex_fw_dpc()
644 adapter->if_ops.disable_int(adapter); in _mwifiex_fw_dpc()
646 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
648 if (adapter->if_ops.unregister_dev) in _mwifiex_fw_dpc()
649 adapter->if_ops.unregister_dev(adapter); in _mwifiex_fw_dpc()
651 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in _mwifiex_fw_dpc()
652 mwifiex_terminate_workqueue(adapter); in _mwifiex_fw_dpc()
654 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in _mwifiex_fw_dpc()
656 mwifiex_shutdown_drv(adapter); in _mwifiex_fw_dpc()
657 mwifiex_free_cmd_buffers(adapter); in _mwifiex_fw_dpc()
662 if (adapter->cal_data) { in _mwifiex_fw_dpc()
663 release_firmware(adapter->cal_data); in _mwifiex_fw_dpc()
664 adapter->cal_data = NULL; in _mwifiex_fw_dpc()
666 if (adapter->firmware) { in _mwifiex_fw_dpc()
667 release_firmware(adapter->firmware); in _mwifiex_fw_dpc()
668 adapter->firmware = NULL; in _mwifiex_fw_dpc()
671 if (adapter->irq_wakeup >= 0) in _mwifiex_fw_dpc()
672 device_init_wakeup(adapter->dev, false); in _mwifiex_fw_dpc()
673 mwifiex_free_adapter(adapter); in _mwifiex_fw_dpc()
690 static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, in mwifiex_init_hw_fw() argument
699 if (strlcpy(adapter->fw_name, MFG_FIRMWARE, in mwifiex_init_hw_fw()
700 sizeof(adapter->fw_name)) >= in mwifiex_init_hw_fw()
701 sizeof(adapter->fw_name)) { in mwifiex_init_hw_fw()
708 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, in mwifiex_init_hw_fw()
709 adapter->dev, GFP_KERNEL, adapter, in mwifiex_init_hw_fw()
712 ret = request_firmware(&adapter->firmware, in mwifiex_init_hw_fw()
713 adapter->fw_name, in mwifiex_init_hw_fw()
714 adapter->dev); in mwifiex_init_hw_fw()
718 mwifiex_dbg(adapter, ERROR, "request_firmware%s error %d\n", in mwifiex_init_hw_fw()
749 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
757 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
775 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_bypass_tx_queue()
777 mwifiex_dbg(priv->adapter, DATA, in mwifiex_bypass_tx_queue()
798 mwifiex_dbg(priv->adapter, DATA, in mwifiex_queue_tx_pkt()
804 atomic_inc(&priv->adapter->tx_pending); in mwifiex_queue_tx_pkt()
805 atomic_inc(&priv->adapter->bypass_tx_pending); in mwifiex_queue_tx_pkt()
808 atomic_inc(&priv->adapter->tx_pending); in mwifiex_queue_tx_pkt()
812 mwifiex_queue_main_work(priv->adapter); in mwifiex_queue_tx_pkt()
869 mwifiex_dbg(priv->adapter, DATA, in mwifiex_hard_start_xmit()
873 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &priv->adapter->work_flags)) { in mwifiex_hard_start_xmit()
879 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_hard_start_xmit()
886 mwifiex_dbg(priv->adapter, DATA, in mwifiex_hard_start_xmit()
893 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_hard_start_xmit()
901 mwifiex_dbg(priv->adapter, INFO, in mwifiex_hard_start_xmit()
916 priv->adapter->fw_api_ver == MWIFIEX_FW_V15)) in mwifiex_hard_start_xmit()
930 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_hard_start_xmit()
933 if (priv->adapter->auto_tdls && priv->check_tdls_tx) in mwifiex_hard_start_xmit()
963 } else if (priv->adapter->priv[0] != priv) { in mwifiex_set_mac_address()
978 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_set_mac_address()
1029 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1036 priv->adapter->if_ops.card_reset) { in mwifiex_tx_timeout()
1037 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1040 priv->adapter->if_ops.card_reset(priv->adapter); in mwifiex_tx_timeout()
1044 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter) in mwifiex_multi_chan_resync() argument
1046 struct usb_card_rec *card = adapter->card; in mwifiex_multi_chan_resync()
1054 mwifiex_dbg(adapter, WARN, "pending data urb in sys\n"); in mwifiex_multi_chan_resync()
1061 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_multi_chan_resync()
1065 mwifiex_dbg(adapter, ERROR, in mwifiex_multi_chan_resync()
1070 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter) in mwifiex_upload_device_dump() argument
1075 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1077 dev_coredumpv(adapter->dev, adapter->devdump_data, adapter->devdump_len, in mwifiex_upload_device_dump()
1079 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1086 adapter->devdump_data = NULL; in mwifiex_upload_device_dump()
1087 adapter->devdump_len = 0; in mwifiex_upload_device_dump()
1091 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter) in mwifiex_drv_info_dump() argument
1102 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n"); in mwifiex_drv_info_dump()
1104 p = adapter->devdump_data; in mwifiex_drv_info_dump()
1109 mwifiex_drv_get_driver_version(adapter, drv_version, in mwifiex_drv_info_dump()
1113 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_drv_info_dump()
1114 cardp = (struct usb_card_rec *)adapter->card; in mwifiex_drv_info_dump()
1128 atomic_read(&adapter->tx_pending)); in mwifiex_drv_info_dump()
1130 atomic_read(&adapter->rx_pending)); in mwifiex_drv_info_dump()
1132 if (adapter->iface_type == MWIFIEX_SDIO) { in mwifiex_drv_info_dump()
1133 sdio_card = (struct sdio_mmc_card *)adapter->card; in mwifiex_drv_info_dump()
1140 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1141 if (!adapter->priv[i] || !adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1143 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1168 if (adapter->iface_type == MWIFIEX_SDIO || in mwifiex_drv_info_dump()
1169 adapter->iface_type == MWIFIEX_PCIE) { in mwifiex_drv_info_dump()
1171 adapter->iface_type == MWIFIEX_SDIO ? in mwifiex_drv_info_dump()
1173 if (adapter->if_ops.reg_dump) in mwifiex_drv_info_dump()
1174 p += adapter->if_ops.reg_dump(adapter, p); in mwifiex_drv_info_dump()
1179 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1180 if (!adapter->priv[i] || !adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1182 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1192 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n"); in mwifiex_drv_info_dump()
1193 adapter->devdump_len = p - (char *)adapter->devdump_data; in mwifiex_drv_info_dump()
1197 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter) in mwifiex_prepare_fw_dump_info() argument
1203 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1205 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1216 if (dump_len + 1 + adapter->devdump_len > MWIFIEX_FW_DUMP_SIZE) { in mwifiex_prepare_fw_dump_info()
1218 fw_dump_ptr = vzalloc(dump_len + 1 + adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1219 mwifiex_dbg(adapter, MSG, "Realloc device dump data.\n"); in mwifiex_prepare_fw_dump_info()
1221 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1222 mwifiex_dbg(adapter, ERROR, in mwifiex_prepare_fw_dump_info()
1227 memmove(fw_dump_ptr, adapter->devdump_data, in mwifiex_prepare_fw_dump_info()
1228 adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1229 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1230 adapter->devdump_data = fw_dump_ptr; in mwifiex_prepare_fw_dump_info()
1233 fw_dump_ptr = (char *)adapter->devdump_data + adapter->devdump_len; in mwifiex_prepare_fw_dump_info()
1235 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1237 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1257 adapter->devdump_len = fw_dump_ptr - (char *)adapter->devdump_data; in mwifiex_prepare_fw_dump_info()
1259 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1261 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1339 ether_addr_copy(priv->curr_addr, priv->adapter->perm_addr); in mwifiex_init_priv_params()
1352 int is_command_pending(struct mwifiex_adapter *adapter) in is_command_pending() argument
1356 spin_lock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1357 is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q); in is_command_pending()
1358 spin_unlock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1370 struct mwifiex_adapter *adapter = in mwifiex_rx_work_queue() local
1373 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_rx_work_queue()
1375 mwifiex_process_rx(adapter); in mwifiex_rx_work_queue()
1386 struct mwifiex_adapter *adapter = in mwifiex_main_work_queue() local
1389 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_main_work_queue()
1391 mwifiex_main_process(adapter); in mwifiex_main_work_queue()
1395 static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) in mwifiex_uninit_sw() argument
1403 if (adapter->if_ops.disable_int) in mwifiex_uninit_sw()
1404 adapter->if_ops.disable_int(adapter); in mwifiex_uninit_sw()
1406 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_uninit_sw()
1407 mwifiex_terminate_workqueue(adapter); in mwifiex_uninit_sw()
1408 adapter->int_status = 0; in mwifiex_uninit_sw()
1411 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1412 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1414 mwifiex_stop_net_dev_queue(priv->netdev, adapter); in mwifiex_uninit_sw()
1421 mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n"); in mwifiex_uninit_sw()
1422 mwifiex_shutdown_drv(adapter); in mwifiex_uninit_sw()
1423 mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n"); in mwifiex_uninit_sw()
1425 if (atomic_read(&adapter->rx_pending) || in mwifiex_uninit_sw()
1426 atomic_read(&adapter->tx_pending) || in mwifiex_uninit_sw()
1427 atomic_read(&adapter->cmd_pending)) { in mwifiex_uninit_sw()
1428 mwifiex_dbg(adapter, ERROR, in mwifiex_uninit_sw()
1431 atomic_read(&adapter->rx_pending), in mwifiex_uninit_sw()
1432 atomic_read(&adapter->tx_pending), in mwifiex_uninit_sw()
1433 atomic_read(&adapter->cmd_pending)); in mwifiex_uninit_sw()
1436 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1437 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1443 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); in mwifiex_uninit_sw()
1447 wiphy_unregister(adapter->wiphy); in mwifiex_uninit_sw()
1448 wiphy_free(adapter->wiphy); in mwifiex_uninit_sw()
1449 adapter->wiphy = NULL; in mwifiex_uninit_sw()
1451 vfree(adapter->chan_stats); in mwifiex_uninit_sw()
1452 mwifiex_free_cmd_buffers(adapter); in mwifiex_uninit_sw()
1458 int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) in mwifiex_shutdown_sw() argument
1462 if (!adapter) in mwifiex_shutdown_sw()
1465 wait_for_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1467 reinit_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1469 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_shutdown_sw()
1472 mwifiex_uninit_sw(adapter); in mwifiex_shutdown_sw()
1473 adapter->is_up = false; in mwifiex_shutdown_sw()
1475 if (adapter->if_ops.down_dev) in mwifiex_shutdown_sw()
1476 adapter->if_ops.down_dev(adapter); in mwifiex_shutdown_sw()
1486 mwifiex_reinit_sw(struct mwifiex_adapter *adapter) in mwifiex_reinit_sw() argument
1490 mwifiex_init_lock_list(adapter); in mwifiex_reinit_sw()
1491 if (adapter->if_ops.up_dev) in mwifiex_reinit_sw()
1492 adapter->if_ops.up_dev(adapter); in mwifiex_reinit_sw()
1494 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_reinit_sw()
1495 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1496 init_waitqueue_head(&adapter->init_wait_q); in mwifiex_reinit_sw()
1497 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_reinit_sw()
1498 adapter->hs_activated = false; in mwifiex_reinit_sw()
1499 clear_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags); in mwifiex_reinit_sw()
1500 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_reinit_sw()
1501 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_reinit_sw()
1502 adapter->cmd_wait_q.status = 0; in mwifiex_reinit_sw()
1503 adapter->scan_wait_q_woken = false; in mwifiex_reinit_sw()
1505 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_reinit_sw()
1506 adapter->rx_work_enabled = true; in mwifiex_reinit_sw()
1508 adapter->workqueue = in mwifiex_reinit_sw()
1511 if (!adapter->workqueue) in mwifiex_reinit_sw()
1514 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_reinit_sw()
1516 if (adapter->rx_work_enabled) { in mwifiex_reinit_sw()
1517 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_reinit_sw()
1521 if (!adapter->rx_workqueue) in mwifiex_reinit_sw()
1523 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_reinit_sw()
1530 mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__); in mwifiex_reinit_sw()
1532 if (mwifiex_init_hw_fw(adapter, false)) { in mwifiex_reinit_sw()
1533 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1539 ret = _mwifiex_fw_dpc(adapter->firmware, adapter); in mwifiex_reinit_sw()
1544 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); in mwifiex_reinit_sw()
1549 mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__); in mwifiex_reinit_sw()
1550 if (adapter->if_ops.unregister_dev) in mwifiex_reinit_sw()
1551 adapter->if_ops.unregister_dev(adapter); in mwifiex_reinit_sw()
1554 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1555 mwifiex_terminate_workqueue(adapter); in mwifiex_reinit_sw()
1556 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_reinit_sw()
1557 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1559 mwifiex_shutdown_drv(adapter); in mwifiex_reinit_sw()
1560 mwifiex_free_cmd_buffers(adapter); in mwifiex_reinit_sw()
1563 complete_all(adapter->fw_done); in mwifiex_reinit_sw()
1564 mwifiex_dbg(adapter, INFO, "%s, error\n", __func__); in mwifiex_reinit_sw()
1572 struct mwifiex_adapter *adapter = priv; in mwifiex_irq_wakeup_handler() local
1574 dev_dbg(adapter->dev, "%s: wake by wifi", __func__); in mwifiex_irq_wakeup_handler()
1575 adapter->wake_by_wifi = true; in mwifiex_irq_wakeup_handler()
1579 pm_wakeup_event(adapter->dev, 0); in mwifiex_irq_wakeup_handler()
1585 static void mwifiex_probe_of(struct mwifiex_adapter *adapter) in mwifiex_probe_of() argument
1588 struct device *dev = adapter->dev; in mwifiex_probe_of()
1593 adapter->dt_node = dev->of_node; in mwifiex_probe_of()
1594 adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0); in mwifiex_probe_of()
1595 if (!adapter->irq_wakeup) { in mwifiex_probe_of()
1600 ret = devm_request_irq(dev, adapter->irq_wakeup, in mwifiex_probe_of()
1602 "wifi_wake", adapter); in mwifiex_probe_of()
1605 adapter->irq_wakeup, ret); in mwifiex_probe_of()
1609 disable_irq(adapter->irq_wakeup); in mwifiex_probe_of()
1617 adapter->irq_wakeup = -1; in mwifiex_probe_of()
1638 struct mwifiex_adapter *adapter; in mwifiex_add_card() local
1640 if (mwifiex_register(card, dev, if_ops, (void **)&adapter)) { in mwifiex_add_card()
1645 mwifiex_probe_of(adapter); in mwifiex_add_card()
1647 adapter->iface_type = iface_type; in mwifiex_add_card()
1648 adapter->fw_done = fw_done; in mwifiex_add_card()
1650 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_add_card()
1651 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1652 init_waitqueue_head(&adapter->init_wait_q); in mwifiex_add_card()
1653 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_add_card()
1654 adapter->hs_activated = false; in mwifiex_add_card()
1655 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_add_card()
1656 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_add_card()
1657 adapter->cmd_wait_q.status = 0; in mwifiex_add_card()
1658 adapter->scan_wait_q_woken = false; in mwifiex_add_card()
1660 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_add_card()
1661 adapter->rx_work_enabled = true; in mwifiex_add_card()
1663 adapter->workqueue = in mwifiex_add_card()
1666 if (!adapter->workqueue) in mwifiex_add_card()
1669 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_add_card()
1671 if (adapter->rx_work_enabled) { in mwifiex_add_card()
1672 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_add_card()
1676 if (!adapter->rx_workqueue) in mwifiex_add_card()
1679 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_add_card()
1684 if (adapter->if_ops.register_dev(adapter)) { in mwifiex_add_card()
1689 if (mwifiex_init_hw_fw(adapter, true)) { in mwifiex_add_card()
1698 if (adapter->if_ops.unregister_dev) in mwifiex_add_card()
1699 adapter->if_ops.unregister_dev(adapter); in mwifiex_add_card()
1701 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1702 mwifiex_terminate_workqueue(adapter); in mwifiex_add_card()
1703 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_add_card()
1705 mwifiex_shutdown_drv(adapter); in mwifiex_add_card()
1706 mwifiex_free_cmd_buffers(adapter); in mwifiex_add_card()
1709 if (adapter->irq_wakeup >= 0) in mwifiex_add_card()
1710 device_init_wakeup(adapter->dev, false); in mwifiex_add_card()
1711 mwifiex_free_adapter(adapter); in mwifiex_add_card()
1730 int mwifiex_remove_card(struct mwifiex_adapter *adapter) in mwifiex_remove_card() argument
1732 if (!adapter) in mwifiex_remove_card()
1735 if (adapter->is_up) in mwifiex_remove_card()
1736 mwifiex_uninit_sw(adapter); in mwifiex_remove_card()
1738 if (adapter->irq_wakeup >= 0) in mwifiex_remove_card()
1739 device_init_wakeup(adapter->dev, false); in mwifiex_remove_card()
1742 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1744 if (adapter->if_ops.unregister_dev) in mwifiex_remove_card()
1745 adapter->if_ops.unregister_dev(adapter); in mwifiex_remove_card()
1747 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1749 mwifiex_free_adapter(adapter); in mwifiex_remove_card()
1755 void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, in _mwifiex_dbg() argument
1761 if (!(adapter->debug_mask & mask)) in _mwifiex_dbg()
1769 if (adapter->dev) in _mwifiex_dbg()
1770 dev_info(adapter->dev, "%pV", &vaf); in _mwifiex_dbg()