blob: 8426949a640317ecfc01061f7c36ba10b49ded12 [file] [log] [blame]
Dmitry Shmidt7972aa82011-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 Shmidt5bfb83a2012-08-22 11:29:44 -070027 * $Id: dhd.h 344123 2012-07-11 09:33:49Z $
Dmitry Shmidt7972aa82011-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) */
Dmitry Shmidtb8f9fb92012-05-31 14:06:50 -070054
Dmitry Shmidt7972aa82011-05-24 11:14:33 -070055/* The kernel threading is sdio-specific */
Howard M. Hartea2e9fb42011-08-29 19:01:55 -070056struct task_struct;
57struct sched_param;
58int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -070059
60#define ALL_INTERFACES 0xff
61
62#include <wlioctl.h>
63
64
65/* Forward decls */
66struct dhd_bus;
67struct dhd_prot;
68struct dhd_info;
69struct dhd_cmn;
70
71/* The level of bus communication with the dongle */
72enum dhd_bus_state {
73 DHD_BUS_DOWN, /* Not ready for frame transfers */
74 DHD_BUS_LOAD, /* Download access only (CPU reset) */
75 DHD_BUS_DATA /* Ready for frame transfers */
76};
77
ECCO PARK8ee09cb2011-08-18 15:18:04 -070078/* Firmware requested operation mode */
79#define STA_MASK 0x0001
jim1_lina5b31ba2012-05-04 14:39:00 -070080#define HOSTAPD_MASK 0x0002
ECCO PARK8ee09cb2011-08-18 15:18:04 -070081#define WFD_MASK 0x0004
jim1_lina5b31ba2012-05-04 14:39:00 -070082#define SOFTAP_FW_MASK 0x0008
83#define P2P_GO_ENABLED 0x0010
84#define P2P_GC_ENABLED 0x0020
85#define CONCURENT_MASK 0x00F0
86
87#define MANUFACTRING_FW "WLTEST"
ECCO PARK8ee09cb2011-08-18 15:18:04 -070088
Dmitry Shmidtc3c5c902011-09-21 13:09:58 -070089/* max sequential rxcntl timeouts to set HANG event */
90#define MAX_CNTL_TIMEOUT 2
91
andy2_kuoc19e85e2012-03-29 11:02:33 +080092#define DHD_SCAN_ACTIVE_TIME 40 /* ms : Embedded default Active setting from DHD Driver */
93#define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD Driver */
94
jim1_lina5b31ba2012-05-04 14:39:00 -070095#define DHD_BEACON_TIMEOUT_NORMAL 4
96#define DHD_BEACON_TIMEOUT_HIGH 10
97
andy2_kuo05aad622012-07-27 11:46:33 +080098#define DYNAMIC_DTIM_SKIP 1
99
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700100enum dhd_bus_wake_state {
101 WAKE_LOCK_OFF,
102 WAKE_LOCK_PRIV,
103 WAKE_LOCK_DPC,
104 WAKE_LOCK_IOCTL,
105 WAKE_LOCK_DOWNLOAD,
106 WAKE_LOCK_TMOUT,
107 WAKE_LOCK_WATCHDOG,
108 WAKE_LOCK_LINK_DOWN_TMOUT,
109 WAKE_LOCK_PNO_FIND_TMOUT,
110 WAKE_LOCK_SOFTAP_SET,
111 WAKE_LOCK_SOFTAP_STOP,
112 WAKE_LOCK_SOFTAP_START,
113 WAKE_LOCK_SOFTAP_THREAD,
114 WAKE_LOCK_MAX
115};
Dmitry Shmidtc3c5c902011-09-21 13:09:58 -0700116
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700117enum dhd_prealloc_index {
118 DHD_PREALLOC_PROT = 0,
119 DHD_PREALLOC_RXBUF,
120 DHD_PREALLOC_DATABUF,
121 DHD_PREALLOC_OSL_BUF
122};
Lin Ma2ef3ac72011-06-27 18:53:59 -0700123
Dmitry Shmidtdfd7f3b2011-10-25 16:32:46 -0700124typedef enum {
125 DHD_IF_NONE = 0,
126 DHD_IF_ADD,
127 DHD_IF_DEL,
128 DHD_IF_CHANGE,
129 DHD_IF_DELETING
130} dhd_if_state_t;
131
jim1_lina5b31ba2012-05-04 14:39:00 -0700132#if defined(CONFIG_DHD_USE_STATIC_BUF)
Lin Ma2ef3ac72011-06-27 18:53:59 -0700133
134uint8* dhd_os_prealloc(void *osh, int section, uint size);
135void dhd_os_prefree(void *osh, void *addr, uint size);
136#define DHD_OS_PREALLOC(osh, section, size) dhd_os_prealloc(osh, section, size)
137#define DHD_OS_PREFREE(osh, addr, size) dhd_os_prefree(osh, addr, size)
138
139#else
140
141#define DHD_OS_PREALLOC(osh, section, size) MALLOC(osh, size)
142#define DHD_OS_PREFREE(osh, addr, size) MFREE(osh, addr, size)
143
jim1_lina5b31ba2012-05-04 14:39:00 -0700144#endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
Lin Ma2ef3ac72011-06-27 18:53:59 -0700145
Howard M. Hartea2e9fb42011-08-29 19:01:55 -0700146/* Packet alignment for most efficient SDIO (can change based on platform) */
147#ifndef DHD_SDALIGN
148#define DHD_SDALIGN 32
149#endif
Dmitry Shmidtc3c5c902011-09-21 13:09:58 -0700150
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700151/* Common structure for module and instance linkage */
152typedef struct dhd_pub {
153 /* Linkage ponters */
154 osl_t *osh; /* OSL handle */
155 struct dhd_bus *bus; /* Bus module handle */
156 struct dhd_prot *prot; /* Protocol module handle */
157 struct dhd_info *info; /* Info module handle */
158 struct dhd_cmn *cmn; /* dhd_common module handle */
159
160 /* Internal dhd items */
161 bool up; /* Driver up/down (to OS) */
162 bool txoff; /* Transmit flow-controlled */
163 bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
164 enum dhd_bus_state busstate;
165 uint hdrlen; /* Total DHD header length (proto + bus) */
166 uint maxctl; /* Max size rxctl request from proto to bus */
167 uint rxsz; /* Rx buffer size bus module should use */
168 uint8 wme_dp; /* wme discard priority */
169
170 /* Dongle media info */
171 bool iswl; /* Dongle-resident driver is wl */
172 ulong drv_version; /* Version of dongle-resident driver */
173 struct ether_addr mac; /* MAC address obtained from dongle */
174 dngl_stats_t dstats; /* Stats for dongle-based data */
175
176 /* Additional stats for the bus level */
177 ulong tx_packets; /* Data packets sent to dongle */
178 ulong tx_multicast; /* Multicast data packets sent to dongle */
179 ulong tx_errors; /* Errors in sending data to dongle */
180 ulong tx_ctlpkts; /* Control packets sent to dongle */
181 ulong tx_ctlerrs; /* Errors sending control frames to dongle */
182 ulong rx_packets; /* Packets sent up the network interface */
183 ulong rx_multicast; /* Multicast packets sent up the network interface */
184 ulong rx_errors; /* Errors processing rx data packets */
185 ulong rx_ctlpkts; /* Control frames processed from dongle */
186 ulong rx_ctlerrs; /* Errors in processing rx control frames */
187 ulong rx_dropped; /* Packets dropped locally (no memory) */
188 ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
189 ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
190
191 ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
192 ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
193 ulong fc_packets; /* Number of flow control pkts recvd */
194
195 /* Last error return */
196 int bcmerror;
197 uint tickcnt;
198
199 /* Last error from dongle */
200 int dongle_error;
201
202 /* Suspend disable flag and "in suspend" flag */
203 int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
204 int in_suspend; /* flag set to 1 when early suspend called */
205#ifdef PNO_SUPPORT
206 int pno_enable; /* pno status : "1" is pno enable */
207#endif /* PNO_SUPPORT */
208 int dtim_skip; /* dtim skip , default 0 means wake each dtim */
209
210 /* Pkt filter defination */
211 char * pktfilter[100];
212 int pktfilter_count;
213
214 wl_country_t dhd_cspec; /* Current Locale info */
215 char eventmask[WL_EVENTING_MASK_LEN];
ECCO PARK8ee09cb2011-08-18 15:18:04 -0700216 int op_mode; /* STA, HostAPD, WFD, SoftAP */
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700217
jim1_lina5b31ba2012-05-04 14:39:00 -0700218/* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
219 * For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
220 * see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
221 */
222
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700223#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
224 struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
225 struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
226#endif
227
228 uint16 maxdatablks;
229#ifdef PROP_TXSTATUS
230 int wlfc_enabled;
231 void* wlfc_state;
232#endif
233 bool dongle_isolation;
Dmitry Shmidtc14da072011-09-07 10:30:45 -0700234 int hang_was_sent;
Dmitry Shmidtc3c5c902011-09-21 13:09:58 -0700235 int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
236 int txcnt_timeout; /* counter txcnt timeout to send HANG */
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700237#ifdef WLMEDIA_HTSF
238 uint8 htsfdlystat_sz; /* Size of delay stats, max 255B */
239#endif
andy2_kuo05aad622012-07-27 11:46:33 +0800240#ifdef DYNAMIC_DTIM_SKIP
241 ulong pre_rx_packets;
242 int dynamic_dtim_skip;
243 int dynamic_dtim_data_counter;
244#endif
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700245} dhd_pub_t;
246
247typedef struct dhd_cmn {
248 osl_t *osh; /* OSL handle */
249 dhd_pub_t *dhd;
250} dhd_cmn_t;
251
252
253 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
254
255 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
256 #define _DHD_PM_RESUME_WAIT(a, b) do {\
257 int retry = 0; \
Dmitry Shmidt7dc754a2011-11-02 16:51:29 -0700258 SMP_RD_BARRIER_DEPENDS(); \
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700259 while (dhd_mmc_suspend && retry++ != b) { \
Dmitry Shmidt7dc754a2011-11-02 16:51:29 -0700260 SMP_RD_BARRIER_DEPENDS(); \
Dmitry Shmidtdb6b2852012-07-13 14:30:33 -0700261 wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700262 } \
Dmitry Shmidt7dc754a2011-11-02 16:51:29 -0700263 } while (0)
Dmitry Shmidt1e864d92011-06-13 16:47:58 -0700264 #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700265 #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
266 #define DHD_PM_RESUME_RETURN_ERROR(a) do { if (dhd_mmc_suspend) return a; } while (0)
267 #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
268
269 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
270 #define SPINWAIT_SLEEP(a, exp, us) do { \
271 uint countdown = (us) + 9999; \
272 while ((exp) && (countdown >= 10000)) { \
Dmitry Shmidtdb6b2852012-07-13 14:30:33 -0700273 wait_event_interruptible_timeout(a, FALSE, 1); \
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700274 countdown -= 10000; \
275 } \
276 } while (0)
277
278 #else
279
280 #define DHD_PM_RESUME_WAIT_INIT(a)
281 #define DHD_PM_RESUME_WAIT(a)
282 #define DHD_PM_RESUME_WAIT_FOREVER(a)
283 #define DHD_PM_RESUME_RETURN_ERROR(a)
284 #define DHD_PM_RESUME_RETURN
285
286 #define DHD_SPINWAIT_SLEEP_INIT(a)
287 #define SPINWAIT_SLEEP(a, exp, us) do { \
288 uint countdown = (us) + 9; \
289 while ((exp) && (countdown >= 10)) { \
290 OSL_DELAY(10); \
291 countdown -= 10; \
292 } \
293 } while (0)
294
295 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
296#ifndef DHDTHREAD
297#undef SPINWAIT_SLEEP
298#define SPINWAIT_SLEEP(a, exp, us) SPINWAIT(exp, us)
299#endif /* DHDTHREAD */
300#define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
301
Greg Goldmane1fa2ad2011-06-29 14:34:18 -0700302unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
303void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
304
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700305/* Wakelock Functions */
306extern int dhd_os_wake_lock(dhd_pub_t *pub);
307extern int dhd_os_wake_unlock(dhd_pub_t *pub);
308extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
jim1_lina5b31ba2012-05-04 14:39:00 -0700309extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
310extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700311
312inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
313{
314#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
315 mutex_init(&dhdp->wl_softap_lock);
316#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
317}
318
319inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
320{
321#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
322 mutex_lock(&dhdp->wl_softap_lock);
323#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
324}
325
326inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
327{
328#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
329 mutex_unlock(&dhdp->wl_softap_lock);
330#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
331}
332
Ramanan Rajeswaran22b4fcd2012-11-02 10:29:13 -0700333#define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
334#define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700335#define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
jim1_lina5b31ba2012-05-04 14:39:00 -0700336#define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) dhd_os_wake_lock_rx_timeout_enable(pub, val)
337#define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
338#define DHD_PACKET_TIMEOUT_MS 1000
339#define DHD_EVENT_TIMEOUT_MS 1500
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700340
Lin Ma2ef3ac72011-06-27 18:53:59 -0700341/* interface operations (register, remove) should be atomic, use this lock to prevent race
342 * condition among wifi on/off and interface operation functions
343 */
344void dhd_net_if_lock(struct net_device *dev);
345void dhd_net_if_unlock(struct net_device *dev);
Howard M. Harte964ac832011-06-15 18:52:15 -0700346
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700347typedef struct dhd_if_event {
348 uint8 ifidx;
349 uint8 action;
350 uint8 flags;
351 uint8 bssidx;
352 uint8 is_AP;
353} dhd_if_event_t;
354
355typedef enum dhd_attach_states
356{
357 DHD_ATTACH_STATE_INIT = 0x0,
358 DHD_ATTACH_STATE_NET_ALLOC = 0x1,
359 DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
360 DHD_ATTACH_STATE_ADD_IF = 0x4,
361 DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
362 DHD_ATTACH_STATE_WL_ATTACH = 0x10,
363 DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
364 DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
365 DHD_ATTACH_STATE_CFG80211 = 0x80,
366 DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
367 DHD_ATTACH_STATE_DONE = 0x200
368} dhd_attach_states_t;
369
370/* Value -1 means we are unsuccessful in creating the kthread. */
371#define DHD_PID_KT_INVALID -1
372/* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
373#define DHD_PID_KT_TL_INVALID -2
374
375/*
376 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
377 */
378
379/* To allow osl_attach/detach calls from os-independent modules */
380osl_t *dhd_osl_attach(void *pdev, uint bustype);
381void dhd_osl_detach(osl_t *osh);
382
383/* Indication from bus module regarding presence/insertion of dongle.
384 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
385 * Returned structure should have bus and prot pointers filled in.
386 * bus_hdrlen specifies required headroom for bus module header.
387 */
andy2_kuoc19e85e2012-03-29 11:02:33 +0800388extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
389#if defined(WLP2P) && defined(WL_CFG80211)
390/* To allow attach/detach calls corresponding to p2p0 interface */
391extern int dhd_attach_p2p(dhd_pub_t *);
392extern int dhd_detach_p2p(dhd_pub_t *);
393#endif /* WLP2P && WL_CFG80211 */
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700394extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
395
396/* Indication from bus module regarding removal/absence of dongle */
397extern void dhd_detach(dhd_pub_t *dhdp);
398extern void dhd_free(dhd_pub_t *dhdp);
399
400/* Indication from bus module to change flow-control state */
401extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
402
403extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
404
405/* Receive frame for delivery to OS. Callee disposes of rxp. */
406extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
407
408/* Return pointer to interface name */
409extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
410
411/* Request scheduling of the bus dpc */
412extern void dhd_sched_dpc(dhd_pub_t *dhdp);
413
414/* Notify tx completion */
415extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
416
417/* OS independent layer functions */
418extern int dhd_os_proto_block(dhd_pub_t * pub);
419extern int dhd_os_proto_unblock(dhd_pub_t * pub);
420extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition, bool * pending);
421extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
422extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
423extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
424extern void * dhd_os_open_image(char * filename);
425extern int dhd_os_get_image_block(char * buf, int len, void * image);
426extern void dhd_os_close_image(void * image);
427extern void dhd_os_wd_timer(void *bus, uint wdtick);
428extern void dhd_os_sdlock(dhd_pub_t * pub);
429extern void dhd_os_sdunlock(dhd_pub_t * pub);
430extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
431extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
432extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
433extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
434extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
435extern void dhd_customer_gpio_wlan_ctrl(int onoff);
Dmitry Shmidtc14da072011-09-07 10:30:45 -0700436extern int dhd_custom_get_mac_address(unsigned char *buf);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700437extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
438extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
439extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
andy2_kuoc19e85e2012-03-29 11:02:33 +0800440extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
Dmitry Shmidt2d660ac2012-07-18 11:15:10 -0700441extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
Dmitry Shmidt6f45c822012-06-14 10:59:25 -0700442extern int net_os_send_hang_message(struct net_device *dev);
Dmitry Shmidtcb8e7962012-07-12 16:58:00 -0700443extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
andy2_kuoc19e85e2012-03-29 11:02:33 +0800444
445#ifdef PNO_SUPPORT
Howard M. Harte964ac832011-06-15 18:52:15 -0700446extern int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled);
447extern int dhd_pno_clean(dhd_pub_t *dhd);
448extern int dhd_pno_set(dhd_pub_t *dhd, wlc_ssid_t* ssids_local, int nssid,
449 ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
Dmitry Shmidtb8f9fb92012-05-31 14:06:50 -0700450extern int dhd_pno_set_ex(dhd_pub_t *dhd, wl_pfn_t* ssidnet, int nssid,
451 ushort pno_interval, int pno_repeat, int pno_expo_max, int pno_lost_time);
Howard M. Harte964ac832011-06-15 18:52:15 -0700452extern int dhd_pno_get_status(dhd_pub_t *dhd);
453extern int dhd_dev_pno_reset(struct net_device *dev);
454extern int dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local,
455 int nssid, ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
Dmitry Shmidtb8f9fb92012-05-31 14:06:50 -0700456extern int dhd_dev_pno_set_ex(struct net_device *dev, wl_pfn_t* ssidnet, int nssid,
457 ushort pno_interval, int pno_repeat, int pno_expo_max, int pno_lost_time);
Howard M. Harte964ac832011-06-15 18:52:15 -0700458extern int dhd_dev_pno_enable(struct net_device *dev, int pfn_enabled);
459extern int dhd_dev_get_pno_status(struct net_device *dev);
andy2_kuoc19e85e2012-03-29 11:02:33 +0800460#endif /* PNO_SUPPORT */
Howard M. Harte964ac832011-06-15 18:52:15 -0700461
Dmitry Shmidta0d14aa2011-07-07 17:04:44 -0700462#define DHD_UNICAST_FILTER_NUM 0
463#define DHD_BROADCAST_FILTER_NUM 1
464#define DHD_MULTICAST4_FILTER_NUM 2
465#define DHD_MULTICAST6_FILTER_NUM 3
jim1_lina5b31ba2012-05-04 14:39:00 -0700466#define DHD_MDNS_FILTER_NUM 4
Leslie Yua4091742012-05-10 17:24:32 -0700467extern int dhd_os_set_packet_filter(dhd_pub_t *dhdp, int val);
Dmitry Shmidta0d14aa2011-07-07 17:04:44 -0700468extern int net_os_set_packet_filter(struct net_device *dev, int val);
469extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
470
andy2_kuoc19e85e2012-03-29 11:02:33 +0800471extern int dhd_get_dtim_skip(dhd_pub_t *dhd);
472extern bool dhd_check_ap_wfd_mode_set(dhd_pub_t *dhd);
473
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700474#ifdef DHD_DEBUG
475extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
476#endif /* DHD_DEBUG */
477#if defined(OOB_INTR_ONLY)
478extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
479#endif /* defined(OOB_INTR_ONLY) */
480extern void dhd_os_sdtxlock(dhd_pub_t * pub);
481extern void dhd_os_sdtxunlock(dhd_pub_t * pub);
482
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700483typedef struct {
484 uint32 limit; /* Expiration time (usec) */
485 uint32 increment; /* Current expiration increment (usec) */
486 uint32 elapsed; /* Current elapsed time (usec) */
487 uint32 tick; /* O/S tick time (usec) */
488} dhd_timeout_t;
489
490extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
491extern int dhd_timeout_expired(dhd_timeout_t *tmo);
492
493extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
Greg Goldman04592722011-08-23 10:28:41 -0700494extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
jim1_lina5b31ba2012-05-04 14:39:00 -0700495extern struct net_device * dhd_idx2net(void *pub, int ifidx);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700496extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata,
497 wl_event_msg_t *, void **data_ptr);
498extern void wl_event_to_host_order(wl_event_msg_t * evt);
499
500extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
501extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
502 int ifindex);
503
andy2_kuoc19e85e2012-03-29 11:02:33 +0800504extern struct dhd_cmn *dhd_common_init(osl_t *osh);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700505extern void dhd_common_deinit(dhd_pub_t *dhd_pub, dhd_cmn_t *sa_cmn);
506
jim1_lina5b31ba2012-05-04 14:39:00 -0700507extern int dhd_do_driver_init(struct net_device *net);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700508extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
509 char *name, uint8 *mac_addr, uint32 flags, uint8 bssidx);
510extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
511
512extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
513extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
514
515extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
516extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
517
518
519/* Send packet to dongle via data channel */
520extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
521
522/* send up locally generated event */
523extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
524/* Send event to host */
525extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
526extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
527extern uint dhd_bus_status(dhd_pub_t *dhdp);
528extern int dhd_bus_start(dhd_pub_t *dhdp);
529extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
530extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
jim1_lina5b31ba2012-05-04 14:39:00 -0700531extern bool dhd_is_associated(dhd_pub_t *dhd, void *bss_buf, int *retval);
532extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
Dmitry Shmidtcb8e7962012-07-12 16:58:00 -0700533extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
534extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
Dmitry Shmidt6f992a72011-10-19 13:09:49 -0700535
Howard M. Hartea2e9fb42011-08-29 19:01:55 -0700536#if defined(KEEP_ALIVE)
537extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
538#endif /* KEEP_ALIVE */
539
540#ifdef ARP_OFFLOAD_SUPPORT
541extern void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
542extern void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
543#endif /* ARP_OFFLOAD_SUPPORT */
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700544
545
546typedef enum cust_gpio_modes {
547 WLAN_RESET_ON,
548 WLAN_RESET_OFF,
549 WLAN_POWER_ON,
550 WLAN_POWER_OFF
551} cust_gpio_modes_t;
552
553extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
554extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
555/*
556 * Insmod parameters for debug/test
557 */
558
559/* Watchdog timer interval */
560extern uint dhd_watchdog_ms;
561
562#if defined(DHD_DEBUG)
563/* Console output poll interval */
564extern uint dhd_console_ms;
565extern uint wl_msg_level;
566#endif /* defined(DHD_DEBUG) */
567
568/* Use interrupts */
569extern uint dhd_intr;
570
571/* Use polling */
572extern uint dhd_poll;
573
574/* ARP offload agent mode */
575extern uint dhd_arp_mode;
576
577/* ARP offload enable */
578extern uint dhd_arp_enable;
579
580/* Pkt filte enable control */
581extern uint dhd_pkt_filter_enable;
582
583/* Pkt filter init setup */
584extern uint dhd_pkt_filter_init;
585
586/* Pkt filter mode control */
587extern uint dhd_master_mode;
588
589/* Roaming mode control */
590extern uint dhd_roam_disable;
591
592/* Roaming mode control */
593extern uint dhd_radio_up;
594
595/* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
596extern int dhd_idletime;
597#define DHD_IDLETIME_TICKS 1
598
599/* SDIO Drive Strength */
600extern uint dhd_sdiod_drive_strength;
601
602/* Override to force tx queueing all the time */
603extern uint dhd_force_tx_queueing;
Howard M. Hartef5b388b2011-05-27 16:07:36 -0700604/* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
605#define KEEP_ALIVE_PERIOD 55000
606#define NULL_PKT_STR "null_pkt"
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700607
608#ifdef SDTEST
609/* Echo packet generator (SDIO), pkts/s */
610extern uint dhd_pktgen;
611
612/* Echo packet len (0 => sawtooth, max 1800) */
613extern uint dhd_pktgen_len;
614#define MAX_PKTGEN_LEN 1800
615#endif
616
617
Dmitry Shmidt45f35632012-09-13 13:56:32 -0700618/* hooks for custom Roaming Trigger setting via Makefile */
619#define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
620#define DEFAULT_ROAM_TRIGGER_SETTING -1
621#ifndef CUSTOM_ROAM_TRIGGER_SETTING
622#define CUSTOM_ROAM_TRIGGER_SETTING DEFAULT_ROAM_TRIGGER_VALUE
623#endif
624
625/* hooks for custom Roaming Romaing setting via Makefile */
626#define DEFAULT_ROAM_DELTA_VALUE 10 /* dBm default roam delta all band */
627#define DEFAULT_ROAM_DELTA_SETTING -1
628#ifndef CUSTOM_ROAM_DELTA_SETTING
629#define CUSTOM_ROAM_DELTA_SETTING DEFAULT_ROAM_DELTA_VALUE
630#endif
631
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700632/* optionally set by a module_param_string() */
633#define MOD_PARAM_PATHLEN 2048
634extern char fw_path[MOD_PARAM_PATHLEN];
635extern char nv_path[MOD_PARAM_PATHLEN];
636
Dmitry Shmidtcb8e7962012-07-12 16:58:00 -0700637#define MOD_PARAM_INFOLEN 512
638
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700639#ifdef SOFTAP
640extern char fw_path2[MOD_PARAM_PATHLEN];
641#endif
642
Lin Ma2ef3ac72011-06-27 18:53:59 -0700643/* Flag to indicate if we should download firmware on driver load */
644extern uint dhd_download_fw_on_driverload;
645
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700646/* For supporting multiple interfaces */
647#define DHD_MAX_IFS 16
648#define DHD_DEL_IF -0xe
649#define DHD_BAD_IF -0xf
650
651#ifdef PROP_TXSTATUS
652/* Please be mindful that total pkttag space is 32 octets only */
653typedef struct dhd_pkttag {
654 /*
655 b[11 ] - 1 = this packet was sent in response to one time packet request,
656 do not increment credit on status for this one. [WLFC_CTL_TYPE_MAC_REQUEST_PACKET].
657 b[10 ] - 1 = signal-only-packet to firmware [i.e. nothing to piggyback on]
658 b[9 ] - 1 = packet is host->firmware (transmit direction)
659 - 0 = packet received from firmware (firmware->host)
660 b[8 ] - 1 = packet was sent due to credit_request (pspoll),
661 packet does not count against FIFO credit.
662 - 0 = normal transaction, packet counts against FIFO credit
663 b[7 ] - 1 = AP, 0 = STA
664 b[6:4] - AC FIFO number
665 b[3:0] - interface index
666 */
667 uint16 if_flags;
668 /* destination MAC address for this packet so that not every
669 module needs to open the packet to find this
670 */
671 uint8 dstn_ether[ETHER_ADDR_LEN];
672 /*
673 This 32-bit goes from host to device for every packet.
674 */
675 uint32 htod_tag;
676 /* bus specific stuff */
677 union {
678 struct {
679 void* stuff;
680 uint32 thing1;
681 uint32 thing2;
682 } sd;
683 struct {
684 void* bus;
685 void* urb;
686 } usb;
687 } bus_specific;
688} dhd_pkttag_t;
689
690#define DHD_PKTTAG_SET_H2DTAG(tag, h2dvalue) ((dhd_pkttag_t*)(tag))->htod_tag = (h2dvalue)
691#define DHD_PKTTAG_H2DTAG(tag) (((dhd_pkttag_t*)(tag))->htod_tag)
692
693#define DHD_PKTTAG_IFMASK 0xf
694#define DHD_PKTTAG_IFTYPE_MASK 0x1
695#define DHD_PKTTAG_IFTYPE_SHIFT 7
696#define DHD_PKTTAG_FIFO_MASK 0x7
697#define DHD_PKTTAG_FIFO_SHIFT 4
698
699#define DHD_PKTTAG_SIGNALONLY_MASK 0x1
700#define DHD_PKTTAG_SIGNALONLY_SHIFT 10
701
702#define DHD_PKTTAG_ONETIMEPKTRQST_MASK 0x1
703#define DHD_PKTTAG_ONETIMEPKTRQST_SHIFT 11
704
705#define DHD_PKTTAG_PKTDIR_MASK 0x1
706#define DHD_PKTTAG_PKTDIR_SHIFT 9
707
708#define DHD_PKTTAG_CREDITCHECK_MASK 0x1
709#define DHD_PKTTAG_CREDITCHECK_SHIFT 8
710
711#define DHD_PKTTAG_INVALID_FIFOID 0x7
712
713#define DHD_PKTTAG_SETFIFO(tag, fifo) ((dhd_pkttag_t*)(tag))->if_flags = \
714 (((dhd_pkttag_t*)(tag))->if_flags & ~(DHD_PKTTAG_FIFO_MASK << DHD_PKTTAG_FIFO_SHIFT)) | \
715 (((fifo) & DHD_PKTTAG_FIFO_MASK) << DHD_PKTTAG_FIFO_SHIFT)
716#define DHD_PKTTAG_FIFO(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
717 DHD_PKTTAG_FIFO_SHIFT) & DHD_PKTTAG_FIFO_MASK)
718
719#define DHD_PKTTAG_SETIF(tag, if) ((dhd_pkttag_t*)(tag))->if_flags = \
720 (((dhd_pkttag_t*)(tag))->if_flags & ~DHD_PKTTAG_IFMASK) | ((if) & DHD_PKTTAG_IFMASK)
721#define DHD_PKTTAG_IF(tag) (((dhd_pkttag_t*)(tag))->if_flags & DHD_PKTTAG_IFMASK)
722
723#define DHD_PKTTAG_SETIFTYPE(tag, isAP) ((dhd_pkttag_t*)(tag))->if_flags = \
724 (((dhd_pkttag_t*)(tag))->if_flags & \
725 ~(DHD_PKTTAG_IFTYPE_MASK << DHD_PKTTAG_IFTYPE_SHIFT)) | \
726 (((isAP) & DHD_PKTTAG_IFTYPE_MASK) << DHD_PKTTAG_IFTYPE_SHIFT)
727#define DHD_PKTTAG_IFTYPE(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
728 DHD_PKTTAG_IFTYPE_SHIFT) & DHD_PKTTAG_IFTYPE_MASK)
729
730#define DHD_PKTTAG_SETCREDITCHECK(tag, check) ((dhd_pkttag_t*)(tag))->if_flags = \
731 (((dhd_pkttag_t*)(tag))->if_flags & \
732 ~(DHD_PKTTAG_CREDITCHECK_MASK << DHD_PKTTAG_CREDITCHECK_SHIFT)) | \
733 (((check) & DHD_PKTTAG_CREDITCHECK_MASK) << DHD_PKTTAG_CREDITCHECK_SHIFT)
734#define DHD_PKTTAG_CREDITCHECK(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
735 DHD_PKTTAG_CREDITCHECK_SHIFT) & DHD_PKTTAG_CREDITCHECK_MASK)
736
737#define DHD_PKTTAG_SETPKTDIR(tag, dir) ((dhd_pkttag_t*)(tag))->if_flags = \
738 (((dhd_pkttag_t*)(tag))->if_flags & \
739 ~(DHD_PKTTAG_PKTDIR_MASK << DHD_PKTTAG_PKTDIR_SHIFT)) | \
740 (((dir) & DHD_PKTTAG_PKTDIR_MASK) << DHD_PKTTAG_PKTDIR_SHIFT)
741#define DHD_PKTTAG_PKTDIR(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
742 DHD_PKTTAG_PKTDIR_SHIFT) & DHD_PKTTAG_PKTDIR_MASK)
743
744#define DHD_PKTTAG_SETSIGNALONLY(tag, signalonly) ((dhd_pkttag_t*)(tag))->if_flags = \
745 (((dhd_pkttag_t*)(tag))->if_flags & \
746 ~(DHD_PKTTAG_SIGNALONLY_MASK << DHD_PKTTAG_SIGNALONLY_SHIFT)) | \
747 (((signalonly) & DHD_PKTTAG_SIGNALONLY_MASK) << DHD_PKTTAG_SIGNALONLY_SHIFT)
748#define DHD_PKTTAG_SIGNALONLY(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
749 DHD_PKTTAG_SIGNALONLY_SHIFT) & DHD_PKTTAG_SIGNALONLY_MASK)
750
751#define DHD_PKTTAG_SETONETIMEPKTRQST(tag) ((dhd_pkttag_t*)(tag))->if_flags = \
752 (((dhd_pkttag_t*)(tag))->if_flags & \
753 ~(DHD_PKTTAG_ONETIMEPKTRQST_MASK << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)) | \
754 (1 << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)
755#define DHD_PKTTAG_ONETIMEPKTRQST(tag) ((((dhd_pkttag_t*)(tag))->if_flags >> \
756 DHD_PKTTAG_ONETIMEPKTRQST_SHIFT) & DHD_PKTTAG_ONETIMEPKTRQST_MASK)
757
758#define DHD_PKTTAG_SETDSTN(tag, dstn_MAC_ea) memcpy(((dhd_pkttag_t*)((tag)))->dstn_ether, \
759 (dstn_MAC_ea), ETHER_ADDR_LEN)
760#define DHD_PKTTAG_DSTN(tag) ((dhd_pkttag_t*)(tag))->dstn_ether
761
762typedef int (*f_commitpkt_t)(void* ctx, void* p);
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700763
764#ifdef PROP_TXSTATUS_DEBUG
765#define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do { (entry)->closed_ct++; } while (0)
766#define DHD_WLFC_CTRINC_MAC_OPEN(entry) do { (entry)->opened_ct++; } while (0)
767#else
768#define DHD_WLFC_CTRINC_MAC_CLOSE(entry) do {} while (0)
769#define DHD_WLFC_CTRINC_MAC_OPEN(entry) do {} while (0)
770#endif
771
772#endif /* PROP_TXSTATUS */
773
774extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
775extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
776
Howard M. Hartef5b388b2011-05-27 16:07:36 -0700777#ifdef ARP_OFFLOAD_SUPPORT
Dmitry Shmidt8fd99382011-08-03 14:11:58 -0700778#define MAX_IPV4_ENTRIES 8
Howard M. Hartef5b388b2011-05-27 16:07:36 -0700779/* dhd_commn arp offload wrapers */
780void dhd_aoe_hostip_clr(dhd_pub_t *dhd);
781void dhd_aoe_arp_clr(dhd_pub_t *dhd);
782int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen);
783void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr);
784#endif /* ARP_OFFLOAD_SUPPORT */
Dmitry Shmidtc3c5c902011-09-21 13:09:58 -0700785
Dmitry Shmidt7972aa82011-05-24 11:14:33 -0700786#endif /* _dhd_h_ */