Lines Matching full:adapter
58 * - Allocate adapter structure
59 * - Save interface specific operations table in adapter
62 * - Set default adapter structure parameters
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()
82 /* Save interface specific operations in adapter */ 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()
129 * - Free adapter structure
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 mwifiex_process_tx_queue(adapter); in mwifiex_main_process()
405 if (adapter->hs_activated) { in mwifiex_main_process()
407 &adapter->work_flags); in mwifiex_main_process()
410 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
415 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
416 !adapter->scan_processing) && in mwifiex_main_process()
417 !adapter->data_sent && in mwifiex_main_process()
418 !mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
420 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
421 mwifiex_process_bypass_tx(adapter); in mwifiex_main_process()
422 if (adapter->hs_activated) { in mwifiex_main_process()
424 &adapter->work_flags); in mwifiex_main_process()
427 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
432 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
433 !adapter->scan_processing) && in mwifiex_main_process()
434 !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
436 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
437 mwifiex_wmm_process_tx(adapter); in mwifiex_main_process()
438 if (adapter->hs_activated) { in mwifiex_main_process()
440 &adapter->work_flags); in mwifiex_main_process()
443 (adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
448 if (adapter->delay_null_pkt && !adapter->cmd_sent && in mwifiex_main_process()
449 !adapter->curr_cmd && !is_command_pending(adapter) && in mwifiex_main_process()
450 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
451 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
452 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
454 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_main_process()
457 adapter->delay_null_pkt = false; in mwifiex_main_process()
458 adapter->ps_state = PS_STATE_SLEEP; in mwifiex_main_process()
464 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
465 if (adapter->more_task_flag) { in mwifiex_main_process()
466 adapter->more_task_flag = false; in mwifiex_main_process()
467 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
470 adapter->mwifiex_processing = false; in mwifiex_main_process()
471 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
478 * This function frees the adapter structure.
483 static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) in mwifiex_free_adapter() argument
485 if (!adapter) { in mwifiex_free_adapter()
486 pr_err("%s: adapter is NULL\n", __func__); in mwifiex_free_adapter()
490 mwifiex_unregister(adapter); in mwifiex_free_adapter()
491 pr_debug("info: %s: free adapter\n", __func__); in mwifiex_free_adapter()
498 static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) in mwifiex_terminate_workqueue() argument
500 if (adapter->workqueue) { in mwifiex_terminate_workqueue()
501 flush_workqueue(adapter->workqueue); in mwifiex_terminate_workqueue()
502 destroy_workqueue(adapter->workqueue); in mwifiex_terminate_workqueue()
503 adapter->workqueue = NULL; in mwifiex_terminate_workqueue()
506 if (adapter->rx_workqueue) { in mwifiex_terminate_workqueue()
507 flush_workqueue(adapter->rx_workqueue); in mwifiex_terminate_workqueue()
508 destroy_workqueue(adapter->rx_workqueue); in mwifiex_terminate_workqueue()
509 adapter->rx_workqueue = NULL; in mwifiex_terminate_workqueue()
524 struct mwifiex_adapter *adapter = context; in _mwifiex_fw_dpc() local
528 struct completion *fw_done = adapter->fw_done; in _mwifiex_fw_dpc()
531 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
532 "Failed to get firmware %s\n", adapter->fw_name); in _mwifiex_fw_dpc()
537 adapter->firmware = firmware; in _mwifiex_fw_dpc()
538 fw.fw_buf = (u8 *) adapter->firmware->data; in _mwifiex_fw_dpc()
539 fw.fw_len = adapter->firmware->size; in _mwifiex_fw_dpc()
541 if (adapter->if_ops.dnld_fw) { in _mwifiex_fw_dpc()
542 ret = adapter->if_ops.dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
544 ret = mwifiex_dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
550 mwifiex_dbg(adapter, MSG, "WLAN FW is active\n"); in _mwifiex_fw_dpc()
553 if ((request_firmware(&adapter->cal_data, cal_data_cfg, in _mwifiex_fw_dpc()
554 adapter->dev)) < 0) in _mwifiex_fw_dpc()
555 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
560 if (adapter->if_ops.enable_int) { in _mwifiex_fw_dpc()
561 if (adapter->if_ops.enable_int(adapter)) in _mwifiex_fw_dpc()
565 adapter->init_wait_q_woken = false; in _mwifiex_fw_dpc()
566 ret = mwifiex_init_fw(adapter); in _mwifiex_fw_dpc()
570 adapter->hw_status = MWIFIEX_HW_STATUS_READY; in _mwifiex_fw_dpc()
574 if (!adapter->mfg_mode) { in _mwifiex_fw_dpc()
575 wait_event_interruptible(adapter->init_wait_q, in _mwifiex_fw_dpc()
576 adapter->init_wait_q_woken); in _mwifiex_fw_dpc()
577 if (adapter->hw_status != MWIFIEX_HW_STATUS_READY) in _mwifiex_fw_dpc()
581 if (!adapter->wiphy) { in _mwifiex_fw_dpc()
582 if (mwifiex_register_cfg80211(adapter)) { in _mwifiex_fw_dpc()
583 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
589 if (mwifiex_init_channel_scan_gap(adapter)) { in _mwifiex_fw_dpc()
590 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
601 wiphy_lock(adapter->wiphy); in _mwifiex_fw_dpc()
603 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
606 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
608 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
614 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
617 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
619 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
626 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
629 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
631 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
636 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
639 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); in _mwifiex_fw_dpc()
640 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); in _mwifiex_fw_dpc()
641 adapter->is_up = true; in _mwifiex_fw_dpc()
645 vfree(adapter->chan_stats); in _mwifiex_fw_dpc()
647 wiphy_unregister(adapter->wiphy); in _mwifiex_fw_dpc()
648 wiphy_free(adapter->wiphy); in _mwifiex_fw_dpc()
650 if (adapter->if_ops.disable_int) in _mwifiex_fw_dpc()
651 adapter->if_ops.disable_int(adapter); in _mwifiex_fw_dpc()
653 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
655 if (adapter->if_ops.unregister_dev) in _mwifiex_fw_dpc()
656 adapter->if_ops.unregister_dev(adapter); in _mwifiex_fw_dpc()
658 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in _mwifiex_fw_dpc()
659 mwifiex_terminate_workqueue(adapter); in _mwifiex_fw_dpc()
661 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in _mwifiex_fw_dpc()
663 mwifiex_shutdown_drv(adapter); in _mwifiex_fw_dpc()
664 mwifiex_free_cmd_buffers(adapter); in _mwifiex_fw_dpc()
669 if (adapter->cal_data) { in _mwifiex_fw_dpc()
670 release_firmware(adapter->cal_data); in _mwifiex_fw_dpc()
671 adapter->cal_data = NULL; in _mwifiex_fw_dpc()
673 if (adapter->firmware) { in _mwifiex_fw_dpc()
674 release_firmware(adapter->firmware); in _mwifiex_fw_dpc()
675 adapter->firmware = NULL; in _mwifiex_fw_dpc()
678 if (adapter->irq_wakeup >= 0) in _mwifiex_fw_dpc()
679 device_init_wakeup(adapter->dev, false); in _mwifiex_fw_dpc()
680 mwifiex_free_adapter(adapter); in _mwifiex_fw_dpc()
697 static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, in mwifiex_init_hw_fw() argument
706 if (strlcpy(adapter->fw_name, MFG_FIRMWARE, in mwifiex_init_hw_fw()
707 sizeof(adapter->fw_name)) >= in mwifiex_init_hw_fw()
708 sizeof(adapter->fw_name)) { in mwifiex_init_hw_fw()
715 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, in mwifiex_init_hw_fw()
716 adapter->dev, GFP_KERNEL, adapter, in mwifiex_init_hw_fw()
719 ret = request_firmware(&adapter->firmware, in mwifiex_init_hw_fw()
720 adapter->fw_name, in mwifiex_init_hw_fw()
721 adapter->dev); in mwifiex_init_hw_fw()
725 mwifiex_dbg(adapter, ERROR, "request_firmware%s error %d\n", in mwifiex_init_hw_fw()
756 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
764 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
782 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_bypass_tx_queue()
784 mwifiex_dbg(priv->adapter, DATA, in mwifiex_bypass_tx_queue()
805 mwifiex_dbg(priv->adapter, DATA, in mwifiex_queue_tx_pkt()
811 atomic_inc(&priv->adapter->tx_pending); in mwifiex_queue_tx_pkt()
812 atomic_inc(&priv->adapter->bypass_tx_pending); in mwifiex_queue_tx_pkt()
815 atomic_inc(&priv->adapter->tx_pending); in mwifiex_queue_tx_pkt()
819 mwifiex_queue_main_work(priv->adapter); in mwifiex_queue_tx_pkt()
876 mwifiex_dbg(priv->adapter, DATA, in mwifiex_hard_start_xmit()
880 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &priv->adapter->work_flags)) { in mwifiex_hard_start_xmit()
886 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_hard_start_xmit()
893 mwifiex_dbg(priv->adapter, DATA, in mwifiex_hard_start_xmit()
900 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_hard_start_xmit()
908 mwifiex_dbg(priv->adapter, INFO, in mwifiex_hard_start_xmit()
923 priv->adapter->fw_api_ver == MWIFIEX_FW_V15)) in mwifiex_hard_start_xmit()
937 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_hard_start_xmit()
940 if (priv->adapter->auto_tdls && priv->check_tdls_tx) in mwifiex_hard_start_xmit()
970 } else if (priv->adapter->priv[0] != priv) { in mwifiex_set_mac_address()
985 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_set_mac_address()
1036 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1043 priv->adapter->if_ops.card_reset) { in mwifiex_tx_timeout()
1044 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1047 priv->adapter->if_ops.card_reset(priv->adapter); in mwifiex_tx_timeout()
1051 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter) in mwifiex_multi_chan_resync() argument
1053 struct usb_card_rec *card = adapter->card; in mwifiex_multi_chan_resync()
1061 mwifiex_dbg(adapter, WARN, "pending data urb in sys\n"); in mwifiex_multi_chan_resync()
1068 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_multi_chan_resync()
1072 mwifiex_dbg(adapter, ERROR, in mwifiex_multi_chan_resync()
1077 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter) in mwifiex_upload_device_dump() argument
1082 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1084 dev_coredumpv(adapter->dev, adapter->devdump_data, adapter->devdump_len, in mwifiex_upload_device_dump()
1086 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1090 * after 5 min. Here reset adapter->devdump_data and ->devdump_len in mwifiex_upload_device_dump()
1093 adapter->devdump_data = NULL; in mwifiex_upload_device_dump()
1094 adapter->devdump_len = 0; in mwifiex_upload_device_dump()
1098 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter) in mwifiex_drv_info_dump() argument
1109 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n"); in mwifiex_drv_info_dump()
1111 p = adapter->devdump_data; in mwifiex_drv_info_dump()
1116 mwifiex_drv_get_driver_version(adapter, drv_version, in mwifiex_drv_info_dump()
1120 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_drv_info_dump()
1121 cardp = (struct usb_card_rec *)adapter->card; in mwifiex_drv_info_dump()
1135 atomic_read(&adapter->tx_pending)); in mwifiex_drv_info_dump()
1137 atomic_read(&adapter->rx_pending)); in mwifiex_drv_info_dump()
1139 if (adapter->iface_type == MWIFIEX_SDIO) { in mwifiex_drv_info_dump()
1140 sdio_card = (struct sdio_mmc_card *)adapter->card; in mwifiex_drv_info_dump()
1147 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1148 if (!adapter->priv[i] || !adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1150 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1175 if (adapter->iface_type == MWIFIEX_SDIO || in mwifiex_drv_info_dump()
1176 adapter->iface_type == MWIFIEX_PCIE) { in mwifiex_drv_info_dump()
1178 adapter->iface_type == MWIFIEX_SDIO ? in mwifiex_drv_info_dump()
1180 if (adapter->if_ops.reg_dump) in mwifiex_drv_info_dump()
1181 p += adapter->if_ops.reg_dump(adapter, p); in mwifiex_drv_info_dump()
1186 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1187 if (!adapter->priv[i] || !adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1189 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1199 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n"); in mwifiex_drv_info_dump()
1200 adapter->devdump_len = p - (char *)adapter->devdump_data; in mwifiex_drv_info_dump()
1204 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter) in mwifiex_prepare_fw_dump_info() argument
1210 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1212 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1223 if (dump_len + 1 + adapter->devdump_len > MWIFIEX_FW_DUMP_SIZE) { in mwifiex_prepare_fw_dump_info()
1225 fw_dump_ptr = vzalloc(dump_len + 1 + adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1226 mwifiex_dbg(adapter, MSG, "Realloc device dump data.\n"); in mwifiex_prepare_fw_dump_info()
1228 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1229 mwifiex_dbg(adapter, ERROR, in mwifiex_prepare_fw_dump_info()
1234 memmove(fw_dump_ptr, adapter->devdump_data, in mwifiex_prepare_fw_dump_info()
1235 adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1236 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1237 adapter->devdump_data = fw_dump_ptr; in mwifiex_prepare_fw_dump_info()
1240 fw_dump_ptr = (char *)adapter->devdump_data + adapter->devdump_len; in mwifiex_prepare_fw_dump_info()
1242 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1244 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1264 adapter->devdump_len = fw_dump_ptr - (char *)adapter->devdump_data; in mwifiex_prepare_fw_dump_info()
1266 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1268 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1346 ether_addr_copy(priv->curr_addr, priv->adapter->perm_addr); in mwifiex_init_priv_params()
1359 int is_command_pending(struct mwifiex_adapter *adapter) in is_command_pending() argument
1363 spin_lock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1364 is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q); in is_command_pending()
1365 spin_unlock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1377 struct mwifiex_adapter *adapter = in mwifiex_rx_work_queue() local
1380 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_rx_work_queue()
1382 mwifiex_process_rx(adapter); in mwifiex_rx_work_queue()
1393 struct mwifiex_adapter *adapter = in mwifiex_main_work_queue() local
1396 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_main_work_queue()
1398 mwifiex_main_process(adapter); in mwifiex_main_work_queue()
1402 static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) in mwifiex_uninit_sw() argument
1410 if (adapter->if_ops.disable_int) in mwifiex_uninit_sw()
1411 adapter->if_ops.disable_int(adapter); in mwifiex_uninit_sw()
1413 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_uninit_sw()
1414 mwifiex_terminate_workqueue(adapter); in mwifiex_uninit_sw()
1415 adapter->int_status = 0; in mwifiex_uninit_sw()
1418 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1419 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1421 mwifiex_stop_net_dev_queue(priv->netdev, adapter); in mwifiex_uninit_sw()
1428 mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n"); in mwifiex_uninit_sw()
1429 mwifiex_shutdown_drv(adapter); in mwifiex_uninit_sw()
1430 mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n"); in mwifiex_uninit_sw()
1432 if (atomic_read(&adapter->rx_pending) || in mwifiex_uninit_sw()
1433 atomic_read(&adapter->tx_pending) || in mwifiex_uninit_sw()
1434 atomic_read(&adapter->cmd_pending)) { in mwifiex_uninit_sw()
1435 mwifiex_dbg(adapter, ERROR, in mwifiex_uninit_sw()
1438 atomic_read(&adapter->rx_pending), in mwifiex_uninit_sw()
1439 atomic_read(&adapter->tx_pending), in mwifiex_uninit_sw()
1440 atomic_read(&adapter->cmd_pending)); in mwifiex_uninit_sw()
1443 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1444 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1456 wiphy_lock(adapter->wiphy); in mwifiex_uninit_sw()
1457 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); in mwifiex_uninit_sw()
1458 wiphy_unlock(adapter->wiphy); in mwifiex_uninit_sw()
1463 wiphy_unregister(adapter->wiphy); in mwifiex_uninit_sw()
1464 wiphy_free(adapter->wiphy); in mwifiex_uninit_sw()
1465 adapter->wiphy = NULL; in mwifiex_uninit_sw()
1467 vfree(adapter->chan_stats); in mwifiex_uninit_sw()
1468 mwifiex_free_cmd_buffers(adapter); in mwifiex_uninit_sw()
1472 * This function can be used for shutting down the adapter SW.
1474 int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) in mwifiex_shutdown_sw() argument
1478 if (!adapter) in mwifiex_shutdown_sw()
1481 wait_for_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1483 reinit_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1485 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_shutdown_sw()
1490 mwifiex_uninit_sw(adapter); in mwifiex_shutdown_sw()
1491 adapter->is_up = false; in mwifiex_shutdown_sw()
1493 if (adapter->if_ops.down_dev) in mwifiex_shutdown_sw()
1494 adapter->if_ops.down_dev(adapter); in mwifiex_shutdown_sw()
1500 /* This function can be used for reinitting the adapter SW. Required
1504 mwifiex_reinit_sw(struct mwifiex_adapter *adapter) in mwifiex_reinit_sw() argument
1508 mwifiex_init_lock_list(adapter); in mwifiex_reinit_sw()
1509 if (adapter->if_ops.up_dev) in mwifiex_reinit_sw()
1510 adapter->if_ops.up_dev(adapter); in mwifiex_reinit_sw()
1512 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_reinit_sw()
1513 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1514 init_waitqueue_head(&adapter->init_wait_q); in mwifiex_reinit_sw()
1515 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_reinit_sw()
1516 adapter->hs_activated = false; in mwifiex_reinit_sw()
1517 clear_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags); in mwifiex_reinit_sw()
1518 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_reinit_sw()
1519 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_reinit_sw()
1520 adapter->cmd_wait_q.status = 0; in mwifiex_reinit_sw()
1521 adapter->scan_wait_q_woken = false; in mwifiex_reinit_sw()
1523 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_reinit_sw()
1524 adapter->rx_work_enabled = true; in mwifiex_reinit_sw()
1526 adapter->workqueue = in mwifiex_reinit_sw()
1529 if (!adapter->workqueue) in mwifiex_reinit_sw()
1532 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_reinit_sw()
1534 if (adapter->rx_work_enabled) { in mwifiex_reinit_sw()
1535 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_reinit_sw()
1539 if (!adapter->rx_workqueue) in mwifiex_reinit_sw()
1541 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_reinit_sw()
1548 mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__); in mwifiex_reinit_sw()
1550 if (mwifiex_init_hw_fw(adapter, false)) { in mwifiex_reinit_sw()
1551 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1557 ret = _mwifiex_fw_dpc(adapter->firmware, adapter); in mwifiex_reinit_sw()
1559 pr_err("Failed to bring up adapter: %d\n", ret); in mwifiex_reinit_sw()
1562 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); in mwifiex_reinit_sw()
1567 mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__); in mwifiex_reinit_sw()
1568 if (adapter->if_ops.unregister_dev) in mwifiex_reinit_sw()
1569 adapter->if_ops.unregister_dev(adapter); in mwifiex_reinit_sw()
1572 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1573 mwifiex_terminate_workqueue(adapter); in mwifiex_reinit_sw()
1574 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_reinit_sw()
1575 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1577 mwifiex_shutdown_drv(adapter); in mwifiex_reinit_sw()
1578 mwifiex_free_cmd_buffers(adapter); in mwifiex_reinit_sw()
1581 complete_all(adapter->fw_done); in mwifiex_reinit_sw()
1582 mwifiex_dbg(adapter, INFO, "%s, error\n", __func__); in mwifiex_reinit_sw()
1590 struct mwifiex_adapter *adapter = priv; in mwifiex_irq_wakeup_handler() local
1592 dev_dbg(adapter->dev, "%s: wake by wifi", __func__); in mwifiex_irq_wakeup_handler()
1593 adapter->wake_by_wifi = true; in mwifiex_irq_wakeup_handler()
1597 pm_wakeup_event(adapter->dev, 0); in mwifiex_irq_wakeup_handler()
1603 static void mwifiex_probe_of(struct mwifiex_adapter *adapter) in mwifiex_probe_of() argument
1606 struct device *dev = adapter->dev; in mwifiex_probe_of()
1611 adapter->dt_node = dev->of_node; in mwifiex_probe_of()
1612 adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0); in mwifiex_probe_of()
1613 if (!adapter->irq_wakeup) { in mwifiex_probe_of()
1618 ret = devm_request_irq(dev, adapter->irq_wakeup, in mwifiex_probe_of()
1620 "wifi_wake", adapter); in mwifiex_probe_of()
1623 adapter->irq_wakeup, ret); in mwifiex_probe_of()
1627 disable_irq(adapter->irq_wakeup); in mwifiex_probe_of()
1635 adapter->irq_wakeup = -1; in mwifiex_probe_of()
1644 * adapter structure
1656 struct mwifiex_adapter *adapter; in mwifiex_add_card() local
1658 if (mwifiex_register(card, dev, if_ops, (void **)&adapter)) { in mwifiex_add_card()
1663 mwifiex_probe_of(adapter); in mwifiex_add_card()
1665 adapter->iface_type = iface_type; in mwifiex_add_card()
1666 adapter->fw_done = fw_done; in mwifiex_add_card()
1668 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_add_card()
1669 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1670 init_waitqueue_head(&adapter->init_wait_q); in mwifiex_add_card()
1671 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_add_card()
1672 adapter->hs_activated = false; in mwifiex_add_card()
1673 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_add_card()
1674 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_add_card()
1675 adapter->cmd_wait_q.status = 0; in mwifiex_add_card()
1676 adapter->scan_wait_q_woken = false; in mwifiex_add_card()
1678 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_add_card()
1679 adapter->rx_work_enabled = true; in mwifiex_add_card()
1681 adapter->workqueue = in mwifiex_add_card()
1684 if (!adapter->workqueue) in mwifiex_add_card()
1687 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_add_card()
1689 if (adapter->rx_work_enabled) { in mwifiex_add_card()
1690 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_add_card()
1694 if (!adapter->rx_workqueue) in mwifiex_add_card()
1697 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_add_card()
1702 if (adapter->if_ops.register_dev(adapter)) { in mwifiex_add_card()
1707 if (mwifiex_init_hw_fw(adapter, true)) { in mwifiex_add_card()
1716 if (adapter->if_ops.unregister_dev) in mwifiex_add_card()
1717 adapter->if_ops.unregister_dev(adapter); in mwifiex_add_card()
1719 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1720 mwifiex_terminate_workqueue(adapter); in mwifiex_add_card()
1721 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_add_card()
1723 mwifiex_shutdown_drv(adapter); in mwifiex_add_card()
1724 mwifiex_free_cmd_buffers(adapter); in mwifiex_add_card()
1727 if (adapter->irq_wakeup >= 0) in mwifiex_add_card()
1728 device_init_wakeup(adapter->dev, false); in mwifiex_add_card()
1729 mwifiex_free_adapter(adapter); in mwifiex_add_card()
1746 * - Free the adapter structure
1748 int mwifiex_remove_card(struct mwifiex_adapter *adapter) in mwifiex_remove_card() argument
1750 if (!adapter) in mwifiex_remove_card()
1753 if (adapter->is_up) in mwifiex_remove_card()
1754 mwifiex_uninit_sw(adapter); in mwifiex_remove_card()
1756 if (adapter->irq_wakeup >= 0) in mwifiex_remove_card()
1757 device_init_wakeup(adapter->dev, false); in mwifiex_remove_card()
1760 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1762 if (adapter->if_ops.unregister_dev) in mwifiex_remove_card()
1763 adapter->if_ops.unregister_dev(adapter); in mwifiex_remove_card()
1764 /* Free adapter structure */ in mwifiex_remove_card()
1765 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1766 "info: free adapter\n"); in mwifiex_remove_card()
1767 mwifiex_free_adapter(adapter); in mwifiex_remove_card()
1773 void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, in _mwifiex_dbg() argument
1779 if (!(adapter->debug_mask & mask)) in _mwifiex_dbg()
1787 if (adapter->dev) in _mwifiex_dbg()
1788 dev_info(adapter->dev, "%pV", &vaf); in _mwifiex_dbg()