Commit | Line | Data |
---|---|---|
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 | ||
26 | #include <linux/version.h> | |
27 | #include <linux/semaphore.h> | |
28 | ||
29 | #ifdef WILC_SDIO | |
30 | #include "linux_wlan_sdio.h" | |
31 | #else | |
32 | #include "linux_wlan_spi.h" | |
33 | #endif | |
34 | ||
c5c77ba1 JK |
35 | #if defined(CUSTOMER_PLATFORM) |
36 | /* | |
37 | TODO : Write power control functions as customer platform. | |
38 | */ | |
39 | #else | |
40 | ||
41 | #define _linux_wlan_device_power_on() {} | |
42 | #define _linux_wlan_device_power_off() {} | |
43 | ||
44 | #define _linux_wlan_device_detection() {} | |
45 | #define _linux_wlan_device_removal() {} | |
46 | #endif | |
47 | ||
72ed4dc7 | 48 | extern bool g_obtainingIP; |
72ed4dc7 | 49 | extern u16 Set_machw_change_vir_if(bool bValue); |
c5c77ba1 | 50 | extern void resolve_disconnect_aberration(void *drvHandler); |
63d03e47 | 51 | extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN]; |
f61c5aff | 52 | void wilc1000_wlan_deinit(struct wilc *nic); |
da711eb6 | 53 | extern struct timer_list hDuringIpTimer; |
c5c77ba1 JK |
54 | |
55 | static int linux_wlan_device_power(int on_off) | |
56 | { | |
57 | PRINT_D(INIT_DBG, "linux_wlan_device_power.. (%d)\n", on_off); | |
58 | ||
59 | if (on_off) { | |
60 | _linux_wlan_device_power_on(); | |
61 | } else { | |
62 | _linux_wlan_device_power_off(); | |
63 | } | |
64 | ||
65 | return 0; | |
66 | } | |
67 | ||
68 | static int linux_wlan_device_detection(int on_off) | |
69 | { | |
70 | PRINT_D(INIT_DBG, "linux_wlan_device_detection.. (%d)\n", on_off); | |
71 | ||
72 | #ifdef WILC_SDIO | |
73 | if (on_off) { | |
74 | _linux_wlan_device_detection(); | |
75 | } else { | |
76 | _linux_wlan_device_removal(); | |
77 | } | |
78 | #endif | |
79 | ||
80 | return 0; | |
81 | } | |
82 | ||
c5c77ba1 JK |
83 | static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr); |
84 | ||
85 | static struct notifier_block g_dev_notifier = { | |
86 | .notifier_call = dev_state_ev_handler | |
87 | }; | |
c5c77ba1 | 88 | |
c5c77ba1 JK |
89 | #define IRQ_WAIT 1 |
90 | #define IRQ_NO_WAIT 0 | |
91 | /* | |
92 | * to sync between mac_close and module exit. | |
93 | * don't initialize or de-initialize from init/deinitlocks | |
94 | * to be initialized from module wilc_netdev_init and | |
95 | * deinitialized from mdoule_exit | |
96 | */ | |
97 | static struct semaphore close_exit_sync; | |
c5c77ba1 | 98 | |
f61c5aff TC |
99 | static int wlan_deinit_locks(struct wilc *nic); |
100 | static void wlan_deinitialize_threads(struct wilc *nic); | |
fbc2fe16 CL |
101 | extern void WILC_WFI_monitor_rx(u8 *buff, u32 size); |
102 | extern void WILC_WFI_p2p_rx(struct net_device *dev, u8 *buff, u32 size); | |
c5c77ba1 | 103 | |
c5c77ba1 | 104 | static void linux_wlan_tx_complete(void *priv, int status); |
c5c77ba1 JK |
105 | static int mac_init_fn(struct net_device *ndev); |
106 | int mac_xmit(struct sk_buff *skb, struct net_device *dev); | |
107 | int mac_open(struct net_device *ndev); | |
108 | int mac_close(struct net_device *ndev); | |
109 | static struct net_device_stats *mac_stats(struct net_device *dev); | |
110 | static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd); | |
111 | static void wilc_set_multicast_list(struct net_device *dev); | |
112 | ||
c5c77ba1 JK |
113 | /* |
114 | * for now - in frmw_to_linux there should be private data to be passed to it | |
115 | * and this data should be pointer to net device | |
116 | */ | |
f61c5aff | 117 | struct wilc *g_linux_wlan; |
72ed4dc7 | 118 | bool bEnablePS = true; |
c5c77ba1 | 119 | |
c5c77ba1 JK |
120 | static const struct net_device_ops wilc_netdev_ops = { |
121 | .ndo_init = mac_init_fn, | |
122 | .ndo_open = mac_open, | |
123 | .ndo_stop = mac_close, | |
124 | .ndo_start_xmit = mac_xmit, | |
125 | .ndo_do_ioctl = mac_ioctl, | |
126 | .ndo_get_stats = mac_stats, | |
127 | .ndo_set_rx_mode = wilc_set_multicast_list, | |
128 | ||
129 | }; | |
c5c77ba1 | 130 | |
c5c77ba1 JK |
131 | static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr) |
132 | { | |
133 | struct in_ifaddr *dev_iface = (struct in_ifaddr *)ptr; | |
2726887c | 134 | struct wilc_priv *priv; |
441dc609 | 135 | struct host_if_drv *pstrWFIDrv; |
c5c77ba1 | 136 | struct net_device *dev; |
63d03e47 | 137 | u8 *pIP_Add_buff; |
c5c77ba1 | 138 | perInterface_wlan_t *nic; |
63d03e47 | 139 | u8 null_ip[4] = {0}; |
c5c77ba1 JK |
140 | char wlan_dev_name[5] = "wlan0"; |
141 | ||
142 | if (dev_iface == NULL || dev_iface->ifa_dev == NULL || dev_iface->ifa_dev->dev == NULL) { | |
143 | PRINT_D(GENERIC_DBG, "dev_iface = NULL\n"); | |
144 | return NOTIFY_DONE; | |
145 | } | |
146 | ||
147 | if ((memcmp(dev_iface->ifa_label, "wlan0", 5)) && (memcmp(dev_iface->ifa_label, "p2p0", 4))) { | |
148 | PRINT_D(GENERIC_DBG, "Interface is neither WLAN0 nor P2P0\n"); | |
149 | return NOTIFY_DONE; | |
150 | } | |
151 | ||
152 | dev = (struct net_device *)dev_iface->ifa_dev->dev; | |
153 | if (dev->ieee80211_ptr == NULL || dev->ieee80211_ptr->wiphy == NULL) { | |
154 | PRINT_D(GENERIC_DBG, "No Wireless registerd\n"); | |
155 | return NOTIFY_DONE; | |
156 | } | |
157 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); | |
158 | if (priv == NULL) { | |
159 | PRINT_D(GENERIC_DBG, "No Wireless Priv\n"); | |
160 | return NOTIFY_DONE; | |
161 | } | |
441dc609 | 162 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
c5c77ba1 JK |
163 | nic = netdev_priv(dev); |
164 | if (nic == NULL || pstrWFIDrv == NULL) { | |
165 | PRINT_D(GENERIC_DBG, "No Wireless Priv\n"); | |
166 | return NOTIFY_DONE; | |
167 | } | |
168 | ||
169 | PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler +++\n"); /* tony */ | |
170 | ||
171 | switch (event) { | |
172 | case NETDEV_UP: | |
173 | PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_UP %p\n", dev); /* tony */ | |
174 | ||
175 | PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Obtained ===============\n\n"); | |
176 | ||
c5c77ba1 JK |
177 | /*If we are in station mode or client mode*/ |
178 | if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { | |
179 | pstrWFIDrv->IFC_UP = 1; | |
72ed4dc7 | 180 | g_obtainingIP = false; |
8972d0fe | 181 | del_timer(&hDuringIpTimer); |
c5c77ba1 JK |
182 | PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n"); |
183 | } | |
184 | ||
5a66bf20 | 185 | if (bEnablePS) |
218dc407 | 186 | host_int_set_power_mgmt(pstrWFIDrv, 1, 0); |
c5c77ba1 JK |
187 | |
188 | PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label); | |
189 | ||
190 | pIP_Add_buff = (char *) (&(dev_iface->ifa_address)); | |
17aacd43 | 191 | PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]); |
218dc407 | 192 | host_int_setup_ipaddress(pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); |
c5c77ba1 JK |
193 | |
194 | break; | |
195 | ||
196 | case NETDEV_DOWN: | |
197 | PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_DOWN %p\n", dev); /* tony */ | |
198 | ||
199 | PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Released ===============\n\n"); | |
200 | if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) { | |
201 | pstrWFIDrv->IFC_UP = 0; | |
72ed4dc7 | 202 | g_obtainingIP = false; |
c5c77ba1 JK |
203 | } |
204 | ||
205 | if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0) | |
218dc407 | 206 | host_int_set_power_mgmt(pstrWFIDrv, 0, 0); |
c5c77ba1 JK |
207 | |
208 | resolve_disconnect_aberration(pstrWFIDrv); | |
209 | ||
c5c77ba1 JK |
210 | PRINT_D(GENERIC_DBG, "[%s] Down IP\n", dev_iface->ifa_label); |
211 | ||
212 | pIP_Add_buff = null_ip; | |
17aacd43 | 213 | PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d\n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]); |
c5c77ba1 | 214 | |
218dc407 | 215 | host_int_setup_ipaddress(pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx); |
c5c77ba1 JK |
216 | |
217 | break; | |
218 | ||
219 | default: | |
220 | PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler event=default\n"); /* tony */ | |
221 | PRINT_INFO(GENERIC_DBG, "[%s] unknown dev event: %lu\n", dev_iface->ifa_label, event); | |
222 | ||
223 | break; | |
224 | } | |
225 | ||
226 | return NOTIFY_DONE; | |
227 | ||
228 | } | |
c5c77ba1 | 229 | |
c5c77ba1 JK |
230 | #if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) |
231 | static irqreturn_t isr_uh_routine(int irq, void *user_data) | |
232 | { | |
c5c77ba1 JK |
233 | PRINT_D(INT_DBG, "Interrupt received UH\n"); |
234 | ||
235 | /*While mac is closing cacncel the handling of any interrupts received*/ | |
236 | if (g_linux_wlan->close) { | |
237 | PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n"); | |
c5c77ba1 | 238 | return IRQ_HANDLED; |
c5c77ba1 | 239 | } |
c5c77ba1 | 240 | return IRQ_WAKE_THREAD; |
c5c77ba1 JK |
241 | } |
242 | #endif | |
243 | ||
c5c77ba1 JK |
244 | irqreturn_t isr_bh_routine(int irq, void *userdata) |
245 | { | |
f61c5aff | 246 | struct wilc *nic; |
8dfaafd6 | 247 | |
f61c5aff | 248 | nic = (struct wilc *)userdata; |
c5c77ba1 JK |
249 | |
250 | /*While mac is closing cacncel the handling of any interrupts received*/ | |
251 | if (g_linux_wlan->close) { | |
252 | PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n"); | |
c5c77ba1 | 253 | return IRQ_HANDLED; |
c5c77ba1 JK |
254 | } |
255 | ||
c5c77ba1 | 256 | PRINT_D(INT_DBG, "Interrupt received BH\n"); |
46ca80cd | 257 | wilc_handle_isr(); |
c5c77ba1 | 258 | |
c5c77ba1 | 259 | return IRQ_HANDLED; |
c5c77ba1 | 260 | } |
c5c77ba1 | 261 | |
c5c77ba1 | 262 | #if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) |
f61c5aff | 263 | static int init_irq(struct wilc *p_nic) |
c5c77ba1 JK |
264 | { |
265 | int ret = 0; | |
f61c5aff | 266 | struct wilc *nic = p_nic; |
c5c77ba1 JK |
267 | |
268 | /*initialize GPIO and register IRQ num*/ | |
269 | /*GPIO request*/ | |
270 | if ((gpio_request(GPIO_NUM, "WILC_INTR") == 0) && | |
271 | (gpio_direction_input(GPIO_NUM) == 0)) { | |
272 | #if defined(CUSTOMER_PLATFORM) | |
273 | /* | |
274 | TODO : save the registerd irq number to the private wilc context in kernel. | |
275 | * | |
276 | * ex) nic->dev_irq_num = gpio_to_irq(GPIO_NUM); | |
277 | */ | |
c5c77ba1 JK |
278 | #else |
279 | nic->dev_irq_num = gpio_to_irq(GPIO_NUM); | |
280 | #endif | |
281 | } else { | |
282 | ret = -1; | |
283 | PRINT_ER("could not obtain gpio for WILC_INTR\n"); | |
284 | } | |
285 | ||
c5c77ba1 JK |
286 | if ((ret != -1) && (request_threaded_irq(nic->dev_irq_num, isr_uh_routine, isr_bh_routine, |
287 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, /*Without IRQF_ONESHOT the uh will remain kicked in and dont gave a chance to bh*/ | |
288 | "WILC_IRQ", nic)) < 0) { | |
289 | ||
c5c77ba1 JK |
290 | PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM); |
291 | ret = -1; | |
292 | } else { | |
293 | ||
294 | PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n", | |
295 | nic->dev_irq_num, GPIO_NUM); | |
296 | } | |
297 | ||
298 | return ret; | |
299 | } | |
300 | #endif | |
301 | ||
f61c5aff | 302 | static void deinit_irq(struct wilc *nic) |
c5c77ba1 JK |
303 | { |
304 | #if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO) | |
305 | /* Deintialize IRQ */ | |
306 | if (&nic->dev_irq_num != 0) { | |
307 | free_irq(nic->dev_irq_num, g_linux_wlan); | |
308 | ||
309 | gpio_free(GPIO_NUM); | |
310 | } | |
311 | #endif | |
312 | } | |
313 | ||
c5c77ba1 JK |
314 | /* |
315 | * OS functions | |
316 | */ | |
ef2b784c | 317 | void linux_wlan_dbg(u8 *buff) |
c5c77ba1 JK |
318 | { |
319 | PRINT_D(INIT_DBG, "%d\n", *buff); | |
320 | } | |
321 | ||
b002e20d | 322 | int linux_wlan_lock_timeout(void *vp, u32 timeout) |
c5c77ba1 JK |
323 | { |
324 | int error = -1; | |
8dfaafd6 | 325 | |
c5c77ba1 | 326 | PRINT_D(LOCK_DBG, "Locking %p\n", vp); |
78174ada | 327 | if (vp != NULL) |
c5c77ba1 | 328 | error = down_timeout((struct semaphore *)vp, msecs_to_jiffies(timeout)); |
78174ada | 329 | else |
c5c77ba1 | 330 | PRINT_ER("Failed, mutex is NULL\n"); |
c5c77ba1 JK |
331 | return error; |
332 | } | |
333 | ||
4417d3da | 334 | void linux_wlan_mac_indicate(int flag) |
c5c77ba1 JK |
335 | { |
336 | /*I have to do it that way becuase there is no mean to encapsulate device pointer | |
337 | * as a parameter | |
338 | */ | |
f61c5aff | 339 | struct wilc *pd = g_linux_wlan; |
c5c77ba1 JK |
340 | int status; |
341 | ||
342 | if (flag == WILC_MAC_INDICATE_STATUS) { | |
894de36b | 343 | wilc_wlan_cfg_get_val(WID_STATUS, (unsigned char *)&status, 4); |
c5c77ba1 JK |
344 | if (pd->mac_status == WILC_MAC_STATUS_INIT) { |
345 | pd->mac_status = status; | |
8990d856 | 346 | up(&pd->sync_event); |
c5c77ba1 JK |
347 | } else { |
348 | pd->mac_status = status; | |
349 | } | |
350 | ||
351 | if (pd->mac_status == WILC_MAC_STATUS_CONNECT) { /* Connect */ | |
c5c77ba1 JK |
352 | } |
353 | ||
354 | } else if (flag == WILC_MAC_INDICATE_SCAN) { | |
355 | PRINT_D(GENERIC_DBG, "Scanning ...\n"); | |
356 | ||
357 | } | |
358 | ||
359 | } | |
360 | ||
51e825f7 | 361 | struct net_device *GetIfHandler(u8 *pMacHeader) |
c5c77ba1 | 362 | { |
51e825f7 | 363 | u8 *Bssid, *Bssid1; |
c5c77ba1 JK |
364 | int i = 0; |
365 | ||
366 | Bssid = pMacHeader + 10; | |
367 | Bssid1 = pMacHeader + 4; | |
368 | ||
8259a53e | 369 | for (i = 0; i < g_linux_wlan->vif_num; i++) |
7201cd2c TC |
370 | if (!memcmp(Bssid1, g_linux_wlan->vif[i].bssid, ETH_ALEN) || |
371 | !memcmp(Bssid, g_linux_wlan->vif[i].bssid, ETH_ALEN)) | |
817f3fb9 | 372 | return g_linux_wlan->vif[i].ndev; |
8259a53e | 373 | |
c5c77ba1 | 374 | PRINT_INFO(INIT_DBG, "Invalide handle\n"); |
fc4b95d6 | 375 | for (i = 0; i < 25; i++) |
c5c77ba1 | 376 | PRINT_D(INIT_DBG, "%02x ", pMacHeader[i]); |
c5c77ba1 JK |
377 | Bssid = pMacHeader + 18; |
378 | Bssid1 = pMacHeader + 12; | |
8259a53e | 379 | for (i = 0; i < g_linux_wlan->vif_num; i++) |
7201cd2c TC |
380 | if (!memcmp(Bssid1, g_linux_wlan->vif[i].bssid, ETH_ALEN) || |
381 | !memcmp(Bssid, g_linux_wlan->vif[i].bssid, ETH_ALEN)) | |
817f3fb9 | 382 | return g_linux_wlan->vif[i].ndev; |
8259a53e | 383 | |
c5c77ba1 JK |
384 | PRINT_INFO(INIT_DBG, "\n"); |
385 | return NULL; | |
386 | } | |
387 | ||
51e825f7 | 388 | int linux_wlan_set_bssid(struct net_device *wilc_netdev, u8 *pBSSID) |
c5c77ba1 JK |
389 | { |
390 | int i = 0; | |
391 | int ret = -1; | |
392 | ||
8259a53e | 393 | for (i = 0; i < g_linux_wlan->vif_num; i++) |
817f3fb9 | 394 | if (g_linux_wlan->vif[i].ndev == wilc_netdev) { |
7201cd2c | 395 | memcpy(g_linux_wlan->vif[i].bssid, pBSSID, 6); |
c5c77ba1 JK |
396 | ret = 0; |
397 | break; | |
398 | } | |
8259a53e | 399 | |
c5c77ba1 JK |
400 | return ret; |
401 | } | |
402 | ||
c5c77ba1 JK |
403 | /*Function to get number of connected interfaces*/ |
404 | int linux_wlan_get_num_conn_ifcs(void) | |
405 | { | |
51e825f7 CL |
406 | u8 i = 0; |
407 | u8 null_bssid[6] = {0}; | |
408 | u8 ret_val = 0; | |
c5c77ba1 | 409 | |
8259a53e | 410 | for (i = 0; i < g_linux_wlan->vif_num; i++) |
7201cd2c | 411 | if (memcmp(g_linux_wlan->vif[i].bssid, null_bssid, 6)) |
c5c77ba1 | 412 | ret_val++; |
8259a53e | 413 | |
c5c77ba1 JK |
414 | return ret_val; |
415 | } | |
416 | ||
c5c77ba1 JK |
417 | #define USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS |
418 | ||
419 | static int linux_wlan_txq_task(void *vp) | |
420 | { | |
421 | int ret, txq_count; | |
422 | ||
423 | #if defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS | |
424 | #define TX_BACKOFF_WEIGHT_INCR_STEP (1) | |
425 | #define TX_BACKOFF_WEIGHT_DECR_STEP (1) | |
426 | #define TX_BACKOFF_WEIGHT_MAX (7) | |
427 | #define TX_BACKOFF_WEIGHT_MIN (0) | |
428 | #define TX_BACKOFF_WEIGHT_UNIT_MS (10) | |
429 | int backoff_weight = TX_BACKOFF_WEIGHT_MIN; | |
c5c77ba1 JK |
430 | #endif |
431 | ||
432 | /* inform wilc1000_wlan_init that TXQ task is started. */ | |
8990d856 | 433 | up(&g_linux_wlan->txq_thread_started); |
c5c77ba1 JK |
434 | while (1) { |
435 | ||
436 | PRINT_D(TX_DBG, "txq_task Taking a nap :)\n"); | |
8990d856 | 437 | down(&g_linux_wlan->txq_event); |
c5c77ba1 JK |
438 | /* wait_for_completion(&pd->txq_event); */ |
439 | PRINT_D(TX_DBG, "txq_task Who waked me up :$\n"); | |
440 | ||
441 | if (g_linux_wlan->close) { | |
442 | /*Unlock the mutex in the mac_close function to indicate the exiting of the TX thread */ | |
8990d856 | 443 | up(&g_linux_wlan->txq_thread_started); |
c5c77ba1 JK |
444 | |
445 | while (!kthread_should_stop()) | |
446 | schedule(); | |
447 | ||
448 | PRINT_D(TX_DBG, "TX thread stopped\n"); | |
449 | break; | |
450 | } | |
451 | PRINT_D(TX_DBG, "txq_task handle the sending packet and let me go to sleep.\n"); | |
452 | #if !defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS | |
f590c4ce | 453 | ret = wilc_wlan_handle_txq(&txq_count); |
c5c77ba1 JK |
454 | #else |
455 | do { | |
f590c4ce | 456 | ret = wilc_wlan_handle_txq(&txq_count); |
c5c77ba1 JK |
457 | if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && netif_queue_stopped(pd->wilc_netdev)*/) { |
458 | PRINT_D(TX_DBG, "Waking up queue\n"); | |
459 | /* netif_wake_queue(pd->wilc_netdev); */ | |
817f3fb9 TC |
460 | if (netif_queue_stopped(g_linux_wlan->vif[0].ndev)) |
461 | netif_wake_queue(g_linux_wlan->vif[0].ndev); | |
462 | if (netif_queue_stopped(g_linux_wlan->vif[1].ndev)) | |
463 | netif_wake_queue(g_linux_wlan->vif[1].ndev); | |
c5c77ba1 JK |
464 | } |
465 | ||
466 | if (ret == WILC_TX_ERR_NO_BUF) { /* failed to allocate buffers in chip. */ | |
c5c77ba1 JK |
467 | do { |
468 | /* Back off from sending packets for some time. */ | |
469 | /* schedule_timeout will allow RX task to run and free buffers.*/ | |
470 | /* set_current_state(TASK_UNINTERRUPTIBLE); */ | |
471 | /* timeout = schedule_timeout(timeout); */ | |
472 | msleep(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight); | |
473 | } while (/*timeout*/ 0); | |
474 | backoff_weight += TX_BACKOFF_WEIGHT_INCR_STEP; | |
fc4b95d6 | 475 | if (backoff_weight > TX_BACKOFF_WEIGHT_MAX) |
c5c77ba1 | 476 | backoff_weight = TX_BACKOFF_WEIGHT_MAX; |
c5c77ba1 JK |
477 | } else { |
478 | if (backoff_weight > TX_BACKOFF_WEIGHT_MIN) { | |
479 | backoff_weight -= TX_BACKOFF_WEIGHT_DECR_STEP; | |
fc4b95d6 | 480 | if (backoff_weight < TX_BACKOFF_WEIGHT_MIN) |
c5c77ba1 | 481 | backoff_weight = TX_BACKOFF_WEIGHT_MIN; |
c5c77ba1 JK |
482 | } |
483 | } | |
484 | /*TODO: drop packets after a certain time/number of retry count. */ | |
485 | } while (ret == WILC_TX_ERR_NO_BUF && !g_linux_wlan->close); /* retry sending packets if no more buffers in chip. */ | |
486 | #endif | |
487 | } | |
488 | return 0; | |
489 | } | |
490 | ||
c0cadaa4 | 491 | void linux_wlan_rx_complete(void) |
c5c77ba1 JK |
492 | { |
493 | PRINT_D(RX_DBG, "RX completed\n"); | |
494 | } | |
495 | ||
496 | int linux_wlan_get_firmware(perInterface_wlan_t *p_nic) | |
497 | { | |
498 | ||
499 | perInterface_wlan_t *nic = p_nic; | |
500 | int ret = 0; | |
501 | const struct firmware *wilc_firmware; | |
502 | char *firmware; | |
503 | ||
c5c77ba1 JK |
504 | if (nic->iftype == AP_MODE) |
505 | firmware = AP_FIRMWARE; | |
506 | else if (nic->iftype == STATION_MODE) | |
507 | firmware = STA_FIRMWARE; | |
508 | ||
c5c77ba1 JK |
509 | else { |
510 | PRINT_D(INIT_DBG, "Get P2P_CONCURRENCY_FIRMWARE\n"); | |
511 | firmware = P2P_CONCURRENCY_FIRMWARE; | |
512 | } | |
513 | ||
c5c77ba1 JK |
514 | if (nic == NULL) { |
515 | PRINT_ER("NIC is NULL\n"); | |
516 | goto _fail_; | |
517 | } | |
518 | ||
519 | if (&nic->wilc_netdev->dev == NULL) { | |
520 | PRINT_ER("&nic->wilc_netdev->dev is NULL\n"); | |
521 | goto _fail_; | |
522 | } | |
523 | ||
c5c77ba1 JK |
524 | /* the firmare should be located in /lib/firmware in |
525 | * root file system with the name specified above */ | |
526 | ||
527 | #ifdef WILC_SDIO | |
528 | if (request_firmware(&wilc_firmware, firmware, &g_linux_wlan->wilc_sdio_func->dev) != 0) { | |
529 | PRINT_ER("%s - firmare not available\n", firmware); | |
530 | ret = -1; | |
531 | goto _fail_; | |
532 | } | |
533 | #else | |
534 | if (request_firmware(&wilc_firmware, firmware, &g_linux_wlan->wilc_spidev->dev) != 0) { | |
535 | PRINT_ER("%s - firmare not available\n", firmware); | |
536 | ret = -1; | |
537 | goto _fail_; | |
538 | } | |
539 | #endif | |
8b8ad7bc | 540 | g_linux_wlan->firmware = wilc_firmware; |
c5c77ba1 JK |
541 | |
542 | _fail_: | |
543 | ||
544 | return ret; | |
545 | ||
546 | } | |
547 | ||
c5c77ba1 JK |
548 | static int linux_wlan_start_firmware(perInterface_wlan_t *nic) |
549 | { | |
550 | ||
c5c77ba1 JK |
551 | int ret = 0; |
552 | /* start firmware */ | |
553 | PRINT_D(INIT_DBG, "Starting Firmware ...\n"); | |
e42563bb | 554 | ret = wilc_wlan_start(); |
c5c77ba1 JK |
555 | if (ret < 0) { |
556 | PRINT_ER("Failed to start Firmware\n"); | |
557 | goto _fail_; | |
558 | } | |
559 | ||
560 | /* wait for mac ready */ | |
561 | PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n"); | |
562 | ret = linux_wlan_lock_timeout(&g_linux_wlan->sync_event, 5000); | |
563 | if (ret) { | |
c5c77ba1 JK |
564 | PRINT_D(INIT_DBG, "Firmware start timed out"); |
565 | goto _fail_; | |
566 | } | |
567 | /* | |
568 | * TODO: Driver shouoldn't wait forever for firmware to get started - | |
569 | * in case of timeout this should be handled properly | |
570 | */ | |
571 | PRINT_D(INIT_DBG, "Firmware successfully started\n"); | |
572 | ||
573 | _fail_: | |
574 | return ret; | |
575 | } | |
f61c5aff | 576 | static int linux_wlan_firmware_download(struct wilc *p_nic) |
c5c77ba1 JK |
577 | { |
578 | ||
579 | int ret = 0; | |
580 | ||
8b8ad7bc | 581 | if (!g_linux_wlan->firmware) { |
c5c77ba1 JK |
582 | PRINT_ER("Firmware buffer is NULL\n"); |
583 | ret = -ENOBUFS; | |
584 | goto _FAIL_; | |
585 | } | |
586 | /** | |
587 | * do the firmware download | |
588 | **/ | |
589 | PRINT_D(INIT_DBG, "Downloading Firmware ...\n"); | |
8b8ad7bc TC |
590 | ret = wilc_wlan_firmware_download(g_linux_wlan->firmware->data, |
591 | g_linux_wlan->firmware->size); | |
fc4b95d6 | 592 | if (ret < 0) |
c5c77ba1 | 593 | goto _FAIL_; |
c5c77ba1 JK |
594 | |
595 | /* Freeing FW buffer */ | |
596 | PRINT_D(INIT_DBG, "Freeing FW buffer ...\n"); | |
597 | PRINT_D(INIT_DBG, "Releasing firmware\n"); | |
8b8ad7bc | 598 | release_firmware(g_linux_wlan->firmware); |
c5c77ba1 | 599 | |
17aacd43 | 600 | PRINT_D(INIT_DBG, "Download Succeeded\n"); |
c5c77ba1 JK |
601 | |
602 | _FAIL_: | |
603 | return ret; | |
604 | } | |
605 | ||
c5c77ba1 | 606 | /* startup configuration - could be changed later using iconfig*/ |
f61c5aff | 607 | static int linux_wlan_init_test_config(struct net_device *dev, struct wilc *p_nic) |
c5c77ba1 JK |
608 | { |
609 | ||
610 | unsigned char c_val[64]; | |
c5c77ba1 | 611 | unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff}; |
c5c77ba1 | 612 | |
2726887c | 613 | struct wilc_priv *priv; |
441dc609 | 614 | struct host_if_drv *pstrWFIDrv; |
c5c77ba1 JK |
615 | |
616 | PRINT_D(TX_DBG, "Start configuring Firmware\n"); | |
c5c77ba1 JK |
617 | get_random_bytes(&mac_add[5], 1); |
618 | get_random_bytes(&mac_add[4], 1); | |
c5c77ba1 | 619 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
441dc609 | 620 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
8a14330f | 621 | PRINT_D(INIT_DBG, "Host = %p\n", pstrWFIDrv); |
c5c77ba1 JK |
622 | |
623 | PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]); | |
21175ef7 | 624 | wilc_get_chipid(0); |
c5c77ba1 | 625 | |
e5d57e91 | 626 | *(int *)c_val = 1; |
c5c77ba1 | 627 | |
1028e5a4 | 628 | if (!wilc_wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0)) |
c5c77ba1 JK |
629 | goto _fail_; |
630 | ||
631 | /*to tell fw that we are going to use PC test - WILC specific*/ | |
632 | c_val[0] = 0; | |
1028e5a4 | 633 | if (!wilc_wlan_cfg_set(0, WID_PC_TEST_MODE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
634 | goto _fail_; |
635 | ||
636 | c_val[0] = INFRASTRUCTURE; | |
1028e5a4 | 637 | if (!wilc_wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
638 | goto _fail_; |
639 | ||
c3ca6372 | 640 | /* c_val[0] = RATE_AUTO; */ |
c5c77ba1 | 641 | c_val[0] = RATE_AUTO; |
1028e5a4 | 642 | if (!wilc_wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
643 | goto _fail_; |
644 | ||
645 | c_val[0] = G_MIXED_11B_2_MODE; | |
1028e5a4 | 646 | if (!wilc_wlan_cfg_set(0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
647 | goto _fail_; |
648 | ||
649 | c_val[0] = 1; | |
1028e5a4 | 650 | if (!wilc_wlan_cfg_set(0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0)) |
c5c77ba1 JK |
651 | goto _fail_; |
652 | ||
653 | c_val[0] = G_SHORT_PREAMBLE; | |
1028e5a4 | 654 | if (!wilc_wlan_cfg_set(0, WID_PREAMBLE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
655 | goto _fail_; |
656 | ||
657 | c_val[0] = AUTO_PROT; | |
1028e5a4 | 658 | if (!wilc_wlan_cfg_set(0, WID_11N_PROT_MECH, c_val, 1, 0, 0)) |
c5c77ba1 JK |
659 | goto _fail_; |
660 | ||
c5c77ba1 | 661 | c_val[0] = ACTIVE_SCAN; |
1028e5a4 | 662 | if (!wilc_wlan_cfg_set(0, WID_SCAN_TYPE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
663 | goto _fail_; |
664 | ||
665 | c_val[0] = SITE_SURVEY_OFF; | |
1028e5a4 | 666 | if (!wilc_wlan_cfg_set(0, WID_SITE_SURVEY, c_val, 1, 0, 0)) |
c5c77ba1 JK |
667 | goto _fail_; |
668 | ||
669 | *((int *)c_val) = 0xffff; /* Never use RTS-CTS */ | |
1028e5a4 | 670 | if (!wilc_wlan_cfg_set(0, WID_RTS_THRESHOLD, c_val, 2, 0, 0)) |
c5c77ba1 JK |
671 | goto _fail_; |
672 | ||
673 | *((int *)c_val) = 2346; | |
1028e5a4 | 674 | if (!wilc_wlan_cfg_set(0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0)) |
c5c77ba1 JK |
675 | goto _fail_; |
676 | ||
677 | /* SSID */ | |
678 | /* -------------------------------------------------------------- */ | |
679 | /* Configuration : String with length less than 32 bytes */ | |
680 | /* Values to set : Any string with length less than 32 bytes */ | |
681 | /* ( In BSS Station Set SSID to "" (null string) */ | |
682 | /* to enable Broadcast SSID suppport ) */ | |
683 | /* -------------------------------------------------------------- */ | |
c5c77ba1 | 684 | c_val[0] = 0; |
1028e5a4 | 685 | if (!wilc_wlan_cfg_set(0, WID_BCAST_SSID, c_val, 1, 0, 0)) |
c5c77ba1 JK |
686 | goto _fail_; |
687 | ||
688 | c_val[0] = 1; | |
1028e5a4 | 689 | if (!wilc_wlan_cfg_set(0, WID_QOS_ENABLE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
690 | goto _fail_; |
691 | ||
692 | c_val[0] = NO_POWERSAVE; | |
1028e5a4 | 693 | if (!wilc_wlan_cfg_set(0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) |
c5c77ba1 JK |
694 | goto _fail_; |
695 | ||
696 | c_val[0] = NO_ENCRYPT; /* NO_ENCRYPT, 0x79 */ | |
1028e5a4 | 697 | if (!wilc_wlan_cfg_set(0, WID_11I_MODE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
698 | goto _fail_; |
699 | ||
700 | c_val[0] = OPEN_SYSTEM; | |
1028e5a4 | 701 | if (!wilc_wlan_cfg_set(0, WID_AUTH_TYPE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
702 | goto _fail_; |
703 | ||
704 | /* WEP/802 11I Configuration */ | |
705 | /* ------------------------------------------------------------------ */ | |
706 | /* Configuration : WEP Key */ | |
707 | /* Values (0x) : 5 byte for WEP40 and 13 bytes for WEP104 */ | |
708 | /* In case more than 5 bytes are passed on for WEP 40 */ | |
709 | /* only first 5 bytes will be used as the key */ | |
710 | /* ------------------------------------------------------------------ */ | |
711 | ||
712 | strcpy(c_val, "123456790abcdef1234567890"); | |
1028e5a4 | 713 | if (!wilc_wlan_cfg_set(0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0)) |
c5c77ba1 JK |
714 | goto _fail_; |
715 | ||
716 | /* WEP/802 11I Configuration */ | |
717 | /* ------------------------------------------------------------------ */ | |
718 | /* Configuration : AES/TKIP WPA/RSNA Pre-Shared Key */ | |
719 | /* Values to set : Any string with length greater than equal to 8 bytes */ | |
720 | /* and less than 64 bytes */ | |
721 | /* ------------------------------------------------------------------ */ | |
722 | strcpy(c_val, "12345678"); | |
1028e5a4 | 723 | if (!wilc_wlan_cfg_set(0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0)) |
c5c77ba1 JK |
724 | goto _fail_; |
725 | ||
726 | /* IEEE802.1X Key Configuration */ | |
727 | /* ------------------------------------------------------------------ */ | |
728 | /* Configuration : Radius Server Access Secret Key */ | |
729 | /* Values to set : Any string with length greater than equal to 8 bytes */ | |
730 | /* and less than 65 bytes */ | |
731 | /* ------------------------------------------------------------------ */ | |
732 | strcpy(c_val, "password"); | |
1028e5a4 | 733 | if (!wilc_wlan_cfg_set(0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0)) |
c5c77ba1 JK |
734 | goto _fail_; |
735 | ||
736 | /* IEEE802.1X Server Address Configuration */ | |
737 | /* ------------------------------------------------------------------ */ | |
738 | /* Configuration : Radius Server IP Address */ | |
739 | /* Values to set : Any valid IP Address */ | |
740 | /* ------------------------------------------------------------------ */ | |
741 | c_val[0] = 192; | |
742 | c_val[1] = 168; | |
743 | c_val[2] = 1; | |
744 | c_val[3] = 112; | |
1028e5a4 | 745 | if (!wilc_wlan_cfg_set(0, WID_1X_SERV_ADDR, c_val, 4, 0, 0)) |
c5c77ba1 JK |
746 | goto _fail_; |
747 | ||
748 | c_val[0] = 3; | |
1028e5a4 | 749 | if (!wilc_wlan_cfg_set(0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0)) |
c5c77ba1 JK |
750 | goto _fail_; |
751 | ||
752 | c_val[0] = 3; | |
1028e5a4 | 753 | if (!wilc_wlan_cfg_set(0, WID_DTIM_PERIOD, c_val, 1, 0, 0)) |
c5c77ba1 JK |
754 | goto _fail_; |
755 | ||
756 | c_val[0] = NORMAL_ACK; | |
1028e5a4 | 757 | if (!wilc_wlan_cfg_set(0, WID_ACK_POLICY, c_val, 1, 0, 0)) |
c5c77ba1 JK |
758 | goto _fail_; |
759 | ||
760 | c_val[0] = 0; | |
1028e5a4 | 761 | if (!wilc_wlan_cfg_set(0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0)) |
c5c77ba1 JK |
762 | goto _fail_; |
763 | ||
764 | c_val[0] = 48; | |
1028e5a4 | 765 | if (!wilc_wlan_cfg_set(0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0)) |
c5c77ba1 JK |
766 | goto _fail_; |
767 | ||
768 | c_val[0] = 28; | |
1028e5a4 | 769 | if (!wilc_wlan_cfg_set(0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0)) |
c5c77ba1 JK |
770 | goto _fail_; |
771 | ||
772 | /* Beacon Interval */ | |
773 | /* -------------------------------------------------------------------- */ | |
774 | /* Configuration : Sets the beacon interval value */ | |
775 | /* Values to set : Any 16-bit value */ | |
776 | /* -------------------------------------------------------------------- */ | |
777 | ||
778 | *((int *)c_val) = 100; | |
1028e5a4 | 779 | if (!wilc_wlan_cfg_set(0, WID_BEACON_INTERVAL, c_val, 2, 0, 0)) |
c5c77ba1 JK |
780 | goto _fail_; |
781 | ||
782 | c_val[0] = REKEY_DISABLE; | |
1028e5a4 | 783 | if (!wilc_wlan_cfg_set(0, WID_REKEY_POLICY, c_val, 1, 0, 0)) |
c5c77ba1 JK |
784 | goto _fail_; |
785 | ||
786 | /* Rekey Time (s) (Used only when the Rekey policy is 2 or 4) */ | |
787 | /* -------------------------------------------------------------------- */ | |
788 | /* Configuration : Sets the Rekey Time (s) */ | |
789 | /* Values to set : 32-bit value */ | |
790 | /* -------------------------------------------------------------------- */ | |
791 | *((int *)c_val) = 84600; | |
1028e5a4 | 792 | if (!wilc_wlan_cfg_set(0, WID_REKEY_PERIOD, c_val, 4, 0, 0)) |
c5c77ba1 JK |
793 | goto _fail_; |
794 | ||
795 | /* Rekey Packet Count (in 1000s; used when Rekey Policy is 3) */ | |
796 | /* -------------------------------------------------------------------- */ | |
797 | /* Configuration : Sets Rekey Group Packet count */ | |
798 | /* Values to set : 32-bit Value */ | |
799 | /* -------------------------------------------------------------------- */ | |
800 | *((int *)c_val) = 500; | |
1028e5a4 | 801 | if (!wilc_wlan_cfg_set(0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0)) |
c5c77ba1 JK |
802 | goto _fail_; |
803 | ||
804 | c_val[0] = 1; | |
1028e5a4 | 805 | if (!wilc_wlan_cfg_set(0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0)) |
c5c77ba1 JK |
806 | goto _fail_; |
807 | ||
808 | c_val[0] = G_SELF_CTS_PROT; | |
1028e5a4 | 809 | if (!wilc_wlan_cfg_set(0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
810 | goto _fail_; |
811 | ||
812 | c_val[0] = 1; /* Enable N */ | |
1028e5a4 | 813 | if (!wilc_wlan_cfg_set(0, WID_11N_ENABLE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
814 | goto _fail_; |
815 | ||
816 | c_val[0] = HT_MIXED_MODE; | |
1028e5a4 | 817 | if (!wilc_wlan_cfg_set(0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
818 | goto _fail_; |
819 | ||
820 | c_val[0] = 1; /* TXOP Prot disable in N mode: No RTS-CTS on TX A-MPDUs to save air-time. */ | |
1028e5a4 | 821 | if (!wilc_wlan_cfg_set(0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
822 | goto _fail_; |
823 | ||
824 | memcpy(c_val, mac_add, 6); | |
825 | ||
1028e5a4 | 826 | if (!wilc_wlan_cfg_set(0, WID_MAC_ADDR, c_val, 6, 0, 0)) |
c5c77ba1 JK |
827 | goto _fail_; |
828 | ||
829 | /** | |
830 | * AP only | |
831 | **/ | |
832 | c_val[0] = DETECT_PROTECT_REPORT; | |
1028e5a4 | 833 | if (!wilc_wlan_cfg_set(0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0)) |
c5c77ba1 JK |
834 | goto _fail_; |
835 | ||
836 | c_val[0] = RTS_CTS_NONHT_PROT; | |
1028e5a4 | 837 | if (!wilc_wlan_cfg_set(0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
838 | goto _fail_; |
839 | ||
840 | c_val[0] = 0; | |
1028e5a4 | 841 | if (!wilc_wlan_cfg_set(0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
842 | goto _fail_; |
843 | ||
844 | c_val[0] = MIMO_MODE; | |
1028e5a4 | 845 | if (!wilc_wlan_cfg_set(0, WID_11N_SMPS_MODE, c_val, 1, 0, 0)) |
c5c77ba1 JK |
846 | goto _fail_; |
847 | ||
848 | c_val[0] = 7; | |
1028e5a4 | 849 | if (!wilc_wlan_cfg_set(0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0)) |
c5c77ba1 JK |
850 | goto _fail_; |
851 | ||
852 | c_val[0] = 1; /* Enable N with immediate block ack. */ | |
1028e5a4 | 853 | if (!wilc_wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, 1)) |
c5c77ba1 JK |
854 | goto _fail_; |
855 | ||
856 | return 0; | |
857 | ||
858 | _fail_: | |
859 | return -1; | |
860 | } | |
861 | ||
c5c77ba1 | 862 | /**************************/ |
f61c5aff | 863 | void wilc1000_wlan_deinit(struct wilc *nic) |
c5c77ba1 | 864 | { |
080f11bb | 865 | if (g_linux_wlan->initialized) { |
c5c77ba1 JK |
866 | printk("Deinitializing wilc1000 ...\n"); |
867 | ||
868 | if (nic == NULL) { | |
869 | PRINT_ER("nic is NULL\n"); | |
870 | return; | |
871 | } | |
872 | ||
873 | #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) | |
874 | /* johnny : remove */ | |
875 | PRINT_D(INIT_DBG, "skip wilc_bus_set_default_speed\n"); | |
876 | #else | |
877 | wilc_bus_set_default_speed(); | |
878 | #endif | |
879 | ||
880 | PRINT_D(INIT_DBG, "Disabling IRQ\n"); | |
d59177cb | 881 | #ifdef WILC_SDIO |
5e150b52 | 882 | mutex_lock(&g_linux_wlan->hif_cs); |
c5c77ba1 | 883 | disable_sdio_interrupt(); |
5e150b52 | 884 | mutex_unlock(&g_linux_wlan->hif_cs); |
d59177cb | 885 | #endif |
fc4b95d6 | 886 | if (&g_linux_wlan->txq_event != NULL) |
8990d856 | 887 | up(&g_linux_wlan->txq_event); |
c5c77ba1 | 888 | |
c5c77ba1 JK |
889 | PRINT_D(INIT_DBG, "Deinitializing Threads\n"); |
890 | wlan_deinitialize_threads(nic); | |
891 | ||
892 | PRINT_D(INIT_DBG, "Deinitializing IRQ\n"); | |
893 | deinit_irq(g_linux_wlan); | |
894 | ||
8cec741e | 895 | wilc_wlan_stop(); |
c5c77ba1 JK |
896 | |
897 | PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n"); | |
a17e2ec1 | 898 | wilc_wlan_cleanup(); |
c5c77ba1 JK |
899 | #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) |
900 | #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) | |
901 | PRINT_D(INIT_DBG, "Disabling IRQ 2\n"); | |
902 | ||
5e150b52 | 903 | mutex_lock(&g_linux_wlan->hif_cs); |
c5c77ba1 | 904 | disable_sdio_interrupt(); |
5e150b52 | 905 | mutex_unlock(&g_linux_wlan->hif_cs); |
c5c77ba1 JK |
906 | #endif |
907 | #endif | |
908 | ||
909 | /*De-Initialize locks*/ | |
910 | PRINT_D(INIT_DBG, "Deinitializing Locks\n"); | |
911 | wlan_deinit_locks(g_linux_wlan); | |
912 | ||
913 | /* announce that wilc1000 is not initialized */ | |
080f11bb | 914 | g_linux_wlan->initialized = false; |
c5c77ba1 JK |
915 | |
916 | PRINT_D(INIT_DBG, "wilc1000 deinitialization Done\n"); | |
917 | ||
918 | } else { | |
919 | PRINT_D(INIT_DBG, "wilc1000 is not initialized\n"); | |
920 | } | |
c5c77ba1 JK |
921 | } |
922 | ||
f61c5aff | 923 | int wlan_init_locks(struct wilc *p_nic) |
c5c77ba1 JK |
924 | { |
925 | ||
926 | PRINT_D(INIT_DBG, "Initializing Locks ...\n"); | |
927 | ||
19a33489 GKH |
928 | mutex_init(&g_linux_wlan->hif_cs); |
929 | mutex_init(&g_linux_wlan->rxq_cs); | |
c5c77ba1 | 930 | |
b25a37b9 | 931 | spin_lock_init(&g_linux_wlan->txq_spinlock); |
642768ee | 932 | sema_init(&g_linux_wlan->txq_add_to_head_cs, 1); |
c5c77ba1 | 933 | |
642768ee | 934 | sema_init(&g_linux_wlan->txq_event, 0); |
c5c77ba1 | 935 | |
642768ee GKH |
936 | sema_init(&g_linux_wlan->cfg_event, 0); |
937 | sema_init(&g_linux_wlan->sync_event, 0); | |
c5c77ba1 | 938 | |
642768ee | 939 | sema_init(&g_linux_wlan->txq_thread_started, 0); |
c5c77ba1 | 940 | |
c5c77ba1 JK |
941 | return 0; |
942 | } | |
943 | ||
f61c5aff | 944 | static int wlan_deinit_locks(struct wilc *nic) |
c5c77ba1 JK |
945 | { |
946 | PRINT_D(INIT_DBG, "De-Initializing Locks\n"); | |
947 | ||
948 | if (&g_linux_wlan->hif_cs != NULL) | |
19a33489 | 949 | mutex_destroy(&g_linux_wlan->hif_cs); |
c5c77ba1 JK |
950 | |
951 | if (&g_linux_wlan->rxq_cs != NULL) | |
19a33489 | 952 | mutex_destroy(&g_linux_wlan->rxq_cs); |
c5c77ba1 | 953 | |
c5c77ba1 JK |
954 | return 0; |
955 | } | |
f61c5aff | 956 | void linux_to_wlan(wilc_wlan_inp_t *nwi, struct wilc *nic) |
c5c77ba1 JK |
957 | { |
958 | ||
959 | PRINT_D(INIT_DBG, "Linux to Wlan services ...\n"); | |
960 | ||
c5c77ba1 | 961 | nwi->os_context.os_private = (void *)nic; |
c5c77ba1 | 962 | |
c5c77ba1 JK |
963 | #ifdef WILC_SDIO |
964 | nwi->io_func.io_type = HIF_SDIO; | |
965 | nwi->io_func.io_init = linux_sdio_init; | |
966 | nwi->io_func.io_deinit = linux_sdio_deinit; | |
967 | nwi->io_func.u.sdio.sdio_cmd52 = linux_sdio_cmd52; | |
968 | nwi->io_func.u.sdio.sdio_cmd53 = linux_sdio_cmd53; | |
969 | nwi->io_func.u.sdio.sdio_set_max_speed = linux_sdio_set_max_speed; | |
970 | nwi->io_func.u.sdio.sdio_set_default_speed = linux_sdio_set_default_speed; | |
971 | #else | |
972 | nwi->io_func.io_type = HIF_SPI; | |
973 | nwi->io_func.io_init = linux_spi_init; | |
974 | nwi->io_func.io_deinit = linux_spi_deinit; | |
975 | nwi->io_func.u.spi.spi_tx = linux_spi_write; | |
976 | nwi->io_func.u.spi.spi_rx = linux_spi_read; | |
977 | nwi->io_func.u.spi.spi_trx = linux_spi_write_read; | |
978 | nwi->io_func.u.spi.spi_max_speed = linux_spi_set_max_speed; | |
979 | #endif | |
c5c77ba1 JK |
980 | } |
981 | ||
982 | int wlan_initialize_threads(perInterface_wlan_t *nic) | |
983 | { | |
984 | ||
985 | int ret = 0; | |
8dfaafd6 | 986 | |
c5c77ba1 JK |
987 | PRINT_D(INIT_DBG, "Initializing Threads ...\n"); |
988 | ||
c5c77ba1 JK |
989 | /* create tx task */ |
990 | PRINT_D(INIT_DBG, "Creating kthread for transmission\n"); | |
991 | g_linux_wlan->txq_thread = kthread_run(linux_wlan_txq_task, (void *)g_linux_wlan, "K_TXQ_TASK"); | |
0e04f3f3 | 992 | if (g_linux_wlan->txq_thread == NULL) { |
c5c77ba1 JK |
993 | PRINT_ER("couldn't create TXQ thread\n"); |
994 | ret = -ENOBUFS; | |
995 | goto _fail_2; | |
996 | } | |
c5c77ba1 | 997 | /* wait for TXQ task to start. */ |
8990d856 | 998 | down(&g_linux_wlan->txq_thread_started); |
c5c77ba1 JK |
999 | |
1000 | return 0; | |
1001 | ||
1002 | _fail_2: | |
1003 | /*De-Initialize 2nd thread*/ | |
1004 | g_linux_wlan->close = 1; | |
c5c77ba1 | 1005 | |
c5c77ba1 JK |
1006 | g_linux_wlan->close = 0; |
1007 | return ret; | |
1008 | } | |
1009 | ||
f61c5aff | 1010 | static void wlan_deinitialize_threads(struct wilc *nic) |
c5c77ba1 JK |
1011 | { |
1012 | ||
1013 | g_linux_wlan->close = 1; | |
1014 | PRINT_D(INIT_DBG, "Deinitializing Threads\n"); | |
c5c77ba1 | 1015 | |
c5c77ba1 | 1016 | if (&g_linux_wlan->txq_event != NULL) |
8990d856 | 1017 | up(&g_linux_wlan->txq_event); |
c5c77ba1 | 1018 | |
c5c77ba1 JK |
1019 | if (g_linux_wlan->txq_thread != NULL) { |
1020 | kthread_stop(g_linux_wlan->txq_thread); | |
1021 | g_linux_wlan->txq_thread = NULL; | |
1022 | } | |
c5c77ba1 JK |
1023 | } |
1024 | ||
c5c77ba1 JK |
1025 | int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic) |
1026 | { | |
1027 | wilc_wlan_inp_t nwi; | |
c5c77ba1 JK |
1028 | perInterface_wlan_t *nic = p_nic; |
1029 | int ret = 0; | |
1030 | ||
080f11bb | 1031 | if (!g_linux_wlan->initialized) { |
c5c77ba1 JK |
1032 | g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT; |
1033 | g_linux_wlan->close = 0; | |
c5c77ba1 JK |
1034 | |
1035 | wlan_init_locks(g_linux_wlan); | |
1036 | ||
c5c77ba1 JK |
1037 | linux_to_wlan(&nwi, g_linux_wlan); |
1038 | ||
c9d4834d | 1039 | ret = wilc_wlan_init(&nwi); |
c5c77ba1 JK |
1040 | if (ret < 0) { |
1041 | PRINT_ER("Initializing WILC_Wlan FAILED\n"); | |
1042 | ret = -EIO; | |
1043 | goto _fail_locks_; | |
1044 | } | |
c5c77ba1 | 1045 | |
c5c77ba1 JK |
1046 | #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) |
1047 | if (init_irq(g_linux_wlan)) { | |
1048 | PRINT_ER("couldn't initialize IRQ\n"); | |
1049 | ret = -EIO; | |
b46d6882 | 1050 | goto _fail_locks_; |
c5c77ba1 JK |
1051 | } |
1052 | #endif | |
1053 | ||
b46d6882 TC |
1054 | ret = wlan_initialize_threads(nic); |
1055 | if (ret < 0) { | |
1056 | PRINT_ER("Initializing Threads FAILED\n"); | |
1057 | ret = -EIO; | |
1058 | goto _fail_wilc_wlan_; | |
1059 | } | |
1060 | ||
c5c77ba1 JK |
1061 | #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) |
1062 | if (enable_sdio_interrupt()) { | |
1063 | PRINT_ER("couldn't initialize IRQ\n"); | |
1064 | ret = -EIO; | |
1065 | goto _fail_irq_init_; | |
1066 | } | |
1067 | #endif | |
1068 | ||
1069 | if (linux_wlan_get_firmware(nic)) { | |
17aacd43 | 1070 | PRINT_ER("Can't get firmware\n"); |
c5c77ba1 JK |
1071 | ret = -EIO; |
1072 | goto _fail_irq_enable_; | |
1073 | } | |
1074 | ||
c5c77ba1 JK |
1075 | /*Download firmware*/ |
1076 | ret = linux_wlan_firmware_download(g_linux_wlan); | |
1077 | if (ret < 0) { | |
1078 | PRINT_ER("Failed to download firmware\n"); | |
1079 | ret = -EIO; | |
1080 | goto _fail_irq_enable_; | |
1081 | } | |
1082 | ||
1083 | /* Start firmware*/ | |
1084 | ret = linux_wlan_start_firmware(nic); | |
1085 | if (ret < 0) { | |
1086 | PRINT_ER("Failed to start firmware\n"); | |
1087 | ret = -EIO; | |
1088 | goto _fail_irq_enable_; | |
1089 | } | |
1090 | ||
1091 | wilc_bus_set_max_speed(); | |
1092 | ||
07056a85 | 1093 | if (wilc_wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) { |
c5c77ba1 JK |
1094 | int size; |
1095 | char Firmware_ver[20]; | |
8dfaafd6 | 1096 | |
894de36b | 1097 | size = wilc_wlan_cfg_get_val( |
c5c77ba1 JK |
1098 | WID_FIRMWARE_VERSION, |
1099 | Firmware_ver, sizeof(Firmware_ver)); | |
1100 | Firmware_ver[size] = '\0'; | |
1101 | PRINT_D(INIT_DBG, "***** Firmware Ver = %s *******\n", Firmware_ver); | |
1102 | } | |
1103 | /* Initialize firmware with default configuration */ | |
1104 | ret = linux_wlan_init_test_config(dev, g_linux_wlan); | |
1105 | ||
1106 | if (ret < 0) { | |
1107 | PRINT_ER("Failed to configure firmware\n"); | |
1108 | ret = -EIO; | |
1109 | goto _fail_fw_start_; | |
1110 | } | |
1111 | ||
080f11bb | 1112 | g_linux_wlan->initialized = true; |
c5c77ba1 JK |
1113 | return 0; /*success*/ |
1114 | ||
c5c77ba1 | 1115 | _fail_fw_start_: |
8cec741e | 1116 | wilc_wlan_stop(); |
c5c77ba1 JK |
1117 | |
1118 | _fail_irq_enable_: | |
1119 | #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO) | |
1120 | disable_sdio_interrupt(); | |
c5c77ba1 | 1121 | _fail_irq_init_: |
7a8fd841 | 1122 | #endif |
c5c77ba1 JK |
1123 | #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO) |
1124 | deinit_irq(g_linux_wlan); | |
1125 | ||
1126 | #endif | |
c5c77ba1 JK |
1127 | wlan_deinitialize_threads(g_linux_wlan); |
1128 | _fail_wilc_wlan_: | |
a17e2ec1 | 1129 | wilc_wlan_cleanup(); |
c5c77ba1 JK |
1130 | _fail_locks_: |
1131 | wlan_deinit_locks(g_linux_wlan); | |
1132 | PRINT_ER("WLAN Iinitialization FAILED\n"); | |
1133 | } else { | |
1134 | PRINT_D(INIT_DBG, "wilc1000 already initialized\n"); | |
1135 | } | |
1136 | return ret; | |
1137 | } | |
1138 | ||
c5c77ba1 JK |
1139 | /* |
1140 | * - this function will be called automatically by OS when module inserted. | |
1141 | */ | |
1142 | ||
c5c77ba1 JK |
1143 | int mac_init_fn(struct net_device *ndev) |
1144 | { | |
1145 | ||
1146 | /*Why we do this !!!*/ | |
1147 | netif_start_queue(ndev); /* ma */ | |
1148 | netif_stop_queue(ndev); /* ma */ | |
1149 | ||
1150 | return 0; | |
1151 | } | |
c5c77ba1 | 1152 | |
c5c77ba1 | 1153 | /* This fn is called, when this device is setup using ifconfig */ |
c5c77ba1 JK |
1154 | int mac_open(struct net_device *ndev) |
1155 | { | |
1156 | perInterface_wlan_t *nic; | |
1157 | ||
c5c77ba1 JK |
1158 | /*No need for setting mac address here anymore,*/ |
1159 | /*Just set it in init_test_config()*/ | |
1160 | unsigned char mac_add[ETH_ALEN] = {0}; | |
c5c77ba1 JK |
1161 | int ret = 0; |
1162 | int i = 0; | |
2726887c | 1163 | struct wilc_priv *priv; |
c5c77ba1 | 1164 | |
7d05652c CG |
1165 | #ifdef WILC_SPI |
1166 | if (!g_linux_wlan || !g_linux_wlan->wilc_spidev) { | |
1167 | netdev_err(ndev, "wilc1000: SPI device not ready\n"); | |
1168 | return -ENODEV; | |
1169 | } | |
1170 | #endif | |
c5c77ba1 JK |
1171 | nic = netdev_priv(ndev); |
1172 | priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); | |
1173 | PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev); | |
1174 | ||
dd4b6a83 | 1175 | ret = wilc_init_host_int(ndev); |
c5c77ba1 JK |
1176 | if (ret < 0) { |
1177 | PRINT_ER("Failed to initialize host interface\n"); | |
1178 | ||
1179 | return ret; | |
1180 | } | |
c5c77ba1 JK |
1181 | |
1182 | /*initialize platform*/ | |
1183 | PRINT_D(INIT_DBG, "*** re-init ***\n"); | |
1184 | ret = wilc1000_wlan_init(ndev, nic); | |
1185 | if (ret < 0) { | |
1186 | PRINT_ER("Failed to initialize wilc1000\n"); | |
a9a16823 | 1187 | wilc_deinit_host_int(ndev); |
c5c77ba1 JK |
1188 | return ret; |
1189 | } | |
1190 | ||
72ed4dc7 | 1191 | Set_machw_change_vir_if(false); |
c5c77ba1 | 1192 | |
21175ef7 | 1193 | host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add); |
310a28fd | 1194 | PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add); |
c5c77ba1 JK |
1195 | |
1196 | /* loop through the NUM of supported devices and set the MAC address */ | |
c1b30f6a | 1197 | for (i = 0; i < g_linux_wlan->vif_num; i++) { |
817f3fb9 | 1198 | if (ndev == g_linux_wlan->vif[i].ndev) { |
7e7fa470 | 1199 | memcpy(g_linux_wlan->vif[i].src_addr, mac_add, ETH_ALEN); |
3134a578 | 1200 | g_linux_wlan->vif[i].hif_drv = priv->hWILCWFIDrv; |
c5c77ba1 JK |
1201 | break; |
1202 | } | |
1203 | } | |
1204 | ||
1205 | /* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/ | |
7e7fa470 | 1206 | memcpy(ndev->dev_addr, g_linux_wlan->vif[i].src_addr, ETH_ALEN); |
c5c77ba1 JK |
1207 | |
1208 | if (!is_valid_ether_addr(ndev->dev_addr)) { | |
1209 | PRINT_ER("Error: Wrong MAC address\n"); | |
1210 | ret = -EINVAL; | |
1211 | goto _err_; | |
1212 | } | |
1213 | ||
8e0735c5 CL |
1214 | wilc_mgmt_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev->ieee80211_ptr, |
1215 | nic->g_struct_frame_reg[0].frame_type, nic->g_struct_frame_reg[0].reg); | |
1216 | wilc_mgmt_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev->ieee80211_ptr, | |
1217 | nic->g_struct_frame_reg[1].frame_type, nic->g_struct_frame_reg[1].reg); | |
c5c77ba1 JK |
1218 | netif_wake_queue(ndev); |
1219 | g_linux_wlan->open_ifcs++; | |
1220 | nic->mac_opened = 1; | |
1221 | return 0; | |
1222 | ||
1223 | _err_: | |
a9a16823 | 1224 | wilc_deinit_host_int(ndev); |
c5c77ba1 JK |
1225 | wilc1000_wlan_deinit(g_linux_wlan); |
1226 | return ret; | |
1227 | } | |
c5c77ba1 JK |
1228 | |
1229 | struct net_device_stats *mac_stats(struct net_device *dev) | |
1230 | { | |
1231 | perInterface_wlan_t *nic = netdev_priv(dev); | |
1232 | ||
c5c77ba1 JK |
1233 | return &nic->netstats; |
1234 | } | |
1235 | ||
1236 | /* Setup the multicast filter */ | |
c5c77ba1 JK |
1237 | static void wilc_set_multicast_list(struct net_device *dev) |
1238 | { | |
1239 | ||
1240 | struct netdev_hw_addr *ha; | |
2726887c | 1241 | struct wilc_priv *priv; |
441dc609 | 1242 | struct host_if_drv *pstrWFIDrv; |
c5c77ba1 | 1243 | int i = 0; |
8dfaafd6 | 1244 | |
c5c77ba1 | 1245 | priv = wiphy_priv(dev->ieee80211_ptr->wiphy); |
441dc609 | 1246 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
c5c77ba1 | 1247 | |
c5c77ba1 JK |
1248 | if (!dev) |
1249 | return; | |
1250 | ||
17aacd43 | 1251 | PRINT_D(INIT_DBG, "Setting Multicast List with count = %d.\n", dev->mc.count); |
c5c77ba1 JK |
1252 | |
1253 | if (dev->flags & IFF_PROMISC) { | |
1254 | /* Normally, we should configure the chip to retrive all packets | |
1255 | * but we don't wanna support this right now */ | |
1256 | /* TODO: add promiscuous mode support */ | |
17aacd43 | 1257 | PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets\n"); |
c5c77ba1 JK |
1258 | return; |
1259 | } | |
1260 | ||
1261 | /* If there's more addresses than we handle, get all multicast | |
1262 | * packets and sort them out in software. */ | |
1263 | if ((dev->flags & IFF_ALLMULTI) || (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) { | |
1264 | PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n"); | |
1265 | /* get all multicast packets */ | |
218dc407 | 1266 | host_int_setup_multicast_filter(pstrWFIDrv, false, 0); |
c5c77ba1 JK |
1267 | return; |
1268 | } | |
1269 | ||
1270 | /* No multicast? Just get our own stuff */ | |
1271 | if ((dev->mc.count) == 0) { | |
1272 | PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n"); | |
218dc407 | 1273 | host_int_setup_multicast_filter(pstrWFIDrv, true, 0); |
c5c77ba1 JK |
1274 | return; |
1275 | } | |
1276 | ||
1277 | /* Store all of the multicast addresses in the hardware filter */ | |
1278 | netdev_for_each_mc_addr(ha, dev) | |
1279 | { | |
d00d2ba3 | 1280 | memcpy(gau8MulticastMacAddrList[i], ha->addr, ETH_ALEN); |
c5c77ba1 JK |
1281 | PRINT_D(INIT_DBG, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i, |
1282 | gau8MulticastMacAddrList[i][0], gau8MulticastMacAddrList[i][1], gau8MulticastMacAddrList[i][2], gau8MulticastMacAddrList[i][3], gau8MulticastMacAddrList[i][4], gau8MulticastMacAddrList[i][5]); | |
1283 | i++; | |
1284 | } | |
1285 | ||
218dc407 | 1286 | host_int_setup_multicast_filter(pstrWFIDrv, true, (dev->mc.count)); |
c5c77ba1 JK |
1287 | |
1288 | return; | |
1289 | ||
1290 | } | |
1291 | ||
c5c77ba1 JK |
1292 | static void linux_wlan_tx_complete(void *priv, int status) |
1293 | { | |
1294 | ||
1295 | struct tx_complete_data *pv_data = (struct tx_complete_data *)priv; | |
8dfaafd6 | 1296 | |
78174ada | 1297 | if (status == 1) |
c5c77ba1 | 1298 | PRINT_D(TX_DBG, "Packet sent successfully - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb); |
78174ada | 1299 | else |
c5c77ba1 | 1300 | 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 JK |
1301 | /* Free the SK Buffer, its work is done */ |
1302 | dev_kfree_skb(pv_data->skb); | |
a18dd630 | 1303 | kfree(pv_data); |
c5c77ba1 JK |
1304 | } |
1305 | ||
1306 | int mac_xmit(struct sk_buff *skb, struct net_device *ndev) | |
1307 | { | |
1308 | perInterface_wlan_t *nic; | |
1309 | struct tx_complete_data *tx_data = NULL; | |
1310 | int QueueCount; | |
1311 | char *pu8UdpBuffer; | |
1312 | struct iphdr *ih; | |
1313 | struct ethhdr *eth_h; | |
8dfaafd6 | 1314 | |
c5c77ba1 JK |
1315 | nic = netdev_priv(ndev); |
1316 | ||
c5c77ba1 JK |
1317 | PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n"); |
1318 | ||
1319 | /* Stop the network interface queue */ | |
1320 | if (skb->dev != ndev) { | |
1321 | PRINT_ER("Packet not destined to this device\n"); | |
1322 | return 0; | |
1323 | } | |
1324 | ||
d5df3797 | 1325 | tx_data = kmalloc(sizeof(struct tx_complete_data), GFP_ATOMIC); |
c5c77ba1 JK |
1326 | if (tx_data == NULL) { |
1327 | PRINT_ER("Failed to allocate memory for tx_data structure\n"); | |
1328 | dev_kfree_skb(skb); | |
1329 | netif_wake_queue(ndev); | |
1330 | return 0; | |
1331 | } | |
1332 | ||
1333 | tx_data->buff = skb->data; | |
1334 | tx_data->size = skb->len; | |
1335 | tx_data->skb = skb; | |
1336 | ||
1337 | eth_h = (struct ethhdr *)(skb->data); | |
fc4b95d6 | 1338 | if (eth_h->h_proto == 0x8e88) |
c5c77ba1 | 1339 | PRINT_D(INIT_DBG, "EAPOL transmitted\n"); |
c5c77ba1 JK |
1340 | |
1341 | /*get source and dest ip addresses*/ | |
1342 | ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr)); | |
1343 | ||
1344 | pu8UdpBuffer = (char *)ih + sizeof(struct iphdr); | |
fc4b95d6 | 1345 | if ((pu8UdpBuffer[1] == 68 && pu8UdpBuffer[3] == 67) || (pu8UdpBuffer[1] == 67 && pu8UdpBuffer[3] == 68)) |
c5c77ba1 JK |
1346 | PRINT_D(GENERIC_DBG, "DHCP Message transmitted, type:%x %x %x\n", pu8UdpBuffer[248], pu8UdpBuffer[249], pu8UdpBuffer[250]); |
1347 | ||
c5c77ba1 JK |
1348 | PRINT_D(TX_DBG, "Sending packet - Size = %d - Address = %p - SKB = %p\n", tx_data->size, tx_data->buff, tx_data->skb); |
1349 | ||
1350 | /* Send packet to MAC HW - for now the tx_complete function will be just status | |
1351 | * indicator. still not sure if I need to suspend host transmission till the tx_complete | |
1352 | * function called or not? | |
1353 | * allocated buffer will be freed in tx_complete function. | |
1354 | */ | |
1355 | PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n"); | |
1356 | nic->netstats.tx_packets++; | |
1357 | nic->netstats.tx_bytes += tx_data->size; | |
7201cd2c | 1358 | tx_data->pBssid = g_linux_wlan->vif[nic->u8IfIdx].bssid; |
8fc84a6f GL |
1359 | QueueCount = wilc_wlan_txq_add_net_pkt((void *)tx_data, tx_data->buff, |
1360 | tx_data->size, | |
1361 | linux_wlan_tx_complete); | |
c5c77ba1 | 1362 | |
c5c77ba1 | 1363 | if (QueueCount > FLOW_CONTROL_UPPER_THRESHOLD) { |
817f3fb9 TC |
1364 | netif_stop_queue(g_linux_wlan->vif[0].ndev); |
1365 | netif_stop_queue(g_linux_wlan->vif[1].ndev); | |
c5c77ba1 JK |
1366 | } |
1367 | ||
1368 | return 0; | |
1369 | } | |
1370 | ||
c5c77ba1 JK |
1371 | int mac_close(struct net_device *ndev) |
1372 | { | |
2726887c | 1373 | struct wilc_priv *priv; |
c5c77ba1 | 1374 | perInterface_wlan_t *nic; |
441dc609 | 1375 | struct host_if_drv *pstrWFIDrv; |
c5c77ba1 JK |
1376 | |
1377 | nic = netdev_priv(ndev); | |
1378 | ||
1379 | if ((nic == NULL) || (nic->wilc_netdev == NULL) || (nic->wilc_netdev->ieee80211_ptr == NULL) || (nic->wilc_netdev->ieee80211_ptr->wiphy == NULL)) { | |
1380 | PRINT_ER("nic = NULL\n"); | |
1381 | return 0; | |
1382 | } | |
1383 | ||
1384 | priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); | |
1385 | ||
1386 | if (priv == NULL) { | |
1387 | PRINT_ER("priv = NULL\n"); | |
1388 | return 0; | |
1389 | } | |
1390 | ||
441dc609 | 1391 | pstrWFIDrv = (struct host_if_drv *)priv->hWILCWFIDrv; |
c5c77ba1 | 1392 | |
c5c77ba1 JK |
1393 | PRINT_D(GENERIC_DBG, "Mac close\n"); |
1394 | ||
1395 | if (g_linux_wlan == NULL) { | |
1396 | PRINT_ER("g_linux_wlan = NULL\n"); | |
1397 | return 0; | |
1398 | } | |
1399 | ||
1400 | if (pstrWFIDrv == NULL) { | |
1401 | PRINT_ER("pstrWFIDrv = NULL\n"); | |
1402 | return 0; | |
1403 | } | |
1404 | ||
1405 | if ((g_linux_wlan->open_ifcs) > 0) { | |
1406 | g_linux_wlan->open_ifcs--; | |
1407 | } else { | |
1408 | PRINT_ER("ERROR: MAC close called while number of opened interfaces is zero\n"); | |
1409 | return 0; | |
1410 | } | |
1411 | ||
1412 | if (nic->wilc_netdev != NULL) { | |
1413 | /* Stop the network interface queue */ | |
1414 | netif_stop_queue(nic->wilc_netdev); | |
1415 | ||
a9a16823 | 1416 | wilc_deinit_host_int(nic->wilc_netdev); |
c5c77ba1 JK |
1417 | } |
1418 | ||
1419 | if (g_linux_wlan->open_ifcs == 0) { | |
1420 | PRINT_D(GENERIC_DBG, "Deinitializing wilc1000\n"); | |
1421 | g_linux_wlan->close = 1; | |
1422 | wilc1000_wlan_deinit(g_linux_wlan); | |
c5c77ba1 | 1423 | WILC_WFI_deinit_mon_interface(); |
c5c77ba1 JK |
1424 | } |
1425 | ||
8990d856 | 1426 | up(&close_exit_sync); |
c5c77ba1 JK |
1427 | nic->mac_opened = 0; |
1428 | ||
1429 | return 0; | |
1430 | } | |
1431 | ||
c5c77ba1 JK |
1432 | int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) |
1433 | { | |
1434 | ||
63d03e47 | 1435 | u8 *buff = NULL; |
ca356ada | 1436 | s8 rssi; |
4e4467fd | 1437 | u32 size = 0, length = 0; |
c5c77ba1 | 1438 | perInterface_wlan_t *nic; |
2726887c | 1439 | struct wilc_priv *priv; |
e6e12661 | 1440 | s32 s32Error = 0; |
c5c77ba1 | 1441 | |
c5c77ba1 | 1442 | /* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */ |
c5c77ba1 JK |
1443 | nic = netdev_priv(ndev); |
1444 | ||
080f11bb | 1445 | if (!g_linux_wlan->initialized) |
c5c77ba1 JK |
1446 | return 0; |
1447 | ||
c5c77ba1 | 1448 | switch (cmd) { |
c5c77ba1 JK |
1449 | |
1450 | /* ]] 2013-06-24 */ | |
1451 | case SIOCSIWPRIV: | |
1452 | { | |
1453 | struct iwreq *wrq = (struct iwreq *) req; /* added by tony */ | |
1454 | ||
1455 | size = wrq->u.data.length; | |
1456 | ||
1457 | if (size && wrq->u.data.pointer) { | |
c5c77ba1 | 1458 | |
4a01f1c3 | 1459 | buff = memdup_user(wrq->u.data.pointer, wrq->u.data.length); |
360e27a9 SM |
1460 | if (IS_ERR(buff)) |
1461 | return PTR_ERR(buff); | |
c5c77ba1 JK |
1462 | |
1463 | if (strncasecmp(buff, "RSSI", length) == 0) { | |
c5c77ba1 JK |
1464 | priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); |
1465 | s32Error = host_int_get_rssi(priv->hWILCWFIDrv, &(rssi)); | |
1466 | if (s32Error) | |
1467 | PRINT_ER("Failed to send get rssi param's message queue "); | |
c5c77ba1 JK |
1468 | PRINT_INFO(GENERIC_DBG, "RSSI :%d\n", rssi); |
1469 | ||
1470 | /*Rounding up the rssi negative value*/ | |
1471 | rssi += 5; | |
1472 | ||
1473 | snprintf(buff, size, "rssi %d", rssi); | |
1474 | ||
1475 | if (copy_to_user(wrq->u.data.pointer, buff, size)) { | |
60cb1e20 | 1476 | PRINT_ER("%s: failed to copy data to user buffer\n", __func__); |
c5c77ba1 JK |
1477 | s32Error = -EFAULT; |
1478 | goto done; | |
1479 | } | |
1480 | } | |
1481 | } | |
1482 | } | |
1483 | break; | |
1484 | ||
1485 | default: | |
1486 | { | |
1487 | PRINT_INFO(GENERIC_DBG, "Command - %d - has been received\n", cmd); | |
1488 | s32Error = -EOPNOTSUPP; | |
1489 | goto done; | |
1490 | } | |
1491 | } | |
1492 | ||
1493 | done: | |
1494 | ||
642ac6c0 | 1495 | kfree(buff); |
c5c77ba1 JK |
1496 | |
1497 | return s32Error; | |
1498 | } | |
1499 | ||
fbc2fe16 | 1500 | void frmw_to_linux(u8 *buff, u32 size, u32 pkt_offset) |
c5c77ba1 JK |
1501 | { |
1502 | ||
1503 | unsigned int frame_len = 0; | |
1504 | int stats; | |
1505 | unsigned char *buff_to_send = NULL; | |
1506 | struct sk_buff *skb; | |
c5c77ba1 JK |
1507 | struct net_device *wilc_netdev; |
1508 | perInterface_wlan_t *nic; | |
1509 | ||
1510 | wilc_netdev = GetIfHandler(buff); | |
1511 | if (wilc_netdev == NULL) | |
1512 | return; | |
1513 | ||
1514 | buff += pkt_offset; | |
1515 | nic = netdev_priv(wilc_netdev); | |
1516 | ||
1517 | if (size > 0) { | |
1518 | ||
1519 | frame_len = size; | |
1520 | buff_to_send = buff; | |
1521 | ||
c5c77ba1 JK |
1522 | /* Need to send the packet up to the host, allocate a skb buffer */ |
1523 | skb = dev_alloc_skb(frame_len); | |
1524 | if (skb == NULL) { | |
1525 | PRINT_ER("Low memory - packet droped\n"); | |
1526 | return; | |
1527 | } | |
1528 | ||
fc4b95d6 | 1529 | if (g_linux_wlan == NULL || wilc_netdev == NULL) |
c5c77ba1 | 1530 | PRINT_ER("wilc_netdev in g_linux_wlan is NULL"); |
c5c77ba1 JK |
1531 | skb->dev = wilc_netdev; |
1532 | ||
fc4b95d6 | 1533 | if (skb->dev == NULL) |
c5c77ba1 | 1534 | PRINT_ER("skb->dev is NULL\n"); |
c5c77ba1 JK |
1535 | |
1536 | /* | |
1537 | * for(i=0;i<40;i++) | |
1538 | * { | |
1539 | * if(i<frame_len) | |
1540 | * WILC_PRINTF("buff_to_send[%d]=%2x\n",i,buff_to_send[i]); | |
1541 | * | |
1542 | * }*/ | |
1543 | ||
1544 | /* skb_put(skb, frame_len); */ | |
1545 | memcpy(skb_put(skb, frame_len), buff_to_send, frame_len); | |
1546 | ||
1547 | /* WILC_PRINTF("After MEM_CPY\n"); */ | |
1548 | ||
1549 | /* nic = netdev_priv(wilc_netdev); */ | |
1550 | ||
c5c77ba1 | 1551 | skb->protocol = eth_type_trans(skb, wilc_netdev); |
c5c77ba1 JK |
1552 | /* Send the packet to the stack by giving it to the bridge */ |
1553 | nic->netstats.rx_packets++; | |
1554 | nic->netstats.rx_bytes += frame_len; | |
1555 | skb->ip_summed = CHECKSUM_UNNECESSARY; | |
1556 | stats = netif_rx(skb); | |
1557 | PRINT_D(RX_DBG, "netif_rx ret value is: %d\n", stats); | |
1558 | } | |
c5c77ba1 JK |
1559 | } |
1560 | ||
fbc2fe16 | 1561 | void WILC_WFI_mgmt_rx(u8 *buff, u32 size) |
c5c77ba1 JK |
1562 | { |
1563 | int i = 0; | |
1564 | perInterface_wlan_t *nic; | |
1565 | ||
c5c77ba1 JK |
1566 | /*Pass the frame on the monitor interface, if any.*/ |
1567 | /*Otherwise, pass it on p2p0 netdev, if registered on it*/ | |
c1b30f6a | 1568 | for (i = 0; i < g_linux_wlan->vif_num; i++) { |
817f3fb9 | 1569 | nic = netdev_priv(g_linux_wlan->vif[i].ndev); |
c5c77ba1 JK |
1570 | if (nic->monitor_flag) { |
1571 | WILC_WFI_monitor_rx(buff, size); | |
1572 | return; | |
1573 | } | |
1574 | } | |
1575 | ||
817f3fb9 | 1576 | nic = netdev_priv(g_linux_wlan->vif[1].ndev); /* p2p0 */ |
c5c77ba1 | 1577 | if ((buff[0] == nic->g_struct_frame_reg[0].frame_type && nic->g_struct_frame_reg[0].reg) || |
fc4b95d6 | 1578 | (buff[0] == nic->g_struct_frame_reg[1].frame_type && nic->g_struct_frame_reg[1].reg)) |
817f3fb9 | 1579 | WILC_WFI_p2p_rx(g_linux_wlan->vif[1].ndev, buff, size); |
c5c77ba1 JK |
1580 | } |
1581 | ||
4875c499 TC |
1582 | void wl_wlan_cleanup(void) |
1583 | { | |
1584 | int i = 0; | |
1585 | perInterface_wlan_t *nic[NUM_CONCURRENT_IFC]; | |
1586 | ||
1587 | if (g_linux_wlan && | |
1588 | (g_linux_wlan->vif[0].ndev || g_linux_wlan->vif[1].ndev)) { | |
1589 | unregister_inetaddr_notifier(&g_dev_notifier); | |
1590 | ||
1591 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) | |
1592 | nic[i] = netdev_priv(g_linux_wlan->vif[i].ndev); | |
1593 | } | |
1594 | ||
8b8ad7bc TC |
1595 | if (g_linux_wlan && g_linux_wlan->firmware) |
1596 | release_firmware(g_linux_wlan->firmware); | |
4875c499 TC |
1597 | |
1598 | if (g_linux_wlan && | |
1599 | (g_linux_wlan->vif[0].ndev || g_linux_wlan->vif[1].ndev)) { | |
1600 | linux_wlan_lock_timeout(&close_exit_sync, 12 * 1000); | |
1601 | ||
1602 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) | |
1603 | if (g_linux_wlan->vif[i].ndev) | |
1604 | if (nic[i]->mac_opened) | |
1605 | mac_close(g_linux_wlan->vif[i].ndev); | |
1606 | ||
1607 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) { | |
1608 | unregister_netdev(g_linux_wlan->vif[i].ndev); | |
1609 | wilc_free_wiphy(g_linux_wlan->vif[i].ndev); | |
1610 | free_netdev(g_linux_wlan->vif[i].ndev); | |
1611 | } | |
1612 | } | |
1613 | ||
1614 | kfree(g_linux_wlan); | |
1615 | ||
1616 | #if defined(WILC_DEBUGFS) | |
1617 | wilc_debugfs_remove(); | |
1618 | #endif | |
1619 | linux_wlan_device_detection(0); | |
1620 | linux_wlan_device_power(0); | |
1621 | } | |
1622 | ||
12ba5416 | 1623 | int wilc_netdev_init(struct wilc **wilc) |
c5c77ba1 | 1624 | { |
c5c77ba1 JK |
1625 | int i; |
1626 | perInterface_wlan_t *nic; | |
1627 | struct net_device *ndev; | |
1628 | ||
642768ee | 1629 | sema_init(&close_exit_sync, 0); |
c5c77ba1 JK |
1630 | |
1631 | /*create the common structure*/ | |
f61c5aff | 1632 | g_linux_wlan = kzalloc(sizeof(*g_linux_wlan), GFP_KERNEL); |
ac61ef86 CL |
1633 | if (!g_linux_wlan) |
1634 | return -ENOMEM; | |
c5c77ba1 | 1635 | |
12ba5416 TC |
1636 | *wilc = g_linux_wlan; |
1637 | ||
c5c77ba1 | 1638 | register_inetaddr_notifier(&g_dev_notifier); |
c5c77ba1 JK |
1639 | |
1640 | for (i = 0; i < NUM_CONCURRENT_IFC; i++) { | |
1641 | /*allocate first ethernet device with perinterface_wlan_t as its private data*/ | |
1642 | ndev = alloc_etherdev(sizeof(perInterface_wlan_t)); | |
1643 | if (!ndev) { | |
1644 | PRINT_ER("Failed to allocate ethernet dev\n"); | |
1645 | return -1; | |
1646 | } | |
1647 | ||
1648 | nic = netdev_priv(ndev); | |
1649 | memset(nic, 0, sizeof(perInterface_wlan_t)); | |
1650 | ||
1651 | /*Name the Devices*/ | |
1652 | if (i == 0) { | |
1653 | #if defined(NM73131) /* tony, 2012-09-20 */ | |
1654 | strcpy(ndev->name, "wilc_eth%d"); | |
1655 | #elif defined(PLAT_CLM9722) /* rachel */ | |
1656 | strcpy(ndev->name, "eth%d"); | |
1657 | #else /* PANDA_BOARD, PLAT_ALLWINNER_A10, PLAT_ALLWINNER_A20, PLAT_ALLWINNER_A31, PLAT_AML8726_M3 or PLAT_WMS8304 */ | |
1658 | strcpy(ndev->name, "wlan%d"); | |
1659 | #endif | |
1660 | } else | |
1661 | strcpy(ndev->name, "p2p%d"); | |
1662 | ||
c1b30f6a | 1663 | nic->u8IfIdx = g_linux_wlan->vif_num; |
c5c77ba1 | 1664 | nic->wilc_netdev = ndev; |
38b3001d | 1665 | nic->wilc = *wilc; |
817f3fb9 | 1666 | g_linux_wlan->vif[g_linux_wlan->vif_num].ndev = ndev; |
c1b30f6a | 1667 | g_linux_wlan->vif_num++; |
e5af0561 | 1668 | ndev->netdev_ops = &wilc_netdev_ops; |
c5c77ba1 | 1669 | |
c5c77ba1 JK |
1670 | { |
1671 | struct wireless_dev *wdev; | |
1672 | /*Register WiFi*/ | |
8459fd54 | 1673 | wdev = wilc_create_wiphy(ndev); |
c5c77ba1 JK |
1674 | |
1675 | #ifdef WILC_SDIO | |
1676 | /* set netdev, tony */ | |
1677 | SET_NETDEV_DEV(ndev, &local_sdio_func->dev); | |
1678 | #endif | |
1679 | ||
1680 | if (wdev == NULL) { | |
1681 | PRINT_ER("Can't register WILC Wiphy\n"); | |
1682 | return -1; | |
1683 | } | |
1684 | ||
1685 | /*linking the wireless_dev structure with the netdevice*/ | |
1686 | nic->wilc_netdev->ieee80211_ptr = wdev; | |
1687 | nic->wilc_netdev->ml_priv = nic; | |
1688 | wdev->netdev = nic->wilc_netdev; | |
1689 | nic->netstats.rx_packets = 0; | |
1690 | nic->netstats.tx_packets = 0; | |
1691 | nic->netstats.rx_bytes = 0; | |
1692 | nic->netstats.tx_bytes = 0; | |
1693 | ||
1694 | } | |
c5c77ba1 | 1695 | |
c5c77ba1 JK |
1696 | if (register_netdev(ndev)) { |
1697 | PRINT_ER("Device couldn't be registered - %s\n", ndev->name); | |
1698 | return -1; /* ERROR */ | |
1699 | } | |
1700 | ||
1701 | nic->iftype = STATION_MODE; | |
1702 | nic->mac_opened = 0; | |
1703 | ||
1704 | } | |
1705 | ||
1706 | #ifndef WILC_SDIO | |
1707 | if (!linux_spi_init(&g_linux_wlan->wilc_spidev)) { | |
17aacd43 | 1708 | PRINT_ER("Can't initialize SPI\n"); |
c5c77ba1 JK |
1709 | return -1; /* ERROR */ |
1710 | } | |
1711 | g_linux_wlan->wilc_spidev = wilc_spi_dev; | |
1712 | #else | |
1713 | g_linux_wlan->wilc_sdio_func = local_sdio_func; | |
1714 | #endif | |
1715 | ||
1716 | return 0; | |
1717 | } | |
1718 | ||
c5c77ba1 JK |
1719 | /*The 1st function called after module inserted*/ |
1720 | static int __init init_wilc_driver(void) | |
1721 | { | |
33694632 | 1722 | #if defined(WILC_DEBUGFS) |
c5c77ba1 JK |
1723 | if (wilc_debugfs_init() < 0) { |
1724 | PRINT_D(GENERIC_DBG, "fail to create debugfs for wilc driver\n"); | |
1725 | return -1; | |
1726 | } | |
1727 | #endif | |
1728 | ||
1729 | printk("IN INIT FUNCTION\n"); | |
691f1a2f | 1730 | printk("*** WILC1000 driver VERSION=[10.2] FW_VER=[10.2] ***\n"); |
c5c77ba1 JK |
1731 | |
1732 | linux_wlan_device_power(1); | |
1733 | msleep(100); | |
1734 | linux_wlan_device_detection(1); | |
1735 | ||
1736 | #ifdef WILC_SDIO | |
1737 | { | |
1738 | int ret; | |
1739 | ||
1740 | ret = sdio_register_driver(&wilc_bus); | |
fc4b95d6 | 1741 | if (ret < 0) |
c5c77ba1 | 1742 | PRINT_D(INIT_DBG, "init_wilc_driver: Failed register sdio driver\n"); |
c5c77ba1 JK |
1743 | |
1744 | return ret; | |
1745 | } | |
1746 | #else | |
1747 | PRINT_D(INIT_DBG, "Initializing netdev\n"); | |
fc4b95d6 | 1748 | if (wilc_netdev_init()) |
c5c77ba1 | 1749 | PRINT_ER("Couldn't initialize netdev\n"); |
c5c77ba1 JK |
1750 | return 0; |
1751 | #endif | |
1752 | } | |
1753 | late_initcall(init_wilc_driver); | |
1754 | ||
1755 | static void __exit exit_wilc_driver(void) | |
1756 | { | |
c2eda352 CL |
1757 | #ifndef WILC_SDIO |
1758 | PRINT_D(INIT_DBG, "SPI unregsiter...\n"); | |
1759 | spi_unregister_driver(&wilc_bus); | |
1760 | #else | |
1761 | PRINT_D(INIT_DBG, "SDIO unregsiter...\n"); | |
1762 | sdio_unregister_driver(&wilc_bus); | |
1763 | #endif | |
c5c77ba1 JK |
1764 | } |
1765 | module_exit(exit_wilc_driver); | |
1766 | ||
1767 | MODULE_LICENSE("GPL"); |