2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifdef CONFIG_WIFI_CONTROL_FUNC
18 #include <linux/platform_device.h>
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/kthread.h>
23 #include <linux/slab.h>
24 #include <linux/skbuff.h>
25 #include <linux/netdevice.h>
26 #include <linux/etherdevice.h>
27 #include <linux/mmc/sdio_func.h>
28 #include <linux/random.h>
29 #include <linux/spinlock.h>
30 #include <linux/ethtool.h>
31 #include <linux/fcntl.h>
33 #include <linux/uaccess.h>
37 #include <bcmendian.h>
39 #include <proto/ethernet.h>
40 #include <dngl_stats.h>
43 #include <dhd_proto.h>
46 #include <wl_cfg80211.h>
48 #define EPI_VERSION_STR "4.218.248.5"
50 #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
51 #include <linux/wifi_tiwlan.h>
53 struct semaphore wifi_control_sem
;
55 struct dhd_bus
*g_bus
;
57 static struct wifi_platform_data
*wifi_control_data
;
58 static struct resource
*wifi_irqres
;
60 int wifi_get_irq_number(unsigned long *irq_flags_ptr
)
63 *irq_flags_ptr
= wifi_irqres
->flags
& IRQF_TRIGGER_MASK
;
64 return (int)wifi_irqres
->start
;
66 #ifdef CUSTOM_OOB_GPIO_NUM
67 return CUSTOM_OOB_GPIO_NUM
;
73 int wifi_set_carddetect(int on
)
75 printk(KERN_ERR
"%s = %d\n", __func__
, on
);
76 if (wifi_control_data
&& wifi_control_data
->set_carddetect
)
77 wifi_control_data
->set_carddetect(on
);
81 int wifi_set_power(int on
, unsigned long msec
)
83 printk(KERN_ERR
"%s = %d\n", __func__
, on
);
84 if (wifi_control_data
&& wifi_control_data
->set_power
)
85 wifi_control_data
->set_power(on
);
91 int wifi_set_reset(int on
, unsigned long msec
)
93 printk(KERN_ERR
"%s = %d\n", __func__
, on
);
94 if (wifi_control_data
&& wifi_control_data
->set_reset
)
95 wifi_control_data
->set_reset(on
);
101 static int wifi_probe(struct platform_device
*pdev
)
103 struct wifi_platform_data
*wifi_ctrl
=
104 (struct wifi_platform_data
*)(pdev
->dev
.platform_data
);
106 printk(KERN_ERR
"## %s\n", __func__
);
108 platform_get_resource_byname(pdev
, IORESOURCE_IRQ
,
110 wifi_control_data
= wifi_ctrl
;
112 wifi_set_power(1, 0); /* Power On */
113 wifi_set_carddetect(1); /* CardDetect (0->1) */
115 up(&wifi_control_sem
);
119 static int wifi_remove(struct platform_device
*pdev
)
121 struct wifi_platform_data
*wifi_ctrl
=
122 (struct wifi_platform_data
*)(pdev
->dev
.platform_data
);
124 printk(KERN_ERR
"## %s\n", __func__
);
125 wifi_control_data
= wifi_ctrl
;
127 wifi_set_carddetect(0); /* CardDetect (1->0) */
128 wifi_set_power(0, 0); /* Power Off */
130 up(&wifi_control_sem
);
134 static int wifi_suspend(struct platform_device
*pdev
, pm_message_t state
)
136 DHD_TRACE(("##> %s\n", __func__
));
140 static int wifi_resume(struct platform_device
*pdev
)
142 DHD_TRACE(("##> %s\n", __func__
));
146 static struct platform_driver wifi_device
= {
148 .remove
= wifi_remove
,
149 .suspend
= wifi_suspend
,
150 .resume
= wifi_resume
,
152 .name
= "bcm4329_wlan",
156 int wifi_add_dev(void)
158 DHD_TRACE(("## Calling platform_driver_register\n"));
159 return platform_driver_register(&wifi_device
);
162 void wifi_del_dev(void)
164 DHD_TRACE(("## Unregister platform_driver_register\n"));
165 platform_driver_unregister(&wifi_device
);
167 #endif /* defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
169 #if defined(CONFIG_PM_SLEEP)
170 #include <linux/suspend.h>
171 volatile bool dhd_mmc_suspend
= false;
172 DECLARE_WAIT_QUEUE_HEAD(dhd_dpc_wait
);
173 #endif /* defined(CONFIG_PM_SLEEP) */
175 #if defined(OOB_INTR_ONLY)
176 extern void dhd_enable_oob_intr(struct dhd_bus
*bus
, bool enable
);
177 #endif /* defined(OOB_INTR_ONLY) */
179 MODULE_AUTHOR("Broadcom Corporation");
180 MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver.");
181 MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards");
182 MODULE_LICENSE("Dual BSD/GPL");
184 #define DRV_MODULE_NAME "brcmfmac"
186 /* Linux wireless extension support */
187 #if defined(CONFIG_WIRELESS_EXT)
189 extern wl_iw_extra_params_t g_wl_iw_params
;
190 #endif /* defined(CONFIG_WIRELESS_EXT) */
192 #if defined(CONFIG_HAS_EARLYSUSPEND)
193 #include <linux/earlysuspend.h>
194 extern int dhdcdc_set_ioctl(dhd_pub_t
*dhd
, int ifidx
, uint cmd
, void *buf
,
196 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
198 #ifdef PKT_FILTER_SUPPORT
199 extern void dhd_pktfilter_offload_set(dhd_pub_t
*dhd
, char *arg
);
200 extern void dhd_pktfilter_offload_enable(dhd_pub_t
*dhd
, char *arg
, int enable
,
204 /* Interface control information */
205 typedef struct dhd_if
{
206 struct dhd_info
*info
; /* back pointer to dhd_info */
207 /* OS/stack specifics */
208 struct net_device
*net
;
209 struct net_device_stats stats
;
210 int idx
; /* iface idx in dongle */
211 int state
; /* interface state */
212 uint subunit
; /* subunit */
213 u8 mac_addr
[ETHER_ADDR_LEN
]; /* assigned MAC address */
214 bool attached
; /* Delayed attachment when unset */
215 bool txflowcontrol
; /* Per interface flow control indicator */
216 char name
[IFNAMSIZ
]; /* linux interface name */
219 /* Local private structure (extension of pub) */
220 typedef struct dhd_info
{
221 #if defined(CONFIG_WIRELESS_EXT)
222 wl_iw_t iw
; /* wireless extensions state (must be first) */
223 #endif /* defined(CONFIG_WIRELESS_EXT) */
227 /* OS/stack specifics */
228 dhd_if_t
*iflist
[DHD_MAX_IFS
];
230 struct semaphore proto_sem
;
231 wait_queue_head_t ioctl_resp_wait
;
232 struct timer_list timer
;
234 struct tasklet_struct tasklet
;
237 /* Thread based operation */
239 struct semaphore sdsem
;
240 struct task_struct
*watchdog_tsk
;
241 struct semaphore watchdog_sem
;
242 struct task_struct
*dpc_tsk
;
243 struct semaphore dpc_sem
;
245 /* Thread to issue ioctl for multicast */
246 struct task_struct
*sysioc_tsk
;
247 struct semaphore sysioc_sem
;
250 struct ether_addr macvalue
;
251 wait_queue_head_t ctrl_wait
;
252 atomic_t pend_8021x_cnt
;
254 #ifdef CONFIG_HAS_EARLYSUSPEND
255 struct early_suspend early_suspend
;
256 #endif /* CONFIG_HAS_EARLYSUSPEND */
259 /* Definitions to provide path to the firmware and nvram
260 * example nvram_path[MOD_PARAM_PATHLEN]="/projects/wlan/nvram.txt"
262 char firmware_path
[MOD_PARAM_PATHLEN
];
263 char nvram_path
[MOD_PARAM_PATHLEN
];
265 /* load firmware and/or nvram values from the filesystem */
266 module_param_string(firmware_path
, firmware_path
, MOD_PARAM_PATHLEN
, 0);
267 module_param_string(nvram_path
, nvram_path
, MOD_PARAM_PATHLEN
, 0);
270 module_param(dhd_msg_level
, int, 0);
272 /* Spawn a thread for system ioctls (set mac, set mcast) */
273 uint dhd_sysioc
= true;
274 module_param(dhd_sysioc
, uint
, 0);
276 /* Watchdog interval */
277 uint dhd_watchdog_ms
= 10;
278 module_param(dhd_watchdog_ms
, uint
, 0);
281 /* Console poll interval */
283 module_param(dhd_console_ms
, uint
, 0);
284 #endif /* DHD_DEBUG */
286 /* ARP offload agent mode : Enable ARP Host Auto-Reply
287 and ARP Peer Auto-Reply */
288 uint dhd_arp_mode
= 0xb;
289 module_param(dhd_arp_mode
, uint
, 0);
291 /* ARP offload enable */
292 uint dhd_arp_enable
= true;
293 module_param(dhd_arp_enable
, uint
, 0);
295 /* Global Pkt filter enable control */
296 uint dhd_pkt_filter_enable
= true;
297 module_param(dhd_pkt_filter_enable
, uint
, 0);
299 /* Pkt filter init setup */
300 uint dhd_pkt_filter_init
;
301 module_param(dhd_pkt_filter_init
, uint
, 0);
303 /* Pkt filter mode control */
304 uint dhd_master_mode
= true;
305 module_param(dhd_master_mode
, uint
, 1);
307 /* Watchdog thread priority, -1 to use kernel timer */
308 int dhd_watchdog_prio
= 97;
309 module_param(dhd_watchdog_prio
, int, 0);
311 /* DPC thread priority, -1 to use tasklet */
312 int dhd_dpc_prio
= 98;
313 module_param(dhd_dpc_prio
, int, 0);
315 /* DPC thread priority, -1 to use tasklet */
316 extern int dhd_dongle_memsize
;
317 module_param(dhd_dongle_memsize
, int, 0);
319 /* Contorl fw roaming */
326 /* Control radio state */
327 uint dhd_radio_up
= 1;
329 /* Network inteface name */
330 char iface_name
[IFNAMSIZ
];
331 module_param_string(iface_name
, iface_name
, IFNAMSIZ
, 0);
333 /* The following are specific to the SDIO dongle */
335 /* IOCTL response timeout */
336 int dhd_ioctl_timeout_msec
= IOCTL_RESP_TIMEOUT
;
338 /* Idle timeout for backplane clock */
339 int dhd_idletime
= DHD_IDLETIME_TICKS
;
340 module_param(dhd_idletime
, int, 0);
343 uint dhd_poll
= false;
344 module_param(dhd_poll
, uint
, 0);
347 uint dhd_cfg80211
= true;
348 module_param(dhd_cfg80211
, uint
, 0);
351 uint dhd_intr
= true;
352 module_param(dhd_intr
, uint
, 0);
354 /* SDIO Drive Strength (in milliamps) */
355 uint dhd_sdiod_drive_strength
= 6;
356 module_param(dhd_sdiod_drive_strength
, uint
, 0);
359 extern uint dhd_txbound
;
360 extern uint dhd_rxbound
;
361 module_param(dhd_txbound
, uint
, 0);
362 module_param(dhd_rxbound
, uint
, 0);
364 /* Deferred transmits */
365 extern uint dhd_deferred_tx
;
366 module_param(dhd_deferred_tx
, uint
, 0);
369 /* Echo packet generator (pkts/s) */
371 module_param(dhd_pktgen
, uint
, 0);
373 /* Echo packet len (0 => sawtooth, max 2040) */
375 module_param(dhd_pktgen_len
, uint
, 0);
378 #define FAVORITE_WIFI_CP (!!dhd_cfg80211)
379 #define IS_CFG80211_FAVORITE() FAVORITE_WIFI_CP
380 #define DBG_CFG80211_GET() ((dhd_cfg80211 & WL_DBG_MASK) >> 1)
381 #define NO_FW_REQ() (dhd_cfg80211 & 0x80)
383 /* Version string to report */
385 #define DHD_COMPILED "\nCompiled in " SRCBASE
390 static char dhd_version
[] = "Dongle Host Driver, version " EPI_VERSION_STR
392 "\nCompiled in " " on " __DATE__
" at " __TIME__
396 #if defined(CONFIG_WIRELESS_EXT)
397 struct iw_statistics
*dhd_get_wireless_stats(struct net_device
*dev
);
398 #endif /* defined(CONFIG_WIRELESS_EXT) */
400 static void dhd_dpc(unsigned long data
);
402 extern int dhd_wait_pend8021x(struct net_device
*dev
);
406 #error TOE requires BDC
408 static int dhd_toe_get(dhd_info_t
*dhd
, int idx
, u32
*toe_ol
);
409 static int dhd_toe_set(dhd_info_t
*dhd
, int idx
, u32 toe_ol
);
412 static int dhd_wl_host_event(dhd_info_t
*dhd
, int *ifidx
, void *pktdata
,
413 wl_event_msg_t
*event_ptr
, void **data_ptr
);
415 #if defined(CONFIG_PM_SLEEP)
416 static int dhd_sleep_pm_callback(struct notifier_block
*nfb
,
417 unsigned long action
, void *ignored
)
420 case PM_HIBERNATION_PREPARE
:
421 case PM_SUSPEND_PREPARE
:
422 dhd_mmc_suspend
= true;
424 case PM_POST_HIBERNATION
:
425 case PM_POST_SUSPEND
:
426 dhd_mmc_suspend
= false;
432 static struct notifier_block dhd_sleep_pm_notifier
= {
433 .notifier_call
= dhd_sleep_pm_callback
,
437 extern int register_pm_notifier(struct notifier_block
*nb
);
438 extern int unregister_pm_notifier(struct notifier_block
*nb
);
439 #endif /* defined(CONFIG_PM_SLEEP) */
440 /* && defined(DHD_GPL) */
441 static void dhd_set_packet_filter(int value
, dhd_pub_t
*dhd
)
443 #ifdef PKT_FILTER_SUPPORT
444 DHD_TRACE(("%s: %d\n", __func__
, value
));
445 /* 1 - Enable packet filter, only allow unicast packet to send up */
446 /* 0 - Disable packet filter */
447 if (dhd_pkt_filter_enable
) {
450 for (i
= 0; i
< dhd
->pktfilter_count
; i
++) {
451 dhd_pktfilter_offload_set(dhd
, dhd
->pktfilter
[i
]);
452 dhd_pktfilter_offload_enable(dhd
, dhd
->pktfilter
[i
],
453 value
, dhd_master_mode
);
459 #if defined(CONFIG_HAS_EARLYSUSPEND)
460 static int dhd_set_suspend(int value
, dhd_pub_t
*dhd
)
462 int power_mode
= PM_MAX
;
463 /* wl_pkt_filter_enable_t enable_parm; */
468 #endif /* CUSTOMER_HW2 */
470 DHD_TRACE(("%s: enter, value = %d in_suspend=%d\n",
471 __func__
, value
, dhd
->in_suspend
));
473 if (dhd
&& dhd
->up
) {
474 if (value
&& dhd
->in_suspend
) {
476 /* Kernel suspended */
477 DHD_TRACE(("%s: force extra Suspend setting\n",
480 dhdcdc_set_ioctl(dhd
, 0, WLC_SET_PM
,
484 /* Enable packet filter, only allow unicast
486 dhd_set_packet_filter(1, dhd
);
488 /* if dtim skip setup as default force it
489 * to wake each thrid dtim
490 * for better power saving.
491 * Note that side effect is chance to miss BC/MC
494 if ((dhd
->dtim_skip
== 0) || (dhd
->dtim_skip
== 1))
497 bcn_li_dtim
= dhd
->dtim_skip
;
498 bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim
,
499 4, iovbuf
, sizeof(iovbuf
));
500 dhdcdc_set_ioctl(dhd
, 0, WLC_SET_VAR
, iovbuf
,
503 /* Disable build-in roaming to allowed \
504 * supplicant to take of romaing
506 bcm_mkiovar("roam_off", (char *)&roamvar
, 4,
507 iovbuf
, sizeof(iovbuf
));
508 dhdcdc_set_ioctl(dhd
, 0, WLC_SET_VAR
, iovbuf
,
510 #endif /* CUSTOMER_HW2 */
514 DHD_TRACE(("%s: Remove extra suspend setting\n",
517 power_mode
= PM_FAST
;
518 dhdcdc_set_ioctl(dhd
, 0, WLC_SET_PM
,
522 /* disable pkt filter */
523 dhd_set_packet_filter(0, dhd
);
525 /* restore pre-suspend setting for dtim_skip */
526 bcm_mkiovar("bcn_li_dtim", (char *)&dhd
->dtim_skip
,
527 4, iovbuf
, sizeof(iovbuf
));
529 dhdcdc_set_ioctl(dhd
, 0, WLC_SET_VAR
, iovbuf
,
533 bcm_mkiovar("roam_off", (char *)&roamvar
, 4, iovbuf
,
535 dhdcdc_set_ioctl(dhd
, 0, WLC_SET_VAR
, iovbuf
,
537 #endif /* CUSTOMER_HW2 */
544 static void dhd_suspend_resume_helper(struct dhd_info
*dhd
, int val
)
546 dhd_pub_t
*dhdp
= &dhd
->pub
;
548 dhd_os_proto_block(dhdp
);
549 /* Set flag when early suspend was called */
550 dhdp
->in_suspend
= val
;
551 if (!dhdp
->suspend_disable_flag
)
552 dhd_set_suspend(val
, dhdp
);
553 dhd_os_proto_unblock(dhdp
);
556 static void dhd_early_suspend(struct early_suspend
*h
)
558 struct dhd_info
*dhd
= container_of(h
, struct dhd_info
, early_suspend
);
560 DHD_TRACE(("%s: enter\n", __func__
));
563 dhd_suspend_resume_helper(dhd
, 1);
567 static void dhd_late_resume(struct early_suspend
*h
)
569 struct dhd_info
*dhd
= container_of(h
, struct dhd_info
, early_suspend
);
571 DHD_TRACE(("%s: enter\n", __func__
));
574 dhd_suspend_resume_helper(dhd
, 0);
576 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
579 * Generalized timeout mechanism. Uses spin sleep with exponential
581 * the sleep time reaches one jiffy, then switches over to task delay. Usage:
583 * dhd_timeout_start(&tmo, usec);
584 * while (!dhd_timeout_expired(&tmo))
585 * if (poll_something())
587 * if (dhd_timeout_expired(&tmo))
591 void dhd_timeout_start(dhd_timeout_t
*tmo
, uint usec
)
596 tmo
->tick
= 1000000 / HZ
;
599 int dhd_timeout_expired(dhd_timeout_t
*tmo
)
601 /* Does nothing the first call */
602 if (tmo
->increment
== 0) {
607 if (tmo
->elapsed
>= tmo
->limit
)
610 /* Add the delay that's about to take place */
611 tmo
->elapsed
+= tmo
->increment
;
613 if (tmo
->increment
< tmo
->tick
) {
614 udelay(tmo
->increment
);
616 if (tmo
->increment
> tmo
->tick
)
617 tmo
->increment
= tmo
->tick
;
619 wait_queue_head_t delay_wait
;
620 DECLARE_WAITQUEUE(wait
, current
);
622 init_waitqueue_head(&delay_wait
);
623 add_wait_queue(&delay_wait
, &wait
);
624 set_current_state(TASK_INTERRUPTIBLE
);
626 pending
= signal_pending(current
);
627 remove_wait_queue(&delay_wait
, &wait
);
628 set_current_state(TASK_RUNNING
);
630 return 1; /* Interrupted */
636 static int dhd_net2idx(dhd_info_t
*dhd
, struct net_device
*net
)
641 while (i
< DHD_MAX_IFS
) {
642 if (dhd
->iflist
[i
] && (dhd
->iflist
[i
]->net
== net
))
650 int dhd_ifname2idx(dhd_info_t
*dhd
, char *name
)
656 if (name
== NULL
|| *name
== '\0')
661 && !strncmp(dhd
->iflist
[i
]->name
, name
, IFNAMSIZ
))
664 DHD_TRACE(("%s: return idx %d for \"%s\"\n", __func__
, i
, name
));
666 return i
; /* default - the primary interface */
669 char *dhd_ifname(dhd_pub_t
*dhdp
, int ifidx
)
671 dhd_info_t
*dhd
= (dhd_info_t
*) dhdp
->info
;
675 if (ifidx
< 0 || ifidx
>= DHD_MAX_IFS
) {
676 DHD_ERROR(("%s: ifidx %d out of range\n", __func__
, ifidx
));
680 if (dhd
->iflist
[ifidx
] == NULL
) {
681 DHD_ERROR(("%s: null i/f %d\n", __func__
, ifidx
));
685 if (dhd
->iflist
[ifidx
]->net
)
686 return dhd
->iflist
[ifidx
]->net
->name
;
691 static void _dhd_set_multicast_list(dhd_info_t
*dhd
, int ifidx
)
693 struct net_device
*dev
;
694 struct netdev_hw_addr
*ha
;
702 ASSERT(dhd
&& dhd
->iflist
[ifidx
]);
703 dev
= dhd
->iflist
[ifidx
]->net
;
704 cnt
= netdev_mc_count(dev
);
706 /* Determine initial value of allmulti flag */
707 allmulti
= (dev
->flags
& IFF_ALLMULTI
) ? true : false;
709 /* Send down the multicast list first. */
711 buflen
= sizeof("mcast_list") + sizeof(cnt
) + (cnt
* ETHER_ADDR_LEN
);
712 bufp
= buf
= kmalloc(buflen
, GFP_ATOMIC
);
714 DHD_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
715 dhd_ifname(&dhd
->pub
, ifidx
), cnt
));
719 strcpy(bufp
, "mcast_list");
720 bufp
+= strlen("mcast_list") + 1;
723 memcpy(bufp
, &cnt
, sizeof(cnt
));
726 netdev_for_each_mc_addr(ha
, dev
) {
729 memcpy(bufp
, ha
->addr
, ETHER_ADDR_LEN
);
730 bufp
+= ETHER_ADDR_LEN
;
734 memset(&ioc
, 0, sizeof(ioc
));
735 ioc
.cmd
= WLC_SET_VAR
;
740 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
742 DHD_ERROR(("%s: set mcast_list failed, cnt %d\n",
743 dhd_ifname(&dhd
->pub
, ifidx
), cnt
));
744 allmulti
= cnt
? true : allmulti
;
749 /* Now send the allmulti setting. This is based on the setting in the
750 * net_device flags, but might be modified above to be turned on if we
751 * were trying to set some addresses and dongle rejected it...
754 buflen
= sizeof("allmulti") + sizeof(allmulti
);
755 buf
= kmalloc(buflen
, GFP_ATOMIC
);
757 DHD_ERROR(("%s: out of memory for allmulti\n",
758 dhd_ifname(&dhd
->pub
, ifidx
)));
761 allmulti
= htol32(allmulti
);
764 ("allmulti", (void *)&allmulti
, sizeof(allmulti
), buf
, buflen
)) {
765 DHD_ERROR(("%s: mkiovar failed for allmulti, datalen %d "
766 "buflen %u\n", dhd_ifname(&dhd
->pub
, ifidx
),
767 (int)sizeof(allmulti
), buflen
));
772 memset(&ioc
, 0, sizeof(ioc
));
773 ioc
.cmd
= WLC_SET_VAR
;
778 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
780 DHD_ERROR(("%s: set allmulti %d failed\n",
781 dhd_ifname(&dhd
->pub
, ifidx
), ltoh32(allmulti
)));
786 /* Finally, pick up the PROMISC flag as well, like the NIC
789 allmulti
= (dev
->flags
& IFF_PROMISC
) ? true : false;
790 allmulti
= htol32(allmulti
);
792 memset(&ioc
, 0, sizeof(ioc
));
793 ioc
.cmd
= WLC_SET_PROMISC
;
795 ioc
.len
= sizeof(allmulti
);
798 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
800 DHD_ERROR(("%s: set promisc %d failed\n",
801 dhd_ifname(&dhd
->pub
, ifidx
), ltoh32(allmulti
)));
806 _dhd_set_mac_address(dhd_info_t
*dhd
, int ifidx
, struct ether_addr
*addr
)
812 DHD_TRACE(("%s enter\n", __func__
));
814 ("cur_etheraddr", (char *)addr
, ETHER_ADDR_LEN
, buf
, 32)) {
815 DHD_ERROR(("%s: mkiovar failed for cur_etheraddr\n",
816 dhd_ifname(&dhd
->pub
, ifidx
)));
819 memset(&ioc
, 0, sizeof(ioc
));
820 ioc
.cmd
= WLC_SET_VAR
;
825 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
827 DHD_ERROR(("%s: set cur_etheraddr failed\n",
828 dhd_ifname(&dhd
->pub
, ifidx
)));
830 memcpy(dhd
->iflist
[ifidx
]->net
->dev_addr
, addr
, ETHER_ADDR_LEN
);
837 extern struct net_device
*ap_net_dev
;
840 static void dhd_op_if(dhd_if_t
*ifp
)
843 int ret
= 0, err
= 0;
845 ASSERT(ifp
&& ifp
->info
&& ifp
->idx
); /* Virtual interfaces only */
849 DHD_TRACE(("%s: idx %d, state %d\n", __func__
, ifp
->idx
, ifp
->state
));
851 switch (ifp
->state
) {
854 * Delete the existing interface before overwriting it
855 * in case we missed the WLC_E_IF_DEL event.
857 if (ifp
->net
!= NULL
) {
858 DHD_ERROR(("%s: ERROR: netdev:%s already exists, "
859 "try free & unregister\n",
860 __func__
, ifp
->net
->name
));
861 netif_stop_queue(ifp
->net
);
862 unregister_netdev(ifp
->net
);
863 free_netdev(ifp
->net
);
865 /* Allocate etherdev, including space for private structure */
866 ifp
->net
= alloc_etherdev(sizeof(dhd
));
868 DHD_ERROR(("%s: OOM - alloc_etherdev\n", __func__
));
872 strcpy(ifp
->net
->name
, ifp
->name
);
873 memcpy(netdev_priv(ifp
->net
), &dhd
, sizeof(dhd
));
874 err
= dhd_net_attach(&dhd
->pub
, ifp
->idx
);
876 DHD_ERROR(("%s: dhd_net_attach failed, "
882 /* semaphore that the soft AP CODE
884 extern struct semaphore ap_eth_sema
;
886 /* save ptr to wl0.1 netdev for use
888 ap_net_dev
= ifp
->net
;
889 /* signal to the SOFTAP 'sleeper' thread,
893 DHD_TRACE(("\n ==== pid:%x, net_device for "
894 "if:%s created ===\n\n",
895 current
->pid
, ifp
->net
->name
));
901 if (ifp
->net
!= NULL
) {
902 DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n",
904 netif_stop_queue(ifp
->net
);
905 unregister_netdev(ifp
->net
);
906 ret
= DHD_DEL_IF
; /* Make sure the free_netdev()
911 DHD_ERROR(("%s: bad op %d\n", __func__
, ifp
->state
));
918 free_netdev(ifp
->net
);
920 dhd
->iflist
[ifp
->idx
] = NULL
;
923 if (ifp
->net
== ap_net_dev
)
924 ap_net_dev
= NULL
; /* NULL SOFTAP global
930 static int _dhd_sysioc_thread(void *data
)
932 dhd_info_t
*dhd
= (dhd_info_t
*) data
;
938 allow_signal(SIGTERM
);
940 while (down_interruptible(&dhd
->sysioc_sem
) == 0) {
941 if (kthread_should_stop())
943 for (i
= 0; i
< DHD_MAX_IFS
; i
++) {
944 if (dhd
->iflist
[i
]) {
946 in_ap
= (ap_net_dev
!= NULL
);
948 if (dhd
->iflist
[i
]->state
)
949 dhd_op_if(dhd
->iflist
[i
]);
951 if (dhd
->iflist
[i
] == NULL
) {
952 DHD_TRACE(("\n\n %s: interface %d "
953 "removed!\n", __func__
, i
));
957 if (in_ap
&& dhd
->set_macaddress
) {
958 DHD_TRACE(("attempt to set MAC for %s "
959 "in AP Mode," "blocked. \n",
960 dhd
->iflist
[i
]->net
->name
));
961 dhd
->set_macaddress
= false;
965 if (in_ap
&& dhd
->set_multicast
) {
966 DHD_TRACE(("attempt to set MULTICAST list for %s" "in AP Mode, blocked. \n",
967 dhd
->iflist
[i
]->net
->name
));
968 dhd
->set_multicast
= false;
972 if (dhd
->set_multicast
) {
973 dhd
->set_multicast
= false;
974 _dhd_set_multicast_list(dhd
, i
);
976 if (dhd
->set_macaddress
) {
977 dhd
->set_macaddress
= false;
978 _dhd_set_mac_address(dhd
, i
,
987 static int dhd_set_mac_address(struct net_device
*dev
, void *addr
)
991 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(dev
);
992 struct sockaddr
*sa
= (struct sockaddr
*)addr
;
995 ifidx
= dhd_net2idx(dhd
, dev
);
996 if (ifidx
== DHD_BAD_IF
)
999 ASSERT(dhd
->sysioc_tsk
);
1000 memcpy(&dhd
->macvalue
, sa
->sa_data
, ETHER_ADDR_LEN
);
1001 dhd
->set_macaddress
= true;
1002 up(&dhd
->sysioc_sem
);
1007 static void dhd_set_multicast_list(struct net_device
*dev
)
1009 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(dev
);
1012 ifidx
= dhd_net2idx(dhd
, dev
);
1013 if (ifidx
== DHD_BAD_IF
)
1016 ASSERT(dhd
->sysioc_tsk
);
1017 dhd
->set_multicast
= true;
1018 up(&dhd
->sysioc_sem
);
1021 int dhd_sendpkt(dhd_pub_t
*dhdp
, int ifidx
, void *pktbuf
)
1024 dhd_info_t
*dhd
= (dhd_info_t
*) (dhdp
->info
);
1026 /* Reject if down */
1027 if (!dhdp
->up
|| (dhdp
->busstate
== DHD_BUS_DOWN
))
1030 /* Update multicast statistic */
1031 if (PKTLEN(pktbuf
) >= ETHER_ADDR_LEN
) {
1032 u8
*pktdata
= (u8
*) PKTDATA(pktbuf
);
1033 struct ether_header
*eh
= (struct ether_header
*)pktdata
;
1035 if (ETHER_ISMULTI(eh
->ether_dhost
))
1036 dhdp
->tx_multicast
++;
1037 if (ntoh16(eh
->ether_type
) == ETHER_TYPE_802_1X
)
1038 atomic_inc(&dhd
->pend_8021x_cnt
);
1041 /* If the protocol uses a data header, apply it */
1042 dhd_prot_hdrpush(dhdp
, ifidx
, pktbuf
);
1044 /* Use bus module to send data frame */
1046 ret
= dbus_send_pkt(dhdp
->dbus
, pktbuf
, NULL
/* pktinfo */);
1048 WAKE_LOCK_TIMEOUT(dhdp
, WAKE_LOCK_TMOUT
, 25);
1049 ret
= dhd_bus_txdata(dhdp
->bus
, pktbuf
);
1050 #endif /* BCMDBUS */
1055 static int dhd_start_xmit(struct sk_buff
*skb
, struct net_device
*net
)
1059 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(net
);
1062 DHD_TRACE(("%s: Enter\n", __func__
));
1064 /* Reject if down */
1065 if (!dhd
->pub
.up
|| (dhd
->pub
.busstate
== DHD_BUS_DOWN
)) {
1066 DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n",
1067 __func__
, dhd
->pub
.up
, dhd
->pub
.busstate
));
1068 netif_stop_queue(net
);
1072 ifidx
= dhd_net2idx(dhd
, net
);
1073 if (ifidx
== DHD_BAD_IF
) {
1074 DHD_ERROR(("%s: bad ifidx %d\n", __func__
, ifidx
));
1075 netif_stop_queue(net
);
1079 /* Make sure there's enough room for any header */
1080 if (skb_headroom(skb
) < dhd
->pub
.hdrlen
) {
1081 struct sk_buff
*skb2
;
1083 DHD_INFO(("%s: insufficient headroom\n",
1084 dhd_ifname(&dhd
->pub
, ifidx
)));
1085 dhd
->pub
.tx_realloc
++;
1086 skb2
= skb_realloc_headroom(skb
, dhd
->pub
.hdrlen
);
1090 DHD_ERROR(("%s: skb_realloc_headroom failed\n",
1091 dhd_ifname(&dhd
->pub
, ifidx
)));
1097 /* Convert to packet */
1098 pktbuf
= PKTFRMNATIVE(dhd
->pub
.osh
, skb
);
1100 DHD_ERROR(("%s: PKTFRMNATIVE failed\n",
1101 dhd_ifname(&dhd
->pub
, ifidx
)));
1102 dev_kfree_skb_any(skb
);
1107 ret
= dhd_sendpkt(&dhd
->pub
, ifidx
, pktbuf
);
1111 dhd
->pub
.dstats
.tx_dropped
++;
1113 dhd
->pub
.tx_packets
++;
1115 /* Return ok: we always eat the packet */
1119 void dhd_txflowcontrol(dhd_pub_t
*dhdp
, int ifidx
, bool state
)
1121 struct net_device
*net
;
1122 dhd_info_t
*dhd
= dhdp
->info
;
1124 DHD_TRACE(("%s: Enter\n", __func__
));
1126 dhdp
->txoff
= state
;
1127 ASSERT(dhd
&& dhd
->iflist
[ifidx
]);
1128 net
= dhd
->iflist
[ifidx
]->net
;
1130 netif_stop_queue(net
);
1132 netif_wake_queue(net
);
1135 void dhd_rx_frame(dhd_pub_t
*dhdp
, int ifidx
, void *pktbuf
, int numpkt
)
1137 dhd_info_t
*dhd
= (dhd_info_t
*) dhdp
->info
;
1138 struct sk_buff
*skb
;
1141 void *data
, *pnext
, *save_pktbuf
;
1144 wl_event_msg_t event
;
1146 DHD_TRACE(("%s: Enter\n", __func__
));
1148 save_pktbuf
= pktbuf
;
1150 for (i
= 0; pktbuf
&& i
< numpkt
; i
++, pktbuf
= pnext
) {
1152 pnext
= PKTNEXT(pktbuf
);
1153 PKTSETNEXT(pktbuf
, NULL
);
1155 skb
= PKTTONATIVE(dhdp
->osh
, pktbuf
);
1157 /* Get the protocol, maintain skb around eth_type_trans()
1158 * The main reason for this hack is for the limitation of
1159 * Linux 2.4 where 'eth_type_trans' uses the
1160 * 'net->hard_header_len'
1161 * to perform skb_pull inside vs ETH_HLEN. Since to avoid
1162 * coping of the packet coming from the network stack to add
1163 * BDC, Hardware header etc, during network interface
1165 * we set the 'net->hard_header_len' to ETH_HLEN + extra space
1167 * for BDC, Hardware header etc. and not just the ETH_HLEN
1172 ifp
= dhd
->iflist
[ifidx
];
1174 ifp
= dhd
->iflist
[0];
1177 skb
->dev
= ifp
->net
;
1178 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
1180 if (skb
->pkt_type
== PACKET_MULTICAST
)
1181 dhd
->pub
.rx_multicast
++;
1186 /* Strip header, count, deliver upward */
1187 skb_pull(skb
, ETH_HLEN
);
1189 /* Process special event packets and then discard them */
1190 if (ntoh16(skb
->protocol
) == ETHER_TYPE_BRCM
)
1191 dhd_wl_host_event(dhd
, &ifidx
,
1192 skb_mac_header(skb
),
1195 ASSERT(ifidx
< DHD_MAX_IFS
&& dhd
->iflist
[ifidx
]);
1196 if (dhd
->iflist
[ifidx
] && !dhd
->iflist
[ifidx
]->state
)
1197 ifp
= dhd
->iflist
[ifidx
];
1200 ifp
->net
->last_rx
= jiffies
;
1202 dhdp
->dstats
.rx_bytes
+= skb
->len
;
1203 dhdp
->rx_packets
++; /* Local count */
1205 if (in_interrupt()) {
1208 /* If the receive is not processed inside an ISR,
1209 * the softirqd must be woken explicitly to service
1210 * the NET_RX_SOFTIRQ. In 2.6 kernels, this is handled
1211 * by netif_rx_ni(), but in earlier kernels, we need
1212 * to do it manually.
1219 void dhd_event(struct dhd_info
*dhd
, char *evpkt
, int evlen
, int ifidx
)
1221 /* Linux version has nothing to do */
1225 void dhd_txcomplete(dhd_pub_t
*dhdp
, void *txp
, bool success
)
1228 dhd_info_t
*dhd
= (dhd_info_t
*) (dhdp
->info
);
1229 struct ether_header
*eh
;
1232 dhd_prot_hdrpull(dhdp
, &ifidx
, txp
);
1234 eh
= (struct ether_header
*)PKTDATA(txp
);
1235 type
= ntoh16(eh
->ether_type
);
1237 if (type
== ETHER_TYPE_802_1X
)
1238 atomic_dec(&dhd
->pend_8021x_cnt
);
1242 static struct net_device_stats
*dhd_get_stats(struct net_device
*net
)
1244 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(net
);
1248 DHD_TRACE(("%s: Enter\n", __func__
));
1250 ifidx
= dhd_net2idx(dhd
, net
);
1251 if (ifidx
== DHD_BAD_IF
)
1254 ifp
= dhd
->iflist
[ifidx
];
1258 /* Use the protocol to get dongle stats */
1259 dhd_prot_dstats(&dhd
->pub
);
1262 /* Copy dongle stats to net device stats */
1263 ifp
->stats
.rx_packets
= dhd
->pub
.dstats
.rx_packets
;
1264 ifp
->stats
.tx_packets
= dhd
->pub
.dstats
.tx_packets
;
1265 ifp
->stats
.rx_bytes
= dhd
->pub
.dstats
.rx_bytes
;
1266 ifp
->stats
.tx_bytes
= dhd
->pub
.dstats
.tx_bytes
;
1267 ifp
->stats
.rx_errors
= dhd
->pub
.dstats
.rx_errors
;
1268 ifp
->stats
.tx_errors
= dhd
->pub
.dstats
.tx_errors
;
1269 ifp
->stats
.rx_dropped
= dhd
->pub
.dstats
.rx_dropped
;
1270 ifp
->stats
.tx_dropped
= dhd
->pub
.dstats
.tx_dropped
;
1271 ifp
->stats
.multicast
= dhd
->pub
.dstats
.multicast
;
1276 static int dhd_watchdog_thread(void *data
)
1278 dhd_info_t
*dhd
= (dhd_info_t
*) data
;
1279 WAKE_LOCK_INIT(&dhd
->pub
, WAKE_LOCK_WATCHDOG
, "dhd_watchdog_thread");
1281 /* This thread doesn't need any user-level access,
1282 * so get rid of all our resources
1285 if (dhd_watchdog_prio
> 0) {
1286 struct sched_param param
;
1287 param
.sched_priority
= (dhd_watchdog_prio
< MAX_RT_PRIO
) ?
1288 dhd_watchdog_prio
: (MAX_RT_PRIO
- 1);
1289 setScheduler(current
, SCHED_FIFO
, ¶m
);
1291 #endif /* DHD_SCHED */
1293 allow_signal(SIGTERM
);
1294 /* Run until signal received */
1296 if (kthread_should_stop())
1298 if (down_interruptible(&dhd
->watchdog_sem
) == 0) {
1299 if (dhd
->pub
.dongle_reset
== false) {
1300 WAKE_LOCK(&dhd
->pub
, WAKE_LOCK_WATCHDOG
);
1301 /* Call the bus module watchdog */
1302 dhd_bus_watchdog(&dhd
->pub
);
1303 WAKE_UNLOCK(&dhd
->pub
, WAKE_LOCK_WATCHDOG
);
1305 /* Count the tick for reference */
1311 WAKE_LOCK_DESTROY(&dhd
->pub
, WAKE_LOCK_WATCHDOG
);
1315 static void dhd_watchdog(unsigned long data
)
1317 dhd_info_t
*dhd
= (dhd_info_t
*) data
;
1319 if (dhd
->watchdog_tsk
) {
1320 up(&dhd
->watchdog_sem
);
1322 /* Reschedule the watchdog */
1323 if (dhd
->wd_timer_valid
) {
1324 mod_timer(&dhd
->timer
,
1325 jiffies
+ dhd_watchdog_ms
* HZ
/ 1000);
1330 /* Call the bus module watchdog */
1331 dhd_bus_watchdog(&dhd
->pub
);
1333 /* Count the tick for reference */
1336 /* Reschedule the watchdog */
1337 if (dhd
->wd_timer_valid
)
1338 mod_timer(&dhd
->timer
, jiffies
+ dhd_watchdog_ms
* HZ
/ 1000);
1341 static int dhd_dpc_thread(void *data
)
1343 dhd_info_t
*dhd
= (dhd_info_t
*) data
;
1345 WAKE_LOCK_INIT(&dhd
->pub
, WAKE_LOCK_DPC
, "dhd_dpc_thread");
1346 /* This thread doesn't need any user-level access,
1347 * so get rid of all our resources
1350 if (dhd_dpc_prio
> 0) {
1351 struct sched_param param
;
1352 param
.sched_priority
=
1354 MAX_RT_PRIO
) ? dhd_dpc_prio
: (MAX_RT_PRIO
- 1);
1355 setScheduler(current
, SCHED_FIFO
, ¶m
);
1357 #endif /* DHD_SCHED */
1359 allow_signal(SIGTERM
);
1360 /* Run until signal received */
1362 if (kthread_should_stop())
1364 if (down_interruptible(&dhd
->dpc_sem
) == 0) {
1365 /* Call bus dpc unless it indicated down
1366 (then clean stop) */
1367 if (dhd
->pub
.busstate
!= DHD_BUS_DOWN
) {
1368 WAKE_LOCK(&dhd
->pub
, WAKE_LOCK_DPC
);
1369 if (dhd_bus_dpc(dhd
->pub
.bus
)) {
1371 WAKE_LOCK_TIMEOUT(&dhd
->pub
,
1372 WAKE_LOCK_TMOUT
, 25);
1374 WAKE_UNLOCK(&dhd
->pub
, WAKE_LOCK_DPC
);
1376 dhd_bus_stop(dhd
->pub
.bus
, true);
1382 WAKE_LOCK_DESTROY(&dhd
->pub
, WAKE_LOCK_DPC
);
1386 static void dhd_dpc(unsigned long data
)
1390 dhd
= (dhd_info_t
*) data
;
1392 /* Call bus dpc unless it indicated down (then clean stop) */
1393 if (dhd
->pub
.busstate
!= DHD_BUS_DOWN
) {
1394 if (dhd_bus_dpc(dhd
->pub
.bus
))
1395 tasklet_schedule(&dhd
->tasklet
);
1397 dhd_bus_stop(dhd
->pub
.bus
, true);
1401 void dhd_sched_dpc(dhd_pub_t
*dhdp
)
1403 dhd_info_t
*dhd
= (dhd_info_t
*) dhdp
->info
;
1410 tasklet_schedule(&dhd
->tasklet
);
1414 /* Retrieve current toe component enables, which are kept
1415 as a bitmap in toe_ol iovar */
1416 static int dhd_toe_get(dhd_info_t
*dhd
, int ifidx
, u32
*toe_ol
)
1422 memset(&ioc
, 0, sizeof(ioc
));
1424 ioc
.cmd
= WLC_GET_VAR
;
1426 ioc
.len
= (uint
) sizeof(buf
);
1429 strcpy(buf
, "toe_ol");
1430 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
1432 /* Check for older dongle image that doesn't support toe_ol */
1434 DHD_ERROR(("%s: toe not supported by device\n",
1435 dhd_ifname(&dhd
->pub
, ifidx
)));
1439 DHD_INFO(("%s: could not get toe_ol: ret=%d\n",
1440 dhd_ifname(&dhd
->pub
, ifidx
), ret
));
1444 memcpy(toe_ol
, buf
, sizeof(u32
));
1448 /* Set current toe component enables in toe_ol iovar,
1449 and set toe global enable iovar */
1450 static int dhd_toe_set(dhd_info_t
*dhd
, int ifidx
, u32 toe_ol
)
1456 memset(&ioc
, 0, sizeof(ioc
));
1458 ioc
.cmd
= WLC_SET_VAR
;
1460 ioc
.len
= (uint
) sizeof(buf
);
1463 /* Set toe_ol as requested */
1465 strcpy(buf
, "toe_ol");
1466 memcpy(&buf
[sizeof("toe_ol")], &toe_ol
, sizeof(u32
));
1468 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
1470 DHD_ERROR(("%s: could not set toe_ol: ret=%d\n",
1471 dhd_ifname(&dhd
->pub
, ifidx
), ret
));
1475 /* Enable toe globally only if any components are enabled. */
1477 toe
= (toe_ol
!= 0);
1480 memcpy(&buf
[sizeof("toe")], &toe
, sizeof(u32
));
1482 ret
= dhd_prot_ioctl(&dhd
->pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
1484 DHD_ERROR(("%s: could not set toe: ret=%d\n",
1485 dhd_ifname(&dhd
->pub
, ifidx
), ret
));
1493 static void dhd_ethtool_get_drvinfo(struct net_device
*net
,
1494 struct ethtool_drvinfo
*info
)
1496 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(net
);
1498 sprintf(info
->driver
, DRV_MODULE_NAME
);
1499 sprintf(info
->version
, "%lu", dhd
->pub
.drv_version
);
1500 sprintf(info
->fw_version
, "%s", wl_cfg80211_get_fwname());
1501 sprintf(info
->bus_info
, "%s", dev_name(&wl_cfg80211_get_sdio_func()->dev
));
1504 struct ethtool_ops dhd_ethtool_ops
= {
1505 .get_drvinfo
= dhd_ethtool_get_drvinfo
1508 static int dhd_ethtool(dhd_info_t
*dhd
, void *uaddr
)
1510 struct ethtool_drvinfo info
;
1511 char drvname
[sizeof(info
.driver
)];
1514 struct ethtool_value edata
;
1515 u32 toe_cmpnt
, csum_dir
;
1519 DHD_TRACE(("%s: Enter\n", __func__
));
1521 /* all ethtool calls start with a cmd word */
1522 if (copy_from_user(&cmd
, uaddr
, sizeof(u32
)))
1526 case ETHTOOL_GDRVINFO
:
1527 /* Copy out any request driver name */
1528 if (copy_from_user(&info
, uaddr
, sizeof(info
)))
1530 strncpy(drvname
, info
.driver
, sizeof(info
.driver
));
1531 drvname
[sizeof(info
.driver
) - 1] = '\0';
1533 /* clear struct for return */
1534 memset(&info
, 0, sizeof(info
));
1537 /* if dhd requested, identify ourselves */
1538 if (strcmp(drvname
, "?dhd") == 0) {
1539 sprintf(info
.driver
, "dhd");
1540 strcpy(info
.version
, EPI_VERSION_STR
);
1543 /* otherwise, require dongle to be up */
1544 else if (!dhd
->pub
.up
) {
1545 DHD_ERROR(("%s: dongle is not up\n", __func__
));
1549 /* finally, report dongle driver type */
1550 else if (dhd
->pub
.iswl
)
1551 sprintf(info
.driver
, "wl");
1553 sprintf(info
.driver
, "xx");
1555 sprintf(info
.version
, "%lu", dhd
->pub
.drv_version
);
1556 if (copy_to_user(uaddr
, &info
, sizeof(info
)))
1558 DHD_CTL(("%s: given %*s, returning %s\n", __func__
,
1559 (int)sizeof(drvname
), drvname
, info
.driver
));
1563 /* Get toe offload components from dongle */
1564 case ETHTOOL_GRXCSUM
:
1565 case ETHTOOL_GTXCSUM
:
1566 ret
= dhd_toe_get(dhd
, 0, &toe_cmpnt
);
1571 (cmd
== ETHTOOL_GTXCSUM
) ? TOE_TX_CSUM_OL
: TOE_RX_CSUM_OL
;
1574 edata
.data
= (toe_cmpnt
& csum_dir
) ? 1 : 0;
1576 if (copy_to_user(uaddr
, &edata
, sizeof(edata
)))
1580 /* Set toe offload components in dongle */
1581 case ETHTOOL_SRXCSUM
:
1582 case ETHTOOL_STXCSUM
:
1583 if (copy_from_user(&edata
, uaddr
, sizeof(edata
)))
1586 /* Read the current settings, update and write back */
1587 ret
= dhd_toe_get(dhd
, 0, &toe_cmpnt
);
1592 (cmd
== ETHTOOL_STXCSUM
) ? TOE_TX_CSUM_OL
: TOE_RX_CSUM_OL
;
1594 if (edata
.data
!= 0)
1595 toe_cmpnt
|= csum_dir
;
1597 toe_cmpnt
&= ~csum_dir
;
1599 ret
= dhd_toe_set(dhd
, 0, toe_cmpnt
);
1603 /* If setting TX checksum mode, tell Linux the new mode */
1604 if (cmd
== ETHTOOL_STXCSUM
) {
1606 dhd
->iflist
[0]->net
->features
|=
1609 dhd
->iflist
[0]->net
->features
&=
1623 static s16 linuxbcmerrormap
[] = { 0, /* 0 */
1624 -EINVAL
, /* BCME_ERROR */
1625 -EINVAL
, /* BCME_BADARG */
1626 -EINVAL
, /* BCME_BADOPTION */
1627 -EINVAL
, /* BCME_NOTUP */
1628 -EINVAL
, /* BCME_NOTDOWN */
1629 -EINVAL
, /* BCME_NOTAP */
1630 -EINVAL
, /* BCME_NOTSTA */
1631 -EINVAL
, /* BCME_BADKEYIDX */
1632 -EINVAL
, /* BCME_RADIOOFF */
1633 -EINVAL
, /* BCME_NOTBANDLOCKED */
1634 -EINVAL
, /* BCME_NOCLK */
1635 -EINVAL
, /* BCME_BADRATESET */
1636 -EINVAL
, /* BCME_BADBAND */
1637 -E2BIG
, /* BCME_BUFTOOSHORT */
1638 -E2BIG
, /* BCME_BUFTOOLONG */
1639 -EBUSY
, /* BCME_BUSY */
1640 -EINVAL
, /* BCME_NOTASSOCIATED */
1641 -EINVAL
, /* BCME_BADSSIDLEN */
1642 -EINVAL
, /* BCME_OUTOFRANGECHAN */
1643 -EINVAL
, /* BCME_BADCHAN */
1644 -EFAULT
, /* BCME_BADADDR */
1645 -ENOMEM
, /* BCME_NORESOURCE */
1646 -EOPNOTSUPP
, /* BCME_UNSUPPORTED */
1647 -EMSGSIZE
, /* BCME_BADLENGTH */
1648 -EINVAL
, /* BCME_NOTREADY */
1649 -EPERM
, /* BCME_NOTPERMITTED */
1650 -ENOMEM
, /* BCME_NOMEM */
1651 -EINVAL
, /* BCME_ASSOCIATED */
1652 -ERANGE
, /* BCME_RANGE */
1653 -EINVAL
, /* BCME_NOTFOUND */
1654 -EINVAL
, /* BCME_WME_NOT_ENABLED */
1655 -EINVAL
, /* BCME_TSPEC_NOTFOUND */
1656 -EINVAL
, /* BCME_ACM_NOTSUPPORTED */
1657 -EINVAL
, /* BCME_NOT_WME_ASSOCIATION */
1658 -EIO
, /* BCME_SDIO_ERROR */
1659 -ENODEV
, /* BCME_DONGLE_DOWN */
1660 -EINVAL
, /* BCME_VERSION */
1661 -EIO
, /* BCME_TXFAIL */
1662 -EIO
, /* BCME_RXFAIL */
1663 -EINVAL
, /* BCME_NODEVICE */
1664 -EINVAL
, /* BCME_NMODE_DISABLED */
1665 -ENODATA
, /* BCME_NONRESIDENT */
1668 static int dhd_ioctl_entry(struct net_device
*net
, struct ifreq
*ifr
, int cmd
)
1670 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(net
);
1677 bool is_set_key_cmd
;
1679 ifidx
= dhd_net2idx(dhd
, net
);
1680 DHD_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __func__
, ifidx
, cmd
));
1682 if (ifidx
== DHD_BAD_IF
)
1685 #if defined(CONFIG_WIRELESS_EXT)
1686 /* linux wireless extensions */
1687 if ((cmd
>= SIOCIWFIRST
) && (cmd
<= SIOCIWLAST
)) {
1688 /* may recurse, do NOT lock */
1689 return wl_iw_ioctl(net
, ifr
, cmd
);
1691 #endif /* defined(CONFIG_WIRELESS_EXT) */
1693 if (cmd
== SIOCETHTOOL
)
1694 return dhd_ethtool(dhd
, (void *)ifr
->ifr_data
);
1696 if (cmd
!= SIOCDEVPRIVATE
)
1699 memset(&ioc
, 0, sizeof(ioc
));
1701 /* Copy the ioc control structure part of ioctl request */
1702 if (copy_from_user(&ioc
, ifr
->ifr_data
, sizeof(wl_ioctl_t
))) {
1703 bcmerror
= -BCME_BADADDR
;
1707 /* Copy out any buffer passed */
1709 buflen
= min_t(int, ioc
.len
, DHD_IOCTL_MAXLEN
);
1710 /* optimization for direct ioctl calls from kernel */
1712 if (segment_eq(get_fs(), KERNEL_DS)) {
1717 buf
= kmalloc(buflen
, GFP_ATOMIC
);
1719 bcmerror
= -BCME_NOMEM
;
1722 if (copy_from_user(buf
, ioc
.buf
, buflen
)) {
1723 bcmerror
= -BCME_BADADDR
;
1729 /* To differentiate between wl and dhd read 4 more byes */
1730 if ((copy_from_user(&driver
, (char *)ifr
->ifr_data
+ sizeof(wl_ioctl_t
),
1731 sizeof(uint
)) != 0)) {
1732 bcmerror
= -BCME_BADADDR
;
1736 if (!capable(CAP_NET_ADMIN
)) {
1737 bcmerror
= -BCME_EPERM
;
1741 /* check for local dhd ioctl and handle it */
1742 if (driver
== DHD_IOCTL_MAGIC
) {
1743 bcmerror
= dhd_ioctl((void *)&dhd
->pub
, &ioc
, buf
, buflen
);
1745 dhd
->pub
.bcmerror
= bcmerror
;
1749 /* send to dongle (must be up, and wl) */
1750 if ((dhd
->pub
.busstate
!= DHD_BUS_DATA
)) {
1751 DHD_ERROR(("%s DONGLE_DOWN,__func__\n", __func__
));
1752 bcmerror
= BCME_DONGLE_DOWN
;
1756 if (!dhd
->pub
.iswl
) {
1757 bcmerror
= BCME_DONGLE_DOWN
;
1761 /* Intercept WLC_SET_KEY IOCTL - serialize M4 send and set key IOCTL to
1762 * prevent M4 encryption.
1764 is_set_key_cmd
= ((ioc
.cmd
== WLC_SET_KEY
) ||
1765 ((ioc
.cmd
== WLC_SET_VAR
) &&
1766 !(strncmp("wsec_key", ioc
.buf
, 9))) ||
1767 ((ioc
.cmd
== WLC_SET_VAR
) &&
1768 !(strncmp("bsscfg:wsec_key", ioc
.buf
, 15))));
1770 dhd_wait_pend8021x(net
);
1772 WAKE_LOCK_INIT(&dhd
->pub
, WAKE_LOCK_IOCTL
, "dhd_ioctl_entry");
1773 WAKE_LOCK(&dhd
->pub
, WAKE_LOCK_IOCTL
);
1776 dhd_prot_ioctl(&dhd
->pub
, ifidx
, (wl_ioctl_t
*)&ioc
, buf
, buflen
);
1778 WAKE_UNLOCK(&dhd
->pub
, WAKE_LOCK_IOCTL
);
1779 WAKE_LOCK_DESTROY(&dhd
->pub
, WAKE_LOCK_IOCTL
);
1781 if (!bcmerror
&& buf
&& ioc
.buf
) {
1782 if (copy_to_user(ioc
.buf
, buf
, buflen
))
1791 else if (bcmerror
< BCME_LAST
)
1792 bcmerror
= BCME_ERROR
;
1794 return linuxbcmerrormap
[-bcmerror
];
1797 static int dhd_stop(struct net_device
*net
)
1799 #if !defined(IGNORE_ETH0_DOWN)
1800 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(net
);
1802 DHD_TRACE(("%s: Enter\n", __func__
));
1803 if (IS_CFG80211_FAVORITE()) {
1806 if (dhd
->pub
.up
== 0)
1809 /* Set state and stop OS transmissions */
1811 netif_stop_queue(net
);
1813 DHD_ERROR(("BYPASS %s:due to BRCM compilation : under investigation\n",
1815 #endif /* !defined(IGNORE_ETH0_DOWN) */
1820 static int dhd_open(struct net_device
*net
)
1822 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(net
);
1826 int ifidx
= dhd_net2idx(dhd
, net
);
1829 DHD_TRACE(("%s: ifidx %d\n", __func__
, ifidx
));
1831 if (ifidx
== 0) { /* do it only for primary eth0 */
1833 /* try to bring up bus */
1834 ret
= dhd_bus_start(&dhd
->pub
);
1836 DHD_ERROR(("%s: failed with code %d\n", __func__
, ret
));
1839 atomic_set(&dhd
->pend_8021x_cnt
, 0);
1841 memcpy(net
->dev_addr
, dhd
->pub
.mac
.octet
, ETHER_ADDR_LEN
);
1844 /* Get current TOE mode from dongle */
1845 if (dhd_toe_get(dhd
, ifidx
, &toe_ol
) >= 0
1846 && (toe_ol
& TOE_TX_CSUM_OL
) != 0)
1847 dhd
->iflist
[ifidx
]->net
->features
|= NETIF_F_IP_CSUM
;
1849 dhd
->iflist
[ifidx
]->net
->features
&= ~NETIF_F_IP_CSUM
;
1852 /* Allow transmit calls */
1853 netif_start_queue(net
);
1855 if (IS_CFG80211_FAVORITE()) {
1856 if (unlikely(wl_cfg80211_up())) {
1857 DHD_ERROR(("%s: failed to bring up cfg80211\n",
1866 osl_t
*dhd_osl_attach(void *pdev
, uint bustype
)
1868 return osl_attach(pdev
, bustype
);
1871 void dhd_osl_detach(osl_t
*osh
)
1877 dhd_add_if(dhd_info_t
*dhd
, int ifidx
, void *handle
, char *name
,
1878 u8
*mac_addr
, u32 flags
, u8 bssidx
)
1882 DHD_TRACE(("%s: idx %d, handle->%p\n", __func__
, ifidx
, handle
));
1884 ASSERT(dhd
&& (ifidx
< DHD_MAX_IFS
));
1886 ifp
= dhd
->iflist
[ifidx
];
1887 if (!ifp
&& !(ifp
= kmalloc(sizeof(dhd_if_t
), GFP_ATOMIC
))) {
1888 DHD_ERROR(("%s: OOM - dhd_if_t\n", __func__
));
1892 memset(ifp
, 0, sizeof(dhd_if_t
));
1894 dhd
->iflist
[ifidx
] = ifp
;
1895 strlcpy(ifp
->name
, name
, IFNAMSIZ
);
1896 if (mac_addr
!= NULL
)
1897 memcpy(&ifp
->mac_addr
, mac_addr
, ETHER_ADDR_LEN
);
1899 if (handle
== NULL
) {
1900 ifp
->state
= WLC_E_IF_ADD
;
1902 ASSERT(dhd
->sysioc_tsk
);
1903 up(&dhd
->sysioc_sem
);
1905 ifp
->net
= (struct net_device
*)handle
;
1910 void dhd_del_if(dhd_info_t
*dhd
, int ifidx
)
1914 DHD_TRACE(("%s: idx %d\n", __func__
, ifidx
));
1916 ASSERT(dhd
&& ifidx
&& (ifidx
< DHD_MAX_IFS
));
1917 ifp
= dhd
->iflist
[ifidx
];
1919 DHD_ERROR(("%s: Null interface\n", __func__
));
1923 ifp
->state
= WLC_E_IF_DEL
;
1925 ASSERT(dhd
->sysioc_tsk
);
1926 up(&dhd
->sysioc_sem
);
1929 dhd_pub_t
*dhd_attach(osl_t
*osh
, struct dhd_bus
*bus
, uint bus_hdrlen
)
1931 dhd_info_t
*dhd
= NULL
;
1932 struct net_device
*net
;
1934 DHD_TRACE(("%s: Enter\n", __func__
));
1935 /* updates firmware nvram path if it was provided as module
1937 if ((firmware_path
!= NULL
) && (firmware_path
[0] != '\0'))
1938 strcpy(fw_path
, firmware_path
);
1939 if ((nvram_path
!= NULL
) && (nvram_path
[0] != '\0'))
1940 strcpy(nv_path
, nvram_path
);
1942 /* Allocate etherdev, including space for private structure */
1943 net
= alloc_etherdev(sizeof(dhd
));
1945 DHD_ERROR(("%s: OOM - alloc_etherdev\n", __func__
));
1949 /* Allocate primary dhd_info */
1950 dhd
= kmalloc(sizeof(dhd_info_t
), GFP_ATOMIC
);
1952 DHD_ERROR(("%s: OOM - alloc dhd_info\n", __func__
));
1956 memset(dhd
, 0, sizeof(dhd_info_t
));
1959 * Save the dhd_info into the priv
1961 memcpy(netdev_priv(net
), &dhd
, sizeof(dhd
));
1964 /* Set network interface name if it was provided as module parameter */
1965 if (iface_name
[0]) {
1968 strncpy(net
->name
, iface_name
, IFNAMSIZ
);
1969 net
->name
[IFNAMSIZ
- 1] = 0;
1970 len
= strlen(net
->name
);
1971 ch
= net
->name
[len
- 1];
1972 if ((ch
> '9' || ch
< '0') && (len
< IFNAMSIZ
- 2))
1973 strcat(net
->name
, "%d");
1976 if (dhd_add_if(dhd
, 0, (void *)net
, net
->name
, NULL
, 0, 0) ==
1980 net
->netdev_ops
= NULL
;
1981 sema_init(&dhd
->proto_sem
, 1);
1982 /* Initialize other structure content */
1983 init_waitqueue_head(&dhd
->ioctl_resp_wait
);
1984 init_waitqueue_head(&dhd
->ctrl_wait
);
1986 /* Initialize the spinlocks */
1987 spin_lock_init(&dhd
->sdlock
);
1988 spin_lock_init(&dhd
->txqlock
);
1990 /* Link to info module */
1991 dhd
->pub
.info
= dhd
;
1993 /* Link to bus module */
1995 dhd
->pub
.hdrlen
= bus_hdrlen
;
1997 /* Attach and link in the protocol */
1998 if (dhd_prot_attach(&dhd
->pub
) != 0) {
1999 DHD_ERROR(("dhd_prot_attach failed\n"));
2002 #if defined(CONFIG_WIRELESS_EXT)
2003 /* Attach and link in the iw */
2004 if (wl_iw_attach(net
, (void *)&dhd
->pub
) != 0) {
2005 DHD_ERROR(("wl_iw_attach failed\n"));
2008 #endif /* defined(CONFIG_WIRELESS_EXT) */
2010 /* Attach and link in the cfg80211 */
2011 if (IS_CFG80211_FAVORITE()) {
2012 if (unlikely(wl_cfg80211_attach(net
, &dhd
->pub
))) {
2013 DHD_ERROR(("wl_cfg80211_attach failed\n"));
2017 strcpy(fw_path
, wl_cfg80211_get_fwname());
2018 strcpy(nv_path
, wl_cfg80211_get_nvramname());
2020 wl_cfg80211_dbg_level(DBG_CFG80211_GET());
2023 /* Set up the watchdog timer */
2024 init_timer(&dhd
->timer
);
2025 dhd
->timer
.data
= (unsigned long) dhd
;
2026 dhd
->timer
.function
= dhd_watchdog
;
2028 /* Initialize thread based operation and lock */
2029 sema_init(&dhd
->sdsem
, 1);
2030 if ((dhd_watchdog_prio
>= 0) && (dhd_dpc_prio
>= 0))
2031 dhd
->threads_only
= true;
2033 dhd
->threads_only
= false;
2035 if (dhd_dpc_prio
>= 0) {
2036 /* Initialize watchdog thread */
2037 sema_init(&dhd
->watchdog_sem
, 0);
2038 dhd
->watchdog_tsk
= kthread_run(dhd_watchdog_thread
, dhd
,
2040 if (IS_ERR(dhd
->watchdog_tsk
)) {
2042 "dhd_watchdog thread failed to start\n");
2043 dhd
->watchdog_tsk
= NULL
;
2046 dhd
->watchdog_tsk
= NULL
;
2049 /* Set up the bottom half handler */
2050 if (dhd_dpc_prio
>= 0) {
2051 /* Initialize DPC thread */
2052 sema_init(&dhd
->dpc_sem
, 0);
2053 dhd
->dpc_tsk
= kthread_run(dhd_dpc_thread
, dhd
, "dhd_dpc");
2054 if (IS_ERR(dhd
->dpc_tsk
)) {
2056 "dhd_dpc thread failed to start\n");
2057 dhd
->dpc_tsk
= NULL
;
2060 tasklet_init(&dhd
->tasklet
, dhd_dpc
, (unsigned long) dhd
);
2061 dhd
->dpc_tsk
= NULL
;
2065 sema_init(&dhd
->sysioc_sem
, 0);
2066 dhd
->sysioc_tsk
= kthread_run(_dhd_sysioc_thread
, dhd
,
2068 if (IS_ERR(dhd
->sysioc_tsk
)) {
2070 "_dhd_sysioc thread failed to start\n");
2071 dhd
->sysioc_tsk
= NULL
;
2074 dhd
->sysioc_tsk
= NULL
;
2077 * Save the dhd_info into the priv
2079 memcpy(netdev_priv(net
), &dhd
, sizeof(dhd
));
2081 #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
2084 #if defined(CONFIG_PM_SLEEP)
2085 register_pm_notifier(&dhd_sleep_pm_notifier
);
2086 #endif /* defined(CONFIG_PM_SLEEP) */
2087 /* && defined(DHD_GPL) */
2088 /* Init lock suspend to prevent kernel going to suspend */
2089 WAKE_LOCK_INIT(&dhd
->pub
, WAKE_LOCK_TMOUT
, "dhd_wake_lock");
2090 WAKE_LOCK_INIT(&dhd
->pub
, WAKE_LOCK_LINK_DOWN_TMOUT
,
2091 "dhd_wake_lock_link_dw_event");
2092 WAKE_LOCK_INIT(&dhd
->pub
, WAKE_LOCK_PNO_FIND_TMOUT
,
2093 "dhd_wake_lock_link_pno_find_event");
2094 #ifdef CONFIG_HAS_EARLYSUSPEND
2095 dhd
->early_suspend
.level
= EARLY_SUSPEND_LEVEL_BLANK_SCREEN
+ 20;
2096 dhd
->early_suspend
.suspend
= dhd_early_suspend
;
2097 dhd
->early_suspend
.resume
= dhd_late_resume
;
2098 register_early_suspend(&dhd
->early_suspend
);
2107 dhd_detach(&dhd
->pub
);
2112 int dhd_bus_start(dhd_pub_t
*dhdp
)
2115 dhd_info_t
*dhd
= (dhd_info_t
*) dhdp
->info
;
2116 #ifdef EMBEDDED_PLATFORM
2117 char iovbuf
[WL_EVENTING_MASK_LEN
+ 12]; /* Room for "event_msgs" +
2119 #endif /* EMBEDDED_PLATFORM */
2123 DHD_TRACE(("%s:\n", __func__
));
2125 /* try to download image and nvram to the dongle */
2126 if (dhd
->pub
.busstate
== DHD_BUS_DOWN
) {
2127 WAKE_LOCK_INIT(dhdp
, WAKE_LOCK_DOWNLOAD
, "dhd_bus_start");
2128 WAKE_LOCK(dhdp
, WAKE_LOCK_DOWNLOAD
);
2129 if (!(dhd_bus_download_firmware(dhd
->pub
.bus
, dhd
->pub
.osh
,
2130 fw_path
, nv_path
))) {
2131 DHD_ERROR(("%s: dhdsdio_probe_download failed. "
2132 "firmware = %s nvram = %s\n",
2133 __func__
, fw_path
, nv_path
));
2134 WAKE_UNLOCK(dhdp
, WAKE_LOCK_DOWNLOAD
);
2135 WAKE_LOCK_DESTROY(dhdp
, WAKE_LOCK_DOWNLOAD
);
2139 WAKE_UNLOCK(dhdp
, WAKE_LOCK_DOWNLOAD
);
2140 WAKE_LOCK_DESTROY(dhdp
, WAKE_LOCK_DOWNLOAD
);
2143 /* Start the watchdog timer */
2144 dhd
->pub
.tickcnt
= 0;
2145 dhd_os_wd_timer(&dhd
->pub
, dhd_watchdog_ms
);
2147 /* Bring up the bus */
2148 ret
= dhd_bus_init(&dhd
->pub
, true);
2150 DHD_ERROR(("%s, dhd_bus_init failed %d\n", __func__
, ret
));
2153 #if defined(OOB_INTR_ONLY)
2154 /* Host registration for OOB interrupt */
2155 if (bcmsdh_register_oob_intr(dhdp
)) {
2156 del_timer_sync(&dhd
->timer
);
2157 dhd
->wd_timer_valid
= false;
2158 DHD_ERROR(("%s Host failed to resgister for OOB\n", __func__
));
2162 /* Enable oob at firmware */
2163 dhd_enable_oob_intr(dhd
->pub
.bus
, true);
2164 #endif /* defined(OOB_INTR_ONLY) */
2166 /* If bus is not ready, can't come up */
2167 if (dhd
->pub
.busstate
!= DHD_BUS_DATA
) {
2168 del_timer_sync(&dhd
->timer
);
2169 dhd
->wd_timer_valid
= false;
2170 DHD_ERROR(("%s failed bus is not ready\n", __func__
));
2173 #ifdef EMBEDDED_PLATFORM
2174 bcm_mkiovar("event_msgs", dhdp
->eventmask
, WL_EVENTING_MASK_LEN
, iovbuf
,
2176 dhdcdc_query_ioctl(dhdp
, 0, WLC_GET_VAR
, iovbuf
, sizeof(iovbuf
));
2177 bcopy(iovbuf
, dhdp
->eventmask
, WL_EVENTING_MASK_LEN
);
2179 setbit(dhdp
->eventmask
, WLC_E_SET_SSID
);
2180 setbit(dhdp
->eventmask
, WLC_E_PRUNE
);
2181 setbit(dhdp
->eventmask
, WLC_E_AUTH
);
2182 setbit(dhdp
->eventmask
, WLC_E_REASSOC
);
2183 setbit(dhdp
->eventmask
, WLC_E_REASSOC_IND
);
2184 setbit(dhdp
->eventmask
, WLC_E_DEAUTH_IND
);
2185 setbit(dhdp
->eventmask
, WLC_E_DISASSOC_IND
);
2186 setbit(dhdp
->eventmask
, WLC_E_DISASSOC
);
2187 setbit(dhdp
->eventmask
, WLC_E_JOIN
);
2188 setbit(dhdp
->eventmask
, WLC_E_ASSOC_IND
);
2189 setbit(dhdp
->eventmask
, WLC_E_PSK_SUP
);
2190 setbit(dhdp
->eventmask
, WLC_E_LINK
);
2191 setbit(dhdp
->eventmask
, WLC_E_NDIS_LINK
);
2192 setbit(dhdp
->eventmask
, WLC_E_MIC_ERROR
);
2193 setbit(dhdp
->eventmask
, WLC_E_PMKID_CACHE
);
2194 setbit(dhdp
->eventmask
, WLC_E_TXFAIL
);
2195 setbit(dhdp
->eventmask
, WLC_E_JOIN_START
);
2196 setbit(dhdp
->eventmask
, WLC_E_SCAN_COMPLETE
);
2198 setbit(dhdp
->eventmask
, WLC_E_PFN_NET_FOUND
);
2199 #endif /* PNO_SUPPORT */
2201 /* enable dongle roaming event */
2203 dhdp
->pktfilter_count
= 1;
2204 /* Setup filter to allow only unicast */
2205 dhdp
->pktfilter
[0] = "100 0 0 0 0x01 0x00";
2206 #endif /* EMBEDDED_PLATFORM */
2208 /* Bus is ready, do any protocol initialization */
2209 ret
= dhd_prot_init(&dhd
->pub
);
2217 dhd_iovar(dhd_pub_t
*pub
, int ifidx
, char *name
, char *cmd_buf
, uint cmd_len
,
2220 char buf
[strlen(name
) + 1 + cmd_len
];
2221 int len
= sizeof(buf
);
2225 len
= bcm_mkiovar(name
, cmd_buf
, cmd_len
, buf
, len
);
2227 memset(&ioc
, 0, sizeof(ioc
));
2229 ioc
.cmd
= set
? WLC_SET_VAR
: WLC_GET_VAR
;
2234 ret
= dhd_prot_ioctl(pub
, ifidx
, &ioc
, ioc
.buf
, ioc
.len
);
2235 if (!set
&& ret
>= 0)
2236 memcpy(cmd_buf
, buf
, cmd_len
);
2241 static struct net_device_ops dhd_ops_pri
= {
2242 .ndo_open
= dhd_open
,
2243 .ndo_stop
= dhd_stop
,
2244 .ndo_get_stats
= dhd_get_stats
,
2245 .ndo_do_ioctl
= dhd_ioctl_entry
,
2246 .ndo_start_xmit
= dhd_start_xmit
,
2247 .ndo_set_mac_address
= dhd_set_mac_address
,
2248 .ndo_set_multicast_list
= dhd_set_multicast_list
2251 static struct net_device_ops dhd_ops_virt
= {
2252 .ndo_get_stats
= dhd_get_stats
,
2253 .ndo_do_ioctl
= dhd_ioctl_entry
,
2254 .ndo_start_xmit
= dhd_start_xmit
,
2255 .ndo_set_mac_address
= dhd_set_mac_address
,
2256 .ndo_set_multicast_list
= dhd_set_multicast_list
2259 int dhd_net_attach(dhd_pub_t
*dhdp
, int ifidx
)
2261 dhd_info_t
*dhd
= (dhd_info_t
*) dhdp
->info
;
2262 struct net_device
*net
;
2263 u8 temp_addr
[ETHER_ADDR_LEN
] = {
2264 0x00, 0x90, 0x4c, 0x11, 0x22, 0x33};
2266 DHD_TRACE(("%s: ifidx %d\n", __func__
, ifidx
));
2268 ASSERT(dhd
&& dhd
->iflist
[ifidx
]);
2270 net
= dhd
->iflist
[ifidx
]->net
;
2273 ASSERT(!net
->netdev_ops
);
2274 net
->netdev_ops
= &dhd_ops_virt
;
2276 net
->netdev_ops
= &dhd_ops_pri
;
2279 * We have to use the primary MAC for virtual interfaces
2282 /* for virtual interfaces use the primary MAC */
2283 memcpy(temp_addr
, dhd
->pub
.mac
.octet
, ETHER_ADDR_LEN
);
2288 DHD_TRACE(("%s ACCESS POINT MAC: \n", __func__
));
2289 /* ACCESSPOINT INTERFACE CASE */
2290 temp_addr
[0] |= 0X02; /* set bit 2 ,
2291 - Locally Administered address */
2294 net
->hard_header_len
= ETH_HLEN
+ dhd
->pub
.hdrlen
;
2295 net
->ethtool_ops
= &dhd_ethtool_ops
;
2297 #if defined(CONFIG_WIRELESS_EXT)
2298 if (!IS_CFG80211_FAVORITE()) {
2299 #if WIRELESS_EXT < 19
2300 net
->get_wireless_stats
= dhd_get_wireless_stats
;
2301 #endif /* WIRELESS_EXT < 19 */
2302 #if WIRELESS_EXT > 12
2303 net
->wireless_handlers
=
2304 (struct iw_handler_def
*)&wl_iw_handler_def
;
2305 #endif /* WIRELESS_EXT > 12 */
2307 #endif /* defined(CONFIG_WIRELESS_EXT) */
2309 dhd
->pub
.rxsz
= net
->mtu
+ net
->hard_header_len
+ dhd
->pub
.hdrlen
;
2311 memcpy(net
->dev_addr
, temp_addr
, ETHER_ADDR_LEN
);
2313 if (register_netdev(net
) != 0) {
2314 DHD_ERROR(("%s: couldn't register the net device\n",
2319 printf("%s: Broadcom Dongle Host Driver\n", net
->name
);
2324 net
->netdev_ops
= NULL
;
2328 void dhd_bus_detach(dhd_pub_t
*dhdp
)
2332 DHD_TRACE(("%s: Enter\n", __func__
));
2335 dhd
= (dhd_info_t
*) dhdp
->info
;
2337 /* Stop the protocol module */
2338 dhd_prot_stop(&dhd
->pub
);
2340 /* Stop the bus module */
2341 dhd_bus_stop(dhd
->pub
.bus
, true);
2342 #if defined(OOB_INTR_ONLY)
2343 bcmsdh_unregister_oob_intr();
2344 #endif /* defined(OOB_INTR_ONLY) */
2346 /* Clear the watchdog timer */
2347 del_timer_sync(&dhd
->timer
);
2348 dhd
->wd_timer_valid
= false;
2353 void dhd_detach(dhd_pub_t
*dhdp
)
2357 DHD_TRACE(("%s: Enter\n", __func__
));
2360 dhd
= (dhd_info_t
*) dhdp
->info
;
2365 #if defined(CONFIG_HAS_EARLYSUSPEND)
2366 if (dhd
->early_suspend
.suspend
)
2367 unregister_early_suspend(&dhd
->early_suspend
);
2368 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
2370 for (i
= 1; i
< DHD_MAX_IFS
; i
++)
2374 ifp
= dhd
->iflist
[0];
2376 if (ifp
->net
->netdev_ops
== &dhd_ops_pri
) {
2378 unregister_netdev(ifp
->net
);
2381 if (dhd
->watchdog_tsk
) {
2382 send_sig(SIGTERM
, dhd
->watchdog_tsk
, 1);
2383 kthread_stop(dhd
->watchdog_tsk
);
2384 dhd
->watchdog_tsk
= NULL
;
2388 send_sig(SIGTERM
, dhd
->dpc_tsk
, 1);
2389 kthread_stop(dhd
->dpc_tsk
);
2390 dhd
->dpc_tsk
= NULL
;
2392 tasklet_kill(&dhd
->tasklet
);
2394 if (dhd
->sysioc_tsk
) {
2395 send_sig(SIGTERM
, dhd
->sysioc_tsk
, 1);
2396 kthread_stop(dhd
->sysioc_tsk
);
2397 dhd
->sysioc_tsk
= NULL
;
2400 dhd_bus_detach(dhdp
);
2403 dhd_prot_detach(dhdp
);
2405 #if defined(CONFIG_WIRELESS_EXT)
2407 #endif /* (CONFIG_WIRELESS_EXT) */
2409 if (IS_CFG80211_FAVORITE())
2410 wl_cfg80211_detach();
2412 #if defined(CONFIG_PM_SLEEP)
2413 unregister_pm_notifier(&dhd_sleep_pm_notifier
);
2414 #endif /* defined(CONFIG_PM_SLEEP) */
2415 /* && defined(DHD_GPL) */
2416 WAKE_LOCK_DESTROY(dhdp
, WAKE_LOCK_TMOUT
);
2417 WAKE_LOCK_DESTROY(dhdp
, WAKE_LOCK_LINK_DOWN_TMOUT
);
2418 WAKE_LOCK_DESTROY(dhdp
, WAKE_LOCK_PNO_FIND_TMOUT
);
2419 free_netdev(ifp
->net
);
2426 static void __exit
dhd_module_cleanup(void)
2428 DHD_TRACE(("%s: Enter\n", __func__
));
2430 dhd_bus_unregister();
2431 #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
2434 /* Call customer gpio to turn off power with WL_REG_ON signal */
2435 dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF
);
2438 static int __init
dhd_module_init(void)
2442 DHD_TRACE(("%s: Enter\n", __func__
));
2444 /* Sanity check on the module parameters */
2446 /* Both watchdog and DPC as tasklets are ok */
2447 if ((dhd_watchdog_prio
< 0) && (dhd_dpc_prio
< 0))
2450 /* If both watchdog and DPC are threads, TX must be deferred */
2451 if ((dhd_watchdog_prio
>= 0) && (dhd_dpc_prio
>= 0)
2455 DHD_ERROR(("Invalid module parameters.\n"));
2458 /* Call customer gpio to turn on power with WL_REG_ON signal */
2459 dhd_customer_gpio_wlan_ctrl(WLAN_POWER_ON
);
2461 #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
2462 sema_init(&wifi_control_sem
, 0);
2464 error
= wifi_add_dev();
2466 DHD_ERROR(("%s: platform_driver_register failed\n", __func__
));
2470 /* Waiting callback after platform_driver_register is done or
2472 if (down_timeout(&wifi_control_sem
, msecs_to_jiffies(1000)) != 0) {
2473 printk(KERN_ERR
"%s: platform_driver_register timeout\n",
2479 #endif /* #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC) */
2481 error
= dhd_bus_register();
2484 printf("\n%s\n", dhd_version
);
2486 DHD_ERROR(("%s: sdio_register_driver failed\n", __func__
));
2492 /* turn off power and exit */
2493 dhd_customer_gpio_wlan_ctrl(WLAN_POWER_OFF
);
2497 module_init(dhd_module_init
);
2498 module_exit(dhd_module_cleanup
);
2501 * OS specific functions required to implement DHD driver in OS independent way
2503 int dhd_os_proto_block(dhd_pub_t
*pub
)
2505 dhd_info_t
*dhd
= (dhd_info_t
*) (pub
->info
);
2508 down(&dhd
->proto_sem
);
2514 int dhd_os_proto_unblock(dhd_pub_t
*pub
)
2516 dhd_info_t
*dhd
= (dhd_info_t
*) (pub
->info
);
2519 up(&dhd
->proto_sem
);
2526 unsigned int dhd_os_get_ioctl_resp_timeout(void)
2528 return (unsigned int)dhd_ioctl_timeout_msec
;
2531 void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec
)
2533 dhd_ioctl_timeout_msec
= (int)timeout_msec
;
2536 int dhd_os_ioctl_resp_wait(dhd_pub_t
*pub
, uint
*condition
, bool *pending
)
2538 dhd_info_t
*dhd
= (dhd_info_t
*) (pub
->info
);
2539 DECLARE_WAITQUEUE(wait
, current
);
2540 int timeout
= dhd_ioctl_timeout_msec
;
2542 /* Convert timeout in millsecond to jiffies */
2543 timeout
= timeout
* HZ
/ 1000;
2545 /* Wait until control frame is available */
2546 add_wait_queue(&dhd
->ioctl_resp_wait
, &wait
);
2547 set_current_state(TASK_INTERRUPTIBLE
);
2549 while (!(*condition
) && (!signal_pending(current
) && timeout
))
2550 timeout
= schedule_timeout(timeout
);
2552 if (signal_pending(current
))
2555 set_current_state(TASK_RUNNING
);
2556 remove_wait_queue(&dhd
->ioctl_resp_wait
, &wait
);
2561 int dhd_os_ioctl_resp_wake(dhd_pub_t
*pub
)
2563 dhd_info_t
*dhd
= (dhd_info_t
*) (pub
->info
);
2565 if (waitqueue_active(&dhd
->ioctl_resp_wait
))
2566 wake_up_interruptible(&dhd
->ioctl_resp_wait
);
2571 void dhd_os_wd_timer(void *bus
, uint wdtick
)
2573 dhd_pub_t
*pub
= bus
;
2574 static uint save_dhd_watchdog_ms
;
2575 dhd_info_t
*dhd
= (dhd_info_t
*) pub
->info
;
2577 /* don't start the wd until fw is loaded */
2578 if (pub
->busstate
== DHD_BUS_DOWN
)
2581 /* Totally stop the timer */
2582 if (!wdtick
&& dhd
->wd_timer_valid
== true) {
2583 del_timer_sync(&dhd
->timer
);
2584 dhd
->wd_timer_valid
= false;
2585 save_dhd_watchdog_ms
= wdtick
;
2590 dhd_watchdog_ms
= (uint
) wdtick
;
2592 if (save_dhd_watchdog_ms
!= dhd_watchdog_ms
) {
2594 if (dhd
->wd_timer_valid
== true)
2595 /* Stop timer and restart at new value */
2596 del_timer_sync(&dhd
->timer
);
2598 /* Create timer again when watchdog period is
2599 dynamically changed or in the first instance
2601 dhd
->timer
.expires
=
2602 jiffies
+ dhd_watchdog_ms
* HZ
/ 1000;
2603 add_timer(&dhd
->timer
);
2606 /* Re arm the timer, at last watchdog period */
2607 mod_timer(&dhd
->timer
,
2608 jiffies
+ dhd_watchdog_ms
* HZ
/ 1000);
2611 dhd
->wd_timer_valid
= true;
2612 save_dhd_watchdog_ms
= wdtick
;
2616 void *dhd_os_open_image(char *filename
)
2620 if (IS_CFG80211_FAVORITE() && !NO_FW_REQ())
2621 return wl_cfg80211_request_fw(filename
);
2623 fp
= filp_open(filename
, O_RDONLY
, 0);
2625 * 2.6.11 (FC4) supports filp_open() but later revs don't?
2627 * fp = open_namei(AT_FDCWD, filename, O_RD, 0);
2636 int dhd_os_get_image_block(char *buf
, int len
, void *image
)
2638 struct file
*fp
= (struct file
*)image
;
2641 if (IS_CFG80211_FAVORITE() && !NO_FW_REQ())
2642 return wl_cfg80211_read_fw(buf
, len
);
2647 rdlen
= kernel_read(fp
, fp
->f_pos
, buf
, len
);
2654 void dhd_os_close_image(void *image
)
2656 if (IS_CFG80211_FAVORITE() && !NO_FW_REQ())
2657 return wl_cfg80211_release_fw();
2659 filp_close((struct file
*)image
, NULL
);
2662 void dhd_os_sdlock(dhd_pub_t
*pub
)
2666 dhd
= (dhd_info_t
*) (pub
->info
);
2668 if (dhd
->threads_only
)
2671 spin_lock_bh(&dhd
->sdlock
);
2674 void dhd_os_sdunlock(dhd_pub_t
*pub
)
2678 dhd
= (dhd_info_t
*) (pub
->info
);
2680 if (dhd
->threads_only
)
2683 spin_unlock_bh(&dhd
->sdlock
);
2686 void dhd_os_sdlock_txq(dhd_pub_t
*pub
)
2690 dhd
= (dhd_info_t
*) (pub
->info
);
2691 spin_lock_bh(&dhd
->txqlock
);
2694 void dhd_os_sdunlock_txq(dhd_pub_t
*pub
)
2698 dhd
= (dhd_info_t
*) (pub
->info
);
2699 spin_unlock_bh(&dhd
->txqlock
);
2702 void dhd_os_sdlock_rxq(dhd_pub_t
*pub
)
2706 void dhd_os_sdunlock_rxq(dhd_pub_t
*pub
)
2710 void dhd_os_sdtxlock(dhd_pub_t
*pub
)
2715 void dhd_os_sdtxunlock(dhd_pub_t
*pub
)
2717 dhd_os_sdunlock(pub
);
2720 #if defined(CONFIG_WIRELESS_EXT)
2721 struct iw_statistics
*dhd_get_wireless_stats(struct net_device
*dev
)
2724 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(dev
);
2726 res
= wl_iw_get_wireless_stats(dev
, &dhd
->iw
.wstats
);
2729 return &dhd
->iw
.wstats
;
2733 #endif /* defined(CONFIG_WIRELESS_EXT) */
2736 dhd_wl_host_event(dhd_info_t
*dhd
, int *ifidx
, void *pktdata
,
2737 wl_event_msg_t
*event
, void **data
)
2741 ASSERT(dhd
!= NULL
);
2743 bcmerror
= wl_host_event(dhd
, ifidx
, pktdata
, event
, data
);
2744 if (bcmerror
!= BCME_OK
)
2747 #if defined(CONFIG_WIRELESS_EXT)
2748 if (!IS_CFG80211_FAVORITE()) {
2749 if ((dhd
->iflist
[*ifidx
] == NULL
)
2750 || (dhd
->iflist
[*ifidx
]->net
== NULL
)) {
2751 DHD_ERROR(("%s Exit null pointer\n", __func__
));
2755 if (dhd
->iflist
[*ifidx
]->net
)
2756 wl_iw_event(dhd
->iflist
[*ifidx
]->net
, event
, *data
);
2758 #endif /* defined(CONFIG_WIRELESS_EXT) */
2760 if (IS_CFG80211_FAVORITE()) {
2761 ASSERT(dhd
->iflist
[*ifidx
] != NULL
);
2762 ASSERT(dhd
->iflist
[*ifidx
]->net
!= NULL
);
2763 if (dhd
->iflist
[*ifidx
]->net
)
2764 wl_cfg80211_event(dhd
->iflist
[*ifidx
]->net
, event
,
2771 /* send up locally generated event */
2772 void dhd_sendup_event(dhd_pub_t
*dhdp
, wl_event_msg_t
*event
, void *data
)
2774 switch (ntoh32(event
->event_type
)) {
2780 void dhd_wait_for_event(dhd_pub_t
*dhd
, bool *lockvar
)
2782 struct dhd_info
*dhdinfo
= dhd
->info
;
2783 dhd_os_sdunlock(dhd
);
2784 wait_event_interruptible_timeout(dhdinfo
->ctrl_wait
,
2785 (*lockvar
== false), HZ
* 2);
2790 void dhd_wait_event_wakeup(dhd_pub_t
*dhd
)
2792 struct dhd_info
*dhdinfo
= dhd
->info
;
2793 if (waitqueue_active(&dhdinfo
->ctrl_wait
))
2794 wake_up_interruptible(&dhdinfo
->ctrl_wait
);
2798 int dhd_dev_reset(struct net_device
*dev
, u8 flag
)
2800 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2802 /* Turning off watchdog */
2804 dhd_os_wd_timer(&dhd
->pub
, 0);
2806 dhd_bus_devreset(&dhd
->pub
, flag
);
2808 /* Turning on watchdog back */
2810 dhd_os_wd_timer(&dhd
->pub
, dhd_watchdog_ms
);
2811 DHD_ERROR(("%s: WLAN OFF DONE\n", __func__
));
2816 int net_os_set_suspend_disable(struct net_device
*dev
, int val
)
2818 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2822 ret
= dhd
->pub
.suspend_disable_flag
;
2823 dhd
->pub
.suspend_disable_flag
= val
;
2828 int net_os_set_suspend(struct net_device
*dev
, int val
)
2831 #if defined(CONFIG_HAS_EARLYSUSPEND)
2832 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2835 dhd_os_proto_block(&dhd
->pub
);
2836 ret
= dhd_set_suspend(val
, &dhd
->pub
);
2837 dhd_os_proto_unblock(&dhd
->pub
);
2839 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) */
2843 int net_os_set_dtim_skip(struct net_device
*dev
, int val
)
2845 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(dev
);
2848 dhd
->pub
.dtim_skip
= val
;
2853 int net_os_set_packet_filter(struct net_device
*dev
, int val
)
2855 dhd_info_t
*dhd
= *(dhd_info_t
**) netdev_priv(dev
);
2858 /* Packet filtering is set only if we still in early-suspend and
2859 * we need either to turn it ON or turn it OFF
2860 * We can always turn it OFF in case of early-suspend, but we turn it
2861 * back ON only if suspend_disable_flag was not set
2863 if (dhd
&& dhd
->pub
.up
) {
2864 dhd_os_proto_block(&dhd
->pub
);
2865 if (dhd
->pub
.in_suspend
) {
2866 if (!val
|| (val
&& !dhd
->pub
.suspend_disable_flag
))
2867 dhd_set_packet_filter(val
, &dhd
->pub
);
2869 dhd_os_proto_unblock(&dhd
->pub
);
2874 void dhd_dev_init_ioctl(struct net_device
*dev
)
2876 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2878 dhd_preinit_ioctls(&dhd
->pub
);
2882 /* Linux wrapper to call common dhd_pno_clean */
2883 int dhd_dev_pno_reset(struct net_device
*dev
)
2885 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2887 return dhd_pno_clean(&dhd
->pub
);
2890 /* Linux wrapper to call common dhd_pno_enable */
2891 int dhd_dev_pno_enable(struct net_device
*dev
, int pfn_enabled
)
2893 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2895 return dhd_pno_enable(&dhd
->pub
, pfn_enabled
);
2898 /* Linux wrapper to call common dhd_pno_set */
2900 dhd_dev_pno_set(struct net_device
*dev
, wlc_ssid_t
*ssids_local
, int nssid
,
2901 unsigned char scan_fr
)
2903 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2905 return dhd_pno_set(&dhd
->pub
, ssids_local
, nssid
, scan_fr
);
2908 /* Linux wrapper to get pno status */
2909 int dhd_dev_get_pno_status(struct net_device
*dev
)
2911 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2913 return dhd_pno_get_status(&dhd
->pub
);
2916 #endif /* PNO_SUPPORT */
2918 static int dhd_get_pend_8021x_cnt(dhd_info_t
*dhd
)
2920 return atomic_read(&dhd
->pend_8021x_cnt
);
2923 #define MAX_WAIT_FOR_8021X_TX 10
2925 int dhd_wait_pend8021x(struct net_device
*dev
)
2927 dhd_info_t
*dhd
= *(dhd_info_t
**)netdev_priv(dev
);
2928 int timeout
= 10 * HZ
/ 1000;
2929 int ntimes
= MAX_WAIT_FOR_8021X_TX
;
2930 int pend
= dhd_get_pend_8021x_cnt(dhd
);
2932 while (ntimes
&& pend
) {
2934 set_current_state(TASK_INTERRUPTIBLE
);
2935 schedule_timeout(timeout
);
2936 set_current_state(TASK_RUNNING
);
2939 pend
= dhd_get_pend_8021x_cnt(dhd
);
2945 int write_to_file(dhd_pub_t
*dhd
, u8
*buf
, int size
)
2949 mm_segment_t old_fs
;
2952 /* change to KERNEL_DS address limit */
2956 /* open file to write */
2957 fp
= filp_open("/tmp/mem_dump", O_WRONLY
| O_CREAT
, 0640);
2959 printf("%s: open file error\n", __func__
);
2964 /* Write buf to file */
2965 fp
->f_op
->write(fp
, buf
, size
, &pos
);
2968 /* free buf before return */
2970 /* close file before return */
2972 filp_close(fp
, current
->files
);
2973 /* restore previous address limit */
2978 #endif /* DHD_DEBUG */