1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries.
8 #include <linux/kthread.h>
9 #include <linux/firmware.h>
10 #include <linux/netdevice.h>
11 #include <linux/inetdevice.h>
16 #define WILC_MULTICAST_TABLE_SIZE 8
18 static irqreturn_t isr_uh_routine(int irq, void *user_data)
20 struct net_device *dev = user_data;
21 struct wilc_vif *vif = netdev_priv(dev);
22 struct wilc *wilc = vif->wilc;
25 netdev_err(dev, "Can't handle UH interrupt\n");
28 return IRQ_WAKE_THREAD;
31 static irqreturn_t isr_bh_routine(int irq, void *userdata)
33 struct net_device *dev = userdata;
34 struct wilc_vif *vif = netdev_priv(userdata);
35 struct wilc *wilc = vif->wilc;
38 netdev_err(dev, "Can't handle BH interrupt\n");
42 wilc_handle_isr(wilc);
47 static int init_irq(struct net_device *dev)
50 struct wilc_vif *vif = netdev_priv(dev);
51 struct wilc *wl = vif->wilc;
53 ret = gpiod_direction_input(wl->gpio_irq);
55 netdev_err(dev, "could not obtain gpio for WILC_INTR\n");
59 wl->dev_irq_num = gpiod_to_irq(wl->gpio_irq);
61 ret = request_threaded_irq(wl->dev_irq_num, isr_uh_routine,
63 IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
66 netdev_err(dev, "Failed to request IRQ\n");
68 netdev_dbg(dev, "IRQ request succeeded IRQ-NUM= %d\n",
74 static void deinit_irq(struct net_device *dev)
76 struct wilc_vif *vif = netdev_priv(dev);
77 struct wilc *wilc = vif->wilc;
79 /* Deinitialize IRQ */
80 if (wilc->dev_irq_num)
81 free_irq(wilc->dev_irq_num, wilc);
84 void wilc_mac_indicate(struct wilc *wilc)
88 wilc_wlan_cfg_get_val(wilc, WID_STATUS, &status, 1);
89 if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
90 wilc->mac_status = status;
91 complete(&wilc->sync_event);
93 wilc->mac_status = status;
97 static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
99 struct net_device *ndev = NULL;
100 struct wilc_vif *vif;
101 struct ieee80211_hdr *h = (struct ieee80211_hdr *)mac_header;
103 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
104 if (vif->mode == WILC_STATION_MODE)
105 if (ether_addr_equal_unaligned(h->addr2, vif->bssid)) {
109 if (vif->mode == WILC_AP_MODE)
110 if (ether_addr_equal_unaligned(h->addr1, vif->bssid)) {
119 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
121 struct wilc_vif *vif = netdev_priv(wilc_netdev);
124 ether_addr_copy(vif->bssid, bssid);
126 eth_zero_addr(vif->bssid);
131 int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
135 struct wilc_vif *vif;
137 srcu_idx = srcu_read_lock(&wilc->srcu);
138 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
139 if (!is_zero_ether_addr(vif->bssid))
142 srcu_read_unlock(&wilc->srcu, srcu_idx);
146 static int wilc_txq_task(void *vp)
150 struct wilc *wl = vp;
152 complete(&wl->txq_thread_started);
154 wait_for_completion(&wl->txq_event);
157 complete(&wl->txq_thread_started);
159 while (!kthread_should_stop())
164 ret = wilc_wlan_handle_txq(wl, &txq_count);
165 if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
167 struct wilc_vif *ifc;
169 srcu_idx = srcu_read_lock(&wl->srcu);
170 list_for_each_entry_rcu(ifc, &wl->vif_list,
172 if (ifc->mac_opened && ifc->ndev)
173 netif_wake_queue(ifc->ndev);
175 srcu_read_unlock(&wl->srcu, srcu_idx);
177 } while (ret == WILC_VMM_ENTRY_FULL_RETRY && !wl->close);
182 static int wilc_wlan_get_firmware(struct net_device *dev)
184 struct wilc_vif *vif = netdev_priv(dev);
185 struct wilc *wilc = vif->wilc;
187 const struct firmware *wilc_firmware;
190 chip_id = wilc_get_chipid(wilc, false);
192 if (chip_id < 0x1003a0)
193 firmware = FIRMWARE_1002;
195 firmware = FIRMWARE_1003;
197 netdev_info(dev, "loading firmware %s\n", firmware);
199 if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) {
200 netdev_err(dev, "%s - firmware not available\n", firmware);
203 wilc->firmware = wilc_firmware;
208 static int wilc_start_firmware(struct net_device *dev)
210 struct wilc_vif *vif = netdev_priv(dev);
211 struct wilc *wilc = vif->wilc;
214 ret = wilc_wlan_start(wilc);
218 if (!wait_for_completion_timeout(&wilc->sync_event,
219 msecs_to_jiffies(5000)))
225 static int wilc1000_firmware_download(struct net_device *dev)
227 struct wilc_vif *vif = netdev_priv(dev);
228 struct wilc *wilc = vif->wilc;
231 if (!wilc->firmware) {
232 netdev_err(dev, "Firmware buffer is NULL\n");
236 ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data,
237 wilc->firmware->size);
241 release_firmware(wilc->firmware);
242 wilc->firmware = NULL;
244 netdev_dbg(dev, "Download Succeeded\n");
249 static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif)
251 struct wilc_priv *priv = &vif->priv;
252 struct host_if_drv *hif_drv;
257 netdev_dbg(dev, "Start configuring Firmware\n");
258 hif_drv = (struct host_if_drv *)priv->hif_drv;
259 netdev_dbg(dev, "Host = %p\n", hif_drv);
263 if (!wilc_wlan_cfg_set(vif, 1, WID_SET_OPERATION_MODE, (u8 *)&w, 4,
267 b = WILC_FW_BSS_TYPE_INFRA;
268 if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, &b, 1, 0, 0))
271 b = WILC_FW_TX_RATE_AUTO;
272 if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, &b, 1, 0, 0))
275 b = WILC_FW_OPER_MODE_G_MIXED_11B_2;
276 if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, &b, 1, 0, 0))
279 b = WILC_FW_PREAMBLE_SHORT;
280 if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, &b, 1, 0, 0))
283 b = WILC_FW_11N_PROT_AUTO;
284 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, &b, 1, 0, 0))
287 b = WILC_FW_ACTIVE_SCAN;
288 if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, &b, 1, 0, 0))
291 b = WILC_FW_SITE_SURVEY_OFF;
292 if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, &b, 1, 0, 0))
297 if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, (u8 *)&hw, 2, 0, 0))
302 if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, (u8 *)&hw, 2, 0, 0))
306 if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, &b, 1, 0, 0))
310 if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, &b, 1, 0, 0))
313 b = WILC_FW_NO_POWERSAVE;
314 if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, &b, 1, 0, 0))
318 if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, &b, 1, 0, 0))
321 b = WILC_FW_AUTH_OPEN_SYSTEM;
322 if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, &b, 1, 0, 0))
326 if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, &b, 1, 0, 0))
330 if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, &b, 1, 0, 0))
333 b = WILC_FW_ACK_POLICY_NORMAL;
334 if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, &b, 1, 0, 0))
338 if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, &b, 1,
343 if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, &b, 1, 0, 0))
347 if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, &b, 1, 0, 0))
352 if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, (u8 *)&hw, 2, 0, 0))
355 b = WILC_FW_REKEY_POLICY_DISABLE;
356 if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, &b, 1, 0, 0))
361 if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, (u8 *)&w, 4, 0, 0))
366 if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, (u8 *)&w, 4, 0,
371 if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, &b, 1, 0,
375 b = WILC_FW_ERP_PROT_SELF_CTS;
376 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, &b, 1, 0, 0))
380 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, &b, 1, 0, 0))
383 b = WILC_FW_11N_OP_MODE_HT_MIXED;
384 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, &b, 1, 0, 0))
388 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, &b, 1, 0, 0))
391 b = WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT;
392 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, &b, 1,
396 b = WILC_FW_HT_PROT_RTS_CTS_NONHT;
397 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, &b, 1, 0, 0))
401 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, &b, 1, 0,
406 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, &b, 1, 0, 0))
410 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, &b, 1,
420 static void wlan_deinitialize_threads(struct net_device *dev)
422 struct wilc_vif *vif = netdev_priv(dev);
423 struct wilc *wl = vif->wilc;
427 complete(&wl->txq_event);
429 if (wl->txq_thread) {
430 kthread_stop(wl->txq_thread);
431 wl->txq_thread = NULL;
435 static void wilc_wlan_deinitialize(struct net_device *dev)
437 struct wilc_vif *vif = netdev_priv(dev);
438 struct wilc *wl = vif->wilc;
441 netdev_err(dev, "wl is NULL\n");
445 if (wl->initialized) {
446 netdev_info(dev, "Deinitializing wilc1000...\n");
448 if (!wl->dev_irq_num &&
449 wl->hif_func->disable_interrupt) {
450 mutex_lock(&wl->hif_cs);
451 wl->hif_func->disable_interrupt(wl);
452 mutex_unlock(&wl->hif_cs);
454 complete(&wl->txq_event);
456 wlan_deinitialize_threads(dev);
459 wilc_wlan_stop(wl, vif);
460 wilc_wlan_cleanup(dev);
462 wl->initialized = false;
464 netdev_dbg(dev, "wilc1000 deinitialization Done\n");
466 netdev_dbg(dev, "wilc1000 is not initialized\n");
470 static int wlan_initialize_threads(struct net_device *dev)
472 struct wilc_vif *vif = netdev_priv(dev);
473 struct wilc *wilc = vif->wilc;
475 wilc->txq_thread = kthread_run(wilc_txq_task, (void *)wilc,
477 if (IS_ERR(wilc->txq_thread)) {
478 netdev_err(dev, "couldn't create TXQ thread\n");
480 return PTR_ERR(wilc->txq_thread);
482 wait_for_completion(&wilc->txq_thread_started);
487 static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
490 struct wilc *wl = vif->wilc;
492 if (!wl->initialized) {
493 wl->mac_status = WILC_MAC_STATUS_INIT;
496 ret = wilc_wlan_init(dev);
500 ret = wlan_initialize_threads(dev);
504 if (wl->gpio_irq && init_irq(dev)) {
509 if (!wl->dev_irq_num &&
510 wl->hif_func->enable_interrupt &&
511 wl->hif_func->enable_interrupt(wl)) {
516 ret = wilc_wlan_get_firmware(dev);
518 goto fail_irq_enable;
520 ret = wilc1000_firmware_download(dev);
522 goto fail_irq_enable;
524 ret = wilc_start_firmware(dev);
526 goto fail_irq_enable;
528 if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) {
530 char firmware_ver[20];
532 size = wilc_wlan_cfg_get_val(wl, WID_FIRMWARE_VERSION,
534 sizeof(firmware_ver));
535 firmware_ver[size] = '\0';
536 netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver);
539 ret = wilc_init_fw_config(dev, vif);
541 netdev_err(dev, "Failed to configure firmware\n");
544 wl->initialized = true;
548 wilc_wlan_stop(wl, vif);
551 if (!wl->dev_irq_num &&
552 wl->hif_func->disable_interrupt)
553 wl->hif_func->disable_interrupt(wl);
558 wlan_deinitialize_threads(dev);
560 wilc_wlan_cleanup(dev);
561 netdev_err(dev, "WLAN initialization FAILED\n");
563 netdev_dbg(dev, "wilc1000 already initialized\n");
568 static int mac_init_fn(struct net_device *ndev)
570 netif_start_queue(ndev);
571 netif_stop_queue(ndev);
576 static int wilc_mac_open(struct net_device *ndev)
578 struct wilc_vif *vif = netdev_priv(ndev);
579 struct wilc *wl = vif->wilc;
580 struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr);
581 unsigned char mac_add[ETH_ALEN] = {0};
584 if (!wl || !wl->dev) {
585 netdev_err(ndev, "device not ready\n");
589 netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev);
591 ret = wilc_init_host_int(ndev);
595 ret = wilc_wlan_initialize(ndev, vif);
597 wilc_deinit_host_int(ndev);
601 wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype,
603 wilc_get_mac_address(vif, mac_add);
604 netdev_dbg(ndev, "Mac address: %pM\n", mac_add);
605 ether_addr_copy(ndev->dev_addr, mac_add);
607 if (!is_valid_ether_addr(ndev->dev_addr)) {
608 netdev_err(ndev, "Wrong MAC address\n");
609 wilc_deinit_host_int(ndev);
610 wilc_wlan_deinitialize(ndev);
614 wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
615 vif->ndev->ieee80211_ptr,
616 vif->frame_reg[0].type,
617 vif->frame_reg[0].reg);
618 wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
619 vif->ndev->ieee80211_ptr,
620 vif->frame_reg[1].type,
621 vif->frame_reg[1].reg);
622 netif_wake_queue(ndev);
624 priv->p2p.local_random = 0x01;
629 static struct net_device_stats *mac_stats(struct net_device *dev)
631 struct wilc_vif *vif = netdev_priv(dev);
633 return &vif->netstats;
636 static void wilc_set_multicast_list(struct net_device *dev)
638 struct netdev_hw_addr *ha;
639 struct wilc_vif *vif = netdev_priv(dev);
644 if (dev->flags & IFF_PROMISC)
647 if (dev->flags & IFF_ALLMULTI ||
648 dev->mc.count > WILC_MULTICAST_TABLE_SIZE) {
649 wilc_setup_multicast_filter(vif, 0, 0, NULL);
653 if (dev->mc.count == 0) {
654 wilc_setup_multicast_filter(vif, 1, 0, NULL);
658 mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_ATOMIC);
664 netdev_for_each_mc_addr(ha, dev) {
665 memcpy(cur_mc, ha->addr, ETH_ALEN);
666 netdev_dbg(dev, "Entry[%d]: %pM\n", i, cur_mc);
671 if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list))
675 static void wilc_tx_complete(void *priv, int status)
677 struct tx_complete_data *pv_data = priv;
679 dev_kfree_skb(pv_data->skb);
683 netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
685 struct wilc_vif *vif = netdev_priv(ndev);
686 struct wilc *wilc = vif->wilc;
687 struct tx_complete_data *tx_data = NULL;
690 if (skb->dev != ndev) {
691 netdev_err(ndev, "Packet not destined to this device\n");
695 tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
698 netif_wake_queue(ndev);
702 tx_data->buff = skb->data;
703 tx_data->size = skb->len;
706 vif->netstats.tx_packets++;
707 vif->netstats.tx_bytes += tx_data->size;
708 queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data,
709 tx_data->buff, tx_data->size,
712 if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
714 struct wilc_vif *vif;
716 srcu_idx = srcu_read_lock(&wilc->srcu);
717 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
719 netif_stop_queue(vif->ndev);
721 srcu_read_unlock(&wilc->srcu, srcu_idx);
727 static int wilc_mac_close(struct net_device *ndev)
729 struct wilc_vif *vif = netdev_priv(ndev);
730 struct wilc *wl = vif->wilc;
732 netdev_dbg(ndev, "Mac close\n");
734 if (wl->open_ifcs > 0)
740 netif_stop_queue(vif->ndev);
742 wilc_deinit_host_int(vif->ndev);
745 if (wl->open_ifcs == 0) {
746 netdev_dbg(ndev, "Deinitializing wilc1000\n");
748 wilc_wlan_deinitialize(ndev);
756 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size,
759 unsigned int frame_len = 0;
761 unsigned char *buff_to_send = NULL;
763 struct net_device *wilc_netdev;
764 struct wilc_vif *vif;
769 wilc_netdev = get_if_handler(wilc, buff);
774 vif = netdev_priv(wilc_netdev);
780 skb = dev_alloc_skb(frame_len);
784 skb->dev = wilc_netdev;
786 skb_put_data(skb, buff_to_send, frame_len);
788 skb->protocol = eth_type_trans(skb, wilc_netdev);
789 vif->netstats.rx_packets++;
790 vif->netstats.rx_bytes += frame_len;
791 skb->ip_summed = CHECKSUM_UNNECESSARY;
792 stats = netif_rx(skb);
793 netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats);
797 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
800 struct wilc_vif *vif;
802 srcu_idx = srcu_read_lock(&wilc->srcu);
803 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
804 u16 type = le16_to_cpup((__le16 *)buff);
806 if (vif->priv.p2p_listen_state &&
807 ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) ||
808 (type == vif->frame_reg[1].type && vif->frame_reg[1].reg)))
809 wilc_wfi_p2p_rx(vif, buff, size);
811 if (vif->monitor_flag)
812 wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size);
814 srcu_read_unlock(&wilc->srcu, srcu_idx);
817 static const struct net_device_ops wilc_netdev_ops = {
818 .ndo_init = mac_init_fn,
819 .ndo_open = wilc_mac_open,
820 .ndo_stop = wilc_mac_close,
821 .ndo_start_xmit = wilc_mac_xmit,
822 .ndo_get_stats = mac_stats,
823 .ndo_set_rx_mode = wilc_set_multicast_list,
826 void wilc_netdev_cleanup(struct wilc *wilc)
828 struct wilc_vif *vif;
829 int srcu_idx, ifc_cnt = 0;
834 if (wilc->firmware) {
835 release_firmware(wilc->firmware);
836 wilc->firmware = NULL;
839 srcu_idx = srcu_read_lock(&wilc->srcu);
840 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
842 unregister_netdev(vif->ndev);
844 srcu_read_unlock(&wilc->srcu, srcu_idx);
846 wilc_wfi_deinit_mon_interface(wilc, false);
847 flush_workqueue(wilc->hif_workqueue);
848 destroy_workqueue(wilc->hif_workqueue);
850 while (ifc_cnt < WILC_NUM_CONCURRENT_IFC) {
851 mutex_lock(&wilc->vif_mutex);
852 if (wilc->vif_num <= 0) {
853 mutex_unlock(&wilc->vif_mutex);
856 vif = wilc_get_wl_to_vif(wilc);
858 list_del_rcu(&vif->list);
861 mutex_unlock(&wilc->vif_mutex);
862 synchronize_srcu(&wilc->srcu);
866 wilc_wlan_cfg_deinit(wilc);
867 wlan_deinit_locks(wilc);
868 kfree(wilc->bus_data);
869 wiphy_unregister(wilc->wiphy);
870 wiphy_free(wilc->wiphy);
872 EXPORT_SYMBOL_GPL(wilc_netdev_cleanup);
874 static u8 wilc_get_available_idx(struct wilc *wl)
877 struct wilc_vif *vif;
880 srcu_idx = srcu_read_lock(&wl->srcu);
881 list_for_each_entry_rcu(vif, &wl->vif_list, list) {
887 srcu_read_unlock(&wl->srcu, srcu_idx);
891 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
892 int vif_type, enum nl80211_iftype type,
895 struct net_device *ndev;
896 struct wilc_vif *vif;
899 ndev = alloc_etherdev(sizeof(*vif));
901 return ERR_PTR(-ENOMEM);
903 vif = netdev_priv(ndev);
904 ndev->ieee80211_ptr = &vif->priv.wdev;
905 strcpy(ndev->name, name);
910 ndev->netdev_ops = &wilc_netdev_ops;
912 SET_NETDEV_DEV(ndev, wiphy_dev(wl->wiphy));
914 vif->priv.wdev.wiphy = wl->wiphy;
915 vif->priv.wdev.netdev = ndev;
916 vif->priv.wdev.iftype = type;
917 vif->priv.dev = ndev;
920 ret = register_netdevice(ndev);
922 ret = register_netdev(ndev);
926 return ERR_PTR(-EFAULT);
929 ndev->needs_free_netdev = true;
930 vif->iftype = vif_type;
931 vif->idx = wilc_get_available_idx(wl);
933 mutex_lock(&wl->vif_mutex);
934 list_add_tail_rcu(&vif->list, &wl->vif_list);
936 mutex_unlock(&wl->vif_mutex);
937 synchronize_srcu(&wl->srcu);
942 MODULE_LICENSE("GPL");