blob: ea8f67ce8b4ee9fe6520139966c45d07b17f4bb6 [file] [log] [blame]
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -07001/*
2 * Header file describing the internal (inter-module) DHD interfaces.
3 *
4 * Provides type definitions and function prototypes used to link the
5 * DHD OS, bus, and protocol modules.
6 *
7 * Copyright (C) 1999-2011, Broadcom Corporation
8 *
9 * Unless you and Broadcom execute a separate written software license
10 * agreement governing use of this software, this software is licensed to you
11 * under the terms of the GNU General Public License version 2 (the "GPL"),
12 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
13 * following added to such license:
14 *
15 * As a special exception, the copyright holders of this software give you
16 * permission to link this software with independent modules, and to copy and
17 * distribute the resulting executable under terms of your choice, provided that
18 * you also meet, for each linked independent module, the terms and conditions of
19 * the license of that module. An independent module is a module which is not
20 * derived from this software. The special exception does not apply to any
21 * modifications of the software.
22 *
23 * Notwithstanding the above, under no circumstances may you combine this
24 * software in any way with any other Broadcom software provided under a license
25 * other than the GPL, without Broadcom's express prior written consent.
26 *
27 * $Id: dhd.h,v 1.60.4.17 2011-01-09 08:11:56 Exp $
28 */
29
30/****************
31 * Common types *
32 */
33
34#ifndef _dhd_h_
35#define _dhd_h_
36
37#if defined(CHROMIUMOS_COMPAT_WIRELESS)
38#include <linux/sched.h>
39#endif
40#include <linux/init.h>
41#include <linux/kernel.h>
42#include <linux/slab.h>
43#include <linux/skbuff.h>
44#include <linux/netdevice.h>
45#include <linux/etherdevice.h>
46#include <linux/random.h>
47#include <linux/spinlock.h>
48#include <linux/ethtool.h>
49#include <asm/uaccess.h>
50#include <asm/unaligned.h>
51#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
52#include <linux/wakelock.h>
53#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
54/* The kernel threading is sdio-specific */
55
56#define ALL_INTERFACES 0xff
57
58#include <wlioctl.h>
59
60
61/* Forward decls */
62struct dhd_bus;
63struct dhd_prot;
64struct dhd_info;
65struct dhd_cmn;
66
67/* The level of bus communication with the dongle */
68enum dhd_bus_state {
69 DHD_BUS_DOWN, /* Not ready for frame transfers */
70 DHD_BUS_LOAD, /* Download access only (CPU reset) */
71 DHD_BUS_DATA /* Ready for frame transfers */
72};
73
74enum dhd_bus_wake_state {
75 WAKE_LOCK_OFF,
76 WAKE_LOCK_PRIV,
77 WAKE_LOCK_DPC,
78 WAKE_LOCK_IOCTL,
79 WAKE_LOCK_DOWNLOAD,
80 WAKE_LOCK_TMOUT,
81 WAKE_LOCK_WATCHDOG,
82 WAKE_LOCK_LINK_DOWN_TMOUT,
83 WAKE_LOCK_PNO_FIND_TMOUT,
84 WAKE_LOCK_SOFTAP_SET,
85 WAKE_LOCK_SOFTAP_STOP,
86 WAKE_LOCK_SOFTAP_START,
87 WAKE_LOCK_SOFTAP_THREAD,
88 WAKE_LOCK_MAX
89};
90enum dhd_prealloc_index {
91 DHD_PREALLOC_PROT = 0,
92 DHD_PREALLOC_RXBUF,
93 DHD_PREALLOC_DATABUF,
94 DHD_PREALLOC_OSL_BUF
95};
Lin Ma3f409b92011-06-27 18:53:59 -070096
97#if defined(DHD_USE_STATIC_BUF)
98
99uint8* dhd_os_prealloc(void *osh, int section, uint size);
100void dhd_os_prefree(void *osh, void *addr, uint size);
101#define DHD_OS_PREALLOC(osh, section, size) dhd_os_prealloc(osh, section, size)
102#define DHD_OS_PREFREE(osh, addr, size) dhd_os_prefree(osh, addr, size)
103
104#else
105
106#define DHD_OS_PREALLOC(osh, section, size) MALLOC(osh, size)
107#define DHD_OS_PREFREE(osh, addr, size) MFREE(osh, addr, size)
108
109#endif /* defined(DHD_USE_STATIC_BUF) */
110
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700111/* Common structure for module and instance linkage */
112typedef struct dhd_pub {
113 /* Linkage ponters */
114 osl_t *osh; /* OSL handle */
115 struct dhd_bus *bus; /* Bus module handle */
116 struct dhd_prot *prot; /* Protocol module handle */
117 struct dhd_info *info; /* Info module handle */
118 struct dhd_cmn *cmn; /* dhd_common module handle */
119
120 /* Internal dhd items */
121 bool up; /* Driver up/down (to OS) */
122 bool txoff; /* Transmit flow-controlled */
123 bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
124 enum dhd_bus_state busstate;
125 uint hdrlen; /* Total DHD header length (proto + bus) */
126 uint maxctl; /* Max size rxctl request from proto to bus */
127 uint rxsz; /* Rx buffer size bus module should use */
128 uint8 wme_dp; /* wme discard priority */
129
130 /* Dongle media info */
131 bool iswl; /* Dongle-resident driver is wl */
132 ulong drv_version; /* Version of dongle-resident driver */
133 struct ether_addr mac; /* MAC address obtained from dongle */
134 dngl_stats_t dstats; /* Stats for dongle-based data */
135
136 /* Additional stats for the bus level */
137 ulong tx_packets; /* Data packets sent to dongle */
138 ulong tx_multicast; /* Multicast data packets sent to dongle */
139 ulong tx_errors; /* Errors in sending data to dongle */
140 ulong tx_ctlpkts; /* Control packets sent to dongle */
141 ulong tx_ctlerrs; /* Errors sending control frames to dongle */
142 ulong rx_packets; /* Packets sent up the network interface */
143 ulong rx_multicast; /* Multicast packets sent up the network interface */
144 ulong rx_errors; /* Errors processing rx data packets */
145 ulong rx_ctlpkts; /* Control frames processed from dongle */
146 ulong rx_ctlerrs; /* Errors in processing rx control frames */
147 ulong rx_dropped; /* Packets dropped locally (no memory) */
148 ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
149 ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
150
151 ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
152 ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
153 ulong fc_packets; /* Number of flow control pkts recvd */
154
155 /* Last error return */
156 int bcmerror;
157 uint tickcnt;
158
159 /* Last error from dongle */
160 int dongle_error;
161
162 /* Suspend disable flag and "in suspend" flag */
163 int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
164 int in_suspend; /* flag set to 1 when early suspend called */
165#ifdef PNO_SUPPORT
166 int pno_enable; /* pno status : "1" is pno enable */
167#endif /* PNO_SUPPORT */
168 int dtim_skip; /* dtim skip , default 0 means wake each dtim */
169
170 /* Pkt filter defination */
171 char * pktfilter[100];
172 int pktfilter_count;
173
174 wl_country_t dhd_cspec; /* Current Locale info */
175 char eventmask[WL_EVENTING_MASK_LEN];
176
177#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
178 struct wake_lock wakelock[WAKE_LOCK_MAX];
179#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
180#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
181 struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
182 struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
183#endif
184
185 uint16 maxdatablks;
186#ifdef PROP_TXSTATUS
187 int wlfc_enabled;
188 void* wlfc_state;
189#endif
190 bool dongle_isolation;
191
192#ifdef WLMEDIA_HTSF
193 uint8 htsfdlystat_sz; /* Size of delay stats, max 255B */
194#endif
195} dhd_pub_t;
196
197typedef struct dhd_cmn {
198 osl_t *osh; /* OSL handle */
199 dhd_pub_t *dhd;
200} dhd_cmn_t;
201
202
203 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
204
205 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
206 #define _DHD_PM_RESUME_WAIT(a, b) do {\
207 int retry = 0; \
208 smp_mb(); \
209 while (dhd_mmc_suspend && retry++ != b) { \
210 wait_event_interruptible_timeout(a, FALSE, HZ/100); \
211 } \
212 } while (0)
Dmitry Shmidtde0932b2011-06-13 16:47:58 -0700213 #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700214 #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
215 #define DHD_PM_RESUME_RETURN_ERROR(a) do { if (dhd_mmc_suspend) return a; } while (0)
216 #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
217
218 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
219 #define SPINWAIT_SLEEP(a, exp, us) do { \
220 uint countdown = (us) + 9999; \
221 while ((exp) && (countdown >= 10000)) { \
222 wait_event_interruptible_timeout(a, FALSE, HZ/100); \
223 countdown -= 10000; \
224 } \
225 } while (0)
226
227 #else
228
229 #define DHD_PM_RESUME_WAIT_INIT(a)
230 #define DHD_PM_RESUME_WAIT(a)
231 #define DHD_PM_RESUME_WAIT_FOREVER(a)
232 #define DHD_PM_RESUME_RETURN_ERROR(a)
233 #define DHD_PM_RESUME_RETURN
234
235 #define DHD_SPINWAIT_SLEEP_INIT(a)
236 #define SPINWAIT_SLEEP(a, exp, us) do { \
237 uint countdown = (us) + 9; \
238 while ((exp) && (countdown >= 10)) { \
239 OSL_DELAY(10); \
240 countdown -= 10; \
241 } \
242 } while (0)
243
244 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
245#ifndef DHDTHREAD
246#undef SPINWAIT_SLEEP
247#define SPINWAIT_SLEEP(a, exp, us) SPINWAIT(exp, us)
248#endif /* DHDTHREAD */
249#define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
250
Greg Goldmanff8f36c2011-06-29 14:34:18 -0700251unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
252void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
253
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700254/* Wakelock Functions */
255extern int dhd_os_wake_lock(dhd_pub_t *pub);
256extern int dhd_os_wake_unlock(dhd_pub_t *pub);
257extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
258extern int dhd_os_wake_lock_timeout_enable(dhd_pub_t *pub);
259
260inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
261{
262#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
263 mutex_init(&dhdp->wl_softap_lock);
264#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
265}
266
267inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
268{
269#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
270 mutex_lock(&dhdp->wl_softap_lock);
271#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
272}
273
274inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
275{
276#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
277 mutex_unlock(&dhdp->wl_softap_lock);
278#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
279}
280
281#define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
282#define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
283#define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
284#define DHD_OS_WAKE_LOCK_TIMEOUT_ENABLE(pub) dhd_os_wake_lock_timeout_enable(pub)
285
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700286
Lin Ma3f409b92011-06-27 18:53:59 -0700287/* interface operations (register, remove) should be atomic, use this lock to prevent race
288 * condition among wifi on/off and interface operation functions
289 */
290void dhd_net_if_lock(struct net_device *dev);
291void dhd_net_if_unlock(struct net_device *dev);
Howard M. Harte0d9f3c22011-06-15 18:52:15 -0700292
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700293typedef struct dhd_if_event {
294 uint8 ifidx;
295 uint8 action;
296 uint8 flags;
297 uint8 bssidx;
298 uint8 is_AP;
299} dhd_if_event_t;
300
301typedef enum dhd_attach_states
302{
303 DHD_ATTACH_STATE_INIT = 0x0,
304 DHD_ATTACH_STATE_NET_ALLOC = 0x1,
305 DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
306 DHD_ATTACH_STATE_ADD_IF = 0x4,
307 DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
308 DHD_ATTACH_STATE_WL_ATTACH = 0x10,
309 DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
310 DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
311 DHD_ATTACH_STATE_CFG80211 = 0x80,
312 DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
313 DHD_ATTACH_STATE_DONE = 0x200
314} dhd_attach_states_t;
315
316/* Value -1 means we are unsuccessful in creating the kthread. */
317#define DHD_PID_KT_INVALID -1
318/* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
319#define DHD_PID_KT_TL_INVALID -2
320
321/*
322 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
323 */
324
325/* To allow osl_attach/detach calls from os-independent modules */
326osl_t *dhd_osl_attach(void *pdev, uint bustype);
327void dhd_osl_detach(osl_t *osh);
328
329/* Indication from bus module regarding presence/insertion of dongle.
330 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
331 * Returned structure should have bus and prot pointers filled in.
332 * bus_hdrlen specifies required headroom for bus module header.
333 */
334extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
335extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
336
337/* Indication from bus module regarding removal/absence of dongle */
338extern void dhd_detach(dhd_pub_t *dhdp);
339extern void dhd_free(dhd_pub_t *dhdp);
340
341/* Indication from bus module to change flow-control state */
342extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
343
344extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
345
346/* Receive frame for delivery to OS. Callee disposes of rxp. */
347extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
348
349/* Return pointer to interface name */
350extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
351
352/* Request scheduling of the bus dpc */
353extern void dhd_sched_dpc(dhd_pub_t *dhdp);
354
355/* Notify tx completion */
356extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
357
358/* OS independent layer functions */
359extern int dhd_os_proto_block(dhd_pub_t * pub);
360extern int dhd_os_proto_unblock(dhd_pub_t * pub);
361extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition, bool * pending);
362extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
363extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
364extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
365extern void * dhd_os_open_image(char * filename);
366extern int dhd_os_get_image_block(char * buf, int len, void * image);
367extern void dhd_os_close_image(void * image);
368extern void dhd_os_wd_timer(void *bus, uint wdtick);
369extern void dhd_os_sdlock(dhd_pub_t * pub);
370extern void dhd_os_sdunlock(dhd_pub_t * pub);
371extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
372extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
373extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
374extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
375extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
376extern void dhd_customer_gpio_wlan_ctrl(int onoff);
Dmitry Shmidt2d7bb942011-07-07 17:04:44 -0700377extern int dhd_custom_get_mac_address(unsigned char *buf);
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700378extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
379extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
380extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
Howard M. Harte0d9f3c22011-06-15 18:52:15 -0700381extern int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled);
382extern int dhd_pno_clean(dhd_pub_t *dhd);
383extern int dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid,
384 ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
385extern int dhd_pno_get_status(dhd_pub_t *dhd);
386extern int dhd_dev_pno_reset(struct net_device *dev);
387extern int dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local,
388 int nssid, ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
389extern int dhd_dev_pno_enable(struct net_device *dev, int pfn_enabled);
390extern int dhd_dev_get_pno_status(struct net_device *dev);
391extern int dhd_get_dtim_skip(dhd_pub_t *dhd);
392
Dmitry Shmidt2d7bb942011-07-07 17:04:44 -0700393#define DHD_UNICAST_FILTER_NUM 0
394#define DHD_BROADCAST_FILTER_NUM 1
395#define DHD_MULTICAST4_FILTER_NUM 2
396#define DHD_MULTICAST6_FILTER_NUM 3
397extern int net_os_set_packet_filter(struct net_device *dev, int val);
398extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
399
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700400#ifdef DHD_DEBUG
401extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
402#endif /* DHD_DEBUG */
403#if defined(OOB_INTR_ONLY)
404extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
405#endif /* defined(OOB_INTR_ONLY) */
406extern void dhd_os_sdtxlock(dhd_pub_t * pub);
407extern void dhd_os_sdtxunlock(dhd_pub_t * pub);
408
409#if defined(DHDTHREAD)
410struct task_struct;
411struct sched_param;
412int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
413#endif /* DHDTHREAD && DHD_GPL */
414
415typedef struct {
416 uint32 limit; /* Expiration time (usec) */
417 uint32 increment; /* Current expiration increment (usec) */
418 uint32 elapsed; /* Current elapsed time (usec) */
419 uint32 tick; /* O/S tick time (usec) */
420} dhd_timeout_t;
421
422extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
423extern int dhd_timeout_expired(dhd_timeout_t *tmo);
424
425extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
426extern struct net_device * dhd_idx2net(struct dhd_pub *dhd_pub, int ifidx);
427extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata,
428 wl_event_msg_t *, void **data_ptr);
429extern void wl_event_to_host_order(wl_event_msg_t * evt);
430
431extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
432extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
433 int ifindex);
434
435extern struct dhd_cmn *dhd_common_init(osl_t *osh);
436extern void dhd_common_deinit(dhd_pub_t *dhd_pub, dhd_cmn_t *sa_cmn);
437
438extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
439 char *name, uint8 *mac_addr, uint32 flags, uint8 bssidx);
440extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
441
442extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
443extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
444
445extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
446extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
447
448
449/* Send packet to dongle via data channel */
450extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
451
452/* send up locally generated event */
453extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
454/* Send event to host */
455extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
456extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
457extern uint dhd_bus_status(dhd_pub_t *dhdp);
458extern int dhd_bus_start(dhd_pub_t *dhdp);
459extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
460extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
461
462
463typedef enum cust_gpio_modes {
464 WLAN_RESET_ON,
465 WLAN_RESET_OFF,
466 WLAN_POWER_ON,
467 WLAN_POWER_OFF
468} cust_gpio_modes_t;
469
470extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
471extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
472/*
473 * Insmod parameters for debug/test
474 */
475
476/* Watchdog timer interval */
477extern uint dhd_watchdog_ms;
478
479#if defined(DHD_DEBUG)
480/* Console output poll interval */
481extern uint dhd_console_ms;
482extern uint wl_msg_level;
483#endif /* defined(DHD_DEBUG) */
484
485/* Use interrupts */
486extern uint dhd_intr;
487
488/* Use polling */
489extern uint dhd_poll;
490
491/* ARP offload agent mode */
492extern uint dhd_arp_mode;
493
494/* ARP offload enable */
495extern uint dhd_arp_enable;
496
497/* Pkt filte enable control */
498extern uint dhd_pkt_filter_enable;
499
500/* Pkt filter init setup */
501extern uint dhd_pkt_filter_init;
502
503/* Pkt filter mode control */
504extern uint dhd_master_mode;
505
506/* Roaming mode control */
507extern uint dhd_roam_disable;
508
509/* Roaming mode control */
510extern uint dhd_radio_up;
511
512/* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
513extern int dhd_idletime;
514#define DHD_IDLETIME_TICKS 1
515
516/* SDIO Drive Strength */
517extern uint dhd_sdiod_drive_strength;
518
519/* Override to force tx queueing all the time */
520extern uint dhd_force_tx_queueing;
Howard M. Hartecf77d4c2011-05-27 16:07:36 -0700521/* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
522#define KEEP_ALIVE_PERIOD 55000
523#define NULL_PKT_STR "null_pkt"
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700524
525#ifdef SDTEST
526/* Echo packet generator (SDIO), pkts/s */
527extern uint dhd_pktgen;
528
529/* Echo packet len (0 => sawtooth, max 1800) */
530extern uint dhd_pktgen_len;
531#define MAX_PKTGEN_LEN 1800
532#endif
533
534
535/* optionally set by a module_param_string() */
536#define MOD_PARAM_PATHLEN 2048
537extern char fw_path[MOD_PARAM_PATHLEN];
538extern char nv_path[MOD_PARAM_PATHLEN];
539
540#ifdef SOFTAP
541extern char fw_path2[MOD_PARAM_PATHLEN];
542#endif
543
Lin Ma3f409b92011-06-27 18:53:59 -0700544/* Flag to indicate if we should download firmware on driver load */
545extern uint dhd_download_fw_on_driverload;
546
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700547/* For supporting multiple interfaces */
548#define DHD_MAX_IFS 16
549#define DHD_DEL_IF -0xe
550#define DHD_BAD_IF -0xf
551
552#ifdef PROP_TXSTATUS
553/* Please be mindful that total pkttag space is 32 octets only */
554typedef struct dhd_pkttag {
555 /*
556 b[11 ] - 1 = this packet was sent in response to one time packet request,
557 do not increment credit on status for this one. [WLFC_CTL_TYPE_MAC_REQUEST_PACKET].
558 b[10 ] - 1 = signal-only-packet to firmware [i.e. nothing to piggyback on]
559 b[9 ] - 1 = packet is host->firmware (transmit direction)
560 - 0 = packet received from firmware (firmware->host)
561 b[8 ] - 1 = packet was sent due to credit_request (pspoll),
562 packet does not count against FIFO credit.
563 - 0 = normal transaction, packet counts against FIFO credit
564 b[7 ] - 1 = AP, 0 = STA
565 b[6:4] - AC FIFO number
566 b[3:0] - interface index
567 */
568 uint16 if_flags;
569 /* destination MAC address for this packet so that not every
570 module needs to open the packet to find this
571 */
572 uint8 dstn_ether[ETHER_ADDR_LEN];
573 /*
574 This 32-bit goes from host to device for every packet.
575 */
576 uint32 htod_tag;
577 /* bus specific stuff */
578 union {
579 struct {
580 void* stuff;
581 uint32 thing1;
582 uint32 thing2;
583 } sd;
584 struct {
585 void* bus;
586 void* urb;
587 } usb;
588 } bus_specific;
589} dhd_pkttag_t;
590
591#define DHD_PKTTAG_SET_H2DTAG(tag, h2dvalue) ((dhd_pkttag_t*)(tag))->htod_tag = (h2dvalue)
592#define DHD_PKTTAG_H2DTAG(tag) (((dhd_pkttag_t*)(tag))->htod_tag)
593
594#define DHD_PKTTAG_IFMASK 0xf
595#define DHD_PKTTAG_IFTYPE_MASK 0x1
596#define DHD_PKTTAG_IFTYPE_SHIFT 7
597#define DHD_PKTTAG_FIFO_MASK 0x7
598#define DHD_PKTTAG_FIFO_SHIFT 4
599
600#define DHD_PKTTAG_SIGNALONLY_MASK 0x1
601#define DHD_PKTTAG_SIGNALONLY_SHIFT 10
602
603#define DHD_PKTTAG_ONETIMEPKTRQST_MASK 0x1
604#define DHD_PKTTAG_ONETIMEPKTRQST_SHIFT 11
605
606#define DHD_PKTTAG_PKTDIR_MASK 0x1
607#define DHD_PKTTAG_PKTDIR_SHIFT 9
608
609#define DHD_PKTTAG_CREDITCHECK_MASK 0x1
610#define DHD_PKTTAG_CREDITCHECK_SHIFT 8
611
612#define DHD_PKTTAG_INVALID_FIFOID 0x7
613
614#define DHD_PKTTAG_SETFIFO(tag, fifo) ((dhd_pkttag_t*)(tag))->if_flags = \
615 (((dhd_pkttag_t*)(tag))->if_flags & ~(DHD_PKTTAG_FIFO_MASK << DHD_PKTTAG_FIFO_SHIFT)) | \
616 (((fifo) & DHD_PKTTAG_FIFO_MASK) << DHD_PKTTAG_FIFO_SHIFT)
617#define DHD_PKTTAG_FIFO(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
618 DHD_PKTTAG_FIFO_SHIFT) & DHD_PKTTAG_FIFO_MASK)
619
620#define DHD_PKTTAG_SETIF(tag, if) ((dhd_pkttag_t*)(tag))->if_flags = \
621 (((dhd_pkttag_t*)(tag))->if_flags & ~DHD_PKTTAG_IFMASK) | ((if) & DHD_PKTTAG_IFMASK)
622#define DHD_PKTTAG_IF(tag) (((dhd_pkttag_t*)(tag))->if_flags & DHD_PKTTAG_IFMASK)
623
624#define DHD_PKTTAG_SETIFTYPE(tag, isAP) ((dhd_pkttag_t*)(tag))->if_flags = \
625 (((dhd_pkttag_t*)(tag))->if_flags & \
626 ~(DHD_PKTTAG_IFTYPE_MASK << DHD_PKTTAG_IFTYPE_SHIFT)) | \
627 (((isAP) & DHD_PKTTAG_IFTYPE_MASK) << DHD_PKTTAG_IFTYPE_SHIFT)
628#define DHD_PKTTAG_IFTYPE(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
629 DHD_PKTTAG_IFTYPE_SHIFT) & DHD_PKTTAG_IFTYPE_MASK)
630
631#define DHD_PKTTAG_SETCREDITCHECK(tag, check) ((dhd_pkttag_t*)(tag))->if_flags = \
632 (((dhd_pkttag_t*)(tag))->if_flags & \
633 ~(DHD_PKTTAG_CREDITCHECK_MASK << DHD_PKTTAG_CREDITCHECK_SHIFT)) | \
634 (((check) & DHD_PKTTAG_CREDITCHECK_MASK) << DHD_PKTTAG_CREDITCHECK_SHIFT)
635#define DHD_PKTTAG_CREDITCHECK(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
636 DHD_PKTTAG_CREDITCHECK_SHIFT) & DHD_PKTTAG_CREDITCHECK_MASK)
637
638#define DHD_PKTTAG_SETPKTDIR(tag, dir) ((dhd_pkttag_t*)(tag))->if_flags = \
639 (((dhd_pkttag_t*)(tag))->if_flags & \
640 ~(DHD_PKTTAG_PKTDIR_MASK << DHD_PKTTAG_PKTDIR_SHIFT)) | \
641 (((dir) & DHD_PKTTAG_PKTDIR_MASK) << DHD_PKTTAG_PKTDIR_SHIFT)
642#define DHD_PKTTAG_PKTDIR(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
643 DHD_PKTTAG_PKTDIR_SHIFT) & DHD_PKTTAG_PKTDIR_MASK)
644
645#define DHD_PKTTAG_SETSIGNALONLY(tag, signalonly) ((dhd_pkttag_t*)(tag))->if_flags = \
646 (((dhd_pkttag_t*)(tag))->if_flags & \
647 ~(DHD_PKTTAG_SIGNALONLY_MASK << DHD_PKTTAG_SIGNALONLY_SHIFT)) | \
648 (((signalonly) & DHD_PKTTAG_SIGNALONLY_MASK) << DHD_PKTTAG_SIGNALONLY_SHIFT)
649#define DHD_PKTTAG_SIGNALONLY(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
650 DHD_PKTTAG_SIGNALONLY_SHIFT) & DHD_PKTTAG_SIGNALONLY_MASK)
651
652#define DHD_PKTTAG_SETONETIMEPKTRQST(tag) ((dhd_pkttag_t*)(tag))->if_flags = \
653 (((dhd_pkttag_t*)(tag))->if_flags & \
654 ~(DHD_PKTTAG_ONETIMEPKTRQST_MASK << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)) | \
655 (1 << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)
656#define DHD_PKTTAG_ONETIMEPKTRQST(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
657 DHD_PKTTAG_ONETIMEPKTRQST_SHIFT) & DHD_PKTTAG_ONETIMEPKTRQST_MASK)
658
659#define DHD_PKTTAG_SETDSTN(tag, dstn_MAC_ea) memcpy(((dhd_pkttag_t*)((tag)))->dstn_ether, \
660 (dstn_MAC_ea), ETHER_ADDR_LEN)
661#define DHD_PKTTAG_DSTN(tag) ((dhd_pkttag_t*)(tag))->dstn_ether
662
663typedef int (*f_commitpkt_t)(void* ctx, void* p);
664int dhd_wlfc_enable(dhd_pub_t *dhd);
665int dhd_wlfc_interface_event(struct dhd_info *, uint8 action, uint8 ifid, uint8 iftype, uint8* ea);
666int dhd_wlfc_FIFOcreditmap_event(struct dhd_info *dhd, uint8* event_data);
667int dhd_wlfc_event(struct dhd_info *dhd);
668int dhd_os_wlfc_block(dhd_pub_t *pub);
669int dhd_os_wlfc_unblock(dhd_pub_t *pub);
670
671#ifdef PROP_TXSTATUS_DEBUG
672#define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do { (entry)->closed_ct++; } while (0)
673#define DHD_WLFC_CTRINC_MAC_OPEN(entry) do { (entry)->opened_ct++; } while (0)
674#else
675#define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do {} while (0)
676#define DHD_WLFC_CTRINC_MAC_OPEN(entry) do {} while (0)
677#endif
678
679#endif /* PROP_TXSTATUS */
680
681extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
682extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
683
Howard M. Hartecf77d4c2011-05-27 16:07:36 -0700684#ifdef ARP_OFFLOAD_SUPPORT
Dmitry Shmidt043cda22011-08-03 14:11:58 -0700685#define MAX_IPV4_ENTRIES 8
Howard M. Hartecf77d4c2011-05-27 16:07:36 -0700686/* dhd_commn arp offload wrapers */
687void dhd_aoe_hostip_clr(dhd_pub_t *dhd);
688void dhd_aoe_arp_clr(dhd_pub_t *dhd);
689int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen);
690void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr);
691#endif /* ARP_OFFLOAD_SUPPORT */
Dmitry Shmidt66eb9fa2011-05-24 11:14:33 -0700692#endif /* _dhd_h_ */