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