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