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)
100 struct net_device *ndev = NULL;
101 struct wilc_vif *vif;
103 bssid = mac_header + 10;
104 bssid1 = mac_header + 4;
106 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
107 if (vif->mode == WILC_STATION_MODE)
108 if (ether_addr_equal_unaligned(bssid, vif->bssid)) {
112 if (vif->mode == WILC_AP_MODE)
113 if (ether_addr_equal_unaligned(bssid1, vif->bssid)) {
122 void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
124 struct wilc_vif *vif = netdev_priv(wilc_netdev);
127 ether_addr_copy(vif->bssid, bssid);
129 eth_zero_addr(vif->bssid);
134 int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
138 struct wilc_vif *vif;
140 srcu_idx = srcu_read_lock(&wilc->srcu);
141 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
142 if (!is_zero_ether_addr(vif->bssid))
145 srcu_read_unlock(&wilc->srcu, srcu_idx);
149 static int wilc_txq_task(void *vp)
153 struct wilc *wl = vp;
155 complete(&wl->txq_thread_started);
157 wait_for_completion(&wl->txq_event);
160 complete(&wl->txq_thread_started);
162 while (!kthread_should_stop())
167 ret = wilc_wlan_handle_txq(wl, &txq_count);
168 if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
170 struct wilc_vif *ifc;
172 srcu_idx = srcu_read_lock(&wl->srcu);
173 list_for_each_entry_rcu(ifc, &wl->vif_list,
175 if (ifc->mac_opened && ifc->ndev)
176 netif_wake_queue(ifc->ndev);
178 srcu_read_unlock(&wl->srcu, srcu_idx);
180 } while (ret == -ENOBUFS && !wl->close);
185 static int wilc_wlan_get_firmware(struct net_device *dev)
187 struct wilc_vif *vif = netdev_priv(dev);
188 struct wilc *wilc = vif->wilc;
189 int chip_id, ret = 0;
190 const struct firmware *wilc_firmware;
193 chip_id = wilc_get_chipid(wilc, false);
195 if (chip_id < 0x1003a0)
196 firmware = FIRMWARE_1002;
198 firmware = FIRMWARE_1003;
200 netdev_info(dev, "loading firmware %s\n", firmware);
202 if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) {
203 netdev_err(dev, "%s - firmware not available\n", firmware);
207 wilc->firmware = wilc_firmware;
214 static int wilc_start_firmware(struct net_device *dev)
216 struct wilc_vif *vif = netdev_priv(dev);
217 struct wilc *wilc = vif->wilc;
220 ret = wilc_wlan_start(wilc);
224 if (!wait_for_completion_timeout(&wilc->sync_event,
225 msecs_to_jiffies(5000)))
231 static int wilc1000_firmware_download(struct net_device *dev)
233 struct wilc_vif *vif = netdev_priv(dev);
234 struct wilc *wilc = vif->wilc;
237 if (!wilc->firmware) {
238 netdev_err(dev, "Firmware buffer is NULL\n");
242 ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data,
243 wilc->firmware->size);
247 release_firmware(wilc->firmware);
248 wilc->firmware = NULL;
250 netdev_dbg(dev, "Download Succeeded\n");
255 static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif)
257 struct wilc_priv *priv = &vif->priv;
258 struct host_if_drv *hif_drv;
263 netdev_dbg(dev, "Start configuring Firmware\n");
264 hif_drv = (struct host_if_drv *)priv->hif_drv;
265 netdev_dbg(dev, "Host = %p\n", hif_drv);
269 if (!wilc_wlan_cfg_set(vif, 1, WID_SET_OPERATION_MODE, (u8 *)&w, 4,
273 b = WILC_FW_BSS_TYPE_INFRA;
274 if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, &b, 1, 0, 0))
277 b = WILC_FW_TX_RATE_AUTO;
278 if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, &b, 1, 0, 0))
281 b = WILC_FW_OPER_MODE_G_MIXED_11B_2;
282 if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, &b, 1, 0, 0))
285 b = WILC_FW_PREAMBLE_SHORT;
286 if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, &b, 1, 0, 0))
289 b = WILC_FW_11N_PROT_AUTO;
290 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, &b, 1, 0, 0))
293 b = WILC_FW_ACTIVE_SCAN;
294 if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, &b, 1, 0, 0))
297 b = WILC_FW_SITE_SURVEY_OFF;
298 if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, &b, 1, 0, 0))
303 if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, (u8 *)&hw, 2, 0, 0))
308 if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, (u8 *)&hw, 2, 0, 0))
312 if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, &b, 1, 0, 0))
316 if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, &b, 1, 0, 0))
319 b = WILC_FW_NO_POWERSAVE;
320 if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, &b, 1, 0, 0))
324 if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, &b, 1, 0, 0))
327 b = WILC_FW_AUTH_OPEN_SYSTEM;
328 if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, &b, 1, 0, 0))
332 if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, &b, 1, 0, 0))
336 if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, &b, 1, 0, 0))
339 b = WILC_FW_ACK_POLICY_NORMAL;
340 if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, &b, 1, 0, 0))
344 if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, &b, 1,
349 if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, &b, 1, 0, 0))
353 if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, &b, 1, 0, 0))
358 if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, (u8 *)&hw, 2, 0, 0))
361 b = WILC_FW_REKEY_POLICY_DISABLE;
362 if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, &b, 1, 0, 0))
367 if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, (u8 *)&w, 4, 0, 0))
372 if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, (u8 *)&w, 4, 0,
377 if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, &b, 1, 0,
381 b = WILC_FW_ERP_PROT_SELF_CTS;
382 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, &b, 1, 0, 0))
386 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, &b, 1, 0, 0))
389 b = WILC_FW_11N_OP_MODE_HT_MIXED;
390 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, &b, 1, 0, 0))
394 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, &b, 1, 0, 0))
397 b = WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT;
398 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, &b, 1,
402 b = WILC_FW_HT_PROT_RTS_CTS_NONHT;
403 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, &b, 1, 0, 0))
407 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, &b, 1, 0,
412 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, &b, 1, 0, 0))
416 if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, &b, 1,
426 static void wlan_deinitialize_threads(struct net_device *dev)
428 struct wilc_vif *vif = netdev_priv(dev);
429 struct wilc *wl = vif->wilc;
433 complete(&wl->txq_event);
435 if (wl->txq_thread) {
436 kthread_stop(wl->txq_thread);
437 wl->txq_thread = NULL;
441 static void wilc_wlan_deinitialize(struct net_device *dev)
443 struct wilc_vif *vif = netdev_priv(dev);
444 struct wilc *wl = vif->wilc;
447 netdev_err(dev, "wl is NULL\n");
451 if (wl->initialized) {
452 netdev_info(dev, "Deinitializing wilc1000...\n");
454 if (!wl->dev_irq_num &&
455 wl->hif_func->disable_interrupt) {
456 mutex_lock(&wl->hif_cs);
457 wl->hif_func->disable_interrupt(wl);
458 mutex_unlock(&wl->hif_cs);
460 complete(&wl->txq_event);
462 wlan_deinitialize_threads(dev);
465 wilc_wlan_stop(wl, vif);
466 wilc_wlan_cleanup(dev);
468 wl->initialized = false;
470 netdev_dbg(dev, "wilc1000 deinitialization Done\n");
472 netdev_dbg(dev, "wilc1000 is not initialized\n");
476 static int wlan_initialize_threads(struct net_device *dev)
478 struct wilc_vif *vif = netdev_priv(dev);
479 struct wilc *wilc = vif->wilc;
481 wilc->txq_thread = kthread_run(wilc_txq_task, (void *)wilc,
483 if (IS_ERR(wilc->txq_thread)) {
484 netdev_err(dev, "couldn't create TXQ thread\n");
486 return PTR_ERR(wilc->txq_thread);
488 wait_for_completion(&wilc->txq_thread_started);
493 static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
496 struct wilc *wl = vif->wilc;
498 if (!wl->initialized) {
499 wl->mac_status = WILC_MAC_STATUS_INIT;
502 ret = wilc_wlan_init(dev);
506 ret = wlan_initialize_threads(dev);
512 if (wl->gpio_irq && init_irq(dev)) {
517 if (!wl->dev_irq_num &&
518 wl->hif_func->enable_interrupt &&
519 wl->hif_func->enable_interrupt(wl)) {
524 if (wilc_wlan_get_firmware(dev)) {
526 goto fail_irq_enable;
529 ret = wilc1000_firmware_download(dev);
532 goto fail_irq_enable;
535 ret = wilc_start_firmware(dev);
538 goto fail_irq_enable;
541 if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) {
543 char firmware_ver[20];
545 size = wilc_wlan_cfg_get_val(wl, WID_FIRMWARE_VERSION,
547 sizeof(firmware_ver));
548 firmware_ver[size] = '\0';
549 netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver);
551 ret = wilc_init_fw_config(dev, vif);
554 netdev_err(dev, "Failed to configure firmware\n");
558 wl->initialized = true;
562 wilc_wlan_stop(wl, vif);
565 if (!wl->dev_irq_num &&
566 wl->hif_func->disable_interrupt)
567 wl->hif_func->disable_interrupt(wl);
572 wlan_deinitialize_threads(dev);
574 wilc_wlan_cleanup(dev);
575 netdev_err(dev, "WLAN initialization FAILED\n");
577 netdev_dbg(dev, "wilc1000 already initialized\n");
582 static int mac_init_fn(struct net_device *ndev)
584 netif_start_queue(ndev);
585 netif_stop_queue(ndev);
590 static int wilc_mac_open(struct net_device *ndev)
592 struct wilc_vif *vif = netdev_priv(ndev);
593 struct wilc *wl = vif->wilc;
594 struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr);
595 unsigned char mac_add[ETH_ALEN] = {0};
598 if (!wl || !wl->dev) {
599 netdev_err(ndev, "device not ready\n");
603 netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev);
605 ret = wilc_init_host_int(ndev);
609 ret = wilc_wlan_initialize(ndev, vif);
611 wilc_deinit_host_int(ndev);
615 wilc_set_operation_mode(vif, wilc_get_vif_idx(vif), vif->iftype,
617 wilc_get_mac_address(vif, mac_add);
618 netdev_dbg(ndev, "Mac address: %pM\n", mac_add);
619 ether_addr_copy(ndev->dev_addr, mac_add);
621 if (!is_valid_ether_addr(ndev->dev_addr)) {
622 netdev_err(ndev, "Wrong MAC address\n");
623 wilc_deinit_host_int(ndev);
624 wilc_wlan_deinitialize(ndev);
628 wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
629 vif->ndev->ieee80211_ptr,
630 vif->frame_reg[0].type,
631 vif->frame_reg[0].reg);
632 wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
633 vif->ndev->ieee80211_ptr,
634 vif->frame_reg[1].type,
635 vif->frame_reg[1].reg);
636 netif_wake_queue(ndev);
638 priv->p2p.local_random = 0x01;
643 static struct net_device_stats *mac_stats(struct net_device *dev)
645 struct wilc_vif *vif = netdev_priv(dev);
647 return &vif->netstats;
650 static void wilc_set_multicast_list(struct net_device *dev)
652 struct netdev_hw_addr *ha;
653 struct wilc_vif *vif = netdev_priv(dev);
658 if (dev->flags & IFF_PROMISC)
661 if (dev->flags & IFF_ALLMULTI ||
662 dev->mc.count > WILC_MULTICAST_TABLE_SIZE) {
663 wilc_setup_multicast_filter(vif, 0, 0, NULL);
667 if (dev->mc.count == 0) {
668 wilc_setup_multicast_filter(vif, 1, 0, NULL);
672 mc_list = kmalloc_array(dev->mc.count, ETH_ALEN, GFP_ATOMIC);
678 netdev_for_each_mc_addr(ha, dev) {
679 memcpy(cur_mc, ha->addr, ETH_ALEN);
680 netdev_dbg(dev, "Entry[%d]: %pM\n", i, cur_mc);
685 if (wilc_setup_multicast_filter(vif, 1, dev->mc.count, mc_list))
689 static void wilc_tx_complete(void *priv, int status)
691 struct tx_complete_data *pv_data = priv;
693 dev_kfree_skb(pv_data->skb);
697 netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
699 struct wilc_vif *vif = netdev_priv(ndev);
700 struct wilc *wilc = vif->wilc;
701 struct tx_complete_data *tx_data = NULL;
704 if (skb->dev != ndev) {
705 netdev_err(ndev, "Packet not destined to this device\n");
709 tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
712 netif_wake_queue(ndev);
716 tx_data->buff = skb->data;
717 tx_data->size = skb->len;
720 vif->netstats.tx_packets++;
721 vif->netstats.tx_bytes += tx_data->size;
722 queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data,
723 tx_data->buff, tx_data->size,
726 if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
728 struct wilc_vif *vif;
730 srcu_idx = srcu_read_lock(&wilc->srcu);
731 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
733 netif_stop_queue(vif->ndev);
735 srcu_read_unlock(&wilc->srcu, srcu_idx);
741 static int wilc_mac_close(struct net_device *ndev)
743 struct wilc_vif *vif = netdev_priv(ndev);
744 struct wilc *wl = vif->wilc;
746 netdev_dbg(ndev, "Mac close\n");
748 if (wl->open_ifcs > 0)
754 netif_stop_queue(vif->ndev);
756 wilc_deinit_host_int(vif->ndev);
759 if (wl->open_ifcs == 0) {
760 netdev_dbg(ndev, "Deinitializing wilc1000\n");
762 wilc_wlan_deinitialize(ndev);
770 void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size,
773 unsigned int frame_len = 0;
775 unsigned char *buff_to_send = NULL;
777 struct net_device *wilc_netdev;
778 struct wilc_vif *vif;
783 wilc_netdev = get_if_handler(wilc, buff);
788 vif = netdev_priv(wilc_netdev);
794 skb = dev_alloc_skb(frame_len);
798 skb->dev = wilc_netdev;
800 skb_put_data(skb, buff_to_send, frame_len);
802 skb->protocol = eth_type_trans(skb, wilc_netdev);
803 vif->netstats.rx_packets++;
804 vif->netstats.rx_bytes += frame_len;
805 skb->ip_summed = CHECKSUM_UNNECESSARY;
806 stats = netif_rx(skb);
807 netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats);
811 void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
814 struct wilc_vif *vif;
816 srcu_idx = srcu_read_lock(&wilc->srcu);
817 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
818 u16 type = le16_to_cpup((__le16 *)buff);
820 if (vif->priv.p2p_listen_state &&
821 ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) ||
822 (type == vif->frame_reg[1].type && vif->frame_reg[1].reg)))
823 wilc_wfi_p2p_rx(vif, buff, size);
825 if (vif->monitor_flag)
826 wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size);
828 srcu_read_unlock(&wilc->srcu, srcu_idx);
831 static const struct net_device_ops wilc_netdev_ops = {
832 .ndo_init = mac_init_fn,
833 .ndo_open = wilc_mac_open,
834 .ndo_stop = wilc_mac_close,
835 .ndo_start_xmit = wilc_mac_xmit,
836 .ndo_get_stats = mac_stats,
837 .ndo_set_rx_mode = wilc_set_multicast_list,
840 void wilc_netdev_cleanup(struct wilc *wilc)
842 struct wilc_vif *vif;
848 if (wilc->firmware) {
849 release_firmware(wilc->firmware);
850 wilc->firmware = NULL;
853 srcu_idx = srcu_read_lock(&wilc->srcu);
854 list_for_each_entry_rcu(vif, &wilc->vif_list, list) {
856 unregister_netdev(vif->ndev);
858 srcu_read_unlock(&wilc->srcu, srcu_idx);
860 wilc_wfi_deinit_mon_interface(wilc, false);
861 flush_workqueue(wilc->hif_workqueue);
862 destroy_workqueue(wilc->hif_workqueue);
865 mutex_lock(&wilc->vif_mutex);
866 if (wilc->vif_num <= 0) {
867 mutex_unlock(&wilc->vif_mutex);
870 vif = wilc_get_wl_to_vif(wilc);
872 list_del_rcu(&vif->list);
875 mutex_unlock(&wilc->vif_mutex);
876 synchronize_srcu(&wilc->srcu);
879 wilc_wlan_cfg_deinit(wilc);
880 wlan_deinit_locks(wilc);
881 kfree(wilc->bus_data);
882 wiphy_unregister(wilc->wiphy);
883 wiphy_free(wilc->wiphy);
885 EXPORT_SYMBOL_GPL(wilc_netdev_cleanup);
887 static u8 wilc_get_available_idx(struct wilc *wl)
890 struct wilc_vif *vif;
893 srcu_idx = srcu_read_lock(&wl->srcu);
894 list_for_each_entry_rcu(vif, &wl->vif_list, list) {
900 srcu_read_unlock(&wl->srcu, srcu_idx);
904 struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
905 int vif_type, enum nl80211_iftype type,
908 struct net_device *ndev;
909 struct wilc_vif *vif;
912 ndev = alloc_etherdev(sizeof(*vif));
914 return ERR_PTR(-ENOMEM);
916 vif = netdev_priv(ndev);
917 ndev->ieee80211_ptr = &vif->priv.wdev;
918 strcpy(ndev->name, name);
923 ndev->netdev_ops = &wilc_netdev_ops;
925 SET_NETDEV_DEV(ndev, wiphy_dev(wl->wiphy));
927 vif->priv.wdev.wiphy = wl->wiphy;
928 vif->priv.wdev.netdev = ndev;
929 vif->priv.wdev.iftype = type;
930 vif->priv.dev = ndev;
933 ret = register_netdevice(ndev);
935 ret = register_netdev(ndev);
939 return ERR_PTR(-EFAULT);
942 ndev->needs_free_netdev = true;
943 vif->iftype = vif_type;
944 vif->idx = wilc_get_available_idx(wl);
946 mutex_lock(&wl->vif_mutex);
947 list_add_tail_rcu(&vif->list, &wl->vif_list);
949 mutex_unlock(&wl->vif_mutex);
950 synchronize_srcu(&wl->srcu);
955 MODULE_LICENSE("GPL");