Lines Matching +full:firmware +full:- +full:initialized

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
9 #include <linux/firmware.h>
21 #define WILC1000_FW_PREFIX "atmel/wilc1000_wifi_firmware-"
29 struct wilc *wilc = vif->wilc; in isr_uh_routine()
31 if (wilc->close) { in isr_uh_routine()
42 struct wilc *wilc = vif->wilc; in isr_bh_routine()
44 if (wilc->close) { in isr_bh_routine()
57 struct wilc *wl = vif->wilc; in init_irq()
60 ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine, in init_irq()
68 netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n", wl->dev_irq_num); in init_irq()
76 struct wilc *wilc = vif->wilc; in deinit_irq()
79 if (wilc->dev_irq_num) in deinit_irq()
80 free_irq(wilc->dev_irq_num, wilc); in deinit_irq()
88 if (wilc->mac_status == WILC_MAC_STATUS_INIT) { in wilc_mac_indicate()
89 wilc->mac_status = status; in wilc_mac_indicate()
90 complete(&wilc->sync_event); in wilc_mac_indicate()
92 wilc->mac_status = status; in wilc_mac_indicate()
102 list_for_each_entry_rcu(vif, &wilc->vif_list, list) { in get_if_handler()
103 if (vif->mode == WILC_STATION_MODE) in get_if_handler()
104 if (ether_addr_equal_unaligned(h->addr2, vif->bssid)) { in get_if_handler()
105 ndev = vif->ndev; in get_if_handler()
108 if (vif->mode == WILC_AP_MODE) in get_if_handler()
109 if (ether_addr_equal_unaligned(h->addr1, vif->bssid)) { in get_if_handler()
110 ndev = vif->ndev; in get_if_handler()
123 ether_addr_copy(vif->bssid, bssid); in wilc_wlan_set_bssid()
125 eth_zero_addr(vif->bssid); in wilc_wlan_set_bssid()
127 vif->mode = mode; in wilc_wlan_set_bssid()
136 srcu_idx = srcu_read_lock(&wilc->srcu); in wilc_wlan_get_num_conn_ifcs()
137 list_for_each_entry_rcu(vif, &wilc->vif_list, list) { in wilc_wlan_get_num_conn_ifcs()
138 if (!is_zero_ether_addr(vif->bssid)) in wilc_wlan_get_num_conn_ifcs()
141 srcu_read_unlock(&wilc->srcu, srcu_idx); in wilc_wlan_get_num_conn_ifcs()
151 complete(&wl->txq_thread_started); in wilc_txq_task()
153 wait_for_completion(&wl->txq_event); in wilc_txq_task()
155 if (wl->close) { in wilc_txq_task()
156 complete(&wl->txq_thread_started); in wilc_txq_task()
168 srcu_idx = srcu_read_lock(&wl->srcu); in wilc_txq_task()
169 list_for_each_entry_rcu(ifc, &wl->vif_list, in wilc_txq_task()
171 if (ifc->mac_opened && ifc->ndev) in wilc_txq_task()
172 netif_wake_queue(ifc->ndev); in wilc_txq_task()
174 srcu_read_unlock(&wl->srcu, srcu_idx); in wilc_txq_task()
176 } while (ret == WILC_VMM_ENTRY_FULL_RETRY && !wl->close); in wilc_txq_task()
184 struct wilc *wilc = vif->wilc; in wilc_wlan_get_firmware()
186 const struct firmware *wilc_fw; in wilc_wlan_get_firmware()
191 netdev_info(dev, "ChipID [%x] loading firmware [%s]\n", chip_id, in wilc_wlan_get_firmware()
195 wilc->dev); in wilc_wlan_get_firmware()
197 netdev_err(dev, "%s - firmware not available\n", in wilc_wlan_get_firmware()
199 return -EINVAL; in wilc_wlan_get_firmware()
201 wilc->firmware = wilc_fw; in wilc_wlan_get_firmware()
209 struct wilc *wilc = vif->wilc; in wilc_start_firmware()
216 if (!wait_for_completion_timeout(&wilc->sync_event, in wilc_start_firmware()
218 return -ETIME; in wilc_start_firmware()
226 struct wilc *wilc = vif->wilc; in wilc1000_firmware_download()
229 if (!wilc->firmware) { in wilc1000_firmware_download()
230 netdev_err(dev, "Firmware buffer is NULL\n"); in wilc1000_firmware_download()
231 return -ENOBUFS; in wilc1000_firmware_download()
234 ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data, in wilc1000_firmware_download()
235 wilc->firmware->size); in wilc1000_firmware_download()
239 release_firmware(wilc->firmware); in wilc1000_firmware_download()
240 wilc->firmware = NULL; in wilc1000_firmware_download()
249 struct wilc_priv *priv = &vif->priv; in wilc_init_fw_config()
255 netdev_dbg(dev, "Start configuring Firmware\n"); in wilc_init_fw_config()
256 hif_drv = (struct host_if_drv *)priv->hif_drv; in wilc_init_fw_config()
259 w = vif->iftype; in wilc_init_fw_config()
415 return -EINVAL; in wilc_init_fw_config()
421 struct wilc *wl = vif->wilc; in wlan_deinitialize_threads()
423 wl->close = 1; in wlan_deinitialize_threads()
425 complete(&wl->txq_event); in wlan_deinitialize_threads()
427 if (wl->txq_thread) { in wlan_deinitialize_threads()
428 kthread_stop(wl->txq_thread); in wlan_deinitialize_threads()
429 wl->txq_thread = NULL; in wlan_deinitialize_threads()
436 struct wilc *wl = vif->wilc; in wilc_wlan_deinitialize()
443 if (wl->initialized) { in wilc_wlan_deinitialize()
446 if (!wl->dev_irq_num && in wilc_wlan_deinitialize()
447 wl->hif_func->disable_interrupt) { in wilc_wlan_deinitialize()
448 mutex_lock(&wl->hif_cs); in wilc_wlan_deinitialize()
449 wl->hif_func->disable_interrupt(wl); in wilc_wlan_deinitialize()
450 mutex_unlock(&wl->hif_cs); in wilc_wlan_deinitialize()
452 complete(&wl->txq_event); in wilc_wlan_deinitialize()
460 wl->initialized = false; in wilc_wlan_deinitialize()
464 netdev_dbg(dev, "wilc1000 is not initialized\n"); in wilc_wlan_deinitialize()
471 struct wilc *wilc = vif->wilc; in wlan_initialize_threads()
473 wilc->txq_thread = kthread_run(wilc_txq_task, (void *)wilc, in wlan_initialize_threads()
475 if (IS_ERR(wilc->txq_thread)) { in wlan_initialize_threads()
477 wilc->close = 0; in wlan_initialize_threads()
478 return PTR_ERR(wilc->txq_thread); in wlan_initialize_threads()
480 wait_for_completion(&wilc->txq_thread_started); in wlan_initialize_threads()
488 struct wilc *wl = vif->wilc; in wilc_wlan_initialize()
490 if (!wl->initialized) { in wilc_wlan_initialize()
491 wl->mac_status = WILC_MAC_STATUS_INIT; in wilc_wlan_initialize()
492 wl->close = 0; in wilc_wlan_initialize()
502 if (wl->dev_irq_num && init_irq(dev)) { in wilc_wlan_initialize()
503 ret = -EIO; in wilc_wlan_initialize()
507 if (!wl->dev_irq_num && in wilc_wlan_initialize()
508 wl->hif_func->enable_interrupt && in wilc_wlan_initialize()
509 wl->hif_func->enable_interrupt(wl)) { in wilc_wlan_initialize()
510 ret = -EIO; in wilc_wlan_initialize()
534 netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver); in wilc_wlan_initialize()
539 netdev_err(dev, "Failed to configure firmware\n"); in wilc_wlan_initialize()
542 wl->initialized = true; in wilc_wlan_initialize()
549 if (!wl->dev_irq_num && in wilc_wlan_initialize()
550 wl->hif_func->disable_interrupt) in wilc_wlan_initialize()
551 wl->hif_func->disable_interrupt(wl); in wilc_wlan_initialize()
553 if (wl->dev_irq_num) in wilc_wlan_initialize()
561 netdev_dbg(dev, "wilc1000 already initialized\n"); in wilc_wlan_initialize()
577 struct wilc *wl = vif->wilc; in wilc_mac_open()
582 if (!wl || !wl->dev) { in wilc_mac_open()
584 return -ENODEV; in wilc_mac_open()
599 wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype, in wilc_mac_open()
600 vif->idx); in wilc_mac_open()
603 ether_addr_copy(ndev->dev_addr, mac_add); in wilc_mac_open()
605 if (!is_valid_ether_addr(ndev->dev_addr)) { in wilc_mac_open()
609 return -EINVAL; in wilc_mac_open()
612 mgmt_regs.interface_stypes = vif->mgmt_reg_stypes; in wilc_mac_open()
614 vif->mgmt_reg_stypes = 0; in wilc_mac_open()
615 wilc_update_mgmt_frame_registrations(vif->ndev->ieee80211_ptr->wiphy, in wilc_mac_open()
616 vif->ndev->ieee80211_ptr, in wilc_mac_open()
619 wl->open_ifcs++; in wilc_mac_open()
620 vif->mac_opened = 1; in wilc_mac_open()
628 return &vif->netstats; in mac_stats()
639 if (dev->flags & IFF_PROMISC) in wilc_set_multicast_list()
642 if (dev->flags & IFF_ALLMULTI || in wilc_set_multicast_list()
643 dev->mc.count > WILC_MULTICAST_TABLE_SIZE) { in wilc_set_multicast_list()
648 if (dev->mc.count == 0) { in wilc_set_multicast_list()
653 mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_ATOMIC); in wilc_set_multicast_list()
660 memcpy(cur_mc, ha->addr, ETH_ALEN); in wilc_set_multicast_list()
666 if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list)) in wilc_set_multicast_list()
674 dev_kfree_skb(pv_data->skb); in wilc_tx_complete()
681 struct wilc *wilc = vif->wilc; in wilc_mac_xmit()
685 if (skb->dev != ndev) { in wilc_mac_xmit()
697 tx_data->buff = skb->data; in wilc_mac_xmit()
698 tx_data->size = skb->len; in wilc_mac_xmit()
699 tx_data->skb = skb; in wilc_mac_xmit()
701 vif->netstats.tx_packets++; in wilc_mac_xmit()
702 vif->netstats.tx_bytes += tx_data->size; in wilc_mac_xmit()
704 tx_data->buff, tx_data->size, in wilc_mac_xmit()
711 srcu_idx = srcu_read_lock(&wilc->srcu); in wilc_mac_xmit()
712 list_for_each_entry_rcu(vif, &wilc->vif_list, list) { in wilc_mac_xmit()
713 if (vif->mac_opened) in wilc_mac_xmit()
714 netif_stop_queue(vif->ndev); in wilc_mac_xmit()
716 srcu_read_unlock(&wilc->srcu, srcu_idx); in wilc_mac_xmit()
725 struct wilc *wl = vif->wilc; in wilc_mac_close()
729 if (wl->open_ifcs > 0) in wilc_mac_close()
730 wl->open_ifcs--; in wilc_mac_close()
734 if (vif->ndev) { in wilc_mac_close()
735 netif_stop_queue(vif->ndev); in wilc_mac_close()
737 wilc_deinit_host_int(vif->ndev); in wilc_mac_close()
740 if (wl->open_ifcs == 0) { in wilc_mac_close()
742 wl->close = 1; in wilc_mac_close()
746 vif->mac_opened = 0; in wilc_mac_close()
779 skb->dev = wilc_netdev; in wilc_frmw_to_host()
783 skb->protocol = eth_type_trans(skb, wilc_netdev); in wilc_frmw_to_host()
784 vif->netstats.rx_packets++; in wilc_frmw_to_host()
785 vif->netstats.rx_bytes += frame_len; in wilc_frmw_to_host()
786 skb->ip_summed = CHECKSUM_UNNECESSARY; in wilc_frmw_to_host()
797 srcu_idx = srcu_read_lock(&wilc->srcu); in wilc_wfi_mgmt_rx()
798 list_for_each_entry_rcu(vif, &wilc->vif_list, list) { in wilc_wfi_mgmt_rx()
802 if (vif->priv.p2p_listen_state && in wilc_wfi_mgmt_rx()
803 vif->mgmt_reg_stypes & type_bit) in wilc_wfi_mgmt_rx()
806 if (vif->monitor_flag) in wilc_wfi_mgmt_rx()
807 wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size); in wilc_wfi_mgmt_rx()
809 srcu_read_unlock(&wilc->srcu, srcu_idx); in wilc_wfi_mgmt_rx()
829 if (wilc->firmware) { in wilc_netdev_cleanup()
830 release_firmware(wilc->firmware); in wilc_netdev_cleanup()
831 wilc->firmware = NULL; in wilc_netdev_cleanup()
834 srcu_idx = srcu_read_lock(&wilc->srcu); in wilc_netdev_cleanup()
835 list_for_each_entry_rcu(vif, &wilc->vif_list, list) { in wilc_netdev_cleanup()
836 if (vif->ndev) in wilc_netdev_cleanup()
837 unregister_netdev(vif->ndev); in wilc_netdev_cleanup()
839 srcu_read_unlock(&wilc->srcu, srcu_idx); in wilc_netdev_cleanup()
842 flush_workqueue(wilc->hif_workqueue); in wilc_netdev_cleanup()
843 destroy_workqueue(wilc->hif_workqueue); in wilc_netdev_cleanup()
846 mutex_lock(&wilc->vif_mutex); in wilc_netdev_cleanup()
847 if (wilc->vif_num <= 0) { in wilc_netdev_cleanup()
848 mutex_unlock(&wilc->vif_mutex); in wilc_netdev_cleanup()
853 list_del_rcu(&vif->list); in wilc_netdev_cleanup()
855 wilc->vif_num--; in wilc_netdev_cleanup()
856 mutex_unlock(&wilc->vif_mutex); in wilc_netdev_cleanup()
857 synchronize_srcu(&wilc->srcu); in wilc_netdev_cleanup()
863 kfree(wilc->bus_data); in wilc_netdev_cleanup()
864 wiphy_unregister(wilc->wiphy); in wilc_netdev_cleanup()
865 wiphy_free(wilc->wiphy); in wilc_netdev_cleanup()
875 srcu_idx = srcu_read_lock(&wl->srcu); in wilc_get_available_idx()
876 list_for_each_entry_rcu(vif, &wl->vif_list, list) { in wilc_get_available_idx()
877 if (vif->idx == 0) in wilc_get_available_idx()
882 srcu_read_unlock(&wl->srcu, srcu_idx); in wilc_get_available_idx()
896 return ERR_PTR(-ENOMEM); in wilc_netdev_ifc_init()
899 ndev->ieee80211_ptr = &vif->priv.wdev; in wilc_netdev_ifc_init()
900 strcpy(ndev->name, name); in wilc_netdev_ifc_init()
901 vif->wilc = wl; in wilc_netdev_ifc_init()
902 vif->ndev = ndev; in wilc_netdev_ifc_init()
903 ndev->ml_priv = vif; in wilc_netdev_ifc_init()
905 ndev->netdev_ops = &wilc_netdev_ops; in wilc_netdev_ifc_init()
907 SET_NETDEV_DEV(ndev, wiphy_dev(wl->wiphy)); in wilc_netdev_ifc_init()
909 vif->priv.wdev.wiphy = wl->wiphy; in wilc_netdev_ifc_init()
910 vif->priv.wdev.netdev = ndev; in wilc_netdev_ifc_init()
911 vif->priv.wdev.iftype = type; in wilc_netdev_ifc_init()
912 vif->priv.dev = ndev; in wilc_netdev_ifc_init()
921 return ERR_PTR(-EFAULT); in wilc_netdev_ifc_init()
924 ndev->needs_free_netdev = true; in wilc_netdev_ifc_init()
925 vif->iftype = vif_type; in wilc_netdev_ifc_init()
926 vif->idx = wilc_get_available_idx(wl); in wilc_netdev_ifc_init()
927 vif->mac_opened = 0; in wilc_netdev_ifc_init()
928 mutex_lock(&wl->vif_mutex); in wilc_netdev_ifc_init()
929 list_add_tail_rcu(&vif->list, &wl->vif_list); in wilc_netdev_ifc_init()
930 wl->vif_num += 1; in wilc_netdev_ifc_init()
931 mutex_unlock(&wl->vif_mutex); in wilc_netdev_ifc_init()
932 synchronize_srcu(&wl->srcu); in wilc_netdev_ifc_init()