Lines Matching full:adapter

47  *      - Allocate adapter structure
48 * - Save interface specific operations table in adapter
51 * - Set default adapter structure parameters
60 struct mwifiex_adapter *adapter; in mwifiex_register() local
63 adapter = kzalloc(sizeof(struct mwifiex_adapter), GFP_KERNEL); in mwifiex_register()
64 if (!adapter) in mwifiex_register()
67 *padapter = adapter; in mwifiex_register()
68 adapter->dev = dev; in mwifiex_register()
69 adapter->card = card; in mwifiex_register()
71 /* Save interface specific operations in adapter */ in mwifiex_register()
72 memmove(&adapter->if_ops, if_ops, sizeof(struct mwifiex_if_ops)); in mwifiex_register()
73 adapter->debug_mask = debug_mask; in mwifiex_register()
76 if (adapter->if_ops.init_if) in mwifiex_register()
77 if (adapter->if_ops.init_if(adapter)) in mwifiex_register()
80 adapter->priv_num = 0; in mwifiex_register()
84 adapter->priv[i] = in mwifiex_register()
86 if (!adapter->priv[i]) in mwifiex_register()
89 adapter->priv[i]->adapter = adapter; in mwifiex_register()
90 adapter->priv_num++; in mwifiex_register()
92 mwifiex_init_lock_list(adapter); in mwifiex_register()
94 timer_setup(&adapter->cmd_timer, mwifiex_cmd_timeout_func, 0); in mwifiex_register()
99 mwifiex_dbg(adapter, ERROR, in mwifiex_register()
102 for (i = 0; i < adapter->priv_num; i++) in mwifiex_register()
103 kfree(adapter->priv[i]); in mwifiex_register()
105 kfree(adapter); in mwifiex_register()
118 * - Free adapter structure
120 static int mwifiex_unregister(struct mwifiex_adapter *adapter) in mwifiex_unregister() argument
124 if (adapter->if_ops.cleanup_if) in mwifiex_unregister()
125 adapter->if_ops.cleanup_if(adapter); in mwifiex_unregister()
127 timer_shutdown_sync(&adapter->cmd_timer); in mwifiex_unregister()
130 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_unregister()
131 mwifiex_free_curr_bcn(adapter->priv[i]); in mwifiex_unregister()
132 kfree(adapter->priv[i]); in mwifiex_unregister()
135 if (adapter->nd_info) { in mwifiex_unregister()
136 for (i = 0 ; i < adapter->nd_info->n_matches ; i++) in mwifiex_unregister()
137 kfree(adapter->nd_info->matches[i]); in mwifiex_unregister()
138 kfree(adapter->nd_info); in mwifiex_unregister()
139 adapter->nd_info = NULL; in mwifiex_unregister()
142 kfree(adapter->regd); in mwifiex_unregister()
144 kfree(adapter); in mwifiex_unregister()
148 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter) in mwifiex_queue_main_work() argument
152 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
153 if (adapter->mwifiex_processing) { in mwifiex_queue_main_work()
154 adapter->more_task_flag = true; in mwifiex_queue_main_work()
155 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
157 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_queue_main_work()
158 queue_work(adapter->workqueue, &adapter->main_work); in mwifiex_queue_main_work()
163 static void mwifiex_queue_rx_work(struct mwifiex_adapter *adapter) in mwifiex_queue_rx_work() argument
165 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
166 if (adapter->rx_processing) { in mwifiex_queue_rx_work()
167 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
169 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_queue_rx_work()
170 queue_work(adapter->rx_workqueue, &adapter->rx_work); in mwifiex_queue_rx_work()
174 static int mwifiex_process_rx(struct mwifiex_adapter *adapter) in mwifiex_process_rx() argument
179 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
180 if (adapter->rx_processing || adapter->rx_locked) { in mwifiex_process_rx()
181 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
184 adapter->rx_processing = true; in mwifiex_process_rx()
185 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
189 while ((skb = skb_dequeue(&adapter->rx_data_q))) { in mwifiex_process_rx()
190 atomic_dec(&adapter->rx_pending); in mwifiex_process_rx()
191 if ((adapter->delay_main_work || in mwifiex_process_rx()
192 adapter->iface_type == MWIFIEX_USB) && in mwifiex_process_rx()
193 (atomic_read(&adapter->rx_pending) < LOW_RX_PENDING)) { in mwifiex_process_rx()
194 if (adapter->if_ops.submit_rem_rx_urbs) in mwifiex_process_rx()
195 adapter->if_ops.submit_rem_rx_urbs(adapter); in mwifiex_process_rx()
196 adapter->delay_main_work = false; in mwifiex_process_rx()
197 mwifiex_queue_main_work(adapter); in mwifiex_process_rx()
201 if (adapter->if_ops.deaggr_pkt) in mwifiex_process_rx()
202 adapter->if_ops.deaggr_pkt(adapter, skb); in mwifiex_process_rx()
205 mwifiex_handle_rx_packet(adapter, skb); in mwifiex_process_rx()
208 spin_lock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
209 adapter->rx_processing = false; in mwifiex_process_rx()
210 spin_unlock_bh(&adapter->rx_proc_lock); in mwifiex_process_rx()
216 static void maybe_quirk_fw_disable_ds(struct mwifiex_adapter *adapter) in maybe_quirk_fw_disable_ds() argument
218 struct mwifiex_private *priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA); in maybe_quirk_fw_disable_ds()
221 if (test_and_set_bit(MWIFIEX_IS_REQUESTING_FW_VEREXT, &adapter->work_flags)) in maybe_quirk_fw_disable_ds()
228 mwifiex_dbg(priv->adapter, MSG, in maybe_quirk_fw_disable_ds()
248 int mwifiex_main_process(struct mwifiex_adapter *adapter) in mwifiex_main_process() argument
253 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
256 if (adapter->mwifiex_processing || adapter->main_locked) { in mwifiex_main_process()
257 adapter->more_task_flag = true; in mwifiex_main_process()
258 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
261 adapter->mwifiex_processing = true; in mwifiex_main_process()
262 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
266 if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY) in mwifiex_main_process()
276 if (atomic_read(&adapter->rx_pending) >= HIGH_RX_PENDING && in mwifiex_main_process()
277 adapter->iface_type != MWIFIEX_USB) { in mwifiex_main_process()
278 adapter->delay_main_work = true; in mwifiex_main_process()
279 mwifiex_queue_rx_work(adapter); in mwifiex_main_process()
284 if (adapter->int_status) { in mwifiex_main_process()
285 if (adapter->hs_activated) in mwifiex_main_process()
286 mwifiex_process_hs_config(adapter); in mwifiex_main_process()
287 if (adapter->if_ops.process_int_status) in mwifiex_main_process()
288 adapter->if_ops.process_int_status(adapter); in mwifiex_main_process()
291 if (adapter->rx_work_enabled && adapter->data_received) in mwifiex_main_process()
292 mwifiex_queue_rx_work(adapter); in mwifiex_main_process()
295 if ((adapter->ps_state == PS_STATE_SLEEP) && in mwifiex_main_process()
296 (adapter->pm_wakeup_card_req && in mwifiex_main_process()
297 !adapter->pm_wakeup_fw_try) && in mwifiex_main_process()
298 (is_command_pending(adapter) || in mwifiex_main_process()
299 !skb_queue_empty(&adapter->tx_data_q) || in mwifiex_main_process()
300 !mwifiex_bypass_txlist_empty(adapter) || in mwifiex_main_process()
301 !mwifiex_wmm_lists_empty(adapter))) { in mwifiex_main_process()
302 adapter->pm_wakeup_fw_try = true; in mwifiex_main_process()
303 mod_timer(&adapter->wakeup_timer, jiffies + (HZ*3)); in mwifiex_main_process()
304 adapter->if_ops.wakeup(adapter); in mwifiex_main_process()
308 if (IS_CARD_RX_RCVD(adapter)) { in mwifiex_main_process()
309 adapter->data_received = false; in mwifiex_main_process()
310 adapter->pm_wakeup_fw_try = false; in mwifiex_main_process()
311 timer_delete(&adapter->wakeup_timer); in mwifiex_main_process()
312 if (adapter->ps_state == PS_STATE_SLEEP) in mwifiex_main_process()
313 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_main_process()
316 if (adapter->pm_wakeup_fw_try) in mwifiex_main_process()
318 if (adapter->ps_state == PS_STATE_PRE_SLEEP) in mwifiex_main_process()
319 mwifiex_check_ps_cond(adapter); in mwifiex_main_process()
321 if (adapter->ps_state != PS_STATE_AWAKE) in mwifiex_main_process()
323 if (adapter->tx_lock_flag) { in mwifiex_main_process()
324 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_main_process()
325 if (!adapter->usb_mc_setup) in mwifiex_main_process()
331 if ((!adapter->scan_chan_gap_enabled && in mwifiex_main_process()
332 adapter->scan_processing) || adapter->data_sent || in mwifiex_main_process()
334 (mwifiex_get_priv(adapter, in mwifiex_main_process()
336 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
337 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
338 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
339 if (adapter->cmd_sent || adapter->curr_cmd || in mwifiex_main_process()
341 (mwifiex_get_priv(adapter, in mwifiex_main_process()
343 (!is_command_pending(adapter))) in mwifiex_main_process()
349 if (adapter->event_received) { in mwifiex_main_process()
350 adapter->event_received = false; in mwifiex_main_process()
351 mwifiex_process_event(adapter); in mwifiex_main_process()
355 if (adapter->cmd_resp_received) { in mwifiex_main_process()
356 adapter->cmd_resp_received = false; in mwifiex_main_process()
357 mwifiex_process_cmdresp(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 if (adapter->hs_activated_manually) { in mwifiex_main_process()
403 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
405 adapter->hs_activated_manually = false; in mwifiex_main_process()
408 mwifiex_process_tx_queue(adapter); in mwifiex_main_process()
409 if (adapter->hs_activated) { in mwifiex_main_process()
411 &adapter->work_flags); in mwifiex_main_process()
412 mwifiex_hs_activated_event(adapter, false); in mwifiex_main_process()
416 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
417 !adapter->scan_processing) && in mwifiex_main_process()
418 !adapter->data_sent && in mwifiex_main_process()
419 !mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
421 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
422 if (adapter->hs_activated_manually) { in mwifiex_main_process()
423 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
425 adapter->hs_activated_manually = false; in mwifiex_main_process()
428 mwifiex_process_bypass_tx(adapter); in mwifiex_main_process()
429 if (adapter->hs_activated) { in mwifiex_main_process()
431 &adapter->work_flags); in mwifiex_main_process()
432 mwifiex_hs_activated_event(adapter, false); in mwifiex_main_process()
436 if ((adapter->scan_chan_gap_enabled || in mwifiex_main_process()
437 !adapter->scan_processing) && in mwifiex_main_process()
438 !adapter->data_sent && !mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
440 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA))) { in mwifiex_main_process()
441 if (adapter->hs_activated_manually) { in mwifiex_main_process()
442 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY), in mwifiex_main_process()
444 adapter->hs_activated_manually = false; in mwifiex_main_process()
447 mwifiex_wmm_process_tx(adapter); in mwifiex_main_process()
448 if (adapter->hs_activated) { in mwifiex_main_process()
450 &adapter->work_flags); in mwifiex_main_process()
451 mwifiex_hs_activated_event(adapter, false); in mwifiex_main_process()
455 if (adapter->delay_null_pkt && !adapter->cmd_sent && in mwifiex_main_process()
456 !adapter->curr_cmd && !is_command_pending(adapter) && in mwifiex_main_process()
457 (mwifiex_wmm_lists_empty(adapter) && in mwifiex_main_process()
458 mwifiex_bypass_txlist_empty(adapter) && in mwifiex_main_process()
459 skb_queue_empty(&adapter->tx_data_q))) { in mwifiex_main_process()
461 (mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_main_process()
464 adapter->delay_null_pkt = false; in mwifiex_main_process()
465 adapter->ps_state = PS_STATE_SLEEP; in mwifiex_main_process()
471 spin_lock_irqsave(&adapter->main_proc_lock, flags); in mwifiex_main_process()
472 if (adapter->more_task_flag) { in mwifiex_main_process()
473 adapter->more_task_flag = false; in mwifiex_main_process()
474 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
477 adapter->mwifiex_processing = false; in mwifiex_main_process()
478 spin_unlock_irqrestore(&adapter->main_proc_lock, flags); in mwifiex_main_process()
485 * This function frees the adapter structure.
490 static void mwifiex_free_adapter(struct mwifiex_adapter *adapter) in mwifiex_free_adapter() argument
492 if (!adapter) { in mwifiex_free_adapter()
493 pr_err("%s: adapter is NULL\n", __func__); in mwifiex_free_adapter()
497 if (adapter->rgpower_data) { in mwifiex_free_adapter()
498 release_firmware(adapter->rgpower_data); in mwifiex_free_adapter()
499 adapter->rgpower_data = NULL; in mwifiex_free_adapter()
502 mwifiex_unregister(adapter); in mwifiex_free_adapter()
503 pr_debug("info: %s: free adapter\n", __func__); in mwifiex_free_adapter()
510 static void mwifiex_terminate_workqueue(struct mwifiex_adapter *adapter) in mwifiex_terminate_workqueue() argument
512 if (adapter->workqueue) { in mwifiex_terminate_workqueue()
513 destroy_workqueue(adapter->workqueue); in mwifiex_terminate_workqueue()
514 adapter->workqueue = NULL; in mwifiex_terminate_workqueue()
517 if (adapter->rx_workqueue) { in mwifiex_terminate_workqueue()
518 destroy_workqueue(adapter->rx_workqueue); in mwifiex_terminate_workqueue()
519 adapter->rx_workqueue = NULL; in mwifiex_terminate_workqueue()
522 if (adapter->host_mlme_workqueue) { in mwifiex_terminate_workqueue()
523 destroy_workqueue(adapter->host_mlme_workqueue); in mwifiex_terminate_workqueue()
524 adapter->host_mlme_workqueue = NULL; in mwifiex_terminate_workqueue()
539 struct mwifiex_adapter *adapter = context; in _mwifiex_fw_dpc() local
543 struct completion *fw_done = adapter->fw_done; in _mwifiex_fw_dpc()
546 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
547 "Failed to get firmware %s\n", adapter->fw_name); in _mwifiex_fw_dpc()
552 adapter->firmware = firmware; in _mwifiex_fw_dpc()
553 fw.fw_buf = (u8 *) adapter->firmware->data; in _mwifiex_fw_dpc()
554 fw.fw_len = adapter->firmware->size; in _mwifiex_fw_dpc()
556 if (adapter->if_ops.dnld_fw) { in _mwifiex_fw_dpc()
557 ret = adapter->if_ops.dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
559 ret = mwifiex_dnld_fw(adapter, &fw); in _mwifiex_fw_dpc()
565 mwifiex_dbg(adapter, MSG, "WLAN FW is active\n"); in _mwifiex_fw_dpc()
568 if ((request_firmware(&adapter->cal_data, cal_data_cfg, in _mwifiex_fw_dpc()
569 adapter->dev)) < 0) in _mwifiex_fw_dpc()
570 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
575 if (adapter->if_ops.enable_int) { in _mwifiex_fw_dpc()
576 if (adapter->if_ops.enable_int(adapter)) in _mwifiex_fw_dpc()
580 ret = mwifiex_init_fw(adapter); in _mwifiex_fw_dpc()
584 maybe_quirk_fw_disable_ds(adapter); in _mwifiex_fw_dpc()
586 if (!adapter->wiphy) { in _mwifiex_fw_dpc()
587 if (mwifiex_register_cfg80211(adapter)) { in _mwifiex_fw_dpc()
588 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
594 if (mwifiex_init_channel_scan_gap(adapter)) { in _mwifiex_fw_dpc()
595 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
606 wiphy_lock(adapter->wiphy); in _mwifiex_fw_dpc()
608 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "mlan%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
611 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
613 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
619 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "uap%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()
631 wdev = mwifiex_add_virtual_intf(adapter->wiphy, "p2p%d", NET_NAME_ENUM, in _mwifiex_fw_dpc()
634 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
636 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
641 wiphy_unlock(adapter->wiphy); in _mwifiex_fw_dpc()
644 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); in _mwifiex_fw_dpc()
645 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); in _mwifiex_fw_dpc()
646 adapter->is_up = true; in _mwifiex_fw_dpc()
650 kfree(adapter->chan_stats); in _mwifiex_fw_dpc()
652 wiphy_unregister(adapter->wiphy); in _mwifiex_fw_dpc()
653 wiphy_free(adapter->wiphy); in _mwifiex_fw_dpc()
655 if (adapter->if_ops.disable_int) in _mwifiex_fw_dpc()
656 adapter->if_ops.disable_int(adapter); in _mwifiex_fw_dpc()
658 mwifiex_dbg(adapter, ERROR, in _mwifiex_fw_dpc()
660 if (adapter->if_ops.unregister_dev) in _mwifiex_fw_dpc()
661 adapter->if_ops.unregister_dev(adapter); in _mwifiex_fw_dpc()
663 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in _mwifiex_fw_dpc()
664 mwifiex_terminate_workqueue(adapter); in _mwifiex_fw_dpc()
666 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in _mwifiex_fw_dpc()
668 mwifiex_shutdown_drv(adapter); in _mwifiex_fw_dpc()
669 mwifiex_free_cmd_buffers(adapter); in _mwifiex_fw_dpc()
674 if (adapter->firmware) { in _mwifiex_fw_dpc()
675 release_firmware(adapter->firmware); in _mwifiex_fw_dpc()
676 adapter->firmware = NULL; in _mwifiex_fw_dpc()
679 if (adapter->irq_wakeup >= 0) in _mwifiex_fw_dpc()
680 device_init_wakeup(adapter->dev, false); in _mwifiex_fw_dpc()
681 mwifiex_free_adapter(adapter); in _mwifiex_fw_dpc()
698 static int mwifiex_init_hw_fw(struct mwifiex_adapter *adapter, in mwifiex_init_hw_fw() argument
707 strscpy(adapter->fw_name, MFG_FIRMWARE, in mwifiex_init_hw_fw()
708 sizeof(adapter->fw_name)); in mwifiex_init_hw_fw()
711 ret = request_firmware_nowait(THIS_MODULE, 1, adapter->fw_name, in mwifiex_init_hw_fw()
712 adapter->dev, GFP_KERNEL, adapter, in mwifiex_init_hw_fw()
715 ret = request_firmware(&adapter->firmware, in mwifiex_init_hw_fw()
716 adapter->fw_name, in mwifiex_init_hw_fw()
717 adapter->dev); in mwifiex_init_hw_fw()
721 mwifiex_dbg(adapter, ERROR, "request_firmware%s error %d\n", in mwifiex_init_hw_fw()
752 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
760 mwifiex_dbg(priv->adapter, INFO, in mwifiex_close()
778 ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_bypass_tx_queue()
780 mwifiex_dbg(priv->adapter, DATA, in mwifiex_bypass_tx_queue()
785 mwifiex_dbg(priv->adapter, MSG, 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()
922 priv->adapter->fw_api_ver == MWIFIEX_FW_V15)) in mwifiex_hard_start_xmit()
936 if (ISSUPP_TDLS_ENABLED(priv->adapter->fw_cap_info) && in mwifiex_hard_start_xmit()
939 if (priv->adapter->auto_tdls && priv->check_tdls_tx) in mwifiex_hard_start_xmit()
969 } else if (priv->adapter->priv[0] != priv) { in mwifiex_set_mac_address()
984 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_set_mac_address()
1035 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1042 priv->adapter->if_ops.card_reset) { in mwifiex_tx_timeout()
1043 mwifiex_dbg(priv->adapter, ERROR, in mwifiex_tx_timeout()
1046 priv->adapter->if_ops.card_reset(priv->adapter); in mwifiex_tx_timeout()
1050 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter) in mwifiex_multi_chan_resync() argument
1052 struct usb_card_rec *card = adapter->card; in mwifiex_multi_chan_resync()
1060 mwifiex_dbg(adapter, WARN, "pending data urb in sys\n"); in mwifiex_multi_chan_resync()
1067 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_multi_chan_resync()
1071 mwifiex_dbg(adapter, ERROR, in mwifiex_multi_chan_resync()
1076 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter) in mwifiex_upload_device_dump() argument
1081 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1083 dev_coredumpv(adapter->dev, adapter->devdump_data, adapter->devdump_len, in mwifiex_upload_device_dump()
1085 mwifiex_dbg(adapter, MSG, in mwifiex_upload_device_dump()
1089 * after 5 min. Here reset adapter->devdump_data and ->devdump_len in mwifiex_upload_device_dump()
1092 adapter->devdump_data = NULL; in mwifiex_upload_device_dump()
1093 adapter->devdump_len = 0; in mwifiex_upload_device_dump()
1097 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter) in mwifiex_drv_info_dump() argument
1108 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump start===\n"); in mwifiex_drv_info_dump()
1110 p = adapter->devdump_data; in mwifiex_drv_info_dump()
1115 mwifiex_drv_get_driver_version(adapter, drv_version, in mwifiex_drv_info_dump()
1119 if (adapter->iface_type == MWIFIEX_USB) { in mwifiex_drv_info_dump()
1120 cardp = (struct usb_card_rec *)adapter->card; in mwifiex_drv_info_dump()
1134 atomic_read(&adapter->tx_pending)); in mwifiex_drv_info_dump()
1136 atomic_read(&adapter->rx_pending)); in mwifiex_drv_info_dump()
1138 if (adapter->iface_type == MWIFIEX_SDIO) { in mwifiex_drv_info_dump()
1139 sdio_card = (struct sdio_mmc_card *)adapter->card; in mwifiex_drv_info_dump()
1146 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1147 if (!adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1149 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1174 if (adapter->iface_type == MWIFIEX_SDIO || in mwifiex_drv_info_dump()
1175 adapter->iface_type == MWIFIEX_PCIE) { in mwifiex_drv_info_dump()
1177 adapter->iface_type == MWIFIEX_SDIO ? in mwifiex_drv_info_dump()
1179 if (adapter->if_ops.reg_dump) in mwifiex_drv_info_dump()
1180 p += adapter->if_ops.reg_dump(adapter, p); in mwifiex_drv_info_dump()
1185 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_drv_info_dump()
1186 if (!adapter->priv[i]->netdev) in mwifiex_drv_info_dump()
1188 priv = adapter->priv[i]; in mwifiex_drv_info_dump()
1198 mwifiex_dbg(adapter, MSG, "===mwifiex driverinfo dump end===\n"); in mwifiex_drv_info_dump()
1199 adapter->devdump_len = p - (char *)adapter->devdump_data; in mwifiex_drv_info_dump()
1203 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter) in mwifiex_prepare_fw_dump_info() argument
1209 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1211 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1222 if (dump_len + 1 + adapter->devdump_len > MWIFIEX_FW_DUMP_SIZE) { in mwifiex_prepare_fw_dump_info()
1224 fw_dump_ptr = vzalloc(dump_len + 1 + adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1225 mwifiex_dbg(adapter, MSG, "Realloc device dump data.\n"); in mwifiex_prepare_fw_dump_info()
1227 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1228 mwifiex_dbg(adapter, ERROR, in mwifiex_prepare_fw_dump_info()
1233 memmove(fw_dump_ptr, adapter->devdump_data, in mwifiex_prepare_fw_dump_info()
1234 adapter->devdump_len); in mwifiex_prepare_fw_dump_info()
1235 vfree(adapter->devdump_data); in mwifiex_prepare_fw_dump_info()
1236 adapter->devdump_data = fw_dump_ptr; in mwifiex_prepare_fw_dump_info()
1239 fw_dump_ptr = (char *)adapter->devdump_data + adapter->devdump_len; in mwifiex_prepare_fw_dump_info()
1241 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1243 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1263 adapter->devdump_len = fw_dump_ptr - (char *)adapter->devdump_data; in mwifiex_prepare_fw_dump_info()
1265 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_prepare_fw_dump_info()
1267 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_prepare_fw_dump_info()
1345 ether_addr_copy(priv->curr_addr, priv->adapter->perm_addr); in mwifiex_init_priv_params()
1358 int is_command_pending(struct mwifiex_adapter *adapter) in is_command_pending() argument
1362 spin_lock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1363 is_cmd_pend_q_empty = list_empty(&adapter->cmd_pending_q); in is_command_pending()
1364 spin_unlock_bh(&adapter->cmd_pending_q_lock); in is_command_pending()
1374 struct mwifiex_adapter *adapter = in mwifiex_host_mlme_work_queue() local
1377 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_host_mlme_work_queue()
1381 if (adapter->host_mlme_link_lost) { in mwifiex_host_mlme_work_queue()
1382 if (adapter->priv_link_lost) { in mwifiex_host_mlme_work_queue()
1383 mwifiex_reset_connect_state(adapter->priv_link_lost, in mwifiex_host_mlme_work_queue()
1386 adapter->priv_link_lost = NULL; in mwifiex_host_mlme_work_queue()
1388 adapter->host_mlme_link_lost = false; in mwifiex_host_mlme_work_queue()
1392 if (adapter->assoc_resp_received) { in mwifiex_host_mlme_work_queue()
1393 mwifiex_process_assoc_resp(adapter); in mwifiex_host_mlme_work_queue()
1394 adapter->assoc_resp_received = false; in mwifiex_host_mlme_work_queue()
1405 struct mwifiex_adapter *adapter = in mwifiex_rx_work_queue() local
1408 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_rx_work_queue()
1410 mwifiex_process_rx(adapter); in mwifiex_rx_work_queue()
1421 struct mwifiex_adapter *adapter = in mwifiex_main_work_queue() local
1424 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_main_work_queue()
1426 mwifiex_main_process(adapter); in mwifiex_main_work_queue()
1430 static void mwifiex_uninit_sw(struct mwifiex_adapter *adapter) in mwifiex_uninit_sw() argument
1438 if (adapter->if_ops.disable_int) in mwifiex_uninit_sw()
1439 adapter->if_ops.disable_int(adapter); in mwifiex_uninit_sw()
1441 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_uninit_sw()
1442 mwifiex_terminate_workqueue(adapter); in mwifiex_uninit_sw()
1443 adapter->int_status = 0; in mwifiex_uninit_sw()
1446 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1447 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1449 mwifiex_stop_net_dev_queue(priv->netdev, adapter); in mwifiex_uninit_sw()
1456 mwifiex_dbg(adapter, CMD, "cmd: calling mwifiex_shutdown_drv...\n"); in mwifiex_uninit_sw()
1457 mwifiex_shutdown_drv(adapter); in mwifiex_uninit_sw()
1458 mwifiex_dbg(adapter, CMD, "cmd: mwifiex_shutdown_drv done\n"); in mwifiex_uninit_sw()
1460 if (atomic_read(&adapter->rx_pending) || in mwifiex_uninit_sw()
1461 atomic_read(&adapter->tx_pending) || in mwifiex_uninit_sw()
1462 atomic_read(&adapter->cmd_pending)) { in mwifiex_uninit_sw()
1463 mwifiex_dbg(adapter, ERROR, in mwifiex_uninit_sw()
1466 atomic_read(&adapter->rx_pending), in mwifiex_uninit_sw()
1467 atomic_read(&adapter->tx_pending), in mwifiex_uninit_sw()
1468 atomic_read(&adapter->cmd_pending)); in mwifiex_uninit_sw()
1471 for (i = 0; i < adapter->priv_num; i++) { in mwifiex_uninit_sw()
1472 priv = adapter->priv[i]; in mwifiex_uninit_sw()
1482 wiphy_lock(adapter->wiphy); in mwifiex_uninit_sw()
1483 mwifiex_del_virtual_intf(adapter->wiphy, &priv->wdev); in mwifiex_uninit_sw()
1484 wiphy_unlock(adapter->wiphy); in mwifiex_uninit_sw()
1489 wiphy_unregister(adapter->wiphy); in mwifiex_uninit_sw()
1490 wiphy_free(adapter->wiphy); in mwifiex_uninit_sw()
1491 adapter->wiphy = NULL; in mwifiex_uninit_sw()
1493 kfree(adapter->chan_stats); in mwifiex_uninit_sw()
1494 mwifiex_free_cmd_buffers(adapter); in mwifiex_uninit_sw()
1498 * This function can be used for shutting down the adapter SW.
1500 int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter) in mwifiex_shutdown_sw() argument
1504 if (!adapter) in mwifiex_shutdown_sw()
1507 wait_for_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1509 reinit_completion(adapter->fw_done); in mwifiex_shutdown_sw()
1511 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_shutdown_sw()
1516 mwifiex_uninit_sw(adapter); in mwifiex_shutdown_sw()
1517 adapter->is_up = false; in mwifiex_shutdown_sw()
1519 if (adapter->if_ops.down_dev) in mwifiex_shutdown_sw()
1520 adapter->if_ops.down_dev(adapter); in mwifiex_shutdown_sw()
1526 /* This function can be used for reinitting the adapter SW. Required
1530 mwifiex_reinit_sw(struct mwifiex_adapter *adapter) in mwifiex_reinit_sw() argument
1534 mwifiex_init_lock_list(adapter); in mwifiex_reinit_sw()
1535 if (adapter->if_ops.up_dev) in mwifiex_reinit_sw()
1536 adapter->if_ops.up_dev(adapter); in mwifiex_reinit_sw()
1538 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_reinit_sw()
1539 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1540 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_reinit_sw()
1541 adapter->hs_activated = false; in mwifiex_reinit_sw()
1542 clear_bit(MWIFIEX_IS_CMD_TIMEDOUT, &adapter->work_flags); in mwifiex_reinit_sw()
1543 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_reinit_sw()
1544 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_reinit_sw()
1545 adapter->cmd_wait_q.status = 0; in mwifiex_reinit_sw()
1546 adapter->scan_wait_q_woken = false; in mwifiex_reinit_sw()
1548 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_reinit_sw()
1549 adapter->rx_work_enabled = true; in mwifiex_reinit_sw()
1551 adapter->workqueue = in mwifiex_reinit_sw()
1554 if (!adapter->workqueue) in mwifiex_reinit_sw()
1557 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_reinit_sw()
1559 if (adapter->rx_work_enabled) { in mwifiex_reinit_sw()
1560 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_reinit_sw()
1564 if (!adapter->rx_workqueue) in mwifiex_reinit_sw()
1566 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_reinit_sw()
1569 if (adapter->host_mlme_enabled) { in mwifiex_reinit_sw()
1570 adapter->host_mlme_workqueue = in mwifiex_reinit_sw()
1575 if (!adapter->host_mlme_workqueue) in mwifiex_reinit_sw()
1577 INIT_WORK(&adapter->host_mlme_work, in mwifiex_reinit_sw()
1585 mwifiex_dbg(adapter, INFO, "%s, mwifiex_init_hw_fw()...\n", __func__); in mwifiex_reinit_sw()
1587 if (mwifiex_init_hw_fw(adapter, false)) { in mwifiex_reinit_sw()
1588 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1594 ret = _mwifiex_fw_dpc(adapter->firmware, adapter); in mwifiex_reinit_sw()
1596 pr_err("Failed to bring up adapter: %d\n", ret); in mwifiex_reinit_sw()
1599 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); in mwifiex_reinit_sw()
1604 mwifiex_dbg(adapter, ERROR, "info: %s: unregister device\n", __func__); in mwifiex_reinit_sw()
1605 if (adapter->if_ops.unregister_dev) in mwifiex_reinit_sw()
1606 adapter->if_ops.unregister_dev(adapter); in mwifiex_reinit_sw()
1609 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_reinit_sw()
1610 mwifiex_terminate_workqueue(adapter); in mwifiex_reinit_sw()
1611 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_reinit_sw()
1612 mwifiex_dbg(adapter, ERROR, in mwifiex_reinit_sw()
1614 mwifiex_shutdown_drv(adapter); in mwifiex_reinit_sw()
1615 mwifiex_free_cmd_buffers(adapter); in mwifiex_reinit_sw()
1618 complete_all(adapter->fw_done); in mwifiex_reinit_sw()
1619 mwifiex_dbg(adapter, INFO, "%s, error\n", __func__); in mwifiex_reinit_sw()
1627 struct mwifiex_adapter *adapter = priv; in mwifiex_irq_wakeup_handler() local
1629 dev_dbg(adapter->dev, "%s: wake by wifi", __func__); in mwifiex_irq_wakeup_handler()
1630 adapter->wake_by_wifi = true; in mwifiex_irq_wakeup_handler()
1634 pm_wakeup_event(adapter->dev, 0); in mwifiex_irq_wakeup_handler()
1640 static void mwifiex_probe_of(struct mwifiex_adapter *adapter) in mwifiex_probe_of() argument
1643 struct device *dev = adapter->dev; in mwifiex_probe_of()
1648 adapter->dt_node = dev->of_node; in mwifiex_probe_of()
1649 adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0); in mwifiex_probe_of()
1650 if (!adapter->irq_wakeup) { in mwifiex_probe_of()
1655 ret = devm_request_irq(dev, adapter->irq_wakeup, in mwifiex_probe_of()
1658 "wifi_wake", adapter); in mwifiex_probe_of()
1661 adapter->irq_wakeup, ret); in mwifiex_probe_of()
1672 adapter->irq_wakeup = -1; in mwifiex_probe_of()
1681 * adapter structure
1693 struct mwifiex_adapter *adapter; in mwifiex_add_card() local
1695 if (mwifiex_register(card, dev, if_ops, (void **)&adapter)) { in mwifiex_add_card()
1700 mwifiex_probe_of(adapter); in mwifiex_add_card()
1702 adapter->iface_type = iface_type; in mwifiex_add_card()
1703 adapter->fw_done = fw_done; in mwifiex_add_card()
1705 adapter->hw_status = MWIFIEX_HW_STATUS_INITIALIZING; in mwifiex_add_card()
1706 clear_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1707 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_add_card()
1708 adapter->hs_activated = false; in mwifiex_add_card()
1709 init_waitqueue_head(&adapter->hs_activate_wait_q); in mwifiex_add_card()
1710 init_waitqueue_head(&adapter->cmd_wait_q.wait); in mwifiex_add_card()
1711 adapter->cmd_wait_q.status = 0; in mwifiex_add_card()
1712 adapter->scan_wait_q_woken = false; in mwifiex_add_card()
1714 if ((num_possible_cpus() > 1) || adapter->iface_type == MWIFIEX_USB) in mwifiex_add_card()
1715 adapter->rx_work_enabled = true; in mwifiex_add_card()
1717 adapter->workqueue = in mwifiex_add_card()
1720 if (!adapter->workqueue) in mwifiex_add_card()
1723 INIT_WORK(&adapter->main_work, mwifiex_main_work_queue); in mwifiex_add_card()
1725 if (adapter->rx_work_enabled) { in mwifiex_add_card()
1726 adapter->rx_workqueue = alloc_workqueue("MWIFIEX_RX_WORK_QUEUE", in mwifiex_add_card()
1730 if (!adapter->rx_workqueue) in mwifiex_add_card()
1733 INIT_WORK(&adapter->rx_work, mwifiex_rx_work_queue); in mwifiex_add_card()
1738 if (adapter->if_ops.register_dev(adapter)) { in mwifiex_add_card()
1743 if (adapter->host_mlme_enabled) { in mwifiex_add_card()
1744 adapter->host_mlme_workqueue = in mwifiex_add_card()
1749 if (!adapter->host_mlme_workqueue) in mwifiex_add_card()
1751 INIT_WORK(&adapter->host_mlme_work, in mwifiex_add_card()
1755 if (mwifiex_init_hw_fw(adapter, true)) { in mwifiex_add_card()
1764 if (adapter->if_ops.unregister_dev) in mwifiex_add_card()
1765 adapter->if_ops.unregister_dev(adapter); in mwifiex_add_card()
1767 set_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags); in mwifiex_add_card()
1768 mwifiex_terminate_workqueue(adapter); in mwifiex_add_card()
1769 if (adapter->hw_status == MWIFIEX_HW_STATUS_READY) { in mwifiex_add_card()
1771 mwifiex_shutdown_drv(adapter); in mwifiex_add_card()
1772 mwifiex_free_cmd_buffers(adapter); in mwifiex_add_card()
1775 if (adapter->irq_wakeup >= 0) in mwifiex_add_card()
1776 device_init_wakeup(adapter->dev, false); in mwifiex_add_card()
1777 mwifiex_free_adapter(adapter); in mwifiex_add_card()
1794 * - Free the adapter structure
1796 int mwifiex_remove_card(struct mwifiex_adapter *adapter) in mwifiex_remove_card() argument
1798 if (!adapter) in mwifiex_remove_card()
1801 if (adapter->is_up) in mwifiex_remove_card()
1802 mwifiex_uninit_sw(adapter); in mwifiex_remove_card()
1804 if (adapter->irq_wakeup >= 0) in mwifiex_remove_card()
1805 device_init_wakeup(adapter->dev, false); in mwifiex_remove_card()
1808 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1810 if (adapter->if_ops.unregister_dev) in mwifiex_remove_card()
1811 adapter->if_ops.unregister_dev(adapter); in mwifiex_remove_card()
1812 /* Free adapter structure */ in mwifiex_remove_card()
1813 mwifiex_dbg(adapter, INFO, in mwifiex_remove_card()
1814 "info: free adapter\n"); in mwifiex_remove_card()
1815 mwifiex_free_adapter(adapter); in mwifiex_remove_card()
1821 void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask, in _mwifiex_dbg() argument
1827 if (!(adapter->debug_mask & mask)) in _mwifiex_dbg()
1835 if (adapter->dev) in _mwifiex_dbg()
1836 dev_info(adapter->dev, "%pV", &vaf); in _mwifiex_dbg()