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