Staging: brcm80211: remove TRUE #define
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmfmac / dhd.h
CommitLineData
cf2b4488
HP
1/*
2 * Copyright (c) 2010 Broadcom Corporation
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/****************
18 * Common types *
19 */
20
21#ifndef _dhd_h_
22#define _dhd_h_
23
cf2b4488
HP
24#include <linux/sched.h>
25#include <linux/init.h>
26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/skbuff.h>
29#include <linux/netdevice.h>
30#include <linux/etherdevice.h>
31#include <linux/random.h>
32#include <linux/spinlock.h>
33#include <linux/ethtool.h>
34#include <asm/uaccess.h>
35#include <asm/unaligned.h>
36#if defined(CONFIG_HAS_WAKELOCK)
37#include <linux/wakelock.h>
38#endif /* defined (CONFIG_HAS_WAKELOCK) */
39/* The kernel threading is sdio-specific */
cf2b4488
HP
40
41#include <wlioctl.h>
42
43/* Forward decls */
44struct dhd_bus;
45struct dhd_prot;
46struct dhd_info;
47
48/* The level of bus communication with the dongle */
49enum dhd_bus_state {
50 DHD_BUS_DOWN, /* Not ready for frame transfers */
51 DHD_BUS_LOAD, /* Download access only (CPU reset) */
52 DHD_BUS_DATA /* Ready for frame transfers */
53};
54
55enum dhd_bus_wake_state {
56 WAKE_LOCK_OFF,
57 WAKE_LOCK_PRIV,
58 WAKE_LOCK_DPC,
59 WAKE_LOCK_IOCTL,
60 WAKE_LOCK_DOWNLOAD,
61 WAKE_LOCK_TMOUT,
62 WAKE_LOCK_WATCHDOG,
63 WAKE_LOCK_LINK_DOWN_TMOUT,
64 WAKE_LOCK_PNO_FIND_TMOUT,
65 WAKE_LOCK_SOFTAP_SET,
66 WAKE_LOCK_SOFTAP_STOP,
67 WAKE_LOCK_SOFTAP_START,
68 WAKE_LOCK_MAX
69};
70enum dhd_prealloc_index {
71 DHD_PREALLOC_PROT = 0,
72 DHD_PREALLOC_RXBUF,
73 DHD_PREALLOC_DATABUF,
74 DHD_PREALLOC_OSL_BUF
75};
76#ifdef DHD_USE_STATIC_BUF
77extern void *dhd_os_prealloc(int section, unsigned long size);
78#endif
79/* Common structure for module and instance linkage */
80typedef struct dhd_pub {
81 /* Linkage ponters */
82 osl_t *osh; /* OSL handle */
83 struct dhd_bus *bus; /* Bus module handle */
84 struct dhd_prot *prot; /* Protocol module handle */
85 struct dhd_info *info; /* Info module handle */
86
87 /* Internal dhd items */
88 bool up; /* Driver up/down (to OS) */
89 bool txoff; /* Transmit flow-controlled */
0f0881b0 90 bool dongle_reset; /* true = DEVRESET put dongle into reset */
cf2b4488
HP
91 enum dhd_bus_state busstate;
92 uint hdrlen; /* Total DHD header length (proto + bus) */
93 uint maxctl; /* Max size rxctl request from proto to bus */
94 uint rxsz; /* Rx buffer size bus module should use */
3fd79f7c 95 u8 wme_dp; /* wme discard priority */
cf2b4488
HP
96
97 /* Dongle media info */
98 bool iswl; /* Dongle-resident driver is wl */
3deea904 99 unsigned long drv_version; /* Version of dongle-resident driver */
cf2b4488
HP
100 struct ether_addr mac; /* MAC address obtained from dongle */
101 dngl_stats_t dstats; /* Stats for dongle-based data */
102
103 /* Additional stats for the bus level */
3deea904
GKH
104 unsigned long tx_packets; /* Data packets sent to dongle */
105 unsigned long tx_multicast; /* Multicast data packets sent to dongle */
106 unsigned long tx_errors; /* Errors in sending data to dongle */
107 unsigned long tx_ctlpkts; /* Control packets sent to dongle */
108 unsigned long tx_ctlerrs; /* Errors sending control frames to dongle */
109 unsigned long rx_packets; /* Packets sent up the network interface */
110 unsigned long rx_multicast; /* Multicast packets sent up the network
cf2b4488 111 interface */
3deea904
GKH
112 unsigned long rx_errors; /* Errors processing rx data packets */
113 unsigned long rx_ctlpkts; /* Control frames processed from dongle */
114 unsigned long rx_ctlerrs; /* Errors in processing rx control frames */
115 unsigned long rx_dropped; /* Packets dropped locally (no memory) */
116 unsigned long rx_flushed; /* Packets flushed due to
cf2b4488 117 unscheduled sendup thread */
3deea904 118 unsigned long wd_dpc_sched; /* Number of times dhd dpc scheduled by
cf2b4488
HP
119 watchdog timer */
120
3deea904 121 unsigned long rx_readahead_cnt; /* Number of packets where header read-ahead
cf2b4488 122 was used. */
3deea904 123 unsigned long tx_realloc; /* Number of tx packets we had to realloc for
cf2b4488 124 headroom */
3deea904 125 unsigned long fc_packets; /* Number of flow control pkts recvd */
cf2b4488
HP
126
127 /* Last error return */
128 int bcmerror;
129 uint tickcnt;
130
131 /* Last error from dongle */
132 int dongle_error;
133
134 /* Suspend disable flag flag */
135 int suspend_disable_flag; /* "1" to disable all extra powersaving
136 during suspend */
137 int in_suspend; /* flag set to 1 when early suspend called */
138#ifdef PNO_SUPPORT
139 int pno_enable; /* pno status : "1" is pno enable */
140#endif /* PNO_SUPPORT */
141 int dtim_skip; /* dtim skip , default 0 means wake each dtim */
142
143 /* Pkt filter defination */
144 char *pktfilter[100];
145 int pktfilter_count;
146
3fd79f7c 147 u8 country_code[WLC_CNTRY_BUF_SZ];
cf2b4488
HP
148 char eventmask[WL_EVENTING_MASK_LEN];
149
150#if defined(CONFIG_HAS_WAKELOCK)
151 struct wake_lock wakelock[WAKE_LOCK_MAX];
152#endif /* defined (CONFIG_HAS_WAKELOCK) */
153} dhd_pub_t;
154
155#if defined(CONFIG_PM_SLEEP)
156
157#define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
158#define _DHD_PM_RESUME_WAIT(a, b) do {\
159 int retry = 0; \
160 while (dhd_mmc_suspend && retry++ != b) { \
161 wait_event_timeout(a, FALSE, HZ/100); \
162 } \
163 } while (0)
164#define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 30)
165#define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
166#define DHD_PM_RESUME_RETURN_ERROR(a) \
167 do { if (dhd_mmc_suspend) return a; } while (0)
168#define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
169
170#define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
171#define SPINWAIT_SLEEP(a, exp, us) do { \
172 uint countdown = (us) + 9999; \
173 while ((exp) && (countdown >= 10000)) { \
174 wait_event_timeout(a, FALSE, HZ/100); \
175 countdown -= 10000; \
176 } \
177 } while (0)
178
179#else
180
181#define DHD_PM_RESUME_WAIT_INIT(a)
182#define DHD_PM_RESUME_WAIT(a)
183#define DHD_PM_RESUME_WAIT_FOREVER(a)
184#define DHD_PM_RESUME_RETURN_ERROR(a)
185#define DHD_PM_RESUME_RETURN
186
187#define DHD_SPINWAIT_SLEEP_INIT(a)
188#define SPINWAIT_SLEEP(a, exp, us) do { \
189 uint countdown = (us) + 9; \
190 while ((exp) && (countdown >= 10)) { \
191 OSL_DELAY(10); \
192 countdown -= 10; \
193 } \
194 } while (0)
195
196#endif /* defined(CONFIG_PM_SLEEP) */
197#define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
198
199static inline void MUTEX_LOCK_INIT(dhd_pub_t *dhdp)
200{
201}
202
203static inline void MUTEX_LOCK(dhd_pub_t *dhdp)
204{
205}
206
207static inline void MUTEX_UNLOCK(dhd_pub_t *dhdp)
208{
209}
210
211static inline void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t *dhdp)
212{
213}
214
215static inline void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t *dhdp)
216{
217}
218
219static inline void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t *dhdp)
220{
221}
222
223static inline void MUTEX_LOCK_WL_SCAN_SET_INIT(void)
224{
225}
226
227static inline void MUTEX_LOCK_WL_SCAN_SET(void)
228{
229}
230
231static inline void MUTEX_UNLOCK_WL_SCAN_SET(void)
232{
233}
234
235static inline void WAKE_LOCK_INIT(dhd_pub_t *dhdp, int index, char *y)
236{
237#if defined(CONFIG_HAS_WAKELOCK)
238 wake_lock_init(&dhdp->wakelock[index], WAKE_LOCK_SUSPEND, y);
239#endif /* defined (CONFIG_HAS_WAKELOCK) */
240}
241
242static inline void WAKE_LOCK(dhd_pub_t *dhdp, int index)
243{
244#if defined(CONFIG_HAS_WAKELOCK)
245 wake_lock(&dhdp->wakelock[index]);
246#endif /* defined (CONFIG_HAS_WAKELOCK) */
247}
248
249static inline void WAKE_UNLOCK(dhd_pub_t *dhdp, int index)
250{
251#if defined(CONFIG_HAS_WAKELOCK)
252 wake_unlock(&dhdp->wakelock[index]);
253#endif /* defined (CONFIG_HAS_WAKELOCK) */
254}
255
256static inline void WAKE_LOCK_TIMEOUT(dhd_pub_t *dhdp, int index, long time)
257{
258#if defined(CONFIG_HAS_WAKELOCK)
259 wake_lock_timeout(&dhdp->wakelock[index], time);
260#endif /* defined (CONFIG_HAS_WAKELOCK) */
261}
262
263static inline void WAKE_LOCK_DESTROY(dhd_pub_t *dhdp, int index)
264{
265#if defined(CONFIG_HAS_WAKELOCK)
266 wake_lock_destroy(&dhdp->wakelock[index]);
267#endif /* defined (CONFIG_HAS_WAKELOCK) */
268}
269
270typedef struct dhd_if_event {
3fd79f7c
GKH
271 u8 ifidx;
272 u8 action;
273 u8 flags;
274 u8 bssidx;
cf2b4488
HP
275} dhd_if_event_t;
276
277/*
278 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
279 */
280
281/* To allow osl_attach/detach calls from os-independent modules */
282osl_t *dhd_osl_attach(void *pdev, uint bustype);
283void dhd_osl_detach(osl_t *osh);
284
285/* Indication from bus module regarding presence/insertion of dongle.
286 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
287 * Returned structure should have bus and prot pointers filled in.
288 * bus_hdrlen specifies required headroom for bus module header.
289 */
290extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
291extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
292
293/* Indication from bus module regarding removal/absence of dongle */
294extern void dhd_detach(dhd_pub_t *dhdp);
295
296/* Indication from bus module to change flow-control state */
297extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
298
299extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
300
301/* Receive frame for delivery to OS. Callee disposes of rxp. */
302extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt);
303
304/* Return pointer to interface name */
305extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
306
307/* Request scheduling of the bus dpc */
308extern void dhd_sched_dpc(dhd_pub_t *dhdp);
309
310/* Notify tx completion */
311extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
312
313/* Query ioctl */
314extern int dhdcdc_query_ioctl(dhd_pub_t *dhd, int ifidx, uint cmd, void *buf,
315 uint len);
316
317/* OS independent layer functions */
318extern int dhd_os_proto_block(dhd_pub_t *pub);
319extern int dhd_os_proto_unblock(dhd_pub_t *pub);
320extern int dhd_os_ioctl_resp_wait(dhd_pub_t *pub, uint *condition,
321 bool *pending);
322extern int dhd_os_ioctl_resp_wake(dhd_pub_t *pub);
323extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
324extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
325extern void *dhd_os_open_image(char *filename);
326extern int dhd_os_get_image_block(char *buf, int len, void *image);
327extern void dhd_os_close_image(void *image);
328extern void dhd_os_wd_timer(void *bus, uint wdtick);
329extern void dhd_os_sdlock(dhd_pub_t *pub);
330extern void dhd_os_sdunlock(dhd_pub_t *pub);
331extern void dhd_os_sdlock_txq(dhd_pub_t *pub);
332extern void dhd_os_sdunlock_txq(dhd_pub_t *pub);
333extern void dhd_os_sdlock_rxq(dhd_pub_t *pub);
334extern void dhd_os_sdunlock_rxq(dhd_pub_t *pub);
335extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t *pub);
336extern void dhd_customer_gpio_wlan_ctrl(int onoff);
337extern int dhd_custom_get_mac_address(unsigned char *buf);
338extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t *pub);
339extern void dhd_os_sdlock_eventq(dhd_pub_t *pub);
340extern void dhd_os_sdunlock_eventq(dhd_pub_t *pub);
341#ifdef DHD_DEBUG
3fd79f7c 342extern int write_to_file(dhd_pub_t *dhd, u8 *buf, int size);
cf2b4488
HP
343#endif /* DHD_DEBUG */
344#if defined(OOB_INTR_ONLY)
345extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
346#endif /* defined(OOB_INTR_ONLY) */
347extern void dhd_os_sdtxlock(dhd_pub_t *pub);
348extern void dhd_os_sdtxunlock(dhd_pub_t *pub);
349
350int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
351
352typedef struct {
66cbd3ab
GKH
353 u32 limit; /* Expiration time (usec) */
354 u32 increment; /* Current expiration increment (usec) */
355 u32 elapsed; /* Current elapsed time (usec) */
356 u32 tick; /* O/S tick time (usec) */
cf2b4488
HP
357} dhd_timeout_t;
358
359extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
360extern int dhd_timeout_expired(dhd_timeout_t *tmo);
361
362extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
3fd79f7c 363extern u8 *dhd_bssidx2bssid(dhd_pub_t *dhd, int idx);
cf2b4488
HP
364extern int wl_host_event(struct dhd_info *dhd, int *idx, void *pktdata,
365 wl_event_msg_t *, void **data_ptr);
366extern void wl_event_to_host_order(wl_event_msg_t *evt);
367
368extern void dhd_common_init(void);
369
370extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
66cbd3ab 371 char *name, u8 *mac_addr, u32 flags, u8 bssidx);
cf2b4488
HP
372extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
373
374extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char *name);
375extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
376
377extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
580a0bd9 378extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, unsigned char * cp,
cf2b4488
HP
379 int len);
380
381/* Send packet to dongle via data channel */
382extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
383
384/* Send event to host */
385extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event,
386 void *data);
3fd79f7c 387extern int dhd_bus_devreset(dhd_pub_t *dhdp, u8 flag);
cf2b4488
HP
388extern uint dhd_bus_status(dhd_pub_t *dhdp);
389extern int dhd_bus_start(dhd_pub_t *dhdp);
390
391extern void print_buf(void *pbuf, int len, int bytes_per_line);
392
393typedef enum cust_gpio_modes {
394 WLAN_RESET_ON,
395 WLAN_RESET_OFF,
396 WLAN_POWER_ON,
397 WLAN_POWER_OFF
398} cust_gpio_modes_t;
399/*
400 * Insmod parameters for debug/test
401 */
402
403/* Watchdog timer interval */
404extern uint dhd_watchdog_ms;
405
406#if defined(DHD_DEBUG)
407/* Console output poll interval */
408extern uint dhd_console_ms;
409#endif /* defined(DHD_DEBUG) */
410
411/* Use interrupts */
412extern uint dhd_intr;
413
414/* Use polling */
415extern uint dhd_poll;
416
417/* ARP offload agent mode */
418extern uint dhd_arp_mode;
419
420/* ARP offload enable */
421extern uint dhd_arp_enable;
422
423/* Pkt filte enable control */
424extern uint dhd_pkt_filter_enable;
425
426/* Pkt filter init setup */
427extern uint dhd_pkt_filter_init;
428
429/* Pkt filter mode control */
430extern uint dhd_master_mode;
431
432/* Roaming mode control */
433extern uint dhd_roam;
434
435/* Roaming mode control */
436extern uint dhd_radio_up;
437
438/* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
439extern int dhd_idletime;
440#define DHD_IDLETIME_TICKS 1
441
442/* SDIO Drive Strength */
443extern uint dhd_sdiod_drive_strength;
444
445/* Override to force tx queueing all the time */
446extern uint dhd_force_tx_queueing;
447
448#ifdef SDTEST
449/* Echo packet generator (SDIO), pkts/s */
450extern uint dhd_pktgen;
451
452/* Echo packet len (0 => sawtooth, max 1800) */
453extern uint dhd_pktgen_len;
454#define MAX_PKTGEN_LEN 1800
455#endif
456
457/* optionally set by a module_param_string() */
458#define MOD_PARAM_PATHLEN 2048
459extern char fw_path[MOD_PARAM_PATHLEN];
460extern char nv_path[MOD_PARAM_PATHLEN];
461
462/* For supporting multiple interfaces */
463#define DHD_MAX_IFS 16
464#define DHD_DEL_IF -0xe
465#define DHD_BAD_IF -0xf
466
467extern void dhd_wait_for_event(dhd_pub_t *dhd, bool * lockvar);
468extern void dhd_wait_event_wakeup(dhd_pub_t *dhd);
469
470#endif /* _dhd_h_ */
This page took 0.076677 seconds and 5 git commands to generate.