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