Lines Matching refs:adapter

71 	struct mwifiex_adapter *adapter;  in mwifiex_register()  local
74 adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL); in mwifiex_register()
75 if (!adapter) in mwifiex_register()
78 *padapter = adapter; in mwifiex_register()
79 adapter->dev = dev; in mwifiex_register()
80 adapter->card = card; in mwifiex_register()
83 memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops)); in mwifiex_register()
84 adapter->debug_mask = debug_mask; in mwifiex_register()
87 if (adapter->if_ops.init_if) in mwifiex_register()
88 if (adapter->if_ops.init_if(adapter)) in mwifiex_register()
91 adapter->priv_num = 0; in mwifiex_register()
95 adapter->priv[i] = in mwifiex_register()
97 if (!adapter->priv[i]) in mwifiex_register()
100 adapter->priv[i]->adapter = adapter; in mwifiex_register()
101 adapter->priv_num++; in mwifiex_register()
103 mwifiex_init_lock_list(adapter); in mwifiex_register()
105 timer_setup(&adapter->cmd_timer, mwifiex_cmd_timeout_func, 0); in mwifiex_register()
110 mwifiex_dbg(adapter, ERROR, in mwifiex_register()
113 for (i = 0; i < adapter->priv_num; i++) in mwifiex_register()
114 kfree(adapter->priv[i]); in mwifiex_register()
116 kfree(adapter); in mwifiex_register()
131 static int mwifiex_unregister(struct mwifiex_adapter *adapter) in mwifiex_unregister() argument
135 if (adapter->if_ops.cleanup_if) in mwifiex_unregister()
136 adapter->if_ops.cleanup_if(adapter); in mwifiex_unregister()
138 del_timer_sync(&adapter->cmd_timer); in mwifiex_unregister()
141 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_unregister()
142 if (adapter->priv[i]) { in mwifiex_unregister()
143 mwifiex_free_curr_bcn(adapter->priv[i]); in mwifiex_unregister()
144 kfree(adapter->priv[i]); in mwifiex_unregister()
148 if (adapter->nd_info) { in mwifiex_unregister()
149 for (i = 0 ; i < adapter->nd_info->n_matches ; i++) in mwifiex_unregister()
150 kfree(adapter->nd_info->matches[i]); in mwifiex_unregister()
151 kfree(adapter->nd_info); in mwifiex_unregister()
152 adapter->nd_info = NULL; in mwifiex_unregister()
155 kfree(adapter->regd); in mwifiex_unregister()
157 kfree(adapter); in mwifiex_unregister()
161 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) in mwifiex_queue_main_work() argument
165 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
166 if (adapter->mwifiex_processing) { in mwifiex_queue_main_work()
167 adapter->more_task_flag = true; in mwifiex_queue_main_work()
168 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
170 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
171 queue_work(adapter->workqueue, &adapter->main_work); in mwifiex_queue_main_work()
176 static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) in mwifiex_queue_rx_work() argument
178 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
179 if (adapter->rx_processing) { in mwifiex_queue_rx_work()
180 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
182 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
183 queue_work(adapter->rx_workqueue, &adapter->rx_work); in mwifiex_queue_rx_work()
187 static int mwifiex_process_rx(struct mwifiex_adapter *adapter) in mwifiex_process_rx() argument
192 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
193 if (adapter->rx_processing || adapter->rx_locked) { in mwifiex_process_rx()
194 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
197 adapter->rx_processing = true; in mwifiex_process_rx()
198 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
202 while ((skb = skb_dequeue(&adapter->rx_data_q))) { in mwifiex_process_rx()
203 atomic_dec(&adapter->rx_pending); in mwifiex_process_rx()
204 if ((adapter->delay_main_work || in mwifiex_process_rx()
205 adapter->iface_type == MWIFIEX_USB) && in mwifiex_process_rx()
206 (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) { in mwifiex_process_rx()
207 if (adapter->if_ops.submit_rem_rx_urbs) in mwifiex_process_rx()
208 adapter->if_ops.submit_rem_rx_urbs(adapter); in mwifiex_process_rx()
209 adapter->delay_main_work = false; in mwifiex_process_rx()
210 mwifiex_queue_main_work(adapter); in mwifiex_process_rx()
214 if (adapter->if_ops.deaggr_pkt) in mwifiex_process_rx()
215 adapter->if_ops.deaggr_pkt(adapter, skb); in mwifiex_process_rx()
218 mwifiex_handle_rx_packet(adapter, skb); in mwifiex_process_rx()
221 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
222 adapter->rx_processing = false; in mwifiex_process_rx()
223 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
244 int mwifiex_main_process(struct mwifiex_adapter *adapter) in mwifiex_main_process() argument
249 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
252 if (adapter->mwifiex_processing || adapter->main_locked) { in mwifiex_main_process()
253 adapter->more_task_flag = true; in mwifiex_main_process()
254 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
257 adapter->mwifiex_processing = true; in mwifiex_main_process()
258 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
262 if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY) in mwifiex_main_process()
272 if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING && in mwifiex_main_process()
273 adapter->iface_type != MWIFIEX_USB) { in mwifiex_main_process()
274 adapter->delay_main_work = true; in mwifiex_main_process()
275 mwifiex_queue_rx_work(adapter); in mwifiex_main_process()
280 if (adapter->int_status) { in mwifiex_main_process()
281 if (adapter->hs_activated) in mwifiex_main_process()
282 mwifiex_process_hs_config(adapter); in mwifiex_main_process()
283 if (adapter->if_ops.process_int_status) in mwifiex_main_process()
284 adapter->if_ops.process_int_status(adapter); in mwifiex_main_process()
287 if (adapter->rx_work_enabled && adapter->data_received) in mwifiex_main_process()
288 mwifiex_queue_rx_work(adapter); in mwifiex_main_process()
291 if ((adapter->ps_state == PS_STATE_SLEEP) && in mwifiex_main_process()
292 (adapter->pm_wakeup_card_req && in mwifiex_main_process()
293 !adapter->pm_wakeup_fw_try) && in mwifiex_main_process()
294 (is_command_pending(adapter) || in mwifiex_main_process()
295 !skb_queue_empty(&adapter->tx_data_q) || in mwifiex_main_process()
296 !mwifiex_bypass_txlist_empty(adapter) || in mwifiex_main_process()
297 !mwifiex_wmm_lists_empty(adapter))) { in mwifiex_main_process()
298 adapter->pm_wakeup_fw_try = true; in mwifiex_main_process()
299 mod_timer(&adapter->wakeup_timer, jiffies + (HZ*3)); in mwifiex_main_process()
300 adapter->if_ops.wakeup(adapter); in mwifiex_main_process()
304 if (IS_CARD_RX_RCVD(adapter)) { in mwifiex_main_process()
305 adapter->data_received = false; in mwifiex_main_process()
306 adapter->pm_wakeup_fw_try = false; in mwifiex_main_process()
307 del_timer(&adapter->wakeup_timer); in mwifiex_main_process()
308 if (adapter->ps_state == PS_STATE_SLEEP) in mwifiex_main_process()
309 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_main_process()
312 if (adapter->pm_wakeup_fw_try) in mwifiex_main_process()
314 if (adapter->ps_state == PS_STATE_PRE_SLEEP) in mwifiex_main_process()
315 mwifiex_check_ps_cond(adapter); in mwifiex_main_process()
317 if (adapter->ps_state != PS_STATE_AWAKE) in mwifiex_main_process()
319 if (adapter->tx_lock_flag) { in mwifiex_main_process()
320 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_main_process()
321 if (!adapter->usb_mc_setup) in mwifiex_main_process()
327 if ((!adapter->scan_chan_gap_enabled && in mwifiex_main_process()
328 adapter->scan_processing) || adapter->data_sent || in mwifiex_main_process()
330 (mwifiex_get_priv(adapter, in mwifiex_main_process()
332 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
333 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
334 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
335 if (adapter->cmd_sent || adapter->curr_cmd || in mwifiex_main_process()
337 (mwifiex_get_priv(adapter, in mwifiex_main_process()
339 (!is_command_pending(adapter))) in mwifiex_main_process()
345 if (adapter->event_received) { in mwifiex_main_process()
346 adapter->event_received = false; in mwifiex_main_process()
347 mwifiex_process_event(adapter); in mwifiex_main_process()
351 if (adapter->cmd_resp_received) { in mwifiex_main_process()
352 adapter->cmd_resp_received = false; in mwifiex_main_process()
353 mwifiex_process_cmdresp(adapter); in mwifiex_main_process()
356 if (adapter->hw_status == MWIFIEX_HW_STATUS_INIT_DONE) { in mwifiex_main_process()
357 adapter->hw_status = MWIFIEX_HW_STATUS_READY; in mwifiex_main_process()
358 mwifiex_init_fw_complete(adapter); in mwifiex_main_process()
364 if (adapter->ps_state == PS_STATE_PRE_SLEEP) in mwifiex_main_process()
365 mwifiex_check_ps_cond(adapter); in mwifiex_main_process()
370 if ((adapter->ps_state == PS_STATE_SLEEP) || in mwifiex_main_process()
371 (adapter->ps_state == PS_STATE_PRE_SLEEP) || in mwifiex_main_process()
372 (adapter->ps_state == PS_STATE_SLEEP_CFM)) { in mwifiex_main_process()
376 if (adapter->tx_lock_flag) { in mwifiex_main_process()
377 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_main_process()
378 if (!adapter->usb_mc_setup) in mwifiex_main_process()
384 if (!adapter->cmd_sent && !adapter->curr_cmd && in mwifiex_main_process()
386 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
387 if (mwifiex_exec_next_cmd(adapter) == -1) { in mwifiex_main_process()
396 if (adapter->iface_type == MWIFIEX_USB && in mwifiex_main_process()
397 adapter->usb_mc_setup) in mwifiex_main_process()
400 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
401 !adapter->scan_processing) && in mwifiex_main_process()
402 !adapter->data_sent && in mwifiex_main_process()
403 !skb_queue_empty(&adapter->tx_data_q)) { in mwifiex_main_process()
404 if (adapter->hs_activated_manually) { in mwifiex_main_process()
405 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
407 adapter->hs_activated_manually = false; in mwifiex_main_process()
410 mwifiex_process_tx_queue(adapter); in mwifiex_main_process()
411 if (adapter->hs_activated) { in mwifiex_main_process()
413 &adapter->work_flags); in mwifiex_main_process()
416 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
421 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
422 !adapter->scan_processing) && in mwifiex_main_process()
423 !adapter->data_sent && in mwifiex_main_process()
424 !mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
426 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
427 if (adapter->hs_activated_manually) { in mwifiex_main_process()
428 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
430 adapter->hs_activated_manually = false; in mwifiex_main_process()
433 mwifiex_process_bypass_tx(adapter); in mwifiex_main_process()
434 if (adapter->hs_activated) { in mwifiex_main_process()
436 &adapter->work_flags); in mwifiex_main_process()
439 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
444 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
445 !adapter->scan_processing) && in mwifiex_main_process()
446 !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
448 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
449 if (adapter->hs_activated_manually) { in mwifiex_main_process()
450 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
452 adapter->hs_activated_manually = false; in mwifiex_main_process()
455 mwifiex_wmm_process_tx(adapter); in mwifiex_main_process()
456 if (adapter->hs_activated) { in mwifiex_main_process()
458 &adapter->work_flags); in mwifiex_main_process()
461 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
466 if (adapter->delay_null_pkt && !adapter->cmd_sent && in mwifiex_main_process()
467 !adapter->curr_cmd && !is_command_pending(adapter) && in mwifiex_main_process()
468 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
469 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
470 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
472 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_main_process()
475 adapter->delay_null_pkt = false; in mwifiex_main_process()
476 adapter->ps_state = PS_STATE_SLEEP; in mwifiex_main_process()
482 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
483 if (adapter->more_task_flag) { in mwifiex_main_process()
484 adapter->more_task_flag = false; in mwifiex_main_process()
485 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
488 adapter->mwifiex_processing = false; in mwifiex_main_process()
489 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
501 static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) in mwifiex_free_adapter() argument
503 if (!adapter) { in mwifiex_free_adapter()
508 mwifiex_unregister(adapter); in mwifiex_free_adapter()
516 static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) in mwifiex_terminate_workqueue() argument
518 if (adapter->workqueue) { in mwifiex_terminate_workqueue()
519 destroy_workqueue(adapter->workqueue); in mwifiex_terminate_workqueue()
520 adapter->workqueue = NULL; in mwifiex_terminate_workqueue()
523 if (adapter->rx_workqueue) { in mwifiex_terminate_workqueue()
524 destroy_workqueue(adapter->rx_workqueue); in mwifiex_terminate_workqueue()
525 adapter->rx_workqueue = NULL; in mwifiex_terminate_workqueue()
540 struct mwifiex_adapter *adapter = context; in _mwifiex_fw_dpc() local
544 struct completion *fw_done = adapter->fw_done; in _mwifiex_fw_dpc()
547 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
548 "Failed to get firmware %s\n", adapter->fw_name); in _mwifiex_fw_dpc()
553 adapter->firmware = firmware; in _mwifiex_fw_dpc()
554 fw.fw_buf = (u8 *) adapter->firmware->data; in _mwifiex_fw_dpc()
555 fw.fw_len = adapter->firmware->size; in _mwifiex_fw_dpc()
557 if (adapter->if_ops.dnld_fw) { in _mwifiex_fw_dpc()
558 ret = adapter->if_ops.dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
560 ret = mwifiex_dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
566 mwifiex_dbg(adapter, MSG, "WLAN FW is active\n"); in _mwifiex_fw_dpc()
569 if ((request_firmware(&adapter->cal_data, cal_data_cfg, in _mwifiex_fw_dpc()
570 adapter->dev)) < 0) in _mwifiex_fw_dpc()
571 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
576 if (adapter->if_ops.enable_int) { in _mwifiex_fw_dpc()
577 if (adapter->if_ops.enable_int(adapter)) in _mwifiex_fw_dpc()
581 adapter->init_wait_q_woken = false; in _mwifiex_fw_dpc()
582 ret = mwifiex_init_fw(adapter); in _mwifiex_fw_dpc()
586 adapter->hw_status = MWIFIEX_HW_STATUS_READY; in _mwifiex_fw_dpc()
590 if (!adapter->mfg_mode) { in _mwifiex_fw_dpc()
591 wait_event_interruptible(adapter->init_wait_q, in _mwifiex_fw_dpc()
592 adapter->init_wait_q_woken); in _mwifiex_fw_dpc()
593 if (adapter->hw_status != MWIFIEX_HW_STATUS_READY) in _mwifiex_fw_dpc()
597 if (!adapter->wiphy) { in _mwifiex_fw_dpc()
598 if (mwifiex_register_cfg80211(adapter)) { in _mwifiex_fw_dpc()
599 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
605 if (mwifiex_init_channel_scan_gap(adapter)) { in _mwifiex_fw_dpc()
606 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
617 wiphy_lock(adapter->wiphy); in _mwifiex_fw_dpc()
619 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
622 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
624 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
630 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
633 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
635 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
642 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
645 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
647 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
652 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
655 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); in _mwifiex_fw_dpc()
656 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); in _mwifiex_fw_dpc()
657 adapter->is_up = true; in _mwifiex_fw_dpc()
661 vfree(adapter->chan_stats); in _mwifiex_fw_dpc()
663 wiphy_unregister(adapter->wiphy); in _mwifiex_fw_dpc()
664 wiphy_free(adapter->wiphy); in _mwifiex_fw_dpc()
666 if (adapter->if_ops.disable_int) in _mwifiex_fw_dpc()
667 adapter->if_ops.disable_int(adapter); in _mwifiex_fw_dpc()
669 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
671 if (adapter->if_ops.unregister_dev) in _mwifiex_fw_dpc()
672 adapter->if_ops.unregister_dev(adapter); in _mwifiex_fw_dpc()
674 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in _mwifiex_fw_dpc()
675 mwifiex_terminate_workqueue(adapter); in _mwifiex_fw_dpc()
677 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in _mwifiex_fw_dpc()
679 mwifiex_shutdown_drv(adapter); in _mwifiex_fw_dpc()
680 mwifiex_free_cmd_buffers(adapter); in _mwifiex_fw_dpc()
685 if (adapter->cal_data) { in _mwifiex_fw_dpc()
686 release_firmware(adapter->cal_data); in _mwifiex_fw_dpc()
687 adapter->cal_data = NULL; in _mwifiex_fw_dpc()
689 if (adapter->firmware) { in _mwifiex_fw_dpc()
690 release_firmware(adapter->firmware); in _mwifiex_fw_dpc()
691 adapter->firmware = NULL; in _mwifiex_fw_dpc()
694 if (adapter->irq_wakeup >= 0) in _mwifiex_fw_dpc()
695 device_init_wakeup(adapter->dev, false); in _mwifiex_fw_dpc()
696 mwifiex_free_adapter(adapter); in _mwifiex_fw_dpc()
713 static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, in mwifiex_init_hw_fw() argument
722 if (strlcpy(adapter->fw_name, MFG_FIRMWARE, in mwifiex_init_hw_fw()
723 sizeof(adapter->fw_name)) >= in mwifiex_init_hw_fw()
724 sizeof(adapter->fw_name)) { in mwifiex_init_hw_fw()
731 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, in mwifiex_init_hw_fw()
732 adapter->dev, GFP_KERNEL, adapter, in mwifiex_init_hw_fw()
735 ret = request_firmware(&adapter->firmware, in mwifiex_init_hw_fw()
736 adapter->fw_name, in mwifiex_init_hw_fw()
737 adapter->dev); in mwifiex_init_hw_fw()
741 mwifiex_dbg(adapter, ERROR, "request_firmware%s error %d\n", in mwifiex_init_hw_fw()
772 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
780 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
798 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_bypass_tx_queue()
800 mwifiex_dbg(priv->adapter, DATA, in mwifiex_bypass_tx_queue()
821 mwifiex_dbg(priv->adapter, DATA, in mwifiex_queue_tx_pkt()
827 atomic_inc(&priv->adapter->tx_pending); in mwifiex_queue_tx_pkt()
828 atomic_inc(&priv->adapter->bypass_tx_pending); in mwifiex_queue_tx_pkt()
831 atomic_inc(&priv->adapter->tx_pending); in mwifiex_queue_tx_pkt()
835 mwifiex_queue_main_work(priv->adapter); in mwifiex_queue_tx_pkt()
892 mwifiex_dbg(priv->adapter, DATA, in mwifiex_hard_start_xmit()
896 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &priv->adapter->work_flags)) { in mwifiex_hard_start_xmit()
902 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_hard_start_xmit()
909 mwifiex_dbg(priv->adapter, DATA, in mwifiex_hard_start_xmit()
916 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_hard_start_xmit()
924 mwifiex_dbg(priv->adapter, INFO, in mwifiex_hard_start_xmit()
939 priv->adapter->fw_api_ver == MWIFIEX_FW_V15)) in mwifiex_hard_start_xmit()
953 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_hard_start_xmit()
956 if (priv->adapter->auto_tdls && priv->check_tdls_tx) in mwifiex_hard_start_xmit()
986 } else if (priv->adapter->priv[0] != priv) { in mwifiex_set_mac_address()
1001 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_set_mac_address()
1052 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1059 priv->adapter->if_ops.card_reset) { in mwifiex_tx_timeout()
1060 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1063 priv->adapter->if_ops.card_reset(priv->adapter); in mwifiex_tx_timeout()
1067 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter) in mwifiex_multi_chan_resync() argument
1069 struct usb_card_rec *card = adapter->card; in mwifiex_multi_chan_resync()
1077 mwifiex_dbg(adapter, WARN, "pending data urb in sys\n"); in mwifiex_multi_chan_resync()
1084 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_multi_chan_resync()
1088 mwifiex_dbg(adapter, ERROR, in mwifiex_multi_chan_resync()
1093 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter) in mwifiex_upload_device_dump() argument
1098 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1100 dev_coredumpv(adapter->dev, adapter->devdump_data, adapter->devdump_len, in mwifiex_upload_device_dump()
1102 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1109 adapter->devdump_data = NULL; in mwifiex_upload_device_dump()
1110 adapter->devdump_len = 0; in mwifiex_upload_device_dump()
1114 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter) in mwifiex_drv_info_dump() argument
1125 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n"); in mwifiex_drv_info_dump()
1127 p = adapter->devdump_data; in mwifiex_drv_info_dump()
1132 mwifiex_drv_get_driver_version(adapter, drv_version, in mwifiex_drv_info_dump()
1136 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_drv_info_dump()
1137 cardp = (struct usb_card_rec *)adapter->card; in mwifiex_drv_info_dump()
1151 atomic_read(&adapter->tx_pending)); in mwifiex_drv_info_dump()
1153 atomic_read(&adapter->rx_pending)); in mwifiex_drv_info_dump()
1155 if (adapter->iface_type == MWIFIEX_SDIO) { in mwifiex_drv_info_dump()
1156 sdio_card = (struct sdio_mmc_card *)adapter->card; in mwifiex_drv_info_dump()
1163 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1164 if (!adapter->priv[i] || !adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1166 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1191 if (adapter->iface_type == MWIFIEX_SDIO || in mwifiex_drv_info_dump()
1192 adapter->iface_type == MWIFIEX_PCIE) { in mwifiex_drv_info_dump()
1194 adapter->iface_type == MWIFIEX_SDIO ? in mwifiex_drv_info_dump()
1196 if (adapter->if_ops.reg_dump) in mwifiex_drv_info_dump()
1197 p += adapter->if_ops.reg_dump(adapter, p); in mwifiex_drv_info_dump()
1202 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1203 if (!adapter->priv[i] || !adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1205 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1215 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n"); in mwifiex_drv_info_dump()
1216 adapter->devdump_len = p - (char *)adapter->devdump_data; in mwifiex_drv_info_dump()
1220 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter) in mwifiex_prepare_fw_dump_info() argument
1226 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1228 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1239 if (dump_len + 1 + adapter->devdump_len > MWIFIEX_FW_DUMP_SIZE) { in mwifiex_prepare_fw_dump_info()
1241 fw_dump_ptr = vzalloc(dump_len + 1 + adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1242 mwifiex_dbg(adapter, MSG, "Realloc device dump data.\n"); in mwifiex_prepare_fw_dump_info()
1244 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1245 mwifiex_dbg(adapter, ERROR, in mwifiex_prepare_fw_dump_info()
1250 memmove(fw_dump_ptr, adapter->devdump_data, in mwifiex_prepare_fw_dump_info()
1251 adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1252 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1253 adapter->devdump_data = fw_dump_ptr; in mwifiex_prepare_fw_dump_info()
1256 fw_dump_ptr = (char *)adapter->devdump_data + adapter->devdump_len; in mwifiex_prepare_fw_dump_info()
1258 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1260 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1280 adapter->devdump_len = fw_dump_ptr - (char *)adapter->devdump_data; in mwifiex_prepare_fw_dump_info()
1282 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1284 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1362 ether_addr_copy(priv->curr_addr, priv->adapter->perm_addr); in mwifiex_init_priv_params()
1375 int is_command_pending(struct mwifiex_adapter *adapter) in is_command_pending() argument
1379 spin_lock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1380 is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q); in is_command_pending()
1381 spin_unlock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1393 struct mwifiex_adapter *adapter = in mwifiex_rx_work_queue() local
1396 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_rx_work_queue()
1398 mwifiex_process_rx(adapter); in mwifiex_rx_work_queue()
1409 struct mwifiex_adapter *adapter = in mwifiex_main_work_queue() local
1412 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_main_work_queue()
1414 mwifiex_main_process(adapter); in mwifiex_main_work_queue()
1418 static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) in mwifiex_uninit_sw() argument
1426 if (adapter->if_ops.disable_int) in mwifiex_uninit_sw()
1427 adapter->if_ops.disable_int(adapter); in mwifiex_uninit_sw()
1429 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_uninit_sw()
1430 mwifiex_terminate_workqueue(adapter); in mwifiex_uninit_sw()
1431 adapter->int_status = 0; in mwifiex_uninit_sw()
1434 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1435 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1437 mwifiex_stop_net_dev_queue(priv->netdev, adapter); in mwifiex_uninit_sw()
1444 mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n"); in mwifiex_uninit_sw()
1445 mwifiex_shutdown_drv(adapter); in mwifiex_uninit_sw()
1446 mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n"); in mwifiex_uninit_sw()
1448 if (atomic_read(&adapter->rx_pending) || in mwifiex_uninit_sw()
1449 atomic_read(&adapter->tx_pending) || in mwifiex_uninit_sw()
1450 atomic_read(&adapter->cmd_pending)) { in mwifiex_uninit_sw()
1451 mwifiex_dbg(adapter, ERROR, in mwifiex_uninit_sw()
1454 atomic_read(&adapter->rx_pending), in mwifiex_uninit_sw()
1455 atomic_read(&adapter->tx_pending), in mwifiex_uninit_sw()
1456 atomic_read(&adapter->cmd_pending)); in mwifiex_uninit_sw()
1459 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1460 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1472 wiphy_lock(adapter->wiphy); in mwifiex_uninit_sw()
1473 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); in mwifiex_uninit_sw()
1474 wiphy_unlock(adapter->wiphy); in mwifiex_uninit_sw()
1479 wiphy_unregister(adapter->wiphy); in mwifiex_uninit_sw()
1480 wiphy_free(adapter->wiphy); in mwifiex_uninit_sw()
1481 adapter->wiphy = NULL; in mwifiex_uninit_sw()
1483 vfree(adapter->chan_stats); in mwifiex_uninit_sw()
1484 mwifiex_free_cmd_buffers(adapter); in mwifiex_uninit_sw()
1490 int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) in mwifiex_shutdown_sw() argument
1494 if (!adapter) in mwifiex_shutdown_sw()
1497 wait_for_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1499 reinit_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1501 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_shutdown_sw()
1506 mwifiex_uninit_sw(adapter); in mwifiex_shutdown_sw()
1507 adapter->is_up = false; in mwifiex_shutdown_sw()
1509 if (adapter->if_ops.down_dev) in mwifiex_shutdown_sw()
1510 adapter->if_ops.down_dev(adapter); in mwifiex_shutdown_sw()
1520 mwifiex_reinit_sw(struct mwifiex_adapter *adapter) in mwifiex_reinit_sw() argument
1524 mwifiex_init_lock_list(adapter); in mwifiex_reinit_sw()
1525 if (adapter->if_ops.up_dev) in mwifiex_reinit_sw()
1526 adapter->if_ops.up_dev(adapter); in mwifiex_reinit_sw()
1528 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_reinit_sw()
1529 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1530 init_waitqueue_head(&adapter->init_wait_q); in mwifiex_reinit_sw()
1531 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_reinit_sw()
1532 adapter->hs_activated = false; in mwifiex_reinit_sw()
1533 clear_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags); in mwifiex_reinit_sw()
1534 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_reinit_sw()
1535 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_reinit_sw()
1536 adapter->cmd_wait_q.status = 0; in mwifiex_reinit_sw()
1537 adapter->scan_wait_q_woken = false; in mwifiex_reinit_sw()
1539 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_reinit_sw()
1540 adapter->rx_work_enabled = true; in mwifiex_reinit_sw()
1542 adapter->workqueue = in mwifiex_reinit_sw()
1545 if (!adapter->workqueue) in mwifiex_reinit_sw()
1548 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_reinit_sw()
1550 if (adapter->rx_work_enabled) { in mwifiex_reinit_sw()
1551 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_reinit_sw()
1555 if (!adapter->rx_workqueue) in mwifiex_reinit_sw()
1557 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_reinit_sw()
1564 mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__); in mwifiex_reinit_sw()
1566 if (mwifiex_init_hw_fw(adapter, false)) { in mwifiex_reinit_sw()
1567 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1573 ret = _mwifiex_fw_dpc(adapter->firmware, adapter); in mwifiex_reinit_sw()
1578 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); in mwifiex_reinit_sw()
1583 mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__); in mwifiex_reinit_sw()
1584 if (adapter->if_ops.unregister_dev) in mwifiex_reinit_sw()
1585 adapter->if_ops.unregister_dev(adapter); in mwifiex_reinit_sw()
1588 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1589 mwifiex_terminate_workqueue(adapter); in mwifiex_reinit_sw()
1590 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_reinit_sw()
1591 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1593 mwifiex_shutdown_drv(adapter); in mwifiex_reinit_sw()
1594 mwifiex_free_cmd_buffers(adapter); in mwifiex_reinit_sw()
1597 complete_all(adapter->fw_done); in mwifiex_reinit_sw()
1598 mwifiex_dbg(adapter, INFO, "%s, error\n", __func__); in mwifiex_reinit_sw()
1606 struct mwifiex_adapter *adapter = priv; in mwifiex_irq_wakeup_handler() local
1608 dev_dbg(adapter->dev, "%s: wake by wifi", __func__); in mwifiex_irq_wakeup_handler()
1609 adapter->wake_by_wifi = true; in mwifiex_irq_wakeup_handler()
1613 pm_wakeup_event(adapter->dev, 0); in mwifiex_irq_wakeup_handler()
1619 static void mwifiex_probe_of(struct mwifiex_adapter *adapter) in mwifiex_probe_of() argument
1622 struct device *dev = adapter->dev; in mwifiex_probe_of()
1627 adapter->dt_node = dev->of_node; in mwifiex_probe_of()
1628 adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0); in mwifiex_probe_of()
1629 if (!adapter->irq_wakeup) { in mwifiex_probe_of()
1634 ret = devm_request_irq(dev, adapter->irq_wakeup, in mwifiex_probe_of()
1636 "wifi_wake", adapter); in mwifiex_probe_of()
1639 adapter->irq_wakeup, ret); in mwifiex_probe_of()
1643 disable_irq(adapter->irq_wakeup); in mwifiex_probe_of()
1651 adapter->irq_wakeup = -1; in mwifiex_probe_of()
1672 struct mwifiex_adapter *adapter; in mwifiex_add_card() local
1674 if (mwifiex_register(card, dev, if_ops, (void **)&adapter)) { in mwifiex_add_card()
1679 mwifiex_probe_of(adapter); in mwifiex_add_card()
1681 adapter->iface_type = iface_type; in mwifiex_add_card()
1682 adapter->fw_done = fw_done; in mwifiex_add_card()
1684 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_add_card()
1685 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1686 init_waitqueue_head(&adapter->init_wait_q); in mwifiex_add_card()
1687 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_add_card()
1688 adapter->hs_activated = false; in mwifiex_add_card()
1689 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_add_card()
1690 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_add_card()
1691 adapter->cmd_wait_q.status = 0; in mwifiex_add_card()
1692 adapter->scan_wait_q_woken = false; in mwifiex_add_card()
1694 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_add_card()
1695 adapter->rx_work_enabled = true; in mwifiex_add_card()
1697 adapter->workqueue = in mwifiex_add_card()
1700 if (!adapter->workqueue) in mwifiex_add_card()
1703 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_add_card()
1705 if (adapter->rx_work_enabled) { in mwifiex_add_card()
1706 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_add_card()
1710 if (!adapter->rx_workqueue) in mwifiex_add_card()
1713 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_add_card()
1718 if (adapter->if_ops.register_dev(adapter)) { in mwifiex_add_card()
1723 if (mwifiex_init_hw_fw(adapter, true)) { in mwifiex_add_card()
1732 if (adapter->if_ops.unregister_dev) in mwifiex_add_card()
1733 adapter->if_ops.unregister_dev(adapter); in mwifiex_add_card()
1735 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1736 mwifiex_terminate_workqueue(adapter); in mwifiex_add_card()
1737 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_add_card()
1739 mwifiex_shutdown_drv(adapter); in mwifiex_add_card()
1740 mwifiex_free_cmd_buffers(adapter); in mwifiex_add_card()
1743 if (adapter->irq_wakeup >= 0) in mwifiex_add_card()
1744 device_init_wakeup(adapter->dev, false); in mwifiex_add_card()
1745 mwifiex_free_adapter(adapter); in mwifiex_add_card()
1764 int mwifiex_remove_card(struct mwifiex_adapter *adapter) in mwifiex_remove_card() argument
1766 if (!adapter) in mwifiex_remove_card()
1769 if (adapter->is_up) in mwifiex_remove_card()
1770 mwifiex_uninit_sw(adapter); in mwifiex_remove_card()
1772 if (adapter->irq_wakeup >= 0) in mwifiex_remove_card()
1773 device_init_wakeup(adapter->dev, false); in mwifiex_remove_card()
1776 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1778 if (adapter->if_ops.unregister_dev) in mwifiex_remove_card()
1779 adapter->if_ops.unregister_dev(adapter); in mwifiex_remove_card()
1781 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1783 mwifiex_free_adapter(adapter); in mwifiex_remove_card()
1789 void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, in _mwifiex_dbg() argument
1795 if (!(adapter->debug_mask & mask)) in _mwifiex_dbg()
1803 if (adapter->dev) in _mwifiex_dbg()
1804 dev_info(adapter->dev, "%pV", &vaf); in _mwifiex_dbg()