Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | #include "wilc_wfi_cfgoperations.h" |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 2 | #include "wilc_wlan_if.h" |
| 3 | #include "wilc_wlan.h" |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 4 | |
| 5 | #include <linux/slab.h> |
| 6 | #include <linux/sched.h> |
| 7 | #include <linux/delay.h> |
| 8 | #include <linux/workqueue.h> |
| 9 | #include <linux/interrupt.h> |
| 10 | #include <linux/irq.h> |
Guenter Roeck | f1a9983 | 2015-05-27 13:02:16 -0700 | [diff] [blame] | 11 | #include <linux/gpio.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 12 | |
| 13 | #include <linux/kthread.h> |
| 14 | #include <linux/firmware.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 15 | |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/netdevice.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 18 | #include <linux/inetdevice.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 19 | #include <linux/etherdevice.h> |
| 20 | #include <linux/module.h> |
| 21 | #include <linux/kernel.h> |
| 22 | #include <linux/skbuff.h> |
Binoy Jayan | 334bed0 | 2016-06-15 11:00:35 +0530 | [diff] [blame] | 23 | #include <linux/mutex.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 24 | #include <linux/semaphore.h> |
Leo Kim | 11a54b3 | 2016-04-01 17:44:15 +0900 | [diff] [blame] | 25 | #include <linux/completion.h> |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 26 | |
Leo Kim | 885cabc | 2016-02-04 18:15:35 +0900 | [diff] [blame] | 27 | static int dev_state_ev_handler(struct notifier_block *this, |
| 28 | unsigned long event, void *ptr); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 29 | |
| 30 | static struct notifier_block g_dev_notifier = { |
| 31 | .notifier_call = dev_state_ev_handler |
| 32 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 33 | |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 34 | static int wlan_deinit_locks(struct net_device *dev); |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 35 | static void wlan_deinitialize_threads(struct net_device *dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 36 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 37 | static void linux_wlan_tx_complete(void *priv, int status); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 38 | static int mac_init_fn(struct net_device *ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 39 | static struct net_device_stats *mac_stats(struct net_device *dev); |
| 40 | static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd); |
| 41 | static void wilc_set_multicast_list(struct net_device *dev); |
Arnd Bergmann | 750ffe9 | 2015-11-16 15:05:08 +0100 | [diff] [blame] | 42 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 43 | bool wilc_enable_ps = true; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 44 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 45 | static const struct net_device_ops wilc_netdev_ops = { |
| 46 | .ndo_init = mac_init_fn, |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 47 | .ndo_open = wilc_mac_open, |
| 48 | .ndo_stop = wilc_mac_close, |
| 49 | .ndo_start_xmit = wilc_mac_xmit, |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 50 | .ndo_do_ioctl = mac_ioctl, |
| 51 | .ndo_get_stats = mac_stats, |
| 52 | .ndo_set_rx_mode = wilc_set_multicast_list, |
| 53 | |
| 54 | }; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 55 | |
Leo Kim | 885cabc | 2016-02-04 18:15:35 +0900 | [diff] [blame] | 56 | static int dev_state_ev_handler(struct notifier_block *this, |
| 57 | unsigned long event, void *ptr) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 58 | { |
Alison Schofield | d5c8944 | 2016-02-12 22:53:13 -0800 | [diff] [blame] | 59 | struct in_ifaddr *dev_iface = ptr; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 60 | struct wilc_priv *priv; |
Leo Kim | f24374a | 2015-11-05 14:36:12 +0900 | [diff] [blame] | 61 | struct host_if_drv *hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 62 | struct net_device *dev; |
Leo Kim | eac3e8f | 2015-11-05 14:36:16 +0900 | [diff] [blame] | 63 | u8 *ip_addr_buf; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 64 | struct wilc_vif *vif; |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 65 | u8 null_ip[4] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 66 | char wlan_dev_name[5] = "wlan0"; |
| 67 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 68 | if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 69 | return NOTIFY_DONE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 70 | |
Leo Kim | 582f8a2 | 2015-11-05 14:36:21 +0900 | [diff] [blame] | 71 | if (memcmp(dev_iface->ifa_label, "wlan0", 5) && |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 72 | memcmp(dev_iface->ifa_label, "p2p0", 4)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 73 | return NOTIFY_DONE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 74 | |
| 75 | dev = (struct net_device *)dev_iface->ifa_dev->dev; |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 76 | if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 77 | return NOTIFY_DONE; |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 78 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 79 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 80 | if (!priv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 81 | return NOTIFY_DONE; |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 82 | |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 83 | hif_drv = (struct host_if_drv *)priv->hif_drv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 84 | vif = netdev_priv(dev); |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 85 | if (!vif || !hif_drv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 86 | return NOTIFY_DONE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 87 | |
| 88 | switch (event) { |
| 89 | case NETDEV_UP: |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 90 | if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { |
Leo Kim | f24374a | 2015-11-05 14:36:12 +0900 | [diff] [blame] | 91 | hif_drv->IFC_UP = 1; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 92 | wilc_optaining_ip = false; |
| 93 | del_timer(&wilc_during_ip_timer); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 94 | } |
| 95 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 96 | if (wilc_enable_ps) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 97 | wilc_set_power_mgmt(vif, 1, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 98 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 99 | netdev_dbg(dev, "[%s] Up IP\n", dev_iface->ifa_label); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 100 | |
Leo Kim | eac3e8f | 2015-11-05 14:36:16 +0900 | [diff] [blame] | 101 | ip_addr_buf = (char *)&dev_iface->ifa_address; |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 102 | netdev_dbg(dev, "IP add=%d:%d:%d:%d\n", |
| 103 | ip_addr_buf[0], ip_addr_buf[1], |
| 104 | ip_addr_buf[2], ip_addr_buf[3]); |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 105 | wilc_setup_ipaddress(vif, ip_addr_buf, vif->idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 106 | |
| 107 | break; |
| 108 | |
| 109 | case NETDEV_DOWN: |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 110 | if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { |
Leo Kim | f24374a | 2015-11-05 14:36:12 +0900 | [diff] [blame] | 111 | hif_drv->IFC_UP = 0; |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 112 | wilc_optaining_ip = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0) |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 116 | wilc_set_power_mgmt(vif, 0, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 117 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 118 | wilc_resolve_disconnect_aberration(vif); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 119 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 120 | netdev_dbg(dev, "[%s] Down IP\n", dev_iface->ifa_label); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 121 | |
Leo Kim | eac3e8f | 2015-11-05 14:36:16 +0900 | [diff] [blame] | 122 | ip_addr_buf = null_ip; |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 123 | netdev_dbg(dev, "IP add=%d:%d:%d:%d\n", |
| 124 | ip_addr_buf[0], ip_addr_buf[1], |
| 125 | ip_addr_buf[2], ip_addr_buf[3]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 126 | |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 127 | wilc_setup_ipaddress(vif, ip_addr_buf, vif->idx); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 128 | |
| 129 | break; |
| 130 | |
| 131 | default: |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 132 | break; |
| 133 | } |
| 134 | |
| 135 | return NOTIFY_DONE; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 136 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 137 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 138 | static irqreturn_t isr_uh_routine(int irq, void *user_data) |
| 139 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 140 | struct wilc_vif *vif; |
Glen Lee | 3948362 | 2015-10-27 18:27:37 +0900 | [diff] [blame] | 141 | struct wilc *wilc; |
Alison Schofield | d5c8944 | 2016-02-12 22:53:13 -0800 | [diff] [blame] | 142 | struct net_device *dev = user_data; |
Glen Lee | 3948362 | 2015-10-27 18:27:37 +0900 | [diff] [blame] | 143 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 144 | vif = netdev_priv(dev); |
| 145 | wilc = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 146 | |
Glen Lee | 3948362 | 2015-10-27 18:27:37 +0900 | [diff] [blame] | 147 | if (wilc->close) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 148 | netdev_err(dev, "Can't handle UH interrupt\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 149 | return IRQ_HANDLED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 150 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 151 | return IRQ_WAKE_THREAD; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 152 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 153 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 154 | static irqreturn_t isr_bh_routine(int irq, void *userdata) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 155 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 156 | struct wilc_vif *vif; |
Glen Lee | 2e7933d | 2015-10-27 18:27:38 +0900 | [diff] [blame] | 157 | struct wilc *wilc; |
Alison Schofield | d5c8944 | 2016-02-12 22:53:13 -0800 | [diff] [blame] | 158 | struct net_device *dev = userdata; |
Glen Lee | 2e7933d | 2015-10-27 18:27:38 +0900 | [diff] [blame] | 159 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 160 | vif = netdev_priv(userdata); |
| 161 | wilc = vif->wilc; |
Glen Lee | 2e7933d | 2015-10-27 18:27:38 +0900 | [diff] [blame] | 162 | |
Glen Lee | 2e7933d | 2015-10-27 18:27:38 +0900 | [diff] [blame] | 163 | if (wilc->close) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 164 | netdev_err(dev, "Can't handle BH interrupt\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 165 | return IRQ_HANDLED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 166 | } |
| 167 | |
Glen Lee | 50b929e | 2015-10-27 18:27:40 +0900 | [diff] [blame] | 168 | wilc_handle_isr(wilc); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 169 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 170 | return IRQ_HANDLED; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 171 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 172 | |
Glen Lee | 2c1d05d | 2015-10-20 17:14:03 +0900 | [diff] [blame] | 173 | static int init_irq(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 174 | { |
| 175 | int ret = 0; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 176 | struct wilc_vif *vif; |
Glen Lee | 2c1d05d | 2015-10-20 17:14:03 +0900 | [diff] [blame] | 177 | struct wilc *wl; |
| 178 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 179 | vif = netdev_priv(dev); |
| 180 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 181 | |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 182 | if ((gpio_request(wl->gpio, "WILC_INTR") == 0) && |
| 183 | (gpio_direction_input(wl->gpio) == 0)) { |
| 184 | wl->dev_irq_num = gpio_to_irq(wl->gpio); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 185 | } else { |
| 186 | ret = -1; |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 187 | netdev_err(dev, "could not obtain gpio for WILC_INTR\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 188 | } |
| 189 | |
Leo Kim | 83231b7 | 2015-11-06 11:12:22 +0900 | [diff] [blame] | 190 | if (ret != -1 && request_threaded_irq(wl->dev_irq_num, |
| 191 | isr_uh_routine, |
| 192 | isr_bh_routine, |
| 193 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
| 194 | "WILC_IRQ", dev) < 0) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 195 | netdev_err(dev, "Failed to request IRQ GPIO: %d\n", wl->gpio); |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 196 | gpio_free(wl->gpio); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 197 | ret = -1; |
| 198 | } else { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 199 | netdev_dbg(dev, |
| 200 | "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", |
| 201 | wl->dev_irq_num, wl->gpio); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | return ret; |
| 205 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 206 | |
Glen Lee | ec5cc75 | 2015-10-27 18:27:39 +0900 | [diff] [blame] | 207 | static void deinit_irq(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 208 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 209 | struct wilc_vif *vif; |
Glen Lee | ec5cc75 | 2015-10-27 18:27:39 +0900 | [diff] [blame] | 210 | struct wilc *wilc; |
| 211 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 212 | vif = netdev_priv(dev); |
| 213 | wilc = vif->wilc; |
Glen Lee | ec5cc75 | 2015-10-27 18:27:39 +0900 | [diff] [blame] | 214 | |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 215 | /* Deintialize IRQ */ |
| 216 | if (wilc->dev_irq_num) { |
Glen Lee | ec5cc75 | 2015-10-27 18:27:39 +0900 | [diff] [blame] | 217 | free_irq(wilc->dev_irq_num, wilc); |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 218 | gpio_free(wilc->gpio); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 219 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 220 | } |
| 221 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 222 | int wilc_lock_timeout(struct wilc *nic, void *vp, u32 timeout) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 223 | { |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 224 | /* FIXME: replace with mutex_lock or wait_for_completion */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 225 | int error = -1; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 226 | |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 227 | if (vp) |
Alison Schofield | d5c8944 | 2016-02-12 22:53:13 -0800 | [diff] [blame] | 228 | error = down_timeout(vp, |
Leo Kim | 582f8a2 | 2015-11-05 14:36:21 +0900 | [diff] [blame] | 229 | msecs_to_jiffies(timeout)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 230 | return error; |
| 231 | } |
| 232 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 233 | void wilc_mac_indicate(struct wilc *wilc, int flag) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 234 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 235 | int status; |
| 236 | |
| 237 | if (flag == WILC_MAC_INDICATE_STATUS) { |
Leo Kim | 582f8a2 | 2015-11-05 14:36:21 +0900 | [diff] [blame] | 238 | wilc_wlan_cfg_get_val(WID_STATUS, |
| 239 | (unsigned char *)&status, 4); |
Glen Lee | 64f2b71 | 2015-10-27 18:27:43 +0900 | [diff] [blame] | 240 | if (wilc->mac_status == WILC_MAC_STATUS_INIT) { |
| 241 | wilc->mac_status = status; |
Binoy Jayan | 04247e7 | 2016-06-15 11:00:37 +0530 | [diff] [blame] | 242 | complete(&wilc->sync_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 243 | } else { |
Glen Lee | 64f2b71 | 2015-10-27 18:27:43 +0900 | [diff] [blame] | 244 | wilc->mac_status = status; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 245 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 246 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 247 | } |
| 248 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 249 | static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 250 | { |
Leo Kim | 660786e | 2015-11-05 14:36:27 +0900 | [diff] [blame] | 251 | u8 *bssid, *bssid1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 252 | int i = 0; |
| 253 | |
Leo Kim | d239222 | 2015-11-05 14:36:26 +0900 | [diff] [blame] | 254 | bssid = mac_header + 10; |
Leo Kim | 660786e | 2015-11-05 14:36:27 +0900 | [diff] [blame] | 255 | bssid1 = mac_header + 4; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 256 | |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 257 | for (i = 0; i < wilc->vif_num; i++) { |
| 258 | if (wilc->vif[i]->mode == STATION_MODE) |
Leo Kim | fa63394 | 2016-03-25 21:16:53 +0900 | [diff] [blame] | 259 | if (ether_addr_equal_unaligned(bssid, |
| 260 | wilc->vif[i]->bssid)) |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 261 | return wilc->vif[i]->ndev; |
| 262 | if (wilc->vif[i]->mode == AP_MODE) |
Leo Kim | fa63394 | 2016-03-25 21:16:53 +0900 | [diff] [blame] | 263 | if (ether_addr_equal_unaligned(bssid1, |
| 264 | wilc->vif[i]->bssid)) |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 265 | return wilc->vif[i]->ndev; |
| 266 | } |
Tony Cho | 8259a53 | 2015-10-20 14:26:47 +0900 | [diff] [blame] | 267 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 268 | return NULL; |
| 269 | } |
| 270 | |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 271 | int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 272 | { |
| 273 | int i = 0; |
| 274 | int ret = -1; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 275 | struct wilc_vif *vif; |
Glen Lee | 472791a | 2015-10-27 18:27:44 +0900 | [diff] [blame] | 276 | struct wilc *wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 277 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 278 | vif = netdev_priv(wilc_netdev); |
| 279 | wilc = vif->wilc; |
Glen Lee | 472791a | 2015-10-27 18:27:44 +0900 | [diff] [blame] | 280 | |
| 281 | for (i = 0; i < wilc->vif_num; i++) |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 282 | if (wilc->vif[i]->ndev == wilc_netdev) { |
| 283 | memcpy(wilc->vif[i]->bssid, bssid, 6); |
Glen Lee | ba615f1 | 2016-01-25 16:35:15 +0900 | [diff] [blame] | 284 | wilc->vif[i]->mode = mode; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 285 | ret = 0; |
| 286 | break; |
| 287 | } |
Tony Cho | 8259a53 | 2015-10-20 14:26:47 +0900 | [diff] [blame] | 288 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 289 | return ret; |
| 290 | } |
| 291 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 292 | int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 293 | { |
Chaehyun Lim | 51e825f | 2015-09-15 14:06:14 +0900 | [diff] [blame] | 294 | u8 i = 0; |
| 295 | u8 null_bssid[6] = {0}; |
| 296 | u8 ret_val = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 297 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 298 | for (i = 0; i < wilc->vif_num; i++) |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 299 | if (memcmp(wilc->vif[i]->bssid, null_bssid, 6)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 300 | ret_val++; |
Tony Cho | 8259a53 | 2015-10-20 14:26:47 +0900 | [diff] [blame] | 301 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 302 | return ret_val; |
| 303 | } |
| 304 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 305 | static int linux_wlan_txq_task(void *vp) |
| 306 | { |
| 307 | int ret, txq_count; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 308 | struct wilc_vif *vif; |
Glen Lee | 8868758 | 2015-10-27 18:27:46 +0900 | [diff] [blame] | 309 | struct wilc *wl; |
| 310 | struct net_device *dev = vp; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 311 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 312 | vif = netdev_priv(dev); |
| 313 | wl = vif->wilc; |
Glen Lee | 8868758 | 2015-10-27 18:27:46 +0900 | [diff] [blame] | 314 | |
Leo Kim | 11a54b3 | 2016-04-01 17:44:15 +0900 | [diff] [blame] | 315 | complete(&wl->txq_thread_started); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 316 | while (1) { |
Binoy Jayan | b27a6d5 | 2016-06-15 11:00:34 +0530 | [diff] [blame] | 317 | wait_for_completion(&wl->txq_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 318 | |
Glen Lee | 8868758 | 2015-10-27 18:27:46 +0900 | [diff] [blame] | 319 | if (wl->close) { |
Leo Kim | 11a54b3 | 2016-04-01 17:44:15 +0900 | [diff] [blame] | 320 | complete(&wl->txq_thread_started); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 321 | |
| 322 | while (!kthread_should_stop()) |
| 323 | schedule(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 324 | break; |
| 325 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 326 | do { |
Glen Lee | a1332ca | 2015-10-27 18:27:47 +0900 | [diff] [blame] | 327 | ret = wilc_wlan_handle_txq(dev, &txq_count); |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 328 | if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) { |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 329 | if (netif_queue_stopped(wl->vif[0]->ndev)) |
| 330 | netif_wake_queue(wl->vif[0]->ndev); |
| 331 | if (netif_queue_stopped(wl->vif[1]->ndev)) |
| 332 | netif_wake_queue(wl->vif[1]->ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 333 | } |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 334 | } while (ret == WILC_TX_ERR_NO_BUF && !wl->close); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 335 | } |
| 336 | return 0; |
| 337 | } |
| 338 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 339 | int wilc_wlan_get_firmware(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 340 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 341 | struct wilc_vif *vif; |
Glen Lee | 65c8adc | 2015-10-29 12:18:49 +0900 | [diff] [blame] | 342 | struct wilc *wilc; |
Glen Lee | 14823bf | 2016-01-25 16:35:13 +0900 | [diff] [blame] | 343 | int chip_id, ret = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 344 | const struct firmware *wilc_firmware; |
| 345 | char *firmware; |
| 346 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 347 | vif = netdev_priv(dev); |
| 348 | wilc = vif->wilc; |
Glen Lee | 65c8adc | 2015-10-29 12:18:49 +0900 | [diff] [blame] | 349 | |
Chris Park | 65c3f00 | 2016-02-04 18:15:54 +0900 | [diff] [blame] | 350 | chip_id = wilc_get_chipid(wilc, false); |
Glen Lee | 14823bf | 2016-01-25 16:35:13 +0900 | [diff] [blame] | 351 | |
| 352 | if (chip_id < 0x1003a0) |
| 353 | firmware = FIRMWARE_1002; |
| 354 | else |
| 355 | firmware = FIRMWARE_1003; |
| 356 | |
| 357 | netdev_info(dev, "loading firmware %s\n", firmware); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 358 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 359 | if (!(&vif->ndev->dev)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 360 | goto _fail_; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 361 | |
Arnd Bergmann | b03314e | 2015-11-16 15:05:01 +0100 | [diff] [blame] | 362 | if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) { |
Julia Lawall | b981189 | 2016-05-17 16:38:43 +0200 | [diff] [blame] | 363 | netdev_err(dev, "%s - firmware not available\n", firmware); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 364 | ret = -1; |
| 365 | goto _fail_; |
| 366 | } |
Glen Lee | 65c8adc | 2015-10-29 12:18:49 +0900 | [diff] [blame] | 367 | wilc->firmware = wilc_firmware; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 368 | |
| 369 | _fail_: |
| 370 | |
| 371 | return ret; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 372 | } |
| 373 | |
Glen Lee | 9bf3d72 | 2015-10-29 12:18:46 +0900 | [diff] [blame] | 374 | static int linux_wlan_start_firmware(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 375 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 376 | struct wilc_vif *vif; |
Glen Lee | 9bf3d72 | 2015-10-29 12:18:46 +0900 | [diff] [blame] | 377 | struct wilc *wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 378 | int ret = 0; |
Glen Lee | 9bf3d72 | 2015-10-29 12:18:46 +0900 | [diff] [blame] | 379 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 380 | vif = netdev_priv(dev); |
| 381 | wilc = vif->wilc; |
Glen Lee | 9bf3d72 | 2015-10-29 12:18:46 +0900 | [diff] [blame] | 382 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 383 | ret = wilc_wlan_start(wilc); |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 384 | if (ret < 0) |
Leo Kim | 0aeea1a | 2015-11-05 14:36:30 +0900 | [diff] [blame] | 385 | return ret; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 386 | |
Binoy Jayan | 04247e7 | 2016-06-15 11:00:37 +0530 | [diff] [blame] | 387 | if (!wait_for_completion_timeout(&wilc->sync_event, |
| 388 | msecs_to_jiffies(5000))) |
| 389 | return -ETIME; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 390 | |
Leo Kim | 0aeea1a | 2015-11-05 14:36:30 +0900 | [diff] [blame] | 391 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 392 | } |
Leo Kim | a40b22c | 2015-11-05 14:36:32 +0900 | [diff] [blame] | 393 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 394 | static int wilc1000_firmware_download(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 395 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 396 | struct wilc_vif *vif; |
Glen Lee | ed760b6 | 2015-10-29 12:18:42 +0900 | [diff] [blame] | 397 | struct wilc *wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 398 | int ret = 0; |
| 399 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 400 | vif = netdev_priv(dev); |
| 401 | wilc = vif->wilc; |
Glen Lee | ed760b6 | 2015-10-29 12:18:42 +0900 | [diff] [blame] | 402 | |
| 403 | if (!wilc->firmware) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 404 | netdev_err(dev, "Firmware buffer is NULL\n"); |
Leo Kim | 14b1821 | 2015-11-05 14:36:31 +0900 | [diff] [blame] | 405 | return -ENOBUFS; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 406 | } |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 407 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 408 | ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data, |
Glen Lee | ed760b6 | 2015-10-29 12:18:42 +0900 | [diff] [blame] | 409 | wilc->firmware->size); |
Kim, Leo | fc4b95d | 2015-07-28 17:47:37 +0900 | [diff] [blame] | 410 | if (ret < 0) |
Leo Kim | 14b1821 | 2015-11-05 14:36:31 +0900 | [diff] [blame] | 411 | return ret; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 412 | |
Glen Lee | ed760b6 | 2015-10-29 12:18:42 +0900 | [diff] [blame] | 413 | release_firmware(wilc->firmware); |
Glen Lee | 6f72ed7 | 2015-11-25 11:59:40 +0900 | [diff] [blame] | 414 | wilc->firmware = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 415 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 416 | netdev_dbg(dev, "Download Succeeded\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 417 | |
Leo Kim | 14b1821 | 2015-11-05 14:36:31 +0900 | [diff] [blame] | 418 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 419 | } |
| 420 | |
Glen Lee | 00215dd | 2015-11-18 15:11:25 +0900 | [diff] [blame] | 421 | static int linux_wlan_init_test_config(struct net_device *dev, |
Glen Lee | b8f6ca0 | 2016-01-25 16:35:12 +0900 | [diff] [blame] | 422 | struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 423 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 424 | unsigned char c_val[64]; |
Glen Lee | b8f6ca0 | 2016-01-25 16:35:12 +0900 | [diff] [blame] | 425 | struct wilc *wilc = vif->wilc; |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 426 | struct wilc_priv *priv; |
Leo Kim | 0fa66c7 | 2015-11-05 14:36:13 +0900 | [diff] [blame] | 427 | struct host_if_drv *hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 428 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 429 | netdev_dbg(dev, "Start configuring Firmware\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 430 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 431 | hif_drv = (struct host_if_drv *)priv->hif_drv; |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 432 | netdev_dbg(dev, "Host = %p\n", hif_drv); |
Chris Park | 65c3f00 | 2016-02-04 18:15:54 +0900 | [diff] [blame] | 433 | wilc_get_chipid(wilc, false); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 434 | |
Johnny Kim | e5d57e9 | 2015-08-20 16:32:53 +0900 | [diff] [blame] | 435 | *(int *)c_val = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 436 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 437 | if (!wilc_wlan_cfg_set(vif, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 438 | goto _fail_; |
| 439 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 440 | c_val[0] = 0; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 441 | if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 442 | goto _fail_; |
| 443 | |
| 444 | c_val[0] = INFRASTRUCTURE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 445 | if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 446 | goto _fail_; |
| 447 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 448 | c_val[0] = RATE_AUTO; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 449 | if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 450 | goto _fail_; |
| 451 | |
| 452 | c_val[0] = G_MIXED_11B_2_MODE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 453 | if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 454 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 455 | goto _fail_; |
| 456 | |
| 457 | c_val[0] = 1; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 458 | if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 459 | goto _fail_; |
| 460 | |
| 461 | c_val[0] = G_SHORT_PREAMBLE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 462 | if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 463 | goto _fail_; |
| 464 | |
| 465 | c_val[0] = AUTO_PROT; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 466 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 467 | goto _fail_; |
| 468 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 469 | c_val[0] = ACTIVE_SCAN; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 470 | if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 471 | goto _fail_; |
| 472 | |
| 473 | c_val[0] = SITE_SURVEY_OFF; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 474 | if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 475 | goto _fail_; |
| 476 | |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 477 | *((int *)c_val) = 0xffff; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 478 | if (!wilc_wlan_cfg_set(vif, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 479 | goto _fail_; |
| 480 | |
| 481 | *((int *)c_val) = 2346; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 482 | if (!wilc_wlan_cfg_set(vif, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 483 | goto _fail_; |
| 484 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 485 | c_val[0] = 0; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 486 | if (!wilc_wlan_cfg_set(vif, 0, WID_BCAST_SSID, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 487 | goto _fail_; |
| 488 | |
| 489 | c_val[0] = 1; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 490 | if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 491 | goto _fail_; |
| 492 | |
| 493 | c_val[0] = NO_POWERSAVE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 494 | if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 495 | goto _fail_; |
| 496 | |
Arnd Bergmann | b4d04c1 | 2015-11-16 15:04:56 +0100 | [diff] [blame] | 497 | c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */ |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 498 | if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 499 | goto _fail_; |
| 500 | |
| 501 | c_val[0] = OPEN_SYSTEM; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 502 | if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 503 | goto _fail_; |
| 504 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 505 | strcpy(c_val, "123456790abcdef1234567890"); |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 506 | if (!wilc_wlan_cfg_set(vif, 0, WID_WEP_KEY_VALUE, c_val, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 507 | (strlen(c_val) + 1), 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 508 | goto _fail_; |
| 509 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 510 | strcpy(c_val, "12345678"); |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 511 | if (!wilc_wlan_cfg_set(vif, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 512 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 513 | goto _fail_; |
| 514 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 515 | strcpy(c_val, "password"); |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 516 | if (!wilc_wlan_cfg_set(vif, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1), |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 517 | 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 518 | goto _fail_; |
| 519 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 520 | c_val[0] = 192; |
| 521 | c_val[1] = 168; |
| 522 | c_val[2] = 1; |
| 523 | c_val[3] = 112; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 524 | if (!wilc_wlan_cfg_set(vif, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 525 | goto _fail_; |
| 526 | |
| 527 | c_val[0] = 3; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 528 | if (!wilc_wlan_cfg_set(vif, 0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 529 | goto _fail_; |
| 530 | |
| 531 | c_val[0] = 3; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 532 | if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 533 | goto _fail_; |
| 534 | |
| 535 | c_val[0] = NORMAL_ACK; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 536 | if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 537 | goto _fail_; |
| 538 | |
| 539 | c_val[0] = 0; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 540 | if (!wilc_wlan_cfg_set(vif, 0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 541 | 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 542 | goto _fail_; |
| 543 | |
| 544 | c_val[0] = 48; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 545 | if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 546 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 547 | goto _fail_; |
| 548 | |
| 549 | c_val[0] = 28; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 550 | if (!wilc_wlan_cfg_set(vif, 0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 551 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 552 | goto _fail_; |
| 553 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 554 | *((int *)c_val) = 100; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 555 | if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 556 | goto _fail_; |
| 557 | |
| 558 | c_val[0] = REKEY_DISABLE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 559 | if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 560 | goto _fail_; |
| 561 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 562 | *((int *)c_val) = 84600; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 563 | if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PERIOD, c_val, 4, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 564 | goto _fail_; |
| 565 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 566 | *((int *)c_val) = 500; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 567 | if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 568 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 569 | goto _fail_; |
| 570 | |
| 571 | c_val[0] = 1; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 572 | if (!wilc_wlan_cfg_set(vif, 0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 573 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 574 | goto _fail_; |
| 575 | |
| 576 | c_val[0] = G_SELF_CTS_PROT; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 577 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 578 | goto _fail_; |
| 579 | |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 580 | c_val[0] = 1; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 581 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 582 | goto _fail_; |
| 583 | |
| 584 | c_val[0] = HT_MIXED_MODE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 585 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 586 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 587 | goto _fail_; |
| 588 | |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 589 | c_val[0] = 1; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 590 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 591 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 592 | goto _fail_; |
| 593 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 594 | c_val[0] = DETECT_PROTECT_REPORT; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 595 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 596 | 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 597 | goto _fail_; |
| 598 | |
| 599 | c_val[0] = RTS_CTS_NONHT_PROT; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 600 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 601 | goto _fail_; |
| 602 | |
| 603 | c_val[0] = 0; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 604 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 605 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 606 | goto _fail_; |
| 607 | |
| 608 | c_val[0] = MIMO_MODE; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 609 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 610 | goto _fail_; |
| 611 | |
| 612 | c_val[0] = 7; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 613 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 614 | 0)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 615 | goto _fail_; |
| 616 | |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 617 | c_val[0] = 1; |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 618 | if (!wilc_wlan_cfg_set(vif, 0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, |
Glen Lee | 89758e1 | 2015-11-18 15:11:34 +0900 | [diff] [blame] | 619 | 1, 1)) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 620 | goto _fail_; |
| 621 | |
| 622 | return 0; |
| 623 | |
| 624 | _fail_: |
| 625 | return -1; |
| 626 | } |
| 627 | |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 628 | void wilc1000_wlan_deinit(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 629 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 630 | struct wilc_vif *vif; |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 631 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 632 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 633 | vif = netdev_priv(dev); |
| 634 | wl = vif->wilc; |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 635 | |
| 636 | if (!wl) { |
| 637 | netdev_err(dev, "wl is NULL\n"); |
| 638 | return; |
| 639 | } |
| 640 | |
| 641 | if (wl->initialized) { |
| 642 | netdev_info(dev, "Deinitializing wilc1000...\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 643 | |
Arnd Bergmann | 5547c1f | 2015-11-16 15:05:06 +0100 | [diff] [blame] | 644 | if (!wl->dev_irq_num && |
Glen Lee | af9ae09 | 2015-12-21 14:18:09 +0900 | [diff] [blame] | 645 | wl->hif_func->disable_interrupt) { |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 646 | mutex_lock(&wl->hif_cs); |
Glen Lee | af9ae09 | 2015-12-21 14:18:09 +0900 | [diff] [blame] | 647 | wl->hif_func->disable_interrupt(wl); |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 648 | mutex_unlock(&wl->hif_cs); |
| 649 | } |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 650 | if (&wl->txq_event) |
Binoy Jayan | b27a6d5 | 2016-06-15 11:00:34 +0530 | [diff] [blame] | 651 | wait_for_completion(&wl->txq_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 652 | |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 653 | wlan_deinitialize_threads(dev); |
Glen Lee | ec5cc75 | 2015-10-27 18:27:39 +0900 | [diff] [blame] | 654 | deinit_irq(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 655 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 656 | wilc_wlan_stop(wl); |
Glen Lee | 2de7cbe | 2015-10-27 18:27:54 +0900 | [diff] [blame] | 657 | wilc_wlan_cleanup(dev); |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 658 | wlan_deinit_locks(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 659 | |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 660 | wl->initialized = false; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 661 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 662 | netdev_dbg(dev, "wilc1000 deinitialization Done\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 663 | } else { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 664 | netdev_dbg(dev, "wilc1000 is not initialized\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 665 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 666 | } |
| 667 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 668 | static int wlan_init_locks(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 669 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 670 | struct wilc_vif *vif; |
Glen Lee | 38afb39 | 2015-10-20 17:13:53 +0900 | [diff] [blame] | 671 | struct wilc *wl; |
| 672 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 673 | vif = netdev_priv(dev); |
| 674 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 675 | |
Glen Lee | 38afb39 | 2015-10-20 17:13:53 +0900 | [diff] [blame] | 676 | mutex_init(&wl->hif_cs); |
| 677 | mutex_init(&wl->rxq_cs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 678 | |
Glen Lee | 38afb39 | 2015-10-20 17:13:53 +0900 | [diff] [blame] | 679 | spin_lock_init(&wl->txq_spinlock); |
Binoy Jayan | 334bed0 | 2016-06-15 11:00:35 +0530 | [diff] [blame] | 680 | mutex_init(&wl->txq_add_to_head_cs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 681 | |
Binoy Jayan | b27a6d5 | 2016-06-15 11:00:34 +0530 | [diff] [blame] | 682 | init_completion(&wl->txq_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 683 | |
Binoy Jayan | fa65969 | 2016-06-15 11:00:36 +0530 | [diff] [blame] | 684 | init_completion(&wl->cfg_event); |
Binoy Jayan | 04247e7 | 2016-06-15 11:00:37 +0530 | [diff] [blame] | 685 | init_completion(&wl->sync_event); |
Leo Kim | 11a54b3 | 2016-04-01 17:44:15 +0900 | [diff] [blame] | 686 | init_completion(&wl->txq_thread_started); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 687 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 688 | return 0; |
| 689 | } |
| 690 | |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 691 | static int wlan_deinit_locks(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 692 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 693 | struct wilc_vif *vif; |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 694 | struct wilc *wilc; |
| 695 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 696 | vif = netdev_priv(dev); |
| 697 | wilc = vif->wilc; |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 698 | |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 699 | if (&wilc->hif_cs) |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 700 | mutex_destroy(&wilc->hif_cs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 701 | |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 702 | if (&wilc->rxq_cs) |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 703 | mutex_destroy(&wilc->rxq_cs); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 704 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 705 | return 0; |
| 706 | } |
Leo Kim | a40b22c | 2015-11-05 14:36:32 +0900 | [diff] [blame] | 707 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 708 | static int wlan_initialize_threads(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 709 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 710 | struct wilc_vif *vif; |
Glen Lee | 75a9466 | 2015-10-27 18:27:45 +0900 | [diff] [blame] | 711 | struct wilc *wilc; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 712 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 713 | vif = netdev_priv(dev); |
| 714 | wilc = vif->wilc; |
Glen Lee | 75a9466 | 2015-10-27 18:27:45 +0900 | [diff] [blame] | 715 | |
Glen Lee | 8868758 | 2015-10-27 18:27:46 +0900 | [diff] [blame] | 716 | wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev, |
Glen Lee | 75a9466 | 2015-10-27 18:27:45 +0900 | [diff] [blame] | 717 | "K_TXQ_TASK"); |
Wei Yongjun | b3e6916 | 2016-06-17 17:34:17 +0000 | [diff] [blame] | 718 | if (IS_ERR(wilc->txq_thread)) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 719 | netdev_err(dev, "couldn't create TXQ thread\n"); |
Leo Kim | 6bc72c5 | 2015-11-05 14:36:33 +0900 | [diff] [blame] | 720 | wilc->close = 0; |
Wei Yongjun | b3e6916 | 2016-06-17 17:34:17 +0000 | [diff] [blame] | 721 | return PTR_ERR(wilc->txq_thread); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 722 | } |
Leo Kim | 11a54b3 | 2016-04-01 17:44:15 +0900 | [diff] [blame] | 723 | wait_for_completion(&wilc->txq_thread_started); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 724 | |
| 725 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 726 | } |
| 727 | |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 728 | static void wlan_deinitialize_threads(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 729 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 730 | struct wilc_vif *vif; |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 731 | struct wilc *wl; |
Leo Kim | fa8b23c | 2016-02-04 18:15:33 +0900 | [diff] [blame] | 732 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 733 | vif = netdev_priv(dev); |
| 734 | wl = vif->wilc; |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 735 | |
| 736 | wl->close = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 737 | |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 738 | if (&wl->txq_event) |
Binoy Jayan | b27a6d5 | 2016-06-15 11:00:34 +0530 | [diff] [blame] | 739 | complete(&wl->txq_event); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 740 | |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 741 | if (wl->txq_thread) { |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 742 | kthread_stop(wl->txq_thread); |
| 743 | wl->txq_thread = NULL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 744 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 745 | } |
| 746 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 747 | int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 748 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 749 | int ret = 0; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 750 | struct wilc *wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 751 | |
Glen Lee | 0fa683b | 2015-10-20 17:13:52 +0900 | [diff] [blame] | 752 | if (!wl->initialized) { |
| 753 | wl->mac_status = WILC_MAC_STATUS_INIT; |
| 754 | wl->close = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 755 | |
Glen Lee | 38afb39 | 2015-10-20 17:13:53 +0900 | [diff] [blame] | 756 | wlan_init_locks(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 757 | |
Arnd Bergmann | 4bd7baf | 2015-11-16 15:04:59 +0100 | [diff] [blame] | 758 | ret = wilc_wlan_init(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 759 | if (ret < 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 760 | ret = -EIO; |
| 761 | goto _fail_locks_; |
| 762 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 763 | |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 764 | if (wl->gpio >= 0 && init_irq(dev)) { |
Tony Cho | b46d688 | 2015-10-20 14:26:54 +0900 | [diff] [blame] | 765 | ret = -EIO; |
| 766 | goto _fail_locks_; |
| 767 | } |
Tony Cho | b46d688 | 2015-10-20 14:26:54 +0900 | [diff] [blame] | 768 | |
Glen Lee | 75a9466 | 2015-10-27 18:27:45 +0900 | [diff] [blame] | 769 | ret = wlan_initialize_threads(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 770 | if (ret < 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 771 | ret = -EIO; |
| 772 | goto _fail_wilc_wlan_; |
| 773 | } |
| 774 | |
Arnd Bergmann | 5547c1f | 2015-11-16 15:05:06 +0100 | [diff] [blame] | 775 | if (!wl->dev_irq_num && |
Glen Lee | af9ae09 | 2015-12-21 14:18:09 +0900 | [diff] [blame] | 776 | wl->hif_func->enable_interrupt && |
| 777 | wl->hif_func->enable_interrupt(wl)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 778 | ret = -EIO; |
| 779 | goto _fail_irq_init_; |
| 780 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 781 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 782 | if (wilc_wlan_get_firmware(dev)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 783 | ret = -EIO; |
| 784 | goto _fail_irq_enable_; |
| 785 | } |
| 786 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 787 | ret = wilc1000_firmware_download(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 788 | if (ret < 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 789 | ret = -EIO; |
| 790 | goto _fail_irq_enable_; |
| 791 | } |
| 792 | |
Glen Lee | 9bf3d72 | 2015-10-29 12:18:46 +0900 | [diff] [blame] | 793 | ret = linux_wlan_start_firmware(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 794 | if (ret < 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 795 | ret = -EIO; |
| 796 | goto _fail_irq_enable_; |
| 797 | } |
| 798 | |
Glen Lee | 79df6a4 | 2016-02-04 18:15:31 +0900 | [diff] [blame] | 799 | if (wilc_wlan_cfg_get(vif, 1, WID_FIRMWARE_VERSION, 1, 0)) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 800 | int size; |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 801 | char firmware_ver[20]; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 802 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 803 | size = wilc_wlan_cfg_get_val(WID_FIRMWARE_VERSION, |
| 804 | firmware_ver, |
| 805 | sizeof(firmware_ver)); |
| 806 | firmware_ver[size] = '\0'; |
| 807 | netdev_dbg(dev, "Firmware Ver = %s\n", firmware_ver); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 808 | } |
Glen Lee | b8f6ca0 | 2016-01-25 16:35:12 +0900 | [diff] [blame] | 809 | ret = linux_wlan_init_test_config(dev, vif); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 810 | |
| 811 | if (ret < 0) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 812 | netdev_err(dev, "Failed to configure firmware\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 813 | ret = -EIO; |
| 814 | goto _fail_fw_start_; |
| 815 | } |
| 816 | |
Glen Lee | 0fa683b | 2015-10-20 17:13:52 +0900 | [diff] [blame] | 817 | wl->initialized = true; |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 818 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 819 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 820 | _fail_fw_start_: |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 821 | wilc_wlan_stop(wl); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 822 | |
| 823 | _fail_irq_enable_: |
Arnd Bergmann | 5547c1f | 2015-11-16 15:05:06 +0100 | [diff] [blame] | 824 | if (!wl->dev_irq_num && |
Glen Lee | af9ae09 | 2015-12-21 14:18:09 +0900 | [diff] [blame] | 825 | wl->hif_func->disable_interrupt) |
| 826 | wl->hif_func->disable_interrupt(wl); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 827 | _fail_irq_init_: |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 828 | if (wl->dev_irq_num) |
| 829 | deinit_irq(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 830 | |
Glen Lee | 32dd51b | 2015-10-27 18:27:52 +0900 | [diff] [blame] | 831 | wlan_deinitialize_threads(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 832 | _fail_wilc_wlan_: |
Glen Lee | 2de7cbe | 2015-10-27 18:27:54 +0900 | [diff] [blame] | 833 | wilc_wlan_cleanup(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 834 | _fail_locks_: |
Glen Lee | 7c67c05 | 2015-10-27 18:27:50 +0900 | [diff] [blame] | 835 | wlan_deinit_locks(dev); |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 836 | netdev_err(dev, "WLAN Iinitialization FAILED\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 837 | } else { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 838 | netdev_dbg(dev, "wilc1000 already initialized\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 839 | } |
| 840 | return ret; |
| 841 | } |
| 842 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 843 | static int mac_init_fn(struct net_device *ndev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 844 | { |
Leo Kim | 98b8984 | 2015-11-05 14:36:18 +0900 | [diff] [blame] | 845 | netif_start_queue(ndev); |
| 846 | netif_stop_queue(ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 847 | |
| 848 | return 0; |
| 849 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 850 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 851 | int wilc_mac_open(struct net_device *ndev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 852 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 853 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 854 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 855 | unsigned char mac_add[ETH_ALEN] = {0}; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 856 | int ret = 0; |
| 857 | int i = 0; |
Glen Lee | f3c1366 | 2015-10-20 17:13:54 +0900 | [diff] [blame] | 858 | struct wilc *wl; |
| 859 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 860 | vif = netdev_priv(ndev); |
| 861 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 862 | |
Leo Kim | 40095ad | 2016-01-27 11:50:27 +0900 | [diff] [blame] | 863 | if (!wl || !wl->dev) { |
Leo Kim | 90fd4cc | 2016-03-15 18:48:12 +0900 | [diff] [blame] | 864 | netdev_err(ndev, "device not ready\n"); |
Chandra S Gorentla | 7d05652 | 2015-09-15 18:09:51 +0530 | [diff] [blame] | 865 | return -ENODEV; |
| 866 | } |
Arnd Bergmann | b03314e | 2015-11-16 15:05:01 +0100 | [diff] [blame] | 867 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 868 | netdev_dbg(ndev, "MAC OPEN[%p]\n", ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 869 | |
Chaehyun Lim | dd4b6a8 | 2015-09-20 15:51:25 +0900 | [diff] [blame] | 870 | ret = wilc_init_host_int(ndev); |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 871 | if (ret < 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 872 | return ret; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 873 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 874 | ret = wilc1000_wlan_init(ndev, vif); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 875 | if (ret < 0) { |
Chaehyun Lim | a9a1682 | 2015-09-20 15:51:24 +0900 | [diff] [blame] | 876 | wilc_deinit_host_int(ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 877 | return ret; |
| 878 | } |
| 879 | |
Glen Lee | f3c1366 | 2015-10-20 17:13:54 +0900 | [diff] [blame] | 880 | for (i = 0; i < wl->vif_num; i++) { |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 881 | if (ndev == wl->vif[i]->ndev) { |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 882 | if (vif->iftype == AP_MODE) { |
| 883 | wilc_set_wfi_drv_handler(vif, |
| 884 | wilc_get_vif_idx(vif), |
| 885 | 0); |
Leo Kim | ba75047 | 2016-03-15 18:48:11 +0900 | [diff] [blame] | 886 | } else if (!wilc_wlan_get_num_conn_ifcs(wl)) { |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 887 | wilc_set_wfi_drv_handler(vif, |
| 888 | wilc_get_vif_idx(vif), |
Leo Kim | ba75047 | 2016-03-15 18:48:11 +0900 | [diff] [blame] | 889 | wl->open_ifcs); |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 890 | } else { |
Leo Kim | ba75047 | 2016-03-15 18:48:11 +0900 | [diff] [blame] | 891 | if (memcmp(wl->vif[i ^ 1]->bssid, |
| 892 | wl->vif[i ^ 1]->src_addr, 6)) |
Glen Lee | b330686 | 2016-02-04 18:15:18 +0900 | [diff] [blame] | 893 | wilc_set_wfi_drv_handler(vif, |
| 894 | wilc_get_vif_idx(vif), |
| 895 | 0); |
| 896 | else |
| 897 | wilc_set_wfi_drv_handler(vif, |
| 898 | wilc_get_vif_idx(vif), |
| 899 | 1); |
| 900 | } |
Glen Lee | e32737e | 2016-01-25 16:35:14 +0900 | [diff] [blame] | 901 | wilc_set_operation_mode(vif, vif->iftype); |
Glen Lee | 32cee99 | 2016-02-04 18:15:29 +0900 | [diff] [blame] | 902 | |
| 903 | wilc_get_mac_address(vif, mac_add); |
| 904 | netdev_dbg(ndev, "Mac address: %pM\n", mac_add); |
| 905 | memcpy(wl->vif[i]->src_addr, mac_add, ETH_ALEN); |
| 906 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 907 | break; |
| 908 | } |
| 909 | } |
| 910 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 911 | memcpy(ndev->dev_addr, wl->vif[i]->src_addr, ETH_ALEN); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 912 | |
| 913 | if (!is_valid_ether_addr(ndev->dev_addr)) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 914 | netdev_err(ndev, "Wrong MAC address\n"); |
Leo Kim | 339d244 | 2015-11-05 14:36:34 +0900 | [diff] [blame] | 915 | wilc_deinit_host_int(ndev); |
| 916 | wilc1000_wlan_deinit(ndev); |
| 917 | return -EINVAL; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 918 | } |
| 919 | |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 920 | wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy, |
| 921 | vif->ndev->ieee80211_ptr, |
Leo Kim | 340a84f | 2016-03-25 21:16:50 +0900 | [diff] [blame] | 922 | vif->frame_reg[0].type, |
Leo Kim | 89febb2 | 2016-03-25 21:16:49 +0900 | [diff] [blame] | 923 | vif->frame_reg[0].reg); |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 924 | wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy, |
| 925 | vif->ndev->ieee80211_ptr, |
Leo Kim | 340a84f | 2016-03-25 21:16:50 +0900 | [diff] [blame] | 926 | vif->frame_reg[1].type, |
Leo Kim | 89febb2 | 2016-03-25 21:16:49 +0900 | [diff] [blame] | 927 | vif->frame_reg[1].reg); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 928 | netif_wake_queue(ndev); |
Glen Lee | f3c1366 | 2015-10-20 17:13:54 +0900 | [diff] [blame] | 929 | wl->open_ifcs++; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 930 | vif->mac_opened = 1; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 931 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 932 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 933 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 934 | static struct net_device_stats *mac_stats(struct net_device *dev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 935 | { |
Leo Kim | 40095ad | 2016-01-27 11:50:27 +0900 | [diff] [blame] | 936 | struct wilc_vif *vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 937 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 938 | return &vif->netstats; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 939 | } |
| 940 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 941 | static void wilc_set_multicast_list(struct net_device *dev) |
| 942 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 943 | struct netdev_hw_addr *ha; |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 944 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 945 | int i = 0; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 946 | |
Glen Lee | cf60106 | 2015-12-21 14:18:39 +0900 | [diff] [blame] | 947 | vif = netdev_priv(dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 948 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 949 | if (dev->flags & IFF_PROMISC) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 950 | return; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 951 | |
Leo Kim | 582f8a2 | 2015-11-05 14:36:21 +0900 | [diff] [blame] | 952 | if ((dev->flags & IFF_ALLMULTI) || |
| 953 | (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 954 | wilc_setup_multicast_filter(vif, false, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 955 | return; |
| 956 | } |
| 957 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 958 | if ((dev->mc.count) == 0) { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 959 | wilc_setup_multicast_filter(vif, true, 0); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 960 | return; |
| 961 | } |
| 962 | |
Leo Kim | c8537e6 | 2015-11-06 11:12:24 +0900 | [diff] [blame] | 963 | netdev_for_each_mc_addr(ha, dev) { |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 964 | memcpy(wilc_multicast_mac_addr_list[i], ha->addr, ETH_ALEN); |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 965 | netdev_dbg(dev, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i, |
| 966 | wilc_multicast_mac_addr_list[i][0], |
| 967 | wilc_multicast_mac_addr_list[i][1], |
| 968 | wilc_multicast_mac_addr_list[i][2], |
| 969 | wilc_multicast_mac_addr_list[i][3], |
| 970 | wilc_multicast_mac_addr_list[i][4], |
| 971 | wilc_multicast_mac_addr_list[i][5]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 972 | i++; |
| 973 | } |
| 974 | |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 975 | wilc_setup_multicast_filter(vif, true, (dev->mc.count)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 976 | } |
| 977 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 978 | static void linux_wlan_tx_complete(void *priv, int status) |
| 979 | { |
Alison Schofield | d5c8944 | 2016-02-12 22:53:13 -0800 | [diff] [blame] | 980 | struct tx_complete_data *pv_data = priv; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 981 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 982 | dev_kfree_skb(pv_data->skb); |
Greg Kroah-Hartman | a18dd63 | 2015-09-03 19:04:19 -0700 | [diff] [blame] | 983 | kfree(pv_data); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 984 | } |
| 985 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 986 | int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 987 | { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 988 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 989 | struct tx_complete_data *tx_data = NULL; |
Leo Kim | 44ec3b7 | 2015-11-05 14:36:38 +0900 | [diff] [blame] | 990 | int queue_count; |
Leo Kim | fd8f036 | 2015-11-05 14:36:39 +0900 | [diff] [blame] | 991 | char *udp_buf; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 992 | struct iphdr *ih; |
| 993 | struct ethhdr *eth_h; |
Glen Lee | b7495be | 2015-10-27 18:28:01 +0900 | [diff] [blame] | 994 | struct wilc *wilc; |
Chaehyun Lim | 8dfaafd | 2015-08-18 23:18:11 +0900 | [diff] [blame] | 995 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 996 | vif = netdev_priv(ndev); |
| 997 | wilc = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 998 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 999 | if (skb->dev != ndev) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1000 | netdev_err(ndev, "Packet not destined to this device\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1001 | return 0; |
| 1002 | } |
| 1003 | |
Leo Kim | b38e903 | 2015-11-06 11:12:23 +0900 | [diff] [blame] | 1004 | tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC); |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 1005 | if (!tx_data) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1006 | dev_kfree_skb(skb); |
| 1007 | netif_wake_queue(ndev); |
| 1008 | return 0; |
| 1009 | } |
| 1010 | |
| 1011 | tx_data->buff = skb->data; |
| 1012 | tx_data->size = skb->len; |
| 1013 | tx_data->skb = skb; |
| 1014 | |
| 1015 | eth_h = (struct ethhdr *)(skb->data); |
Kim, Leo | fc4b95d | 2015-07-28 17:47:37 +0900 | [diff] [blame] | 1016 | if (eth_h->h_proto == 0x8e88) |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1017 | netdev_dbg(ndev, "EAPOL transmitted\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1018 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1019 | ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr)); |
| 1020 | |
Leo Kim | fd8f036 | 2015-11-05 14:36:39 +0900 | [diff] [blame] | 1021 | udp_buf = (char *)ih + sizeof(struct iphdr); |
| 1022 | if ((udp_buf[1] == 68 && udp_buf[3] == 67) || |
| 1023 | (udp_buf[1] == 67 && udp_buf[3] == 68)) |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1024 | netdev_dbg(ndev, "DHCP Message transmitted, type:%x %x %x\n", |
| 1025 | udp_buf[248], udp_buf[249], udp_buf[250]); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1026 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1027 | vif->netstats.tx_packets++; |
| 1028 | vif->netstats.tx_bytes += tx_data->size; |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 1029 | tx_data->bssid = wilc->vif[vif->idx]->bssid; |
Leo Kim | 44ec3b7 | 2015-11-05 14:36:38 +0900 | [diff] [blame] | 1030 | queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data, |
| 1031 | tx_data->buff, tx_data->size, |
| 1032 | linux_wlan_tx_complete); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1033 | |
Leo Kim | 44ec3b7 | 2015-11-05 14:36:38 +0900 | [diff] [blame] | 1034 | if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1035 | netif_stop_queue(wilc->vif[0]->ndev); |
| 1036 | netif_stop_queue(wilc->vif[1]->ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1037 | } |
| 1038 | |
| 1039 | return 0; |
| 1040 | } |
| 1041 | |
Arnd Bergmann | 0e1af73 | 2015-11-16 15:04:54 +0100 | [diff] [blame] | 1042 | int wilc_mac_close(struct net_device *ndev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1043 | { |
Chaehyun Lim | 2726887 | 2015-09-15 14:06:13 +0900 | [diff] [blame] | 1044 | struct wilc_priv *priv; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1045 | struct wilc_vif *vif; |
Leo Kim | 2db2c8a | 2015-11-05 14:36:15 +0900 | [diff] [blame] | 1046 | struct host_if_drv *hif_drv; |
Glen Lee | ca64ad6 | 2015-10-20 17:13:55 +0900 | [diff] [blame] | 1047 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1048 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1049 | vif = netdev_priv(ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1050 | |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 1051 | if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr || |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1052 | !vif->ndev->ieee80211_ptr->wiphy) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1053 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1054 | |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 1055 | priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1056 | wl = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1057 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1058 | if (!priv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1059 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1060 | |
Leo Kim | 48b28df | 2016-02-04 18:15:32 +0900 | [diff] [blame] | 1061 | hif_drv = (struct host_if_drv *)priv->hif_drv; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1062 | |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1063 | netdev_dbg(ndev, "Mac close\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1064 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1065 | if (!wl) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1066 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1067 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1068 | if (!hif_drv) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1069 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1070 | |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1071 | if ((wl->open_ifcs) > 0) |
Glen Lee | ca64ad6 | 2015-10-20 17:13:55 +0900 | [diff] [blame] | 1072 | wl->open_ifcs--; |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1073 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1074 | return 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1075 | |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 1076 | if (vif->ndev) { |
| 1077 | netif_stop_queue(vif->ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1078 | |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 1079 | wilc_deinit_host_int(vif->ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1080 | } |
| 1081 | |
Glen Lee | ca64ad6 | 2015-10-20 17:13:55 +0900 | [diff] [blame] | 1082 | if (wl->open_ifcs == 0) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1083 | netdev_dbg(ndev, "Deinitializing wilc1000\n"); |
Glen Lee | ca64ad6 | 2015-10-20 17:13:55 +0900 | [diff] [blame] | 1084 | wl->close = 1; |
Glen Lee | 53dc0cf | 2015-10-20 17:13:57 +0900 | [diff] [blame] | 1085 | wilc1000_wlan_deinit(ndev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1086 | WILC_WFI_deinit_mon_interface(); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1087 | } |
| 1088 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1089 | vif->mac_opened = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1090 | |
| 1091 | return 0; |
| 1092 | } |
| 1093 | |
Arnd Bergmann | 1608c40 | 2015-11-16 15:04:53 +0100 | [diff] [blame] | 1094 | static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1095 | { |
Greg Kroah-Hartman | 63d03e4 | 2015-06-02 14:16:04 +0900 | [diff] [blame] | 1096 | u8 *buff = NULL; |
Chaehyun Lim | ca356ad | 2015-06-11 14:35:57 +0900 | [diff] [blame] | 1097 | s8 rssi; |
Chaehyun Lim | 4e4467f | 2015-06-11 14:35:55 +0900 | [diff] [blame] | 1098 | u32 size = 0, length = 0; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1099 | struct wilc_vif *vif; |
Leo Kim | 9457b05 | 2015-11-05 14:36:37 +0900 | [diff] [blame] | 1100 | s32 ret = 0; |
Glen Lee | 07320b6 | 2015-10-27 18:27:53 +0900 | [diff] [blame] | 1101 | struct wilc *wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1102 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1103 | vif = netdev_priv(ndev); |
| 1104 | wilc = vif->wilc; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1105 | |
Glen Lee | 07320b6 | 2015-10-27 18:27:53 +0900 | [diff] [blame] | 1106 | if (!wilc->initialized) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1107 | return 0; |
| 1108 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1109 | switch (cmd) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1110 | case SIOCSIWPRIV: |
| 1111 | { |
Leo Kim | f05ab24 | 2016-01-27 11:50:26 +0900 | [diff] [blame] | 1112 | struct iwreq *wrq = (struct iwreq *)req; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1113 | |
| 1114 | size = wrq->u.data.length; |
| 1115 | |
| 1116 | if (size && wrq->u.data.pointer) { |
Leo Kim | 582f8a2 | 2015-11-05 14:36:21 +0900 | [diff] [blame] | 1117 | buff = memdup_user(wrq->u.data.pointer, |
| 1118 | wrq->u.data.length); |
Sudip Mukherjee | 360e27a | 2015-09-04 15:34:15 +0530 | [diff] [blame] | 1119 | if (IS_ERR(buff)) |
| 1120 | return PTR_ERR(buff); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1121 | |
| 1122 | if (strncasecmp(buff, "RSSI", length) == 0) { |
Glen Lee | fbf5379 | 2015-12-21 14:18:40 +0900 | [diff] [blame] | 1123 | ret = wilc_get_rssi(vif, &rssi); |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1124 | netdev_info(ndev, "RSSI :%d\n", rssi); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1125 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1126 | rssi += 5; |
| 1127 | |
| 1128 | snprintf(buff, size, "rssi %d", rssi); |
| 1129 | |
| 1130 | if (copy_to_user(wrq->u.data.pointer, buff, size)) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1131 | netdev_err(ndev, "failed to copy\n"); |
Leo Kim | 9457b05 | 2015-11-05 14:36:37 +0900 | [diff] [blame] | 1132 | ret = -EFAULT; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1133 | goto done; |
| 1134 | } |
| 1135 | } |
| 1136 | } |
| 1137 | } |
| 1138 | break; |
| 1139 | |
| 1140 | default: |
| 1141 | { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1142 | netdev_info(ndev, "Command - %d - has been received\n", cmd); |
Leo Kim | 9457b05 | 2015-11-05 14:36:37 +0900 | [diff] [blame] | 1143 | ret = -EOPNOTSUPP; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1144 | goto done; |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | done: |
| 1149 | |
Shraddha Barke | 642ac6c | 2015-08-10 13:30:33 +0530 | [diff] [blame] | 1150 | kfree(buff); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1151 | |
Leo Kim | 9457b05 | 2015-11-05 14:36:37 +0900 | [diff] [blame] | 1152 | return ret; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1153 | } |
| 1154 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 1155 | void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1156 | { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1157 | unsigned int frame_len = 0; |
| 1158 | int stats; |
| 1159 | unsigned char *buff_to_send = NULL; |
| 1160 | struct sk_buff *skb; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1161 | struct net_device *wilc_netdev; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1162 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1163 | |
Leo Kim | 0953a2e | 2016-01-27 11:50:25 +0900 | [diff] [blame] | 1164 | if (!wilc) |
| 1165 | return; |
| 1166 | |
Leo Kim | 7e725b4 | 2015-11-05 14:36:24 +0900 | [diff] [blame] | 1167 | wilc_netdev = get_if_handler(wilc, buff); |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 1168 | if (!wilc_netdev) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1169 | return; |
| 1170 | |
| 1171 | buff += pkt_offset; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1172 | vif = netdev_priv(wilc_netdev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1173 | |
| 1174 | if (size > 0) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1175 | frame_len = size; |
| 1176 | buff_to_send = buff; |
| 1177 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1178 | skb = dev_alloc_skb(frame_len); |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1179 | if (!skb) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1180 | return; |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1181 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1182 | skb->dev = wilc_netdev; |
| 1183 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1184 | memcpy(skb_put(skb, frame_len), buff_to_send, frame_len); |
| 1185 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1186 | skb->protocol = eth_type_trans(skb, wilc_netdev); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1187 | vif->netstats.rx_packets++; |
| 1188 | vif->netstats.rx_bytes += frame_len; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1189 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 1190 | stats = netif_rx(skb); |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1191 | netdev_dbg(wilc_netdev, "netif_rx ret value is: %d\n", stats); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1192 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1193 | } |
| 1194 | |
Glen Lee | 11f4b2e | 2015-10-27 18:27:51 +0900 | [diff] [blame] | 1195 | void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1196 | { |
| 1197 | int i = 0; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1198 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1199 | |
Glen Lee | 11f4b2e | 2015-10-27 18:27:51 +0900 | [diff] [blame] | 1200 | for (i = 0; i < wilc->vif_num; i++) { |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1201 | vif = netdev_priv(wilc->vif[i]->ndev); |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1202 | if (vif->monitor_flag) { |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1203 | WILC_WFI_monitor_rx(buff, size); |
| 1204 | return; |
| 1205 | } |
| 1206 | } |
| 1207 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1208 | vif = netdev_priv(wilc->vif[1]->ndev); |
Leo Kim | 340a84f | 2016-03-25 21:16:50 +0900 | [diff] [blame] | 1209 | if ((buff[0] == vif->frame_reg[0].type && vif->frame_reg[0].reg) || |
| 1210 | (buff[0] == vif->frame_reg[1].type && vif->frame_reg[1].reg)) |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1211 | WILC_WFI_p2p_rx(wilc->vif[1]->ndev, buff, size); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1212 | } |
| 1213 | |
Arnd Bergmann | 857c7b0 | 2015-11-16 15:05:00 +0100 | [diff] [blame] | 1214 | void wilc_netdev_cleanup(struct wilc *wilc) |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1215 | { |
| 1216 | int i = 0; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1217 | struct wilc_vif *vif[NUM_CONCURRENT_IFC]; |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1218 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1219 | if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1220 | unregister_inetaddr_notifier(&g_dev_notifier); |
| 1221 | |
| 1222 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1223 | vif[i] = netdev_priv(wilc->vif[i]->ndev); |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1224 | } |
| 1225 | |
Leo Kim | 3f626cf | 2016-04-01 17:44:17 +0900 | [diff] [blame] | 1226 | if (wilc && wilc->firmware) { |
Glen Lee | 90b984c | 2015-10-29 12:18:50 +0900 | [diff] [blame] | 1227 | release_firmware(wilc->firmware); |
Leo Kim | 3f626cf | 2016-04-01 17:44:17 +0900 | [diff] [blame] | 1228 | wilc->firmware = NULL; |
| 1229 | } |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1230 | |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1231 | if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1232 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1233 | if (wilc->vif[i]->ndev) |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1234 | if (vif[i]->mac_opened) |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1235 | wilc_mac_close(wilc->vif[i]->ndev); |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1236 | |
| 1237 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) { |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1238 | unregister_netdev(wilc->vif[i]->ndev); |
| 1239 | wilc_free_wiphy(wilc->vif[i]->ndev); |
| 1240 | free_netdev(wilc->vif[i]->ndev); |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1241 | } |
| 1242 | } |
| 1243 | |
Glen Lee | 90b984c | 2015-10-29 12:18:50 +0900 | [diff] [blame] | 1244 | kfree(wilc); |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1245 | } |
Arnd Bergmann | 750ffe9 | 2015-11-16 15:05:08 +0100 | [diff] [blame] | 1246 | EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); |
Tony Cho | 4875c49 | 2015-10-20 14:26:52 +0900 | [diff] [blame] | 1247 | |
Arnd Bergmann | 7d37a4a | 2015-11-16 15:05:05 +0100 | [diff] [blame] | 1248 | int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, |
| 1249 | int gpio, const struct wilc_hif_func *ops) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1250 | { |
Amitoj Kaur Chawla | fe747f0 | 2016-02-17 20:41:03 +0530 | [diff] [blame] | 1251 | int i, ret; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1252 | struct wilc_vif *vif; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1253 | struct net_device *ndev; |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 1254 | struct wilc *wl; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1255 | |
Glen Lee | 825b966 | 2015-11-18 15:11:37 +0900 | [diff] [blame] | 1256 | wl = kzalloc(sizeof(*wl), GFP_KERNEL); |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 1257 | if (!wl) |
Chaehyun Lim | ac61ef8 | 2015-09-08 00:36:36 +0900 | [diff] [blame] | 1258 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1259 | |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 1260 | *wilc = wl; |
| 1261 | wl->io_type = io_type; |
| 1262 | wl->gpio = gpio; |
Glen Lee | af9ae09 | 2015-12-21 14:18:09 +0900 | [diff] [blame] | 1263 | wl->hif_func = ops; |
Arnd Bergmann | c4d139c | 2015-11-16 15:05:04 +0100 | [diff] [blame] | 1264 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1265 | register_inetaddr_notifier(&g_dev_notifier); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1266 | |
| 1267 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) { |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1268 | ndev = alloc_etherdev(sizeof(struct wilc_vif)); |
Leo Kim | 1408603 | 2016-02-04 18:15:36 +0900 | [diff] [blame] | 1269 | if (!ndev) |
Amitoj Kaur Chawla | fe747f0 | 2016-02-17 20:41:03 +0530 | [diff] [blame] | 1270 | return -ENOMEM; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1271 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1272 | vif = netdev_priv(ndev); |
| 1273 | memset(vif, 0, sizeof(struct wilc_vif)); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1274 | |
Leo Kim | 84d3b87 | 2015-11-05 14:36:19 +0900 | [diff] [blame] | 1275 | if (i == 0) |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1276 | strcpy(ndev->name, "wlan%d"); |
Leo Kim | 84d3b87 | 2015-11-05 14:36:19 +0900 | [diff] [blame] | 1277 | else |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1278 | strcpy(ndev->name, "p2p%d"); |
| 1279 | |
Leo Kim | 6750140 | 2016-02-04 18:15:39 +0900 | [diff] [blame] | 1280 | vif->idx = wl->vif_num; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1281 | vif->wilc = *wilc; |
Glen Lee | 1f435d2 | 2015-12-21 14:18:37 +0900 | [diff] [blame] | 1282 | wl->vif[i] = vif; |
| 1283 | wl->vif[wl->vif_num]->ndev = ndev; |
Arnd Bergmann | 562ed3f | 2015-11-16 15:05:10 +0100 | [diff] [blame] | 1284 | wl->vif_num++; |
Arnd Bergmann | e5af056 | 2015-05-29 22:52:12 +0200 | [diff] [blame] | 1285 | ndev->netdev_ops = &wilc_netdev_ops; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1286 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1287 | { |
| 1288 | struct wireless_dev *wdev; |
Leo Kim | fa8b23c | 2016-02-04 18:15:33 +0900 | [diff] [blame] | 1289 | |
Arnd Bergmann | 2e7d537 | 2015-11-16 15:05:03 +0100 | [diff] [blame] | 1290 | wdev = wilc_create_wiphy(ndev, dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1291 | |
Arnd Bergmann | 6703992 | 2015-11-16 15:05:02 +0100 | [diff] [blame] | 1292 | if (dev) |
| 1293 | SET_NETDEV_DEV(ndev, dev); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1294 | |
Leo Kim | 3a147c0 | 2015-11-05 14:36:10 +0900 | [diff] [blame] | 1295 | if (!wdev) { |
Leo Kim | 5ac2442 | 2016-02-04 18:15:37 +0900 | [diff] [blame] | 1296 | netdev_err(ndev, "Can't register WILC Wiphy\n"); |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1297 | return -1; |
| 1298 | } |
| 1299 | |
Glen Lee | 1006b5c | 2015-12-21 14:18:38 +0900 | [diff] [blame] | 1300 | vif->ndev->ieee80211_ptr = wdev; |
| 1301 | vif->ndev->ml_priv = vif; |
| 1302 | wdev->netdev = vif->ndev; |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1303 | vif->netstats.rx_packets = 0; |
| 1304 | vif->netstats.tx_packets = 0; |
| 1305 | vif->netstats.rx_bytes = 0; |
| 1306 | vif->netstats.tx_bytes = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1307 | } |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1308 | |
Amitoj Kaur Chawla | fe747f0 | 2016-02-17 20:41:03 +0530 | [diff] [blame] | 1309 | ret = register_netdev(ndev); |
| 1310 | if (ret) |
| 1311 | return ret; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1312 | |
Glen Lee | a4cac48 | 2015-12-21 14:18:36 +0900 | [diff] [blame] | 1313 | vif->iftype = STATION_MODE; |
| 1314 | vif->mac_opened = 0; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1315 | } |
| 1316 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1317 | return 0; |
| 1318 | } |
Arnd Bergmann | 750ffe9 | 2015-11-16 15:05:08 +0100 | [diff] [blame] | 1319 | EXPORT_SYMBOL_GPL(wilc_netdev_init); |
Arnd Bergmann | c94f05e | 2015-11-16 15:05:09 +0100 | [diff] [blame] | 1320 | |
| 1321 | MODULE_LICENSE("GPL"); |