Merge tag 'powerpc-4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[deliverable/linux.git] / drivers / staging / wilc1000 / linux_wlan.c
CommitLineData
c5c77ba1
JK
1#include "wilc_wfi_cfgoperations.h"
2#include "linux_wlan_common.h"
3#include "wilc_wlan_if.h"
4#include "wilc_wlan.h"
c5c77ba1
JK
5
6#include <linux/slab.h>
7#include <linux/sched.h>
8#include <linux/delay.h>
9#include <linux/workqueue.h>
10#include <linux/interrupt.h>
11#include <linux/irq.h>
f1a99830 12#include <linux/gpio.h>
c5c77ba1
JK
13
14#include <linux/kthread.h>
15#include <linux/firmware.h>
16#include <linux/delay.h>
17
18#include <linux/init.h>
19#include <linux/netdevice.h>
c5c77ba1 20#include <linux/inetdevice.h>
c5c77ba1
JK
21#include <linux/etherdevice.h>
22#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/skbuff.h>
25
c5c77ba1
JK
26#include <linux/semaphore.h>
27
c5c77ba1
JK
28static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr);
29
30static struct notifier_block g_dev_notifier = {
31 .notifier_call = dev_state_ev_handler
32};
c5c77ba1 33
c5c77ba1
JK
34#define IRQ_WAIT 1
35#define IRQ_NO_WAIT 0
c5c77ba1 36static struct semaphore close_exit_sync;
c5c77ba1 37
7c67c053 38static int wlan_deinit_locks(struct net_device *dev);
32dd51bc 39static void wlan_deinitialize_threads(struct net_device *dev);
c5c77ba1 40
c5c77ba1 41static void linux_wlan_tx_complete(void *priv, int status);
c5c77ba1 42static int mac_init_fn(struct net_device *ndev);
c5c77ba1
JK
43static struct net_device_stats *mac_stats(struct net_device *dev);
44static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd);
45static void wilc_set_multicast_list(struct net_device *dev);
750ffe9b 46
0e1af73d 47bool wilc_enable_ps = true;
c5c77ba1 48
c5c77ba1
JK
49static const struct net_device_ops wilc_netdev_ops = {
50 .ndo_init = mac_init_fn,
0e1af73d
AB
51 .ndo_open = wilc_mac_open,
52 .ndo_stop = wilc_mac_close,
53 .ndo_start_xmit = wilc_mac_xmit,
c5c77ba1
JK
54 .ndo_do_ioctl = mac_ioctl,
55 .ndo_get_stats = mac_stats,
56 .ndo_set_rx_mode = wilc_set_multicast_list,
57
58};
c5c77ba1 59
c5c77ba1
JK
60static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr)
61{
62 struct in_ifaddr *dev_iface = (struct in_ifaddr *)ptr;
2726887c 63 struct wilc_priv *priv;
f24374aa 64 struct host_if_drv *hif_drv;
c5c77ba1 65 struct net_device *dev;
eac3e8f6 66 u8 *ip_addr_buf;
a4cac481 67 struct wilc_vif *vif;
63d03e47 68 u8 null_ip[4] = {0};
c5c77ba1
JK
69 char wlan_dev_name[5] = "wlan0";
70
3a147c07 71 if (!dev_iface || !dev_iface->ifa_dev || !dev_iface->ifa_dev->dev) {
c5c77ba1
JK
72 PRINT_D(GENERIC_DBG, "dev_iface = NULL\n");
73 return NOTIFY_DONE;
74 }
75
582f8a27
LK
76 if (memcmp(dev_iface->ifa_label, "wlan0", 5) &&
77 memcmp(dev_iface->ifa_label, "p2p0", 4)) {
c5c77ba1
JK
78 PRINT_D(GENERIC_DBG, "Interface is neither WLAN0 nor P2P0\n");
79 return NOTIFY_DONE;
80 }
81
82 dev = (struct net_device *)dev_iface->ifa_dev->dev;
3a147c07 83 if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) {
c5c77ba1
JK
84 PRINT_D(GENERIC_DBG, "No Wireless registerd\n");
85 return NOTIFY_DONE;
86 }
87 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
3a147c07 88 if (!priv) {
c5c77ba1
JK
89 PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
90 return NOTIFY_DONE;
91 }
f24374aa 92 hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv;
a4cac481
GL
93 vif = netdev_priv(dev);
94 if (!vif || !hif_drv) {
c5c77ba1
JK
95 PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
96 return NOTIFY_DONE;
97 }
98
98b89847 99 PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler +++\n");
c5c77ba1
JK
100
101 switch (event) {
102 case NETDEV_UP:
98b89847 103 PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_UP %p\n", dev);
c5c77ba1
JK
104
105 PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Obtained ===============\n\n");
106
a4cac481 107 if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) {
f24374aa 108 hif_drv->IFC_UP = 1;
0e1af73d
AB
109 wilc_optaining_ip = false;
110 del_timer(&wilc_during_ip_timer);
c5c77ba1
JK
111 PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n");
112 }
113
0e1af73d 114 if (wilc_enable_ps)
fbf5379b 115 wilc_set_power_mgmt(vif, 1, 0);
c5c77ba1
JK
116
117 PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label);
118
eac3e8f6
LK
119 ip_addr_buf = (char *)&dev_iface->ifa_address;
120 PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n",
121 ip_addr_buf[0], ip_addr_buf[1],
122 ip_addr_buf[2], ip_addr_buf[3]);
fbf5379b 123 wilc_setup_ipaddress(vif, ip_addr_buf, vif->u8IfIdx);
c5c77ba1
JK
124
125 break;
126
127 case NETDEV_DOWN:
98b89847 128 PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_DOWN %p\n", dev);
c5c77ba1
JK
129
130 PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Released ===============\n\n");
a4cac481 131 if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) {
f24374aa 132 hif_drv->IFC_UP = 0;
0e1af73d 133 wilc_optaining_ip = false;
c5c77ba1
JK
134 }
135
136 if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0)
fbf5379b 137 wilc_set_power_mgmt(vif, 0, 0);
c5c77ba1 138
fbf5379b 139 wilc_resolve_disconnect_aberration(vif);
c5c77ba1 140
c5c77ba1
JK
141 PRINT_D(GENERIC_DBG, "[%s] Down IP\n", dev_iface->ifa_label);
142
eac3e8f6
LK
143 ip_addr_buf = null_ip;
144 PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n",
145 ip_addr_buf[0], ip_addr_buf[1],
146 ip_addr_buf[2], ip_addr_buf[3]);
c5c77ba1 147
fbf5379b 148 wilc_setup_ipaddress(vif, ip_addr_buf, vif->u8IfIdx);
c5c77ba1
JK
149
150 break;
151
152 default:
98b89847 153 PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler event=default\n");
c5c77ba1
JK
154 PRINT_INFO(GENERIC_DBG, "[%s] unknown dev event: %lu\n", dev_iface->ifa_label, event);
155
156 break;
157 }
158
159 return NOTIFY_DONE;
c5c77ba1 160}
c5c77ba1 161
c5c77ba1
JK
162static irqreturn_t isr_uh_routine(int irq, void *user_data)
163{
a4cac481 164 struct wilc_vif *vif;
3948362d
GL
165 struct wilc *wilc;
166 struct net_device *dev = (struct net_device *)user_data;
167
a4cac481
GL
168 vif = netdev_priv(dev);
169 wilc = vif->wilc;
c5c77ba1
JK
170 PRINT_D(INT_DBG, "Interrupt received UH\n");
171
3948362d 172 if (wilc->close) {
c5c77ba1 173 PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n");
c5c77ba1 174 return IRQ_HANDLED;
c5c77ba1 175 }
c5c77ba1 176 return IRQ_WAKE_THREAD;
c5c77ba1 177}
c5c77ba1 178
1608c403 179static irqreturn_t isr_bh_routine(int irq, void *userdata)
c5c77ba1 180{
a4cac481 181 struct wilc_vif *vif;
2e7933d0
GL
182 struct wilc *wilc;
183
a4cac481
GL
184 vif = netdev_priv(userdata);
185 wilc = vif->wilc;
2e7933d0 186
2e7933d0 187 if (wilc->close) {
c5c77ba1 188 PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n");
c5c77ba1 189 return IRQ_HANDLED;
c5c77ba1
JK
190 }
191
c5c77ba1 192 PRINT_D(INT_DBG, "Interrupt received BH\n");
50b929e0 193 wilc_handle_isr(wilc);
c5c77ba1 194
c5c77ba1 195 return IRQ_HANDLED;
c5c77ba1 196}
c5c77ba1 197
2c1d05d1 198static int init_irq(struct net_device *dev)
c5c77ba1
JK
199{
200 int ret = 0;
a4cac481 201 struct wilc_vif *vif;
2c1d05d1
GL
202 struct wilc *wl;
203
a4cac481
GL
204 vif = netdev_priv(dev);
205 wl = vif->wilc;
c5c77ba1 206
c4d139cb
AB
207 if ((gpio_request(wl->gpio, "WILC_INTR") == 0) &&
208 (gpio_direction_input(wl->gpio) == 0)) {
209 wl->dev_irq_num = gpio_to_irq(wl->gpio);
c5c77ba1
JK
210 } else {
211 ret = -1;
212 PRINT_ER("could not obtain gpio for WILC_INTR\n");
213 }
214
83231b72
LK
215 if (ret != -1 && request_threaded_irq(wl->dev_irq_num,
216 isr_uh_routine,
217 isr_bh_routine,
218 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
219 "WILC_IRQ", dev) < 0) {
c4d139cb
AB
220 PRINT_ER("Failed to request IRQ for GPIO: %d\n", wl->gpio);
221 gpio_free(wl->gpio);
c5c77ba1
JK
222 ret = -1;
223 } else {
c5c77ba1 224 PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
c4d139cb 225 wl->dev_irq_num, wl->gpio);
c5c77ba1
JK
226 }
227
228 return ret;
229}
c5c77ba1 230
ec5cc750 231static void deinit_irq(struct net_device *dev)
c5c77ba1 232{
a4cac481 233 struct wilc_vif *vif;
ec5cc750
GL
234 struct wilc *wilc;
235
a4cac481
GL
236 vif = netdev_priv(dev);
237 wilc = vif->wilc;
ec5cc750 238
c4d139cb
AB
239 /* Deintialize IRQ */
240 if (wilc->dev_irq_num) {
ec5cc750 241 free_irq(wilc->dev_irq_num, wilc);
c4d139cb 242 gpio_free(wilc->gpio);
c5c77ba1 243 }
c5c77ba1
JK
244}
245
d36ec22d 246void wilc_dbg(u8 *buff)
c5c77ba1
JK
247{
248 PRINT_D(INIT_DBG, "%d\n", *buff);
249}
250
562ed3f1 251int wilc_lock_timeout(struct wilc *nic, void *vp, u32 timeout)
c5c77ba1 252{
562ed3f1 253 /* FIXME: replace with mutex_lock or wait_for_completion */
c5c77ba1 254 int error = -1;
8dfaafd6 255
c5c77ba1 256 PRINT_D(LOCK_DBG, "Locking %p\n", vp);
3a147c07 257 if (vp)
582f8a27
LK
258 error = down_timeout((struct semaphore *)vp,
259 msecs_to_jiffies(timeout));
78174ada 260 else
c5c77ba1 261 PRINT_ER("Failed, mutex is NULL\n");
c5c77ba1
JK
262 return error;
263}
264
562ed3f1 265void wilc_mac_indicate(struct wilc *wilc, int flag)
c5c77ba1 266{
c5c77ba1
JK
267 int status;
268
269 if (flag == WILC_MAC_INDICATE_STATUS) {
582f8a27
LK
270 wilc_wlan_cfg_get_val(WID_STATUS,
271 (unsigned char *)&status, 4);
64f2b71b
GL
272 if (wilc->mac_status == WILC_MAC_STATUS_INIT) {
273 wilc->mac_status = status;
274 up(&wilc->sync_event);
c5c77ba1 275 } else {
64f2b71b 276 wilc->mac_status = status;
c5c77ba1 277 }
c5c77ba1
JK
278 } else if (flag == WILC_MAC_INDICATE_SCAN) {
279 PRINT_D(GENERIC_DBG, "Scanning ...\n");
c5c77ba1 280 }
c5c77ba1
JK
281}
282
1608c403 283static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header)
c5c77ba1 284{
660786ea 285 u8 *bssid, *bssid1;
c5c77ba1
JK
286 int i = 0;
287
d239222e 288 bssid = mac_header + 10;
660786ea 289 bssid1 = mac_header + 4;
c5c77ba1 290
4ad81fd6 291 for (i = 0; i < wilc->vif_num; i++)
1f435d2e
GL
292 if (!memcmp(bssid1, wilc->vif[i]->bssid, ETH_ALEN) ||
293 !memcmp(bssid, wilc->vif[i]->bssid, ETH_ALEN))
294 return wilc->vif[i]->ndev;
8259a53e 295
c5c77ba1 296 PRINT_INFO(INIT_DBG, "Invalide handle\n");
fc4b95d6 297 for (i = 0; i < 25; i++)
51456c2a 298 PRINT_D(INIT_DBG, "%02x ", mac_header[i]);
d239222e 299 bssid = mac_header + 18;
660786ea 300 bssid1 = mac_header + 12;
4ad81fd6 301 for (i = 0; i < wilc->vif_num; i++)
1f435d2e
GL
302 if (!memcmp(bssid1, wilc->vif[i]->bssid, ETH_ALEN) ||
303 !memcmp(bssid, wilc->vif[i]->bssid, ETH_ALEN))
304 return wilc->vif[i]->ndev;
8259a53e 305
c5c77ba1
JK
306 PRINT_INFO(INIT_DBG, "\n");
307 return NULL;
308}
309
0e1af73d 310int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid)
c5c77ba1
JK
311{
312 int i = 0;
313 int ret = -1;
a4cac481 314 struct wilc_vif *vif;
472791a9 315 struct wilc *wilc;
c5c77ba1 316
a4cac481
GL
317 vif = netdev_priv(wilc_netdev);
318 wilc = vif->wilc;
472791a9
GL
319
320 for (i = 0; i < wilc->vif_num; i++)
1f435d2e
GL
321 if (wilc->vif[i]->ndev == wilc_netdev) {
322 memcpy(wilc->vif[i]->bssid, bssid, 6);
c5c77ba1
JK
323 ret = 0;
324 break;
325 }
8259a53e 326
c5c77ba1
JK
327 return ret;
328}
329
562ed3f1 330int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
c5c77ba1 331{
51e825f7
CL
332 u8 i = 0;
333 u8 null_bssid[6] = {0};
334 u8 ret_val = 0;
c5c77ba1 335
562ed3f1 336 for (i = 0; i < wilc->vif_num; i++)
1f435d2e 337 if (memcmp(wilc->vif[i]->bssid, null_bssid, 6))
c5c77ba1 338 ret_val++;
8259a53e 339
c5c77ba1
JK
340 return ret_val;
341}
342
c5c77ba1
JK
343#define USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
344
345static int linux_wlan_txq_task(void *vp)
346{
347 int ret, txq_count;
a4cac481 348 struct wilc_vif *vif;
88687584
GL
349 struct wilc *wl;
350 struct net_device *dev = vp;
c5c77ba1
JK
351#if defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
352#define TX_BACKOFF_WEIGHT_INCR_STEP (1)
353#define TX_BACKOFF_WEIGHT_DECR_STEP (1)
354#define TX_BACKOFF_WEIGHT_MAX (7)
355#define TX_BACKOFF_WEIGHT_MIN (0)
356#define TX_BACKOFF_WEIGHT_UNIT_MS (10)
357 int backoff_weight = TX_BACKOFF_WEIGHT_MIN;
c5c77ba1
JK
358#endif
359
a4cac481
GL
360 vif = netdev_priv(dev);
361 wl = vif->wilc;
88687584 362
88687584 363 up(&wl->txq_thread_started);
c5c77ba1 364 while (1) {
c5c77ba1 365 PRINT_D(TX_DBG, "txq_task Taking a nap :)\n");
88687584 366 down(&wl->txq_event);
c5c77ba1
JK
367 PRINT_D(TX_DBG, "txq_task Who waked me up :$\n");
368
88687584 369 if (wl->close) {
88687584 370 up(&wl->txq_thread_started);
c5c77ba1
JK
371
372 while (!kthread_should_stop())
373 schedule();
374
375 PRINT_D(TX_DBG, "TX thread stopped\n");
376 break;
377 }
378 PRINT_D(TX_DBG, "txq_task handle the sending packet and let me go to sleep.\n");
379#if !defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
a1332cad 380 ret = wilc_wlan_handle_txq(dev, &txq_count);
c5c77ba1
JK
381#else
382 do {
a1332cad 383 ret = wilc_wlan_handle_txq(dev, &txq_count);
98b89847 384 if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) {
c5c77ba1 385 PRINT_D(TX_DBG, "Waking up queue\n");
98b89847 386
1f435d2e
GL
387 if (netif_queue_stopped(wl->vif[0]->ndev))
388 netif_wake_queue(wl->vif[0]->ndev);
389 if (netif_queue_stopped(wl->vif[1]->ndev))
390 netif_wake_queue(wl->vif[1]->ndev);
c5c77ba1
JK
391 }
392
98b89847 393 if (ret == WILC_TX_ERR_NO_BUF) {
c5c77ba1 394 do {
c5c77ba1 395 msleep(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight);
98b89847 396 } while (0);
c5c77ba1 397 backoff_weight += TX_BACKOFF_WEIGHT_INCR_STEP;
fc4b95d6 398 if (backoff_weight > TX_BACKOFF_WEIGHT_MAX)
c5c77ba1 399 backoff_weight = TX_BACKOFF_WEIGHT_MAX;
c5c77ba1
JK
400 } else {
401 if (backoff_weight > TX_BACKOFF_WEIGHT_MIN) {
402 backoff_weight -= TX_BACKOFF_WEIGHT_DECR_STEP;
fc4b95d6 403 if (backoff_weight < TX_BACKOFF_WEIGHT_MIN)
c5c77ba1 404 backoff_weight = TX_BACKOFF_WEIGHT_MIN;
c5c77ba1
JK
405 }
406 }
98b89847 407 } while (ret == WILC_TX_ERR_NO_BUF && !wl->close);
c5c77ba1
JK
408#endif
409 }
410 return 0;
411}
412
562ed3f1 413void wilc_rx_complete(struct wilc *nic)
c5c77ba1
JK
414{
415 PRINT_D(RX_DBG, "RX completed\n");
416}
417
0e1af73d 418int wilc_wlan_get_firmware(struct net_device *dev)
c5c77ba1 419{
a4cac481 420 struct wilc_vif *vif;
65c8adcf 421 struct wilc *wilc;
c5c77ba1
JK
422 int ret = 0;
423 const struct firmware *wilc_firmware;
424 char *firmware;
425
a4cac481
GL
426 vif = netdev_priv(dev);
427 wilc = vif->wilc;
65c8adcf 428
a4cac481 429 if (vif->iftype == AP_MODE) {
c5c77ba1 430 firmware = AP_FIRMWARE;
a4cac481 431 } else if (vif->iftype == STATION_MODE) {
c5c77ba1 432 firmware = STA_FIRMWARE;
1b7a93ad 433 } else {
c5c77ba1
JK
434 PRINT_D(INIT_DBG, "Get P2P_CONCURRENCY_FIRMWARE\n");
435 firmware = P2P_CONCURRENCY_FIRMWARE;
436 }
437
a4cac481
GL
438 if (!vif) {
439 PRINT_ER("vif is NULL\n");
c5c77ba1
JK
440 goto _fail_;
441 }
442
1006b5c7
GL
443 if (!(&vif->ndev->dev)) {
444 PRINT_ER("&vif->ndev->dev is NULL\n");
c5c77ba1
JK
445 goto _fail_;
446 }
447
b03314e2 448 if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) {
c5c77ba1
JK
449 PRINT_ER("%s - firmare not available\n", firmware);
450 ret = -1;
451 goto _fail_;
452 }
65c8adcf 453 wilc->firmware = wilc_firmware;
c5c77ba1
JK
454
455_fail_:
456
457 return ret;
c5c77ba1
JK
458}
459
9bf3d727 460static int linux_wlan_start_firmware(struct net_device *dev)
c5c77ba1 461{
a4cac481 462 struct wilc_vif *vif;
9bf3d727 463 struct wilc *wilc;
c5c77ba1 464 int ret = 0;
9bf3d727 465
a4cac481
GL
466 vif = netdev_priv(dev);
467 wilc = vif->wilc;
9bf3d727 468
c5c77ba1 469 PRINT_D(INIT_DBG, "Starting Firmware ...\n");
562ed3f1 470 ret = wilc_wlan_start(wilc);
c5c77ba1
JK
471 if (ret < 0) {
472 PRINT_ER("Failed to start Firmware\n");
0aeea1ad 473 return ret;
c5c77ba1
JK
474 }
475
c5c77ba1 476 PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n");
562ed3f1 477 ret = wilc_lock_timeout(wilc, &wilc->sync_event, 5000);
c5c77ba1 478 if (ret) {
c5c77ba1 479 PRINT_D(INIT_DBG, "Firmware start timed out");
0aeea1ad 480 return ret;
c5c77ba1 481 }
c5c77ba1
JK
482 PRINT_D(INIT_DBG, "Firmware successfully started\n");
483
0aeea1ad 484 return 0;
c5c77ba1 485}
a40b22c5 486
562ed3f1 487static int wilc1000_firmware_download(struct net_device *dev)
c5c77ba1 488{
a4cac481 489 struct wilc_vif *vif;
ed760b67 490 struct wilc *wilc;
c5c77ba1
JK
491 int ret = 0;
492
a4cac481
GL
493 vif = netdev_priv(dev);
494 wilc = vif->wilc;
ed760b67
GL
495
496 if (!wilc->firmware) {
c5c77ba1 497 PRINT_ER("Firmware buffer is NULL\n");
14b1821d 498 return -ENOBUFS;
c5c77ba1 499 }
c5c77ba1 500 PRINT_D(INIT_DBG, "Downloading Firmware ...\n");
562ed3f1 501 ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data,
ed760b67 502 wilc->firmware->size);
fc4b95d6 503 if (ret < 0)
14b1821d 504 return ret;
c5c77ba1 505
c5c77ba1
JK
506 PRINT_D(INIT_DBG, "Freeing FW buffer ...\n");
507 PRINT_D(INIT_DBG, "Releasing firmware\n");
ed760b67 508 release_firmware(wilc->firmware);
6f72ed75 509 wilc->firmware = NULL;
c5c77ba1 510
17aacd43 511 PRINT_D(INIT_DBG, "Download Succeeded\n");
c5c77ba1 512
14b1821d 513 return 0;
c5c77ba1
JK
514}
515
00215dde
GL
516static int linux_wlan_init_test_config(struct net_device *dev,
517 struct wilc *wilc)
c5c77ba1 518{
c5c77ba1 519 unsigned char c_val[64];
c5c77ba1 520 unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff};
c5c77ba1 521
2726887c 522 struct wilc_priv *priv;
0fa66c71 523 struct host_if_drv *hif_drv;
c5c77ba1
JK
524
525 PRINT_D(TX_DBG, "Start configuring Firmware\n");
c5c77ba1
JK
526 get_random_bytes(&mac_add[5], 1);
527 get_random_bytes(&mac_add[4], 1);
c5c77ba1 528 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
0fa66c71
LK
529 hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv;
530 PRINT_D(INIT_DBG, "Host = %p\n", hif_drv);
c5c77ba1 531
582f8a27
LK
532 PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n",
533 mac_add[0], mac_add[1], mac_add[2],
534 mac_add[3], mac_add[4], mac_add[5]);
00215dde 535 wilc_get_chipid(wilc, 0);
c5c77ba1 536
e5d57e91 537 *(int *)c_val = 1;
c5c77ba1 538
89758e13 539 if (!wilc_wlan_cfg_set(wilc, 1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
c5c77ba1
JK
540 goto _fail_;
541
c5c77ba1 542 c_val[0] = 0;
89758e13 543 if (!wilc_wlan_cfg_set(wilc, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
c5c77ba1
JK
544 goto _fail_;
545
546 c_val[0] = INFRASTRUCTURE;
89758e13 547 if (!wilc_wlan_cfg_set(wilc, 0, WID_BSS_TYPE, c_val, 1, 0, 0))
c5c77ba1
JK
548 goto _fail_;
549
c5c77ba1 550 c_val[0] = RATE_AUTO;
89758e13 551 if (!wilc_wlan_cfg_set(wilc, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
c5c77ba1
JK
552 goto _fail_;
553
554 c_val[0] = G_MIXED_11B_2_MODE;
89758e13
GL
555 if (!wilc_wlan_cfg_set(wilc, 0, WID_11G_OPERATING_MODE, c_val, 1, 0,
556 0))
c5c77ba1
JK
557 goto _fail_;
558
559 c_val[0] = 1;
89758e13 560 if (!wilc_wlan_cfg_set(wilc, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
c5c77ba1
JK
561 goto _fail_;
562
563 c_val[0] = G_SHORT_PREAMBLE;
89758e13 564 if (!wilc_wlan_cfg_set(wilc, 0, WID_PREAMBLE, c_val, 1, 0, 0))
c5c77ba1
JK
565 goto _fail_;
566
567 c_val[0] = AUTO_PROT;
89758e13 568 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
c5c77ba1
JK
569 goto _fail_;
570
c5c77ba1 571 c_val[0] = ACTIVE_SCAN;
89758e13 572 if (!wilc_wlan_cfg_set(wilc, 0, WID_SCAN_TYPE, c_val, 1, 0, 0))
c5c77ba1
JK
573 goto _fail_;
574
575 c_val[0] = SITE_SURVEY_OFF;
89758e13 576 if (!wilc_wlan_cfg_set(wilc, 0, WID_SITE_SURVEY, c_val, 1, 0, 0))
c5c77ba1
JK
577 goto _fail_;
578
98b89847 579 *((int *)c_val) = 0xffff;
89758e13 580 if (!wilc_wlan_cfg_set(wilc, 0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
c5c77ba1
JK
581 goto _fail_;
582
583 *((int *)c_val) = 2346;
89758e13 584 if (!wilc_wlan_cfg_set(wilc, 0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
c5c77ba1
JK
585 goto _fail_;
586
c5c77ba1 587 c_val[0] = 0;
89758e13 588 if (!wilc_wlan_cfg_set(wilc, 0, WID_BCAST_SSID, c_val, 1, 0, 0))
c5c77ba1
JK
589 goto _fail_;
590
591 c_val[0] = 1;
89758e13 592 if (!wilc_wlan_cfg_set(wilc, 0, WID_QOS_ENABLE, c_val, 1, 0, 0))
c5c77ba1
JK
593 goto _fail_;
594
595 c_val[0] = NO_POWERSAVE;
89758e13 596 if (!wilc_wlan_cfg_set(wilc, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
c5c77ba1
JK
597 goto _fail_;
598
b4d04c15 599 c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */
89758e13 600 if (!wilc_wlan_cfg_set(wilc, 0, WID_11I_MODE, c_val, 1, 0, 0))
c5c77ba1
JK
601 goto _fail_;
602
603 c_val[0] = OPEN_SYSTEM;
89758e13 604 if (!wilc_wlan_cfg_set(wilc, 0, WID_AUTH_TYPE, c_val, 1, 0, 0))
c5c77ba1
JK
605 goto _fail_;
606
c5c77ba1 607 strcpy(c_val, "123456790abcdef1234567890");
89758e13
GL
608 if (!wilc_wlan_cfg_set(wilc, 0, WID_WEP_KEY_VALUE, c_val,
609 (strlen(c_val) + 1), 0, 0))
c5c77ba1
JK
610 goto _fail_;
611
c5c77ba1 612 strcpy(c_val, "12345678");
89758e13
GL
613 if (!wilc_wlan_cfg_set(wilc, 0, WID_11I_PSK, c_val, (strlen(c_val)), 0,
614 0))
c5c77ba1
JK
615 goto _fail_;
616
c5c77ba1 617 strcpy(c_val, "password");
89758e13
GL
618 if (!wilc_wlan_cfg_set(wilc, 0, WID_1X_KEY, c_val, (strlen(c_val) + 1),
619 0, 0))
c5c77ba1
JK
620 goto _fail_;
621
c5c77ba1
JK
622 c_val[0] = 192;
623 c_val[1] = 168;
624 c_val[2] = 1;
625 c_val[3] = 112;
89758e13 626 if (!wilc_wlan_cfg_set(wilc, 0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
c5c77ba1
JK
627 goto _fail_;
628
629 c_val[0] = 3;
89758e13 630 if (!wilc_wlan_cfg_set(wilc, 0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
c5c77ba1
JK
631 goto _fail_;
632
633 c_val[0] = 3;
89758e13 634 if (!wilc_wlan_cfg_set(wilc, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
c5c77ba1
JK
635 goto _fail_;
636
637 c_val[0] = NORMAL_ACK;
89758e13 638 if (!wilc_wlan_cfg_set(wilc, 0, WID_ACK_POLICY, c_val, 1, 0, 0))
c5c77ba1
JK
639 goto _fail_;
640
641 c_val[0] = 0;
89758e13
GL
642 if (!wilc_wlan_cfg_set(wilc, 0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1,
643 0, 0))
c5c77ba1
JK
644 goto _fail_;
645
646 c_val[0] = 48;
89758e13
GL
647 if (!wilc_wlan_cfg_set(wilc, 0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0,
648 0))
c5c77ba1
JK
649 goto _fail_;
650
651 c_val[0] = 28;
89758e13
GL
652 if (!wilc_wlan_cfg_set(wilc, 0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0,
653 0))
c5c77ba1
JK
654 goto _fail_;
655
c5c77ba1 656 *((int *)c_val) = 100;
89758e13 657 if (!wilc_wlan_cfg_set(wilc, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
c5c77ba1
JK
658 goto _fail_;
659
660 c_val[0] = REKEY_DISABLE;
89758e13 661 if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_POLICY, c_val, 1, 0, 0))
c5c77ba1
JK
662 goto _fail_;
663
c5c77ba1 664 *((int *)c_val) = 84600;
89758e13 665 if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
c5c77ba1
JK
666 goto _fail_;
667
c5c77ba1 668 *((int *)c_val) = 500;
89758e13
GL
669 if (!wilc_wlan_cfg_set(wilc, 0, WID_REKEY_PACKET_COUNT, c_val, 4, 0,
670 0))
c5c77ba1
JK
671 goto _fail_;
672
673 c_val[0] = 1;
89758e13
GL
674 if (!wilc_wlan_cfg_set(wilc, 0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0,
675 0))
c5c77ba1
JK
676 goto _fail_;
677
678 c_val[0] = G_SELF_CTS_PROT;
89758e13 679 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
c5c77ba1
JK
680 goto _fail_;
681
98b89847 682 c_val[0] = 1;
89758e13 683 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_ENABLE, c_val, 1, 0, 0))
c5c77ba1
JK
684 goto _fail_;
685
686 c_val[0] = HT_MIXED_MODE;
89758e13
GL
687 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_OPERATING_MODE, c_val, 1, 0,
688 0))
c5c77ba1
JK
689 goto _fail_;
690
98b89847 691 c_val[0] = 1;
89758e13
GL
692 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0,
693 0))
c5c77ba1
JK
694 goto _fail_;
695
696 memcpy(c_val, mac_add, 6);
697
89758e13 698 if (!wilc_wlan_cfg_set(wilc, 0, WID_MAC_ADDR, c_val, 6, 0, 0))
c5c77ba1
JK
699 goto _fail_;
700
c5c77ba1 701 c_val[0] = DETECT_PROTECT_REPORT;
89758e13
GL
702 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1,
703 0, 0))
c5c77ba1
JK
704 goto _fail_;
705
706 c_val[0] = RTS_CTS_NONHT_PROT;
89758e13 707 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
c5c77ba1
JK
708 goto _fail_;
709
710 c_val[0] = 0;
89758e13
GL
711 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0,
712 0))
c5c77ba1
JK
713 goto _fail_;
714
715 c_val[0] = MIMO_MODE;
89758e13 716 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
c5c77ba1
JK
717 goto _fail_;
718
719 c_val[0] = 7;
89758e13
GL
720 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0,
721 0))
c5c77ba1
JK
722 goto _fail_;
723
98b89847 724 c_val[0] = 1;
89758e13
GL
725 if (!wilc_wlan_cfg_set(wilc, 0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1,
726 1, 1))
c5c77ba1
JK
727 goto _fail_;
728
729 return 0;
730
731_fail_:
732 return -1;
733}
734
53dc0cfe 735void wilc1000_wlan_deinit(struct net_device *dev)
c5c77ba1 736{
a4cac481 737 struct wilc_vif *vif;
53dc0cfe 738 struct wilc *wl;
c5c77ba1 739
a4cac481
GL
740 vif = netdev_priv(dev);
741 wl = vif->wilc;
53dc0cfe
GL
742
743 if (!wl) {
744 netdev_err(dev, "wl is NULL\n");
745 return;
746 }
747
748 if (wl->initialized) {
749 netdev_info(dev, "Deinitializing wilc1000...\n");
c5c77ba1 750
c5c77ba1 751 PRINT_D(INIT_DBG, "Disabling IRQ\n");
5547c1f0 752 if (!wl->dev_irq_num &&
af9ae09a 753 wl->hif_func->disable_interrupt) {
c4d139cb 754 mutex_lock(&wl->hif_cs);
af9ae09a 755 wl->hif_func->disable_interrupt(wl);
c4d139cb
AB
756 mutex_unlock(&wl->hif_cs);
757 }
3a147c07 758 if (&wl->txq_event)
53dc0cfe 759 up(&wl->txq_event);
c5c77ba1 760
c5c77ba1 761 PRINT_D(INIT_DBG, "Deinitializing Threads\n");
32dd51bc 762 wlan_deinitialize_threads(dev);
c5c77ba1
JK
763
764 PRINT_D(INIT_DBG, "Deinitializing IRQ\n");
ec5cc750 765 deinit_irq(dev);
c5c77ba1 766
562ed3f1 767 wilc_wlan_stop(wl);
c5c77ba1
JK
768
769 PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n");
2de7cbec 770 wilc_wlan_cleanup(dev);
c4d139cb 771#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
5547c1f0 772 if (!wl->dev_irq_num &&
af9ae09a 773 wl->hif_func->disable_interrupt) {
5547c1f0 774
c4d139cb
AB
775 PRINT_D(INIT_DBG, "Disabling IRQ 2\n");
776
777 mutex_lock(&wl->hif_cs);
af9ae09a 778 wl->hif_func->disable_interrupt(wl);
c4d139cb
AB
779 mutex_unlock(&wl->hif_cs);
780 }
c5c77ba1
JK
781#endif
782
c5c77ba1 783 PRINT_D(INIT_DBG, "Deinitializing Locks\n");
7c67c053 784 wlan_deinit_locks(dev);
c5c77ba1 785
53dc0cfe 786 wl->initialized = false;
c5c77ba1
JK
787
788 PRINT_D(INIT_DBG, "wilc1000 deinitialization Done\n");
789
790 } else {
791 PRINT_D(INIT_DBG, "wilc1000 is not initialized\n");
792 }
c5c77ba1
JK
793}
794
1608c403 795static int wlan_init_locks(struct net_device *dev)
c5c77ba1 796{
a4cac481 797 struct wilc_vif *vif;
38afb390
GL
798 struct wilc *wl;
799
a4cac481
GL
800 vif = netdev_priv(dev);
801 wl = vif->wilc;
c5c77ba1
JK
802
803 PRINT_D(INIT_DBG, "Initializing Locks ...\n");
804
38afb390
GL
805 mutex_init(&wl->hif_cs);
806 mutex_init(&wl->rxq_cs);
c5c77ba1 807
38afb390
GL
808 spin_lock_init(&wl->txq_spinlock);
809 sema_init(&wl->txq_add_to_head_cs, 1);
c5c77ba1 810
38afb390 811 sema_init(&wl->txq_event, 0);
c5c77ba1 812
38afb390
GL
813 sema_init(&wl->cfg_event, 0);
814 sema_init(&wl->sync_event, 0);
c5c77ba1 815
38afb390 816 sema_init(&wl->txq_thread_started, 0);
c5c77ba1 817
c5c77ba1
JK
818 return 0;
819}
820
7c67c053 821static int wlan_deinit_locks(struct net_device *dev)
c5c77ba1 822{
a4cac481 823 struct wilc_vif *vif;
7c67c053
GL
824 struct wilc *wilc;
825
a4cac481
GL
826 vif = netdev_priv(dev);
827 wilc = vif->wilc;
7c67c053 828
c5c77ba1
JK
829 PRINT_D(INIT_DBG, "De-Initializing Locks\n");
830
3a147c07 831 if (&wilc->hif_cs)
7c67c053 832 mutex_destroy(&wilc->hif_cs);
c5c77ba1 833
3a147c07 834 if (&wilc->rxq_cs)
7c67c053 835 mutex_destroy(&wilc->rxq_cs);
c5c77ba1 836
c5c77ba1
JK
837 return 0;
838}
a40b22c5 839
1608c403 840static int wlan_initialize_threads(struct net_device *dev)
c5c77ba1 841{
a4cac481 842 struct wilc_vif *vif;
75a94665 843 struct wilc *wilc;
8dfaafd6 844
a4cac481
GL
845 vif = netdev_priv(dev);
846 wilc = vif->wilc;
75a94665 847
c5c77ba1 848 PRINT_D(INIT_DBG, "Initializing Threads ...\n");
c5c77ba1 849 PRINT_D(INIT_DBG, "Creating kthread for transmission\n");
88687584 850 wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev,
75a94665
GL
851 "K_TXQ_TASK");
852 if (!wilc->txq_thread) {
c5c77ba1 853 PRINT_ER("couldn't create TXQ thread\n");
6bc72c5a
LK
854 wilc->close = 0;
855 return -ENOBUFS;
c5c77ba1 856 }
75a94665 857 down(&wilc->txq_thread_started);
c5c77ba1
JK
858
859 return 0;
c5c77ba1
JK
860}
861
32dd51bc 862static void wlan_deinitialize_threads(struct net_device *dev)
c5c77ba1 863{
a4cac481 864 struct wilc_vif *vif;
32dd51bc 865 struct wilc *wl;
a4cac481
GL
866 vif = netdev_priv(dev);
867 wl = vif->wilc;
c5c77ba1 868
32dd51bc 869 wl->close = 1;
c5c77ba1 870 PRINT_D(INIT_DBG, "Deinitializing Threads\n");
c5c77ba1 871
3a147c07 872 if (&wl->txq_event)
32dd51bc 873 up(&wl->txq_event);
c5c77ba1 874
3a147c07 875 if (wl->txq_thread) {
32dd51bc
GL
876 kthread_stop(wl->txq_thread);
877 wl->txq_thread = NULL;
c5c77ba1 878 }
c5c77ba1
JK
879}
880
a4cac481 881int wilc1000_wlan_init(struct net_device *dev, struct wilc_vif *vif)
c5c77ba1 882{
c5c77ba1 883 int ret = 0;
a4cac481 884 struct wilc *wl = vif->wilc;
c5c77ba1 885
0fa683b6
GL
886 if (!wl->initialized) {
887 wl->mac_status = WILC_MAC_STATUS_INIT;
888 wl->close = 0;
c5c77ba1 889
38afb390 890 wlan_init_locks(dev);
c5c77ba1 891
4bd7baf0 892 ret = wilc_wlan_init(dev);
c5c77ba1
JK
893 if (ret < 0) {
894 PRINT_ER("Initializing WILC_Wlan FAILED\n");
895 ret = -EIO;
896 goto _fail_locks_;
897 }
c5c77ba1 898
c4d139cb 899 if (wl->gpio >= 0 && init_irq(dev)) {
c5c77ba1
JK
900 PRINT_ER("couldn't initialize IRQ\n");
901 ret = -EIO;
b46d6882 902 goto _fail_locks_;
c5c77ba1 903 }
c5c77ba1 904
75a94665 905 ret = wlan_initialize_threads(dev);
b46d6882
TC
906 if (ret < 0) {
907 PRINT_ER("Initializing Threads FAILED\n");
908 ret = -EIO;
909 goto _fail_wilc_wlan_;
910 }
911
5547c1f0 912 if (!wl->dev_irq_num &&
af9ae09a
GL
913 wl->hif_func->enable_interrupt &&
914 wl->hif_func->enable_interrupt(wl)) {
c5c77ba1
JK
915 PRINT_ER("couldn't initialize IRQ\n");
916 ret = -EIO;
917 goto _fail_irq_init_;
918 }
c5c77ba1 919
0e1af73d 920 if (wilc_wlan_get_firmware(dev)) {
17aacd43 921 PRINT_ER("Can't get firmware\n");
c5c77ba1
JK
922 ret = -EIO;
923 goto _fail_irq_enable_;
924 }
925
562ed3f1 926 ret = wilc1000_firmware_download(dev);
c5c77ba1
JK
927 if (ret < 0) {
928 PRINT_ER("Failed to download firmware\n");
929 ret = -EIO;
930 goto _fail_irq_enable_;
931 }
932
9bf3d727 933 ret = linux_wlan_start_firmware(dev);
c5c77ba1
JK
934 if (ret < 0) {
935 PRINT_ER("Failed to start firmware\n");
936 ret = -EIO;
937 goto _fail_irq_enable_;
938 }
939
d40c99c7 940 if (wilc_wlan_cfg_get(wl, 1, WID_FIRMWARE_VERSION, 1, 0)) {
c5c77ba1
JK
941 int size;
942 char Firmware_ver[20];
8dfaafd6 943
894de36b 944 size = wilc_wlan_cfg_get_val(
c5c77ba1
JK
945 WID_FIRMWARE_VERSION,
946 Firmware_ver, sizeof(Firmware_ver));
947 Firmware_ver[size] = '\0';
948 PRINT_D(INIT_DBG, "***** Firmware Ver = %s *******\n", Firmware_ver);
949 }
0fa683b6 950 ret = linux_wlan_init_test_config(dev, wl);
c5c77ba1
JK
951
952 if (ret < 0) {
953 PRINT_ER("Failed to configure firmware\n");
954 ret = -EIO;
955 goto _fail_fw_start_;
956 }
957
0fa683b6 958 wl->initialized = true;
98b89847 959 return 0;
c5c77ba1 960
c5c77ba1 961_fail_fw_start_:
562ed3f1 962 wilc_wlan_stop(wl);
c5c77ba1
JK
963
964_fail_irq_enable_:
5547c1f0 965 if (!wl->dev_irq_num &&
af9ae09a
GL
966 wl->hif_func->disable_interrupt)
967 wl->hif_func->disable_interrupt(wl);
c5c77ba1 968_fail_irq_init_:
c4d139cb
AB
969 if (wl->dev_irq_num)
970 deinit_irq(dev);
c5c77ba1 971
32dd51bc 972 wlan_deinitialize_threads(dev);
c5c77ba1 973_fail_wilc_wlan_:
2de7cbec 974 wilc_wlan_cleanup(dev);
c5c77ba1 975_fail_locks_:
7c67c053 976 wlan_deinit_locks(dev);
c5c77ba1
JK
977 PRINT_ER("WLAN Iinitialization FAILED\n");
978 } else {
979 PRINT_D(INIT_DBG, "wilc1000 already initialized\n");
980 }
981 return ret;
982}
983
1608c403 984static int mac_init_fn(struct net_device *ndev)
c5c77ba1 985{
98b89847
LK
986 netif_start_queue(ndev);
987 netif_stop_queue(ndev);
c5c77ba1
JK
988
989 return 0;
990}
c5c77ba1 991
0e1af73d 992int wilc_mac_open(struct net_device *ndev)
c5c77ba1 993{
a4cac481 994 struct wilc_vif *vif;
562ed3f1 995 struct wilc *wilc;
c5c77ba1 996
c5c77ba1 997 unsigned char mac_add[ETH_ALEN] = {0};
c5c77ba1
JK
998 int ret = 0;
999 int i = 0;
2726887c 1000 struct wilc_priv *priv;
f3c1366e
GL
1001 struct wilc *wl;
1002
a4cac481
GL
1003 vif = netdev_priv(ndev);
1004 wl = vif->wilc;
c5c77ba1 1005
b03314e2 1006 if (!wl|| !wl->dev) {
7d05652c
CG
1007 netdev_err(ndev, "wilc1000: SPI device not ready\n");
1008 return -ENODEV;
1009 }
b03314e2 1010
a4cac481
GL
1011 vif = netdev_priv(ndev);
1012 wilc = vif->wilc;
1006b5c7 1013 priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
c5c77ba1
JK
1014 PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev);
1015
dd4b6a83 1016 ret = wilc_init_host_int(ndev);
c5c77ba1
JK
1017 if (ret < 0) {
1018 PRINT_ER("Failed to initialize host interface\n");
1019
1020 return ret;
1021 }
c5c77ba1 1022
c5c77ba1 1023 PRINT_D(INIT_DBG, "*** re-init ***\n");
a4cac481 1024 ret = wilc1000_wlan_init(ndev, vif);
c5c77ba1
JK
1025 if (ret < 0) {
1026 PRINT_ER("Failed to initialize wilc1000\n");
a9a16823 1027 wilc_deinit_host_int(ndev);
c5c77ba1
JK
1028 return ret;
1029 }
1030
0e1af73d 1031 wilc_set_machw_change_vir_if(ndev, false);
c5c77ba1 1032
fbf5379b 1033 wilc_get_mac_address(vif, mac_add);
310a28fd 1034 PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add);
c5c77ba1 1035
f3c1366e 1036 for (i = 0; i < wl->vif_num; i++) {
1f435d2e
GL
1037 if (ndev == wl->vif[i]->ndev) {
1038 memcpy(wl->vif[i]->src_addr, mac_add, ETH_ALEN);
c5c77ba1
JK
1039 break;
1040 }
1041 }
1042
1f435d2e 1043 memcpy(ndev->dev_addr, wl->vif[i]->src_addr, ETH_ALEN);
c5c77ba1
JK
1044
1045 if (!is_valid_ether_addr(ndev->dev_addr)) {
1046 PRINT_ER("Error: Wrong MAC address\n");
339d244a
LK
1047 wilc_deinit_host_int(ndev);
1048 wilc1000_wlan_deinit(ndev);
1049 return -EINVAL;
c5c77ba1
JK
1050 }
1051
1006b5c7
GL
1052 wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
1053 vif->ndev->ieee80211_ptr,
a4cac481
GL
1054 vif->g_struct_frame_reg[0].frame_type,
1055 vif->g_struct_frame_reg[0].reg);
1006b5c7
GL
1056 wilc_mgmt_frame_register(vif->ndev->ieee80211_ptr->wiphy,
1057 vif->ndev->ieee80211_ptr,
a4cac481
GL
1058 vif->g_struct_frame_reg[1].frame_type,
1059 vif->g_struct_frame_reg[1].reg);
c5c77ba1 1060 netif_wake_queue(ndev);
f3c1366e 1061 wl->open_ifcs++;
a4cac481 1062 vif->mac_opened = 1;
c5c77ba1 1063 return 0;
c5c77ba1 1064}
c5c77ba1 1065
1608c403 1066static struct net_device_stats *mac_stats(struct net_device *dev)
c5c77ba1 1067{
a4cac481 1068 struct wilc_vif *vif= netdev_priv(dev);
c5c77ba1 1069
a4cac481 1070 return &vif->netstats;
c5c77ba1
JK
1071}
1072
c5c77ba1
JK
1073static void wilc_set_multicast_list(struct net_device *dev)
1074{
c5c77ba1 1075 struct netdev_hw_addr *ha;
2726887c 1076 struct wilc_priv *priv;
ef7606c5 1077 struct host_if_drv *hif_drv;
cf60106b 1078 struct wilc_vif *vif;
c5c77ba1 1079 int i = 0;
8dfaafd6 1080
c5c77ba1 1081 priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
cf60106b 1082 vif = netdev_priv(dev);
ef7606c5 1083 hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv;
c5c77ba1 1084
c5c77ba1
JK
1085 if (!dev)
1086 return;
1087
582f8a27
LK
1088 PRINT_D(INIT_DBG, "Setting Multicast List with count = %d.\n",
1089 dev->mc.count);
c5c77ba1
JK
1090
1091 if (dev->flags & IFF_PROMISC) {
17aacd43 1092 PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets\n");
c5c77ba1
JK
1093 return;
1094 }
1095
582f8a27
LK
1096 if ((dev->flags & IFF_ALLMULTI) ||
1097 (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) {
c5c77ba1 1098 PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n");
fbf5379b 1099 wilc_setup_multicast_filter(vif, false, 0);
c5c77ba1
JK
1100 return;
1101 }
1102
c5c77ba1
JK
1103 if ((dev->mc.count) == 0) {
1104 PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n");
fbf5379b 1105 wilc_setup_multicast_filter(vif, true, 0);
c5c77ba1
JK
1106 return;
1107 }
1108
c8537e6d 1109 netdev_for_each_mc_addr(ha, dev) {
0e1af73d 1110 memcpy(wilc_multicast_mac_addr_list[i], ha->addr, ETH_ALEN);
c5c77ba1 1111 PRINT_D(INIT_DBG, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i,
0e1af73d
AB
1112 wilc_multicast_mac_addr_list[i][0],
1113 wilc_multicast_mac_addr_list[i][1],
1114 wilc_multicast_mac_addr_list[i][2],
1115 wilc_multicast_mac_addr_list[i][3],
1116 wilc_multicast_mac_addr_list[i][4],
1117 wilc_multicast_mac_addr_list[i][5]);
c5c77ba1
JK
1118 i++;
1119 }
1120
fbf5379b 1121 wilc_setup_multicast_filter(vif, true, (dev->mc.count));
c5c77ba1
JK
1122
1123 return;
c5c77ba1
JK
1124}
1125
c5c77ba1
JK
1126static void linux_wlan_tx_complete(void *priv, int status)
1127{
c5c77ba1 1128 struct tx_complete_data *pv_data = (struct tx_complete_data *)priv;
8dfaafd6 1129
78174ada 1130 if (status == 1)
c5c77ba1 1131 PRINT_D(TX_DBG, "Packet sent successfully - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
78174ada 1132 else
c5c77ba1 1133 PRINT_D(TX_DBG, "Couldn't send packet - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
c5c77ba1 1134 dev_kfree_skb(pv_data->skb);
a18dd630 1135 kfree(pv_data);
c5c77ba1
JK
1136}
1137
0e1af73d 1138int wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
c5c77ba1 1139{
a4cac481 1140 struct wilc_vif *vif;
c5c77ba1 1141 struct tx_complete_data *tx_data = NULL;
44ec3b75 1142 int queue_count;
fd8f0367 1143 char *udp_buf;
c5c77ba1
JK
1144 struct iphdr *ih;
1145 struct ethhdr *eth_h;
b7495be5 1146 struct wilc *wilc;
8dfaafd6 1147
a4cac481
GL
1148 vif = netdev_priv(ndev);
1149 wilc = vif->wilc;
c5c77ba1 1150
c5c77ba1
JK
1151 PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n");
1152
c5c77ba1
JK
1153 if (skb->dev != ndev) {
1154 PRINT_ER("Packet not destined to this device\n");
1155 return 0;
1156 }
1157
b38e9030 1158 tx_data = kmalloc(sizeof(*tx_data), GFP_ATOMIC);
3a147c07 1159 if (!tx_data) {
c5c77ba1
JK
1160 PRINT_ER("Failed to allocate memory for tx_data structure\n");
1161 dev_kfree_skb(skb);
1162 netif_wake_queue(ndev);
1163 return 0;
1164 }
1165
1166 tx_data->buff = skb->data;
1167 tx_data->size = skb->len;
1168 tx_data->skb = skb;
1169
1170 eth_h = (struct ethhdr *)(skb->data);
fc4b95d6 1171 if (eth_h->h_proto == 0x8e88)
c5c77ba1 1172 PRINT_D(INIT_DBG, "EAPOL transmitted\n");
c5c77ba1 1173
c5c77ba1
JK
1174 ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr));
1175
fd8f0367
LK
1176 udp_buf = (char *)ih + sizeof(struct iphdr);
1177 if ((udp_buf[1] == 68 && udp_buf[3] == 67) ||
1178 (udp_buf[1] == 67 && udp_buf[3] == 68))
1179 PRINT_D(GENERIC_DBG, "DHCP Message transmitted, type:%x %x %x\n",
1180 udp_buf[248], udp_buf[249], udp_buf[250]);
c5c77ba1 1181
c5c77ba1 1182 PRINT_D(TX_DBG, "Sending packet - Size = %d - Address = %p - SKB = %p\n", tx_data->size, tx_data->buff, tx_data->skb);
c5c77ba1 1183 PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n");
a4cac481
GL
1184 vif->netstats.tx_packets++;
1185 vif->netstats.tx_bytes += tx_data->size;
1f435d2e 1186 tx_data->pBssid = wilc->vif[vif->u8IfIdx]->bssid;
44ec3b75
LK
1187 queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data,
1188 tx_data->buff, tx_data->size,
1189 linux_wlan_tx_complete);
c5c77ba1 1190
44ec3b75 1191 if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) {
1f435d2e
GL
1192 netif_stop_queue(wilc->vif[0]->ndev);
1193 netif_stop_queue(wilc->vif[1]->ndev);
c5c77ba1
JK
1194 }
1195
1196 return 0;
1197}
1198
0e1af73d 1199int wilc_mac_close(struct net_device *ndev)
c5c77ba1 1200{
2726887c 1201 struct wilc_priv *priv;
a4cac481 1202 struct wilc_vif *vif;
2db2c8a7 1203 struct host_if_drv *hif_drv;
ca64ad6e 1204 struct wilc *wl;
c5c77ba1 1205
a4cac481 1206 vif = netdev_priv(ndev);
c5c77ba1 1207
1006b5c7
GL
1208 if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr ||
1209 !vif->ndev->ieee80211_ptr->wiphy) {
a4cac481 1210 PRINT_ER("vif = NULL\n");
c5c77ba1
JK
1211 return 0;
1212 }
1213
1006b5c7 1214 priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
a4cac481 1215 wl = vif->wilc;
c5c77ba1 1216
3a147c07 1217 if (!priv) {
c5c77ba1
JK
1218 PRINT_ER("priv = NULL\n");
1219 return 0;
1220 }
1221
2db2c8a7 1222 hif_drv = (struct host_if_drv *)priv->hWILCWFIDrv;
c5c77ba1 1223
c5c77ba1
JK
1224 PRINT_D(GENERIC_DBG, "Mac close\n");
1225
ca64ad6e
GL
1226 if (!wl) {
1227 PRINT_ER("wl = NULL\n");
c5c77ba1
JK
1228 return 0;
1229 }
1230
2db2c8a7
LK
1231 if (!hif_drv) {
1232 PRINT_ER("hif_drv = NULL\n");
c5c77ba1
JK
1233 return 0;
1234 }
1235
ca64ad6e
GL
1236 if ((wl->open_ifcs) > 0) {
1237 wl->open_ifcs--;
c5c77ba1
JK
1238 } else {
1239 PRINT_ER("ERROR: MAC close called while number of opened interfaces is zero\n");
1240 return 0;
1241 }
1242
1006b5c7
GL
1243 if (vif->ndev) {
1244 netif_stop_queue(vif->ndev);
c5c77ba1 1245
1006b5c7 1246 wilc_deinit_host_int(vif->ndev);
c5c77ba1
JK
1247 }
1248
ca64ad6e 1249 if (wl->open_ifcs == 0) {
c5c77ba1 1250 PRINT_D(GENERIC_DBG, "Deinitializing wilc1000\n");
ca64ad6e 1251 wl->close = 1;
53dc0cfe 1252 wilc1000_wlan_deinit(ndev);
c5c77ba1 1253 WILC_WFI_deinit_mon_interface();
c5c77ba1
JK
1254 }
1255
8990d856 1256 up(&close_exit_sync);
a4cac481 1257 vif->mac_opened = 0;
c5c77ba1
JK
1258
1259 return 0;
1260}
1261
1608c403 1262static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
c5c77ba1 1263{
63d03e47 1264 u8 *buff = NULL;
ca356ada 1265 s8 rssi;
4e4467fd 1266 u32 size = 0, length = 0;
a4cac481 1267 struct wilc_vif *vif;
2726887c 1268 struct wilc_priv *priv;
9457b05e 1269 s32 ret = 0;
07320b6b 1270 struct wilc *wilc;
c5c77ba1 1271
a4cac481
GL
1272 vif = netdev_priv(ndev);
1273 wilc = vif->wilc;
c5c77ba1 1274
07320b6b 1275 if (!wilc->initialized)
c5c77ba1
JK
1276 return 0;
1277
c5c77ba1 1278 switch (cmd) {
c5c77ba1
JK
1279 case SIOCSIWPRIV:
1280 {
98b89847 1281 struct iwreq *wrq = (struct iwreq *) req;
c5c77ba1
JK
1282
1283 size = wrq->u.data.length;
1284
1285 if (size && wrq->u.data.pointer) {
582f8a27
LK
1286 buff = memdup_user(wrq->u.data.pointer,
1287 wrq->u.data.length);
360e27a9
SM
1288 if (IS_ERR(buff))
1289 return PTR_ERR(buff);
c5c77ba1
JK
1290
1291 if (strncasecmp(buff, "RSSI", length) == 0) {
1006b5c7 1292 priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy);
fbf5379b 1293 ret = wilc_get_rssi(vif, &rssi);
9457b05e 1294 if (ret)
c5c77ba1 1295 PRINT_ER("Failed to send get rssi param's message queue ");
c5c77ba1
JK
1296 PRINT_INFO(GENERIC_DBG, "RSSI :%d\n", rssi);
1297
c5c77ba1
JK
1298 rssi += 5;
1299
1300 snprintf(buff, size, "rssi %d", rssi);
1301
1302 if (copy_to_user(wrq->u.data.pointer, buff, size)) {
60cb1e20 1303 PRINT_ER("%s: failed to copy data to user buffer\n", __func__);
9457b05e 1304 ret = -EFAULT;
c5c77ba1
JK
1305 goto done;
1306 }
1307 }
1308 }
1309 }
1310 break;
1311
1312 default:
1313 {
1314 PRINT_INFO(GENERIC_DBG, "Command - %d - has been received\n", cmd);
9457b05e 1315 ret = -EOPNOTSUPP;
c5c77ba1
JK
1316 goto done;
1317 }
1318 }
1319
1320done:
1321
642ac6c0 1322 kfree(buff);
c5c77ba1 1323
9457b05e 1324 return ret;
c5c77ba1
JK
1325}
1326
562ed3f1 1327void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset)
c5c77ba1 1328{
c5c77ba1
JK
1329 unsigned int frame_len = 0;
1330 int stats;
1331 unsigned char *buff_to_send = NULL;
1332 struct sk_buff *skb;
c5c77ba1 1333 struct net_device *wilc_netdev;
a4cac481 1334 struct wilc_vif *vif;
c5c77ba1 1335
7e725b47 1336 wilc_netdev = get_if_handler(wilc, buff);
3a147c07 1337 if (!wilc_netdev)
c5c77ba1
JK
1338 return;
1339
1340 buff += pkt_offset;
a4cac481 1341 vif = netdev_priv(wilc_netdev);
c5c77ba1
JK
1342
1343 if (size > 0) {
c5c77ba1
JK
1344 frame_len = size;
1345 buff_to_send = buff;
1346
c5c77ba1 1347 skb = dev_alloc_skb(frame_len);
3a147c07 1348 if (!skb) {
c5c77ba1
JK
1349 PRINT_ER("Low memory - packet droped\n");
1350 return;
1351 }
1352
3a147c07 1353 if (!wilc || !wilc_netdev)
cb1991ac 1354 PRINT_ER("wilc_netdev in wilc is NULL");
c5c77ba1
JK
1355 skb->dev = wilc_netdev;
1356
3a147c07 1357 if (!skb->dev)
c5c77ba1 1358 PRINT_ER("skb->dev is NULL\n");
c5c77ba1 1359
c5c77ba1
JK
1360 memcpy(skb_put(skb, frame_len), buff_to_send, frame_len);
1361
c5c77ba1 1362 skb->protocol = eth_type_trans(skb, wilc_netdev);
a4cac481
GL
1363 vif->netstats.rx_packets++;
1364 vif->netstats.rx_bytes += frame_len;
c5c77ba1
JK
1365 skb->ip_summed = CHECKSUM_UNNECESSARY;
1366 stats = netif_rx(skb);
1367 PRINT_D(RX_DBG, "netif_rx ret value is: %d\n", stats);
1368 }
c5c77ba1
JK
1369}
1370
11f4b2ee 1371void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
c5c77ba1
JK
1372{
1373 int i = 0;
a4cac481 1374 struct wilc_vif *vif;
c5c77ba1 1375
11f4b2ee 1376 for (i = 0; i < wilc->vif_num; i++) {
1f435d2e 1377 vif = netdev_priv(wilc->vif[i]->ndev);
a4cac481 1378 if (vif->monitor_flag) {
c5c77ba1
JK
1379 WILC_WFI_monitor_rx(buff, size);
1380 return;
1381 }
1382 }
1383
1f435d2e 1384 vif = netdev_priv(wilc->vif[1]->ndev);
a4cac481
GL
1385 if ((buff[0] == vif->g_struct_frame_reg[0].frame_type && vif->g_struct_frame_reg[0].reg) ||
1386 (buff[0] == vif->g_struct_frame_reg[1].frame_type && vif->g_struct_frame_reg[1].reg))
1f435d2e 1387 WILC_WFI_p2p_rx(wilc->vif[1]->ndev, buff, size);
c5c77ba1
JK
1388}
1389
857c7b00 1390void wilc_netdev_cleanup(struct wilc *wilc)
4875c499
TC
1391{
1392 int i = 0;
a4cac481 1393 struct wilc_vif *vif[NUM_CONCURRENT_IFC];
4875c499 1394
1f435d2e 1395 if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
4875c499
TC
1396 unregister_inetaddr_notifier(&g_dev_notifier);
1397
1398 for (i = 0; i < NUM_CONCURRENT_IFC; i++)
1f435d2e 1399 vif[i] = netdev_priv(wilc->vif[i]->ndev);
4875c499
TC
1400 }
1401
90b984c8
GL
1402 if (wilc && wilc->firmware)
1403 release_firmware(wilc->firmware);
4875c499 1404
1f435d2e 1405 if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
562ed3f1 1406 wilc_lock_timeout(wilc, &close_exit_sync, 12 * 1000);
4875c499
TC
1407
1408 for (i = 0; i < NUM_CONCURRENT_IFC; i++)
1f435d2e 1409 if (wilc->vif[i]->ndev)
a4cac481 1410 if (vif[i]->mac_opened)
1f435d2e 1411 wilc_mac_close(wilc->vif[i]->ndev);
4875c499
TC
1412
1413 for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
1f435d2e
GL
1414 unregister_netdev(wilc->vif[i]->ndev);
1415 wilc_free_wiphy(wilc->vif[i]->ndev);
1416 free_netdev(wilc->vif[i]->ndev);
4875c499
TC
1417 }
1418 }
1419
90b984c8 1420 kfree(wilc);
4875c499 1421}
750ffe9b 1422EXPORT_SYMBOL_GPL(wilc_netdev_cleanup);
4875c499 1423
7d37a4a1
AB
1424int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
1425 int gpio, const struct wilc_hif_func *ops)
c5c77ba1 1426{
c5c77ba1 1427 int i;
a4cac481 1428 struct wilc_vif *vif;
c5c77ba1 1429 struct net_device *ndev;
562ed3f1 1430 struct wilc *wl;
c5c77ba1 1431
642768ee 1432 sema_init(&close_exit_sync, 0);
c5c77ba1 1433
825b966f 1434 wl = kzalloc(sizeof(*wl), GFP_KERNEL);
562ed3f1 1435 if (!wl)
ac61ef86 1436 return -ENOMEM;
c5c77ba1 1437
562ed3f1
AB
1438 *wilc = wl;
1439 wl->io_type = io_type;
1440 wl->gpio = gpio;
af9ae09a 1441 wl->hif_func = ops;
c4d139cb 1442
c5c77ba1 1443 register_inetaddr_notifier(&g_dev_notifier);
c5c77ba1
JK
1444
1445 for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
a4cac481 1446 ndev = alloc_etherdev(sizeof(struct wilc_vif));
c5c77ba1
JK
1447 if (!ndev) {
1448 PRINT_ER("Failed to allocate ethernet dev\n");
1449 return -1;
1450 }
1451
a4cac481
GL
1452 vif = netdev_priv(ndev);
1453 memset(vif, 0, sizeof(struct wilc_vif));
c5c77ba1 1454
84d3b87e 1455 if (i == 0)
c5c77ba1 1456 strcpy(ndev->name, "wlan%d");
84d3b87e 1457 else
c5c77ba1
JK
1458 strcpy(ndev->name, "p2p%d");
1459
a4cac481 1460 vif->u8IfIdx = wl->vif_num;
a4cac481 1461 vif->wilc = *wilc;
1f435d2e
GL
1462 wl->vif[i] = vif;
1463 wl->vif[wl->vif_num]->ndev = ndev;
562ed3f1 1464 wl->vif_num++;
e5af0561 1465 ndev->netdev_ops = &wilc_netdev_ops;
c5c77ba1 1466
c5c77ba1
JK
1467 {
1468 struct wireless_dev *wdev;
2e7d5377 1469 wdev = wilc_create_wiphy(ndev, dev);
c5c77ba1 1470
67039928
AB
1471 if (dev)
1472 SET_NETDEV_DEV(ndev, dev);
c5c77ba1 1473
3a147c07 1474 if (!wdev) {
c5c77ba1
JK
1475 PRINT_ER("Can't register WILC Wiphy\n");
1476 return -1;
1477 }
1478
1006b5c7
GL
1479 vif->ndev->ieee80211_ptr = wdev;
1480 vif->ndev->ml_priv = vif;
1481 wdev->netdev = vif->ndev;
a4cac481
GL
1482 vif->netstats.rx_packets = 0;
1483 vif->netstats.tx_packets = 0;
1484 vif->netstats.rx_bytes = 0;
1485 vif->netstats.tx_bytes = 0;
c5c77ba1 1486 }
c5c77ba1 1487
c5c77ba1 1488 if (register_netdev(ndev)) {
582f8a27
LK
1489 PRINT_ER("Device couldn't be registered - %s\n",
1490 ndev->name);
98b89847 1491 return -1;
c5c77ba1
JK
1492 }
1493
a4cac481
GL
1494 vif->iftype = STATION_MODE;
1495 vif->mac_opened = 0;
c5c77ba1
JK
1496 }
1497
c5c77ba1
JK
1498 return 0;
1499}
750ffe9b 1500EXPORT_SYMBOL_GPL(wilc_netdev_init);
c94f05ee
AB
1501
1502MODULE_LICENSE("GPL");
This page took 0.275944 seconds and 5 git commands to generate.