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