add rk3288 pinctrl dts code
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rkwifi / bcmdhd / dhd.h
1 /*
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 Open Broadcom Corporation$
8  *
9  * $Id: dhd.h 419132 2013-08-19 21:33:05Z $
10  */
11
12 /****************
13  * Common types *
14  */
15
16 #ifndef _dhd_h_
17 #define _dhd_h_
18
19 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <linux/slab.h>
22 #include <linux/skbuff.h>
23 #include <linux/netdevice.h>
24 #include <linux/etherdevice.h>
25 #include <linux/random.h>
26 #include <linux/spinlock.h>
27 #include <linux/ethtool.h>
28 #include <linux/string.h>
29 #include <asm/uaccess.h>
30 #include <asm/unaligned.h>
31 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
32 #include <linux/wakelock.h>
33 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
34 /* The kernel threading is sdio-specific */
35 struct task_struct;
36 struct sched_param;
37 int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
38
39 #define ALL_INTERFACES  0xff
40
41 #include <wlioctl.h>
42 #include <wlfc_proto.h>
43
44 #if defined(NDISVER) && (NDISVER >= 0x0600)
45 #include <wdf.h>
46 #include <WdfMiniport.h>
47 #endif /* (NDISVER >= 0x0600)  */
48
49 #if defined(KEEP_ALIVE)
50 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
51 #define KEEP_ALIVE_PERIOD 55000
52 #define NULL_PKT_STR    "null_pkt"
53 #endif /* KEEP_ALIVE */
54 /* Forward decls */
55 struct dhd_bus;
56 struct dhd_prot;
57 struct dhd_info;
58 struct dhd_ioctl;
59 struct dhd_cmn;
60
61 /* The level of bus communication with the dongle */
62 enum dhd_bus_state {
63         DHD_BUS_DOWN,           /* Not ready for frame transfers */
64         DHD_BUS_LOAD,           /* Download access only (CPU reset) */
65         DHD_BUS_DATA            /* Ready for frame transfers */
66 };
67
68 #if defined(NDISVER) && (NDISVER >= 0x0600)
69 /* Firmware requested operation mode */
70 #define STA_MASK                        0x0001
71 #define HOSTAPD_MASK            0x0002
72 #define WFD_MASK                        0x0004
73 #define SOFTAP_FW_MASK  0x0008
74 #define P2P_GO_ENABLED          0x0010
75 #define P2P_GC_ENABLED          0x0020
76 #define CONCURENT_MASK          0x00F0
77 #endif /* (NDISVER >= 0x0600)  */
78
79 enum dhd_op_flags {
80 /* Firmware requested operation mode */
81         DHD_FLAG_STA_MODE                               = (1 << (0)), /* STA only */
82         DHD_FLAG_HOSTAP_MODE                            = (1 << (1)), /* SOFTAP only */
83         DHD_FLAG_P2P_MODE                               = (1 << (2)), /* P2P Only */
84         /* STA + P2P */
85         DHD_FLAG_CONCURR_SINGLE_CHAN_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_P2P_MODE),
86         DHD_FLAG_CONCURR_MULTI_CHAN_MODE                = (1 << (4)), /* STA + P2P */
87         /* Current P2P mode for P2P connection */
88         DHD_FLAG_P2P_GC_MODE                            = (1 << (5)),
89         DHD_FLAG_P2P_GO_MODE                            = (1 << (6)),
90         DHD_FLAG_MBSS_MODE                              = (1 << (7)), /* MBSS in future */
91         DHD_FLAG_IBSS_MODE                              = (1 << (8))
92 };
93
94 #define MANUFACTRING_FW         "WLTEST"
95
96 /* Max sequential TX/RX Control timeouts to set HANG event */
97 #ifndef MAX_CNTL_TX_TIMEOUT
98 #define MAX_CNTL_TX_TIMEOUT 2
99 #endif /* MAX_CNTL_TX_TIMEOUT */
100 #ifndef MAX_CNTL_RX_TIMEOUT
101 #define MAX_CNTL_RX_TIMEOUT 1
102 #endif /* MAX_CNTL_RX_TIMEOUT */
103
104 #define DHD_SCAN_ASSOC_ACTIVE_TIME      40 /* ms: Embedded default Active setting from DHD */
105 #define DHD_SCAN_UNASSOC_ACTIVE_TIME 80 /* ms: Embedded def. Unassoc Active setting from DHD */
106 #define DHD_SCAN_PASSIVE_TIME           130 /* ms: Embedded default Passive setting from DHD */
107
108 #ifndef POWERUP_MAX_RETRY
109 #define POWERUP_MAX_RETRY       3 /* how many times we retry to power up the chip */
110 #endif
111 #ifndef POWERUP_WAIT_MS
112 #define POWERUP_WAIT_MS         2000 /* ms: time out in waiting wifi to come up */
113 #endif
114
115 enum dhd_bus_wake_state {
116         WAKE_LOCK_OFF,
117         WAKE_LOCK_PRIV,
118         WAKE_LOCK_DPC,
119         WAKE_LOCK_IOCTL,
120         WAKE_LOCK_DOWNLOAD,
121         WAKE_LOCK_TMOUT,
122         WAKE_LOCK_WATCHDOG,
123         WAKE_LOCK_LINK_DOWN_TMOUT,
124         WAKE_LOCK_PNO_FIND_TMOUT,
125         WAKE_LOCK_SOFTAP_SET,
126         WAKE_LOCK_SOFTAP_STOP,
127         WAKE_LOCK_SOFTAP_START,
128         WAKE_LOCK_SOFTAP_THREAD
129 };
130
131 enum dhd_prealloc_index {
132         DHD_PREALLOC_PROT = 0,
133         DHD_PREALLOC_RXBUF,
134         DHD_PREALLOC_DATABUF,
135         DHD_PREALLOC_OSL_BUF,
136 #if defined(STATIC_WL_PRIV_STRUCT)
137         DHD_PREALLOC_WIPHY_ESCAN0 = 5,
138 #endif /* STATIC_WL_PRIV_STRUCT */
139         DHD_PREALLOC_DHD_INFO = 7
140 };
141
142 typedef enum  {
143         DHD_IF_NONE = 0,
144         DHD_IF_ADD,
145         DHD_IF_DEL,
146         DHD_IF_CHANGE,
147         DHD_IF_DELETING
148 } dhd_if_state_t;
149
150
151 typedef enum  {
152         DHD_IPV6_ADDR_NONE = 0,
153         DHD_IPV6_ADDR_ADD,
154         DHD_IPV6_ADDR_DELETE
155 } dhd_ipv6_op_t;
156
157
158 #if defined(CONFIG_DHD_USE_STATIC_BUF)
159
160 uint8* dhd_os_prealloc(void *osh, int section, uint size);
161 void dhd_os_prefree(void *osh, void *addr, uint size);
162 #define DHD_OS_PREALLOC(osh, section, size) dhd_os_prealloc(osh, section, size)
163 #define DHD_OS_PREFREE(osh, addr, size) dhd_os_prefree(osh, addr, size)
164
165 #else
166
167 #define DHD_OS_PREALLOC(osh, section, size) MALLOC(osh, size)
168 #define DHD_OS_PREFREE(osh, addr, size) MFREE(osh, addr, size)
169
170 #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
171
172 /* Packet alignment for most efficient SDIO (can change based on platform) */
173 #ifndef DHD_SDALIGN
174 #define DHD_SDALIGN     32
175 #endif
176
177 /* host reordering packts logic */
178 /* followed the structure to hold the reorder buffers (void **p) */
179 typedef struct reorder_info {
180         void **p;
181         uint8 flow_id;
182         uint8 cur_idx;
183         uint8 exp_idx;
184         uint8 max_idx;
185         uint8 pend_pkts;
186 } reorder_info_t;
187
188 #ifdef DHDTCPACK_SUPPRESS
189 #define MAXTCPSTREAMS 4 /* Keep this to be power of 2 */
190 typedef struct tcp_ack_info {
191         void *p_tcpackinqueue;
192         uint32 tcpack_number;
193         uint ip_tcp_ttllen;
194         uint8 ipaddrs[8];               /* Each 4bytes src and dst IP addrs */
195         uint8 tcpports[4];              /* Each 2bytes src and dst port number */
196 } tcp_ack_info_t;
197
198 void dhd_onoff_tcpack_sup(void *pub, bool on);
199 #endif /* DHDTCPACK_SUPPRESS */
200
201 /* Common structure for module and instance linkage */
202 typedef struct dhd_pub {
203         /* Linkage ponters */
204         osl_t *osh;             /* OSL handle */
205         struct dhd_bus *bus;    /* Bus module handle */
206         struct dhd_prot *prot;  /* Protocol module handle */
207         struct dhd_info  *info; /* Info module handle */
208         struct dhd_cmn  *cmn;   /* dhd_common module handle */
209
210         /* Internal dhd items */
211         bool up;                /* Driver up/down (to OS) */
212         bool txoff;             /* Transmit flow-controlled */
213         bool dongle_reset;  /* TRUE = DEVRESET put dongle into reset */
214         enum dhd_bus_state busstate;
215         uint hdrlen;            /* Total DHD header length (proto + bus) */
216         uint maxctl;            /* Max size rxctl request from proto to bus */
217         uint rxsz;              /* Rx buffer size bus module should use */
218         uint8 wme_dp;   /* wme discard priority */
219
220         /* Dongle media info */
221         bool iswl;              /* Dongle-resident driver is wl */
222         ulong drv_version;      /* Version of dongle-resident driver */
223         struct ether_addr mac;  /* MAC address obtained from dongle */
224         dngl_stats_t dstats;    /* Stats for dongle-based data */
225
226         /* Additional stats for the bus level */
227         ulong tx_packets;       /* Data packets sent to dongle */
228         ulong tx_multicast;     /* Multicast data packets sent to dongle */
229         ulong tx_errors;        /* Errors in sending data to dongle */
230         ulong tx_ctlpkts;       /* Control packets sent to dongle */
231         ulong tx_ctlerrs;       /* Errors sending control frames to dongle */
232         ulong rx_packets;       /* Packets sent up the network interface */
233         ulong rx_multicast;     /* Multicast packets sent up the network interface */
234         ulong rx_errors;        /* Errors processing rx data packets */
235         ulong rx_ctlpkts;       /* Control frames processed from dongle */
236         ulong rx_ctlerrs;       /* Errors in processing rx control frames */
237         ulong rx_dropped;       /* Packets dropped locally (no memory) */
238         ulong rx_flushed;  /* Packets flushed due to unscheduled sendup thread */
239         ulong wd_dpc_sched;   /* Number of times dhd dpc scheduled by watchdog timer */
240
241         ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
242         ulong tx_realloc;       /* Number of tx packets we had to realloc for headroom */
243         ulong fc_packets;       /* Number of flow control pkts recvd */
244
245         /* Last error return */
246         int bcmerror;
247         uint tickcnt;
248
249         /* Last error from dongle */
250         int dongle_error;
251
252         uint8 country_code[WLC_CNTRY_BUF_SZ];
253
254         /* Suspend disable flag and "in suspend" flag */
255         int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
256         int in_suspend;                 /* flag set to 1 when early suspend called */
257         /* DTIM skip value, default 0(or 1) means wake each DTIM
258          * 3 means skip 2 DTIMs and wake up 3rd DTIM(9th beacon when AP DTIM is 3)
259          */
260         int suspend_bcn_li_dtim;         /* bcn_li_dtim value in suspend mode */
261 #ifdef PKT_FILTER_SUPPORT
262         int early_suspended;    /* Early suspend status */
263         int dhcp_in_progress;   /* DHCP period */
264 #endif
265
266         /* Pkt filter defination */
267         char * pktfilter[100];
268         int pktfilter_count;
269
270         wl_country_t dhd_cspec;         /* Current Locale info */
271         char eventmask[WL_EVENTING_MASK_LEN];
272         int     op_mode;                                /* STA, HostAPD, WFD, SoftAP */
273
274 /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
275  *  For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
276  *  see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
277  */
278 /* #define WL_ENABLE_P2P_IF             1 */
279
280 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
281         struct mutex    wl_start_stop_lock; /* lock/unlock for Android start/stop */
282         struct mutex    wl_softap_lock;          /* lock/unlock for any SoftAP/STA settings */
283 #endif 
284
285 #ifdef WLBTAMP
286         uint16  maxdatablks;
287 #endif /* WLBTAMP */
288 #ifdef PROP_TXSTATUS
289         int     wlfc_enabled;
290         void*   wlfc_state;
291         int     ptx_opt_enabled;
292         bool    pending_tx_pkts;
293
294         /*
295          * implement below functions in each platform if needed.
296          */
297         /* platform specific function whether to skip flow control */
298         bool (*skip_fc)(void);
299         /* platform specific function for wlfc_enable and wlfc_deinit */
300         void (*plat_enable)(void *dhd);
301         void (*plat_deinit)(void *dhd);
302 #endif
303 #ifdef PNO_SUPPORT
304         void *pno_state;
305 #endif
306         bool    dongle_isolation;
307         bool    dongle_trap_occured;    /* flag for sending HANG event to upper layer */
308         int   hang_was_sent;
309         int   rxcnt_timeout;            /* counter rxcnt timeout to send HANG */
310         int   txcnt_timeout;            /* counter txcnt timeout to send HANG */
311         bool hang_report;               /* enable hang report by default */
312 #ifdef WLMEDIA_HTSF
313         uint8 htsfdlystat_sz; /* Size of delay stats, max 255B */
314 #endif
315 #ifdef WLTDLS
316         bool tdls_enable;
317 #endif
318         struct reorder_info *reorder_bufs[WLHOST_REORDERDATA_MAXFLOWS];
319         char  fw_capabilities[WLC_IOCTL_SMLEN];
320 #ifdef RXFRAME_THREAD
321 #define MAXSKBPEND 1024
322         void *skbbuf[MAXSKBPEND];
323         uint32 store_idx;
324         uint32 sent_idx;
325 #endif /* RXFRAME_THREAD */
326 #ifdef DHDTCPACK_SUPPRESS
327         int tcp_ack_info_cnt;
328         tcp_ack_info_t tcp_ack_info_tbl[MAXTCPSTREAMS];
329 #endif /* DHDTCPACK_SUPPRESS */
330         uint32 arp_version;
331 #if defined(BCMSUP_4WAY_HANDSHAKE) && defined(WLAN_AKM_SUITE_FT_8021X)
332         bool fw_4way_handshake;         /* Whether firmware will to do the 4way handshake. */
333 #endif
334         char            *conf_path;             /* module_param: path to config vars file */
335         struct dhd_conf *conf;  /* Bus module handle */
336 } dhd_pub_t;
337
338 typedef struct dhd_cmn {
339         osl_t *osh;             /* OSL handle */
340         dhd_pub_t *dhd;
341 } dhd_cmn_t;
342
343         #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
344
345         #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
346         #define _DHD_PM_RESUME_WAIT(a, b) do {\
347                         int retry = 0; \
348                         SMP_RD_BARRIER_DEPENDS(); \
349                         while (dhd_mmc_suspend && retry++ != b) { \
350                                 SMP_RD_BARRIER_DEPENDS(); \
351                                 wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
352                         } \
353                 }       while (0)
354         #define DHD_PM_RESUME_WAIT(a)           _DHD_PM_RESUME_WAIT(a, 200)
355         #define DHD_PM_RESUME_WAIT_FOREVER(a)   _DHD_PM_RESUME_WAIT(a, ~0)
356         #define DHD_PM_RESUME_RETURN_ERROR(a)   do { if (dhd_mmc_suspend) return a; } while (0)
357         #define DHD_PM_RESUME_RETURN            do { if (dhd_mmc_suspend) return; } while (0)
358
359         #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
360         #define SPINWAIT_SLEEP(a, exp, us) do { \
361                 uint countdown = (us) + 9999; \
362                 while ((exp) && (countdown >= 10000)) { \
363                         wait_event_interruptible_timeout(a, FALSE, 1); \
364                         countdown -= 10000; \
365                 } \
366         } while (0)
367
368         #else
369
370         #define DHD_PM_RESUME_WAIT_INIT(a)
371         #define DHD_PM_RESUME_WAIT(a)
372         #define DHD_PM_RESUME_WAIT_FOREVER(a)
373         #define DHD_PM_RESUME_RETURN_ERROR(a)
374         #define DHD_PM_RESUME_RETURN
375
376         #define DHD_SPINWAIT_SLEEP_INIT(a)
377         #define SPINWAIT_SLEEP(a, exp, us)  do { \
378                 uint countdown = (us) + 9; \
379                 while ((exp) && (countdown >= 10)) { \
380                         OSL_DELAY(10);  \
381                         countdown -= 10;  \
382                 } \
383         } while (0)
384
385         #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
386 #ifndef DHDTHREAD
387 #undef  SPINWAIT_SLEEP
388 #define SPINWAIT_SLEEP(a, exp, us) SPINWAIT(exp, us)
389 #endif /* DHDTHREAD */
390
391 #ifndef OSL_SLEEP
392 #define OSL_SLEEP(ms)           OSL_DELAY(ms*1000)
393 #endif /* OSL_SLEEP */
394
395 #define DHD_IF_VIF      0x01    /* Virtual IF (Hidden from user) */
396
397 unsigned long dhd_os_spin_lock(dhd_pub_t *pub);
398 void dhd_os_spin_unlock(dhd_pub_t *pub, unsigned long flags);
399
400 /*  Wakelock Functions */
401 extern int dhd_os_wake_lock(dhd_pub_t *pub);
402 extern int dhd_os_wake_unlock(dhd_pub_t *pub);
403 extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
404 extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
405 extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
406 extern int dhd_os_wd_wake_lock(dhd_pub_t *pub);
407 extern int dhd_os_wd_wake_unlock(dhd_pub_t *pub);
408
409 inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
410 {
411 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
412         mutex_init(&dhdp->wl_softap_lock);
413 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
414 }
415
416 inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
417 {
418 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
419         mutex_lock(&dhdp->wl_softap_lock);
420 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
421 }
422
423 inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
424 {
425 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1
426         mutex_unlock(&dhdp->wl_softap_lock);
427 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
428 }
429
430 #define DHD_OS_WAKE_LOCK(pub)                   dhd_os_wake_lock(pub)
431 #define DHD_OS_WAKE_UNLOCK(pub)         dhd_os_wake_unlock(pub)
432 #define DHD_OS_WD_WAKE_LOCK(pub)                dhd_os_wd_wake_lock(pub)
433 #define DHD_OS_WD_WAKE_UNLOCK(pub)              dhd_os_wd_wake_unlock(pub)
434 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub)           dhd_os_wake_lock_timeout(pub)
435 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
436         dhd_os_wake_lock_rx_timeout_enable(pub, val)
437 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
438         dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
439 #define DHD_PACKET_TIMEOUT_MS   1000
440 #define DHD_EVENT_TIMEOUT_MS    1500
441
442 /* interface operations (register, remove) should be atomic, use this lock to prevent race
443  * condition among wifi on/off and interface operation functions
444  */
445 void dhd_net_if_lock(struct net_device *dev);
446 void dhd_net_if_unlock(struct net_device *dev);
447
448 #if defined(MULTIPLE_SUPPLICANT)
449 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1 && 1
450 extern struct mutex _dhd_sdio_mutex_lock_;
451 #endif
452 #endif /* MULTIPLE_SUPPLICANT */
453
454 typedef struct dhd_if_event {
455         uint8 ifidx;
456         uint8 action;
457         uint8 flags;
458         uint8 bssidx;
459         uint8 is_AP;
460 } dhd_if_event_t;
461
462 typedef enum dhd_attach_states
463 {
464         DHD_ATTACH_STATE_INIT = 0x0,
465         DHD_ATTACH_STATE_NET_ALLOC = 0x1,
466         DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
467         DHD_ATTACH_STATE_ADD_IF = 0x4,
468         DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
469         DHD_ATTACH_STATE_WL_ATTACH = 0x10,
470         DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
471         DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
472         DHD_ATTACH_STATE_CFG80211 = 0x80,
473         DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
474         DHD_ATTACH_STATE_DONE = 0x200
475 } dhd_attach_states_t;
476
477 /* Value -1 means we are unsuccessful in creating the kthread. */
478 #define DHD_PID_KT_INVALID      -1
479 /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
480 #define DHD_PID_KT_TL_INVALID   -2
481
482 /*
483  * Exported from dhd OS modules (dhd_linux/dhd_ndis)
484  */
485
486 /* To allow osl_attach/detach calls from os-independent modules */
487 osl_t *dhd_osl_attach(void *pdev, uint bustype);
488 void dhd_osl_detach(osl_t *osh);
489
490 /* Indication from bus module regarding presence/insertion of dongle.
491  * Return dhd_pub_t pointer, used as handle to OS module in later calls.
492  * Returned structure should have bus and prot pointers filled in.
493  * bus_hdrlen specifies required headroom for bus module header.
494  */
495 extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
496 #if defined(WLP2P) && defined(WL_CFG80211)
497 /* To allow attach/detach calls corresponding to p2p0 interface  */
498 extern int dhd_attach_p2p(dhd_pub_t *);
499 extern int dhd_detach_p2p(dhd_pub_t *);
500 #endif /* WLP2P && WL_CFG80211 */
501 extern int dhd_net_attach(dhd_pub_t *dhdp, int idx);
502
503 /* Indication from bus module regarding removal/absence of dongle */
504 extern void dhd_detach(dhd_pub_t *dhdp);
505 extern void dhd_free(dhd_pub_t *dhdp);
506
507 /* Indication from bus module to change flow-control state */
508 extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
509
510 /* Store the status of a connection attempt for later retrieval by an iovar */
511 extern void dhd_store_conn_status(uint32 event, uint32 status, uint32 reason);
512
513 extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
514
515 /* Receive frame for delivery to OS.  Callee disposes of rxp. */
516 extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
517
518 /* Return pointer to interface name */
519 extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
520
521 /* Request scheduling of the bus dpc */
522 extern void dhd_sched_dpc(dhd_pub_t *dhdp);
523
524 /* Notify tx completion */
525 extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
526
527 /* OS independent layer functions */
528 extern int dhd_os_proto_block(dhd_pub_t * pub);
529 extern int dhd_os_proto_unblock(dhd_pub_t * pub);
530 extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition, bool * pending);
531 extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
532 extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
533 extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
534 extern void * dhd_os_open_image(char * filename);
535 extern int dhd_os_get_image_block(char * buf, int len, void * image);
536 extern void dhd_os_close_image(void * image);
537 extern void dhd_os_wd_timer(void *bus, uint wdtick);
538 extern void dhd_os_sdlock(dhd_pub_t * pub);
539 extern void dhd_os_sdunlock(dhd_pub_t * pub);
540 extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
541 extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
542 extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
543 extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
544 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
545 #ifdef DHDTCPACK_SUPPRESS
546 extern void dhd_os_tcpacklock(dhd_pub_t *pub);
547 extern void dhd_os_tcpackunlock(dhd_pub_t *pub);
548 #endif /* DHDTCPACK_SUPPRESS */
549
550 extern void dhd_customer_gpio_wlan_ctrl(int onoff);
551 extern int dhd_custom_get_mac_address(unsigned char *buf);
552 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
553 extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
554 extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
555 extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
556 extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
557 extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
558
559 #if defined(KEEP_ALIVE)
560 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
561 #endif /* KEEP_ALIVE */
562
563
564 #ifdef PKT_FILTER_SUPPORT
565 #define DHD_UNICAST_FILTER_NUM          0
566 #define DHD_BROADCAST_FILTER_NUM        1
567 #define DHD_MULTICAST4_FILTER_NUM       2
568 #define DHD_MULTICAST6_FILTER_NUM       3
569 #define DHD_MDNS_FILTER_NUM             4
570 #define DHD_ARP_FILTER_NUM              5
571 extern int      dhd_os_enable_packet_filter(dhd_pub_t *dhdp, int val);
572 extern void dhd_enable_packet_filter(int value, dhd_pub_t *dhd);
573 extern int net_os_enable_packet_filter(struct net_device *dev, int val);
574 extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
575 #endif /* PKT_FILTER_SUPPORT */
576
577 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
578 extern bool dhd_support_sta_mode(dhd_pub_t *dhd);
579
580 #ifdef DHD_DEBUG
581 extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
582 #endif /* DHD_DEBUG */
583 #if defined(OOB_INTR_ONLY)
584 extern int dhd_customer_oob_irq_map(unsigned long *irq_flags_ptr);
585 #endif 
586 extern void dhd_os_sdtxlock(dhd_pub_t * pub);
587 extern void dhd_os_sdtxunlock(dhd_pub_t * pub);
588
589 typedef struct {
590         uint32 limit;           /* Expiration time (usec) */
591         uint32 increment;       /* Current expiration increment (usec) */
592         uint32 elapsed;         /* Current elapsed time (usec) */
593         uint32 tick;            /* O/S tick time (usec) */
594 } dhd_timeout_t;
595
596 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
597 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
598
599 extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
600 extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
601 extern struct net_device * dhd_idx2net(void *pub, int ifidx);
602 extern int net_os_send_hang_message(struct net_device *dev);
603 extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata,
604                          wl_event_msg_t *, void **data_ptr);
605 extern void wl_event_to_host_order(wl_event_msg_t * evt);
606
607 extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
608 extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
609                             int ifindex);
610 extern void dhd_common_init(osl_t *osh);
611 extern void dhd_common_deinit(dhd_pub_t *dhd_pub, dhd_cmn_t *sa_cmn);
612
613 extern int dhd_do_driver_init(struct net_device *net);
614 extern int dhd_add_if(struct dhd_info *dhd, int ifidx, void *handle,
615         char *name, uint8 *mac_addr, uint32 flags, uint8 bssidx);
616 extern void dhd_del_if(struct dhd_info *dhd, int ifidx);
617
618 extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
619 extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
620
621 extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
622 extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
623
624
625 /* Send packet to dongle via data channel */
626 extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
627
628 /* send up locally generated event */
629 extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
630 /* Send event to host */
631 extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
632 extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
633 extern uint dhd_bus_status(dhd_pub_t *dhdp);
634 extern int  dhd_bus_start(dhd_pub_t *dhdp);
635 extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
636 extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
637 extern bool dhd_is_associated(dhd_pub_t *dhd, void *bss_buf, int *retval);
638 extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
639 extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
640 extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
641
642 #if defined(KEEP_ALIVE)
643 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
644 #endif /* KEEP_ALIVE */
645
646 extern bool dhd_is_concurrent_mode(dhd_pub_t *dhd);
647 extern int dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf, uint cmd_len, int set);
648 typedef enum cust_gpio_modes {
649         WLAN_RESET_ON,
650         WLAN_RESET_OFF,
651         WLAN_POWER_ON,
652         WLAN_POWER_OFF
653 } cust_gpio_modes_t;
654
655 extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
656 extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
657 /*
658  * Insmod parameters for debug/test
659  */
660
661 /* Watchdog timer interval */
662 extern uint dhd_watchdog_ms;
663
664 #if defined(DHD_DEBUG)
665 /* Console output poll interval */
666 extern uint dhd_console_ms;
667 #endif /* defined(DHD_DEBUG) */
668 extern uint android_msg_level;
669 extern uint config_msg_level;
670 #ifdef WL_WIRELESS_EXT
671 extern uint iw_msg_level;
672 #endif
673 #ifdef WL_CFG80211
674 extern uint wl_dbg_level;
675 #endif
676 extern uint dhd_slpauto;
677
678 /* Use interrupts */
679 extern uint dhd_intr;
680
681 /* Use polling */
682 extern uint dhd_poll;
683
684 /* ARP offload agent mode */
685 extern uint dhd_arp_mode;
686
687 /* ARP offload enable */
688 extern uint dhd_arp_enable;
689
690 /* Pkt filte enable control */
691 extern uint dhd_pkt_filter_enable;
692
693 /*  Pkt filter init setup */
694 extern uint dhd_pkt_filter_init;
695
696 /* Pkt filter mode control */
697 extern uint dhd_master_mode;
698
699 /* Roaming mode control */
700 extern uint dhd_roam_disable;
701
702 /* Roaming mode control */
703 extern uint dhd_radio_up;
704
705 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
706 extern int dhd_idletime;
707 #ifdef DHD_USE_IDLECOUNT
708 #define DHD_IDLETIME_TICKS 5
709 #else
710 #define DHD_IDLETIME_TICKS 1
711 #endif /* DHD_USE_IDLECOUNT */
712
713 /* SDIO Drive Strength */
714 extern uint dhd_sdiod_drive_strength;
715
716 /* Override to force tx queueing all the time */
717 extern uint dhd_force_tx_queueing;
718 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
719 #define DEFAULT_KEEP_ALIVE_VALUE        55000 /* msec */
720 #ifndef CUSTOM_KEEP_ALIVE_SETTING
721 #define CUSTOM_KEEP_ALIVE_SETTING       DEFAULT_KEEP_ALIVE_VALUE
722 #endif /* DEFAULT_KEEP_ALIVE_VALUE */
723
724 #define NULL_PKT_STR    "null_pkt"
725
726 /* hooks for custom glom setting option via Makefile */
727 #define DEFAULT_GLOM_VALUE      -1
728 #ifndef CUSTOM_GLOM_SETTING
729 #define CUSTOM_GLOM_SETTING     DEFAULT_GLOM_VALUE
730 #endif
731 #define WL_AUTO_ROAM_TRIGGER -75
732 /* hooks for custom Roaming Trigger  setting via Makefile */
733 #define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
734 #define DEFAULT_ROAM_TRIGGER_SETTING    -1
735 #ifndef CUSTOM_ROAM_TRIGGER_SETTING
736 #define CUSTOM_ROAM_TRIGGER_SETTING     DEFAULT_ROAM_TRIGGER_VALUE
737 #endif
738
739 /* hooks for custom Roaming Romaing  setting via Makefile */
740 #define DEFAULT_ROAM_DELTA_VALUE  10 /* dBm default roam delta all band */
741 #define DEFAULT_ROAM_DELTA_SETTING      -1
742 #ifndef CUSTOM_ROAM_DELTA_SETTING
743 #define CUSTOM_ROAM_DELTA_SETTING       DEFAULT_ROAM_DELTA_VALUE
744 #endif
745
746 /* hooks for custom PNO Event wake lock to guarantee enough time
747         for the Platform to detect Event before system suspended
748 */
749 #define DEFAULT_PNO_EVENT_LOCK_xTIME    2       /* multiplay of DHD_PACKET_TIMEOUT_MS */
750 #ifndef CUSTOM_PNO_EVENT_LOCK_xTIME
751 #define CUSTOM_PNO_EVENT_LOCK_xTIME      DEFAULT_PNO_EVENT_LOCK_xTIME
752 #endif
753
754 /* hooks for custom dhd_dpc_prio setting option via Makefile */
755 #define DEFAULT_DHP_DPC_PRIO  1
756 #ifndef CUSTOM_DPC_PRIO_SETTING
757 #define CUSTOM_DPC_PRIO_SETTING         DEFAULT_DHP_DPC_PRIO
758 #endif
759
760 #ifndef CUSTOM_LISTEN_INTERVAL
761 #define CUSTOM_LISTEN_INTERVAL          LISTEN_INTERVAL
762 #endif /* CUSTOM_LISTEN_INTERVAL */
763
764 #define DEFAULT_SUSPEND_BCN_LI_DTIM             3
765 #ifndef CUSTOM_SUSPEND_BCN_LI_DTIM
766 #define CUSTOM_SUSPEND_BCN_LI_DTIM              DEFAULT_SUSPEND_BCN_LI_DTIM
767 #endif
768
769 #define DEFAULT_WIFI_TURNOFF_DELAY      0
770 #ifndef WIFI_TURNOFF_DELAY
771 #define WIFI_TURNOFF_DELAY              DEFAULT_WIFI_TURNOFF_DELAY
772 #endif /* WIFI_TURNOFF_DELAY */
773
774 #ifdef RXFRAME_THREAD
775 #ifndef CUSTOM_RXF_PRIO_SETTING
776 #define CUSTOM_RXF_PRIO_SETTING         MAX((CUSTOM_DPC_PRIO_SETTING - 1), 1)
777 #endif
778 #endif /* RXFRAME_THREAD */
779
780 #ifdef WLTDLS
781 #ifndef CUSTOM_TDLS_IDLE_MODE_SETTING
782 #define CUSTOM_TDLS_IDLE_MODE_SETTING  60000 /* 60sec to tear down TDLS of not active */
783 #endif
784 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_HIGH
785 #define CUSTOM_TDLS_RSSI_THRESHOLD_HIGH -70 /* rssi threshold for establishing TDLS link */
786 #endif
787 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_LOW
788 #define CUSTOM_TDLS_RSSI_THRESHOLD_LOW -80 /* rssi threshold for tearing down TDLS link */
789 #endif
790 #endif /* WLTDLS */
791
792
793 #define MAX_DTIM_SKIP_BEACON_ITERVAL    100 /* max allowed associated AP beacon for dtim skip */
794
795 #ifdef SDTEST
796 /* Echo packet generator (SDIO), pkts/s */
797 extern uint dhd_pktgen;
798
799 /* Echo packet len (0 => sawtooth, max 1800) */
800 extern uint dhd_pktgen_len;
801 #define MAX_PKTGEN_LEN 1800
802 #endif
803
804
805 /* optionally set by a module_param_string() */
806 #define MOD_PARAM_PATHLEN       2048
807 extern char fw_path[MOD_PARAM_PATHLEN];
808 extern char nv_path[MOD_PARAM_PATHLEN];
809 extern char conf_path[MOD_PARAM_PATHLEN];
810
811 #define MOD_PARAM_INFOLEN       512
812 #ifdef SOFTAP
813 extern char fw_path2[MOD_PARAM_PATHLEN];
814 #endif
815
816 /* Flag to indicate if we should download firmware on driver load */
817 extern uint dhd_download_fw_on_driverload;
818
819
820 /* For supporting multiple interfaces */
821 #define DHD_MAX_IFS     16
822 #define DHD_DEL_IF      -0xe
823 #define DHD_BAD_IF      -0xf
824
825 #ifdef PROP_TXSTATUS
826 /* Please be mindful that total pkttag space is 32 octets only */
827 typedef struct dhd_pkttag {
828         /*
829         b[14:13]  - encryption exemption
830         b[12 ] - 1 = event channel
831         b[11 ] - 1 = this packet was sent in response to one time packet request,
832         do not increment credit on status for this one. [WLFC_CTL_TYPE_MAC_REQUEST_PACKET].
833         b[10 ] - 1 = signal-only-packet to firmware [i.e. nothing to piggyback on]
834         b[9  ] - 1 = packet is host->firmware (transmit direction)
835                - 0 = packet received from firmware (firmware->host)
836         b[8  ] - 1 = packet was sent due to credit_request (pspoll),
837                      packet does not count against FIFO credit.
838                - 0 = normal transaction, packet counts against FIFO credit
839         b[7  ] - 1 = AP, 0 = STA
840         b[6:4] - AC FIFO number
841         b[3:0] - interface index
842         */
843         uint16  if_flags;
844         /* destination MAC address for this packet so that not every
845         module needs to open the packet to find this
846         */
847         uint8   dstn_ether[ETHER_ADDR_LEN];
848         /*
849         This 32-bit goes from host to device for every packet.
850         */
851         uint32  htod_tag;
852         /* bus specific stuff */
853         union {
854                 struct {
855                         void* stuff;
856                         uint32 thing1;
857                         uint32 thing2;
858                 } sd;
859                 struct {
860                         void* bus;
861                         void* urb;
862                 } usb;
863         } bus_specific;
864 } dhd_pkttag_t;
865
866 #define DHD_PKTTAG_SET_H2DTAG(tag, h2dvalue)    ((dhd_pkttag_t*)(tag))->htod_tag = (h2dvalue)
867 #define DHD_PKTTAG_H2DTAG(tag)                                  (((dhd_pkttag_t*)(tag))->htod_tag)
868
869 #define DHD_PKTTAG_IFMASK               0xf
870 #define DHD_PKTTAG_IFTYPE_MASK  0x1
871 #define DHD_PKTTAG_IFTYPE_SHIFT 7
872 #define DHD_PKTTAG_FIFO_MASK    0x7
873 #define DHD_PKTTAG_FIFO_SHIFT   4
874
875 #define DHD_PKTTAG_SIGNALONLY_MASK                      0x1
876 #define DHD_PKTTAG_SIGNALONLY_SHIFT                     10
877
878 #define DHD_PKTTAG_ONETIMEPKTRQST_MASK          0x1
879 #define DHD_PKTTAG_ONETIMEPKTRQST_SHIFT         11
880
881 #define DHD_PKTTAG_EVENT_MASK                           0x1
882 #define DHD_PKTTAG_EVENT_SHIFT                          12
883
884 #define DHD_PKTTAG_EXEMPT_MASK                          0x3
885 #define DHD_PKTTAG_EXEMPT_SHIFT                         13
886
887 #define DHD_PKTTAG_PKTDIR_MASK                  0x1
888 #define DHD_PKTTAG_PKTDIR_SHIFT                 9
889
890 #define DHD_PKTTAG_CREDITCHECK_MASK             0x1
891 #define DHD_PKTTAG_CREDITCHECK_SHIFT    8
892
893 #define DHD_PKTTAG_INVALID_FIFOID 0x7
894
895 #define DHD_PKTTAG_SETFIFO(tag, fifo)   ((dhd_pkttag_t*)(tag))->if_flags = \
896         (((dhd_pkttag_t*)(tag))->if_flags & ~(DHD_PKTTAG_FIFO_MASK << DHD_PKTTAG_FIFO_SHIFT)) | \
897         (((fifo) & DHD_PKTTAG_FIFO_MASK) << DHD_PKTTAG_FIFO_SHIFT)
898 #define DHD_PKTTAG_FIFO(tag)                    ((((dhd_pkttag_t*)(tag))->if_flags >> \
899         DHD_PKTTAG_FIFO_SHIFT) & DHD_PKTTAG_FIFO_MASK)
900
901 #define DHD_PKTTAG_SETIF(tag, if)       ((dhd_pkttag_t*)(tag))->if_flags = \
902         (((dhd_pkttag_t*)(tag))->if_flags & ~DHD_PKTTAG_IFMASK) | ((if) & DHD_PKTTAG_IFMASK)
903 #define DHD_PKTTAG_IF(tag)      (((dhd_pkttag_t*)(tag))->if_flags & DHD_PKTTAG_IFMASK)
904
905 #define DHD_PKTTAG_SETIFTYPE(tag, isAP) ((dhd_pkttag_t*)(tag))->if_flags = \
906         (((dhd_pkttag_t*)(tag))->if_flags & \
907         ~(DHD_PKTTAG_IFTYPE_MASK << DHD_PKTTAG_IFTYPE_SHIFT)) | \
908         (((isAP) & DHD_PKTTAG_IFTYPE_MASK) << DHD_PKTTAG_IFTYPE_SHIFT)
909 #define DHD_PKTTAG_IFTYPE(tag)  ((((dhd_pkttag_t*)(tag))->if_flags >> \
910         DHD_PKTTAG_IFTYPE_SHIFT) & DHD_PKTTAG_IFTYPE_MASK)
911
912 #define DHD_PKTTAG_SETCREDITCHECK(tag, check)   ((dhd_pkttag_t*)(tag))->if_flags = \
913         (((dhd_pkttag_t*)(tag))->if_flags & \
914         ~(DHD_PKTTAG_CREDITCHECK_MASK << DHD_PKTTAG_CREDITCHECK_SHIFT)) | \
915         (((check) & DHD_PKTTAG_CREDITCHECK_MASK) << DHD_PKTTAG_CREDITCHECK_SHIFT)
916 #define DHD_PKTTAG_CREDITCHECK(tag)     ((((dhd_pkttag_t*)(tag))->if_flags >> \
917         DHD_PKTTAG_CREDITCHECK_SHIFT) & DHD_PKTTAG_CREDITCHECK_MASK)
918
919 #define DHD_PKTTAG_SETPKTDIR(tag, dir)  ((dhd_pkttag_t*)(tag))->if_flags = \
920         (((dhd_pkttag_t*)(tag))->if_flags & \
921         ~(DHD_PKTTAG_PKTDIR_MASK << DHD_PKTTAG_PKTDIR_SHIFT)) | \
922         (((dir) & DHD_PKTTAG_PKTDIR_MASK) << DHD_PKTTAG_PKTDIR_SHIFT)
923 #define DHD_PKTTAG_PKTDIR(tag)  ((((dhd_pkttag_t*)(tag))->if_flags >> \
924         DHD_PKTTAG_PKTDIR_SHIFT) & DHD_PKTTAG_PKTDIR_MASK)
925
926 #define DHD_PKTTAG_SETSIGNALONLY(tag, signalonly)       ((dhd_pkttag_t*)(tag))->if_flags = \
927         (((dhd_pkttag_t*)(tag))->if_flags & \
928         ~(DHD_PKTTAG_SIGNALONLY_MASK << DHD_PKTTAG_SIGNALONLY_SHIFT)) | \
929         (((signalonly) & DHD_PKTTAG_SIGNALONLY_MASK) << DHD_PKTTAG_SIGNALONLY_SHIFT)
930 #define DHD_PKTTAG_SIGNALONLY(tag)      ((((dhd_pkttag_t*)(tag))->if_flags >> \
931         DHD_PKTTAG_SIGNALONLY_SHIFT) & DHD_PKTTAG_SIGNALONLY_MASK)
932
933 #define DHD_PKTTAG_SETONETIMEPKTRQST(tag)       ((dhd_pkttag_t*)(tag))->if_flags = \
934         (((dhd_pkttag_t*)(tag))->if_flags & \
935         ~(DHD_PKTTAG_ONETIMEPKTRQST_MASK << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)) | \
936         (1 << DHD_PKTTAG_ONETIMEPKTRQST_SHIFT)
937 #define DHD_PKTTAG_ONETIMEPKTRQST(tag)  ((((dhd_pkttag_t*)(tag))->if_flags >> \
938         DHD_PKTTAG_ONETIMEPKTRQST_SHIFT) & DHD_PKTTAG_ONETIMEPKTRQST_MASK)
939
940 #define DHD_PKTTAG_SETEVENT(tag, event) ((dhd_pkttag_t*)(tag))->if_flags = \
941         (((dhd_pkttag_t*)(tag))->if_flags & \
942         ~(DHD_PKTTAG_EVENT_MASK << DHD_PKTTAG_EVENT_SHIFT)) | \
943         (((event) & DHD_PKTTAG_EVENT_MASK) << DHD_PKTTAG_EVENT_SHIFT)
944 #define DHD_PKTTAG_EVENT(tag)   ((((dhd_pkttag_t*)(tag))->if_flags >> \
945         DHD_PKTTAG_EVENT_SHIFT) & DHD_PKTTAG_EVENT_MASK)
946
947 #define DHD_PKTTAG_EXEMPT_SET(tag, value)       ((dhd_pkttag_t*)(tag))->if_flags = \
948         (((dhd_pkttag_t*)(tag))->if_flags & \
949         ~(DHD_PKTTAG_EXEMPT_MASK << DHD_PKTTAG_EXEMPT_SHIFT)) | \
950         (((value) & DHD_PKTTAG_EXEMPT_MASK) << DHD_PKTTAG_EXEMPT_SHIFT)
951 #define DHD_PKTTAG_EXEMPT(tag)  ((((dhd_pkttag_t*)(tag))->if_flags >> \
952         DHD_PKTTAG_EXEMPT_SHIFT) & DHD_PKTTAG_EXEMPT_MASK)
953
954 #define DHD_PKTTAG_SETDSTN(tag, dstn_MAC_ea)    memcpy(((dhd_pkttag_t*)((tag)))->dstn_ether, \
955         (dstn_MAC_ea), ETHER_ADDR_LEN)
956 #define DHD_PKTTAG_DSTN(tag)    ((dhd_pkttag_t*)(tag))->dstn_ether
957
958 typedef int (*f_commitpkt_t)(void* ctx, void* p);
959 int dhd_os_wlfc_block(dhd_pub_t *pub);
960 int dhd_os_wlfc_unblock(dhd_pub_t *pub);
961 void dhd_schedule_tx(struct dhd_info *dhd);
962
963 #ifdef PROP_TXSTATUS_DEBUG
964 #define DHD_WLFC_CTRINC_MAC_CLOSE(entry)        do { (entry)->closed_ct++; } while (0)
965 #define DHD_WLFC_CTRINC_MAC_OPEN(entry)         do { (entry)->opened_ct++; } while (0)
966 #else
967 #define DHD_WLFC_CTRINC_MAC_CLOSE(entry)        do {} while (0)
968 #define DHD_WLFC_CTRINC_MAC_OPEN(entry)         do {} while (0)
969 #endif
970
971 #endif /* PROP_TXSTATUS */
972
973 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
974 extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
975
976 #define IFLOCK_INIT(lock)       *lock = 0
977 #define IFLOCK(lock)    while (InterlockedCompareExchange((lock), 1, 0))        \
978         NdisStallExecution(1);
979 #define IFUNLOCK(lock)  InterlockedExchange((lock), 0)
980 #define IFLOCK_FREE(lock)
981 #define FW_SUPPORTED(dhd, capa) ((strstr(dhd->fw_capabilities, #capa) != NULL))
982 #ifdef ARP_OFFLOAD_SUPPORT
983 #define MAX_IPV4_ENTRIES        8
984 void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
985 void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
986
987 /* dhd_commn arp offload wrapers */
988 void dhd_aoe_hostip_clr(dhd_pub_t *dhd, int idx);
989 void dhd_aoe_arp_clr(dhd_pub_t *dhd, int idx);
990 int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen, int idx);
991 void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr, int idx);
992 #endif /* ARP_OFFLOAD_SUPPORT */
993 #ifdef WLTDLS
994 int dhd_tdls_enable_disable(dhd_pub_t *dhd, bool flag);
995 #endif
996 /* Neighbor Discovery Offload Support */
997 int dhd_ndo_enable(dhd_pub_t * dhd, int ndo_enable);
998 int dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipaddr, int idx);
999 int dhd_ndo_remove_ip(dhd_pub_t *dhd, int idx);
1000 /* ioctl processing for nl80211 */
1001 int dhd_ioctl_process(dhd_pub_t *pub, int ifidx, struct dhd_ioctl *ioc);
1002
1003 void dhd_set_bus_state(void *bus, uint32 state);
1004
1005 /* Remove proper pkts(either one no-frag pkt or whole fragmented pkts) */
1006 extern bool dhd_prec_drop_pkts(osl_t *osh, struct pktq *pq, int prec);
1007
1008 #endif /* _dhd_h_ */