1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Header file describing the internal (inter-module) DHD interfaces.
4 *
5 * Provides type definitions and function prototypes used to link the
6 * DHD OS, bus, and protocol modules.
7 *
8 * Copyright (C) 1999-2017, Broadcom Corporation
9 *
10 * Unless you and Broadcom execute a separate written software license
11 * agreement governing use of this software, this software is licensed to you
12 * under the terms of the GNU General Public License version 2 (the "GPL"),
13 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
14 * following added to such license:
15 *
16 * As a special exception, the copyright holders of this software give you
17 * permission to link this software with independent modules, and to copy and
18 * distribute the resulting executable under terms of your choice, provided that
19 * you also meet, for each linked independent module, the terms and conditions of
20 * the license of that module. An independent module is a module which is not
21 * derived from this software. The special exception does not apply to any
22 * modifications of the software.
23 *
24 * Notwithstanding the above, under no circumstances may you combine this
25 * software in any way with any other Broadcom software provided under a license
26 * other than the GPL, without Broadcom's express prior written consent.
27 *
28 *
29 * <<Broadcom-WL-IPTag/Open:>>
30 *
31 * $Id: dhd.h 711448 2017-07-18 08:27:03Z $
32 */
33
34 /****************
35 * Common types *
36 */
37
38 #ifndef _dhd_h_
39 #define _dhd_h_
40
41 #include <linux/init.h>
42 #include <linux/kernel.h>
43 #include <linux/slab.h>
44 #include <linux/skbuff.h>
45 #include <linux/netdevice.h>
46 #include <linux/etherdevice.h>
47 #include <linux/random.h>
48 #include <linux/spinlock.h>
49 #include <linux/ethtool.h>
50 #include <linux/uaccess.h>
51 #include <asm/unaligned.h>
52 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
53 #include <linux/wakelock.h>
54 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
55 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
56 #include <linux/sched/types.h>
57 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */
58 /* The kernel threading is sdio-specific */
59 struct task_struct;
60 struct sched_param;
61 #if defined(BT_OVER_SDIO)
62 #include <dhd_bt_interface.h>
63 #endif /* defined (BT_OVER_SDIO) */
64 int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
65 int get_scheduler_policy(struct task_struct *p);
66 #define MAX_EVENT 16
67
68 #define ALL_INTERFACES 0xff
69
70 #include <wlioctl.h>
71 #include <wlfc_proto.h>
72 #include <hnd_armtrap.h>
73 #if defined(DUMP_IOCTL_IOV_LIST) || defined(DHD_DEBUG)
74 #include <bcmutils.h>
75 #endif /* DUMP_IOCTL_IOV_LIST || DHD_DEBUG */
76 #include <hnd_pktq.h>
77
78 #if defined(BCMWDF)
79 #include <wdf.h>
80 #include <WdfMiniport.h>
81 #endif /* (BCMWDF) */
82
83 #ifdef DEBUG_DPC_THREAD_WATCHDOG
84 #define MAX_RESCHED_CNT 600
85 #endif /* DEBUG_DPC_THREAD_WATCHDOG */
86
87 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) && LINUX_VERSION_CODE < \
88 KERNEL_VERSION(3, 18, 0) || defined(CONFIG_BCMDHD_VENDOR_EXT))
89 #define WL_VENDOR_EXT_SUPPORT
90 #endif /* 3.18 > KERNEL_VER >= 3.14 || defined(CONFIG_BCMDHD_VENDOR_EXT) */
91
92 #if defined(KEEP_ALIVE)
93 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
94 #define KEEP_ALIVE_PERIOD 55000
95 #define NULL_PKT_STR "null_pkt"
96 #endif /* KEEP_ALIVE */
97
98 /* Forward decls */
99 struct dhd_bus;
100 struct dhd_prot;
101 struct dhd_info;
102 struct dhd_ioctl;
103 struct dhd_dbg;
104 struct dhd_ts;
105
106 /* The level of bus communication with the dongle */
107 enum dhd_bus_state {
108 DHD_BUS_DOWN, /* Not ready for frame transfers */
109 DHD_BUS_LOAD, /* Download access only (CPU reset) */
110 DHD_BUS_DATA, /* Ready for frame transfers */
111 DHD_BUS_SUSPEND, /* Bus has been suspended */
112 DHD_BUS_DOWN_IN_PROGRESS, /* Bus going Down */
113 DHD_BUS_REMOVE, /* Bus has been removed */
114 };
115
116 /*
117 * Bit fields to Indicate clean up process that wait till they are finished.
118 * Future synchronizable processes can add their bit filed below and update
119 * their functionalities accordingly
120 */
121 #define DHD_BUS_BUSY_IN_TX 0x01
122 #define DHD_BUS_BUSY_IN_SEND_PKT 0x02
123 #define DHD_BUS_BUSY_IN_DPC 0x04
124 #define DHD_BUS_BUSY_IN_WD 0x08
125 #define DHD_BUS_BUSY_IN_IOVAR 0x10
126 #define DHD_BUS_BUSY_IN_DHD_IOVAR 0x20
127 #define DHD_BUS_BUSY_SUSPEND_IN_PROGRESS 0x40
128 #define DHD_BUS_BUSY_RESUME_IN_PROGRESS 0x80
129 #define DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS 0x100
130 #define DHD_BUS_BUSY_RPM_SUSPEND_DONE 0x200
131 #define DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS 0x400
132 #define DHD_BUS_BUSY_RPM_ALL (DHD_BUS_BUSY_RPM_SUSPEND_DONE | \
133 DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS | \
134 DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
135 #define DHD_BUS_BUSY_IN_CHECKDIED 0x800
136
137 #define DHD_BUS_BUSY_SET_IN_TX(dhdp) \
138 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_TX
139 #define DHD_BUS_BUSY_SET_IN_SEND_PKT(dhdp) \
140 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SEND_PKT
141 #define DHD_BUS_BUSY_SET_IN_DPC(dhdp) \
142 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DPC
143 #define DHD_BUS_BUSY_SET_IN_WD(dhdp) \
144 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_WD
145 #define DHD_BUS_BUSY_SET_IN_IOVAR(dhdp) \
146 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_IOVAR
147 #define DHD_BUS_BUSY_SET_IN_DHD_IOVAR(dhdp) \
148 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DHD_IOVAR
149 #define DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(dhdp) \
150 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
151 #define DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(dhdp) \
152 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RESUME_IN_PROGRESS
153 #define DHD_BUS_BUSY_SET_RPM_SUSPEND_IN_PROGRESS(dhdp) \
154 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
155 #define DHD_BUS_BUSY_SET_RPM_SUSPEND_DONE(dhdp) \
156 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_DONE
157 #define DHD_BUS_BUSY_SET_RPM_RESUME_IN_PROGRESS(dhdp) \
158 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
159 #define DHD_BUS_BUSY_SET_IN_CHECKDIED(dhdp) \
160 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_CHECKDIED
161
162 #define DHD_BUS_BUSY_CLEAR_IN_TX(dhdp) \
163 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_TX
164 #define DHD_BUS_BUSY_CLEAR_IN_SEND_PKT(dhdp) \
165 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SEND_PKT
166 #define DHD_BUS_BUSY_CLEAR_IN_DPC(dhdp) \
167 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DPC
168 #define DHD_BUS_BUSY_CLEAR_IN_WD(dhdp) \
169 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_WD
170 #define DHD_BUS_BUSY_CLEAR_IN_IOVAR(dhdp) \
171 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_IOVAR
172 #define DHD_BUS_BUSY_CLEAR_IN_DHD_IOVAR(dhdp) \
173 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DHD_IOVAR
174 #define DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(dhdp) \
175 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
176 #define DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(dhdp) \
177 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RESUME_IN_PROGRESS
178 #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_IN_PROGRESS(dhdp) \
179 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
180 #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_DONE(dhdp) \
181 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_DONE
182 #define DHD_BUS_BUSY_CLEAR_RPM_RESUME_IN_PROGRESS(dhdp) \
183 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
184 #define DHD_BUS_BUSY_CLEAR_IN_CHECKDIED(dhdp) \
185 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_CHECKDIED
186
187 #define DHD_BUS_BUSY_CHECK_IN_TX(dhdp) \
188 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_TX)
189 #define DHD_BUS_BUSY_CHECK_IN_SEND_PKT(dhdp) \
190 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SEND_PKT)
191 #define DHD_BUS_BUSY_CHECK_IN_DPC(dhdp) \
192 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DPC)
193 #define DHD_BUS_BUSY_CHECK_IN_WD(dhdp) \
194 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_WD)
195 #define DHD_BUS_BUSY_CHECK_IN_IOVAR(dhdp) \
196 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_IOVAR)
197 #define DHD_BUS_BUSY_CHECK_IN_DHD_IOVAR(dhdp) \
198 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DHD_IOVAR)
199 #define DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) \
200 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_SUSPEND_IN_PROGRESS)
201 #define DHD_BUS_BUSY_CHECK_RESUME_IN_PROGRESS(dhdp) \
202 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RESUME_IN_PROGRESS)
203 #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp) \
204 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS)
205 #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_DONE(dhdp) \
206 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_DONE)
207 #define DHD_BUS_BUSY_CHECK_RPM_RESUME_IN_PROGRESS(dhdp) \
208 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
209 #define DHD_BUS_BUSY_CHECK_RPM_ALL(dhdp) \
210 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_ALL)
211 #define DHD_BUS_BUSY_CHECK_IN_CHECKDIED(dhdp) \
212 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_CHECKDIED)
213 #define DHD_BUS_BUSY_CHECK_IDLE(dhdp) \
214 ((dhdp)->dhd_bus_busy_state == 0)
215
216 #define DHD_BUS_CHECK_SUSPEND_OR_SUSPEND_IN_PROGRESS(dhdp) \
217 ((dhdp)->busstate == DHD_BUS_SUSPEND || DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) || \
218 DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp))
219
220 #define DHD_BUS_CHECK_ANY_SUSPEND_IN_PROGRESS(dhdp) \
221 (DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) || \
222 DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp))
223
224 #define DHD_BUS_CHECK_DOWN_OR_DOWN_IN_PROGRESS(dhdp) \
225 ((dhdp)->busstate == DHD_BUS_DOWN || (dhdp)->busstate == DHD_BUS_DOWN_IN_PROGRESS || \
226 (dhdp)->busstate == DHD_BUS_REMOVE)
227
228 #define DHD_BUS_CHECK_REMOVE(dhdp) \
229 ((dhdp)->busstate == DHD_BUS_REMOVE)
230
231 /* Macro to print Ethernet Address as String
232 * expects both arguements as (char *)
233 */
234 #define DHD_MAC_TO_STR(mac, str) (snprintf(str, ETHER_ADDR_STR_LEN, \
235 "%02x:%02x:%02x:%02x:%02x:%02x\n", \
236 (uchar)mac[0]&0xff, \
237 (uchar)mac[1]&0xff, \
238 (uchar)mac[2]&0xff, \
239 (uchar)mac[3]&0xff, \
240 (uchar)mac[4]&0xff, \
241 (uchar)mac[5]&0xff))
242
243
244 /* Download Types */
245 typedef enum download_type {
246 FW,
247 NVRAM,
248 CLM_BLOB
249 } download_type_t;
250
251
252 /* For supporting multiple interfaces */
253 #define DHD_MAX_IFS 16
254 #define DHD_DEL_IF -0xE
255 #define DHD_BAD_IF -0xF
256 #define DHD_EVENT_IF 0xFFFF /* Hack i/f to handle events from INFO Ring */
257
258 enum dhd_op_flags {
259 /* Firmware requested operation mode */
260 DHD_FLAG_STA_MODE = (1 << (0)), /* STA only */
261 DHD_FLAG_HOSTAP_MODE = (1 << (1)), /* SOFTAP only */
262 DHD_FLAG_P2P_MODE = (1 << (2)), /* P2P Only */
263 /* STA + P2P */
264 DHD_FLAG_CONCURR_SINGLE_CHAN_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_P2P_MODE),
265 /* STA + SoftAP */
266 DHD_FLAG_CONCURR_STA_HOSTAP_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_HOSTAP_MODE),
267 DHD_FLAG_CONCURR_MULTI_CHAN_MODE = (1 << (4)), /* STA + P2P */
268 /* Current P2P mode for P2P connection */
269 DHD_FLAG_P2P_GC_MODE = (1 << (5)),
270 DHD_FLAG_P2P_GO_MODE = (1 << (6)),
271 DHD_FLAG_MBSS_MODE = (1 << (7)), /* MBSS in future */
272 DHD_FLAG_IBSS_MODE = (1 << (8)),
273 DHD_FLAG_MFG_MODE = (1 << (9)),
274 DHD_FLAG_RSDB_MODE = (1 << (10)),
275 DHD_FLAG_MP2P_MODE = (1 << (11))
276 };
277
278 #define DHD_OPMODE_SUPPORTED(dhd, opmode_flag) \
279 (dhd ? ((((dhd_pub_t *)dhd)->op_mode) & opmode_flag) : -1)
280
281 /* Max sequential TX/RX Control timeouts to set HANG event */
282 #ifndef MAX_CNTL_TX_TIMEOUT
283 #define MAX_CNTL_TX_TIMEOUT 2
284 #endif /* MAX_CNTL_TX_TIMEOUT */
285 #ifndef MAX_CNTL_RX_TIMEOUT
286 #define MAX_CNTL_RX_TIMEOUT 1
287 #endif /* MAX_CNTL_RX_TIMEOUT */
288
289 #define DHD_SCAN_ASSOC_ACTIVE_TIME 40 /* ms: Embedded default Active setting from DHD */
290 #define DHD_SCAN_UNASSOC_ACTIVE_TIME 80 /* ms: Embedded def. Unassoc Active setting from DHD */
291 #define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD */
292 #define DHD_SCAN_HOME_TIME 45 /* ms: Embedded default Home time setting from DHD */
293 #define DHD_SCAN_HOME_AWAY_TIME 100 /* ms: Embedded default Home Away time setting from DHD */
294
295 #ifndef POWERUP_MAX_RETRY
296 #define POWERUP_MAX_RETRY 1 /* how many times we retry to power up the chip */
297 #endif
298 #ifndef POWERUP_WAIT_MS
299 #define POWERUP_WAIT_MS 2000 /* ms: time out in waiting wifi to come up */
300 #endif
301 /*
302 * MAX_NVRAMBUF_SIZE determines the size of the Buffer in the DHD that holds
303 * the NVRAM data. That is the size of the buffer pointed by bus->vars
304 * This also needs to be increased to 16K to support NVRAM size higher than 8K
305 */
306 #define MAX_NVRAMBUF_SIZE (16 * 1024) /* max nvram buf size */
307 #define MAX_CLM_BUF_SIZE (48 * 1024) /* max clm blob size */
308 #ifdef DHD_DEBUG
309 #define DHD_JOIN_MAX_TIME_DEFAULT 10000 /* ms: Max time out for joining AP */
310 #define DHD_SCAN_DEF_TIMEOUT 10000 /* ms: Max time out for scan in progress */
311 #endif
312
313 #ifndef CONFIG_BCMDHD_CLM_PATH
314 #define CONFIG_BCMDHD_CLM_PATH "/system/etc/wifi/bcmdhd_clm.blob"
315 #endif /* CONFIG_BCMDHD_CLM_PATH */
316 #define WL_CCODE_NULL_COUNTRY "#n"
317
318 #define FW_VER_STR_LEN 128
319 #define CLM_VER_STR_LEN 128
320 #define BUS_API_REV_STR_LEN 128
321 extern char bus_api_revision[];
322
323 enum dhd_bus_wake_state {
324 WAKE_LOCK_OFF,
325 WAKE_LOCK_PRIV,
326 WAKE_LOCK_DPC,
327 WAKE_LOCK_IOCTL,
328 WAKE_LOCK_DOWNLOAD,
329 WAKE_LOCK_TMOUT,
330 WAKE_LOCK_WATCHDOG,
331 WAKE_LOCK_LINK_DOWN_TMOUT,
332 WAKE_LOCK_PNO_FIND_TMOUT,
333 WAKE_LOCK_SOFTAP_SET,
334 WAKE_LOCK_SOFTAP_STOP,
335 WAKE_LOCK_SOFTAP_START,
336 WAKE_LOCK_SOFTAP_THREAD
337 };
338
339 #ifdef PCIE_INB_DW
340 enum dhd_bus_ds_state {
341 DW_DEVICE_DS_INVALID = -1,
342 DW_DEVICE_DS_DEV_SLEEP = 0,
343 DW_DEVICE_DS_DEV_SLEEP_PEND,
344 DW_DEVICE_DS_DISABLED_WAIT,
345 DW_DEVICE_DS_DEV_WAKE,
346 DW_DEVICE_DS_ACTIVE,
347 DW_DEVICE_HOST_SLEEP_WAIT,
348 DW_DEVICE_HOST_SLEEP,
349 DW_DEVICE_HOST_WAKE_WAIT,
350 DW_DEVICE_DS_D3_INFORM_WAIT
351 };
352 #endif /* PCIE_INB_DW */
353
354 enum dhd_prealloc_index {
355 DHD_PREALLOC_PROT = 0,
356 DHD_PREALLOC_RXBUF = 1,
357 DHD_PREALLOC_DATABUF = 2,
358 DHD_PREALLOC_OSL_BUF = 3,
359 DHD_PREALLOC_SKB_BUF = 4,
360 #if defined(STATIC_WL_PRIV_STRUCT)
361 DHD_PREALLOC_WIPHY_ESCAN0 = 5,
362 #endif /* STATIC_WL_PRIV_STRUCT */
363 DHD_PREALLOC_DHD_INFO = 7,
364 DHD_PREALLOC_DHD_WLFC_INFO = 8,
365 DHD_PREALLOC_IF_FLOW_LKUP = 9,
366 /* 10 */
367 DHD_PREALLOC_MEMDUMP_RAM = 11,
368 DHD_PREALLOC_DHD_WLFC_HANGER = 12,
369 DHD_PREALLOC_PKTID_MAP = 13,
370 DHD_PREALLOC_PKTID_MAP_IOCTL = 14,
371 DHD_PREALLOC_DHD_LOG_DUMP_BUF = 15,
372 DHD_PREALLOC_DHD_LOG_DUMP_BUF_EX = 16,
373 DHD_PREALLOC_DHD_PKTLOG_DUMP_BUF = 17,
374 DHD_PREALLOC_STAT_REPORT_BUF = 18,
375 DHD_PREALLOC_WL_ESCAN = 19,
376 DHD_PREALLOC_FW_VERBOSE_RING = 20,
377 DHD_PREALLOC_FW_EVENT_RING = 21,
378 DHD_PREALLOC_DHD_EVENT_RING = 22,
379 DHD_PREALLOC_NAN_EVENT_RING = 23
380 };
381
382 enum dhd_dongledump_mode {
383 DUMP_DISABLED = 0,
384 DUMP_MEMONLY,
385 DUMP_MEMFILE,
386 DUMP_MEMFILE_BUGON,
387 DUMP_MEMFILE_MAX
388 };
389
390 enum dhd_dongledump_type {
391 DUMP_TYPE_RESUMED_ON_TIMEOUT = 1,
392 DUMP_TYPE_D3_ACK_TIMEOUT,
393 DUMP_TYPE_DONGLE_TRAP,
394 DUMP_TYPE_MEMORY_CORRUPTION,
395 DUMP_TYPE_PKTID_AUDIT_FAILURE,
396 DUMP_TYPE_PKTID_INVALID,
397 DUMP_TYPE_SCAN_TIMEOUT,
398 DUMP_TYPE_JOIN_TIMEOUT,
399 DUMP_TYPE_SCAN_BUSY,
400 DUMP_TYPE_BY_SYSDUMP,
401 DUMP_TYPE_BY_LIVELOCK,
402 DUMP_TYPE_AP_LINKUP_FAILURE,
403 DUMP_TYPE_AP_ABNORMAL_ACCESS,
404 DUMP_TYPE_CFG_VENDOR_TRIGGERED,
405 DUMP_TYPE_RESUMED_ON_TIMEOUT_TX,
406 DUMP_TYPE_RESUMED_ON_TIMEOUT_RX,
407 DUMP_TYPE_RESUMED_ON_INVALID_RING_RDWR,
408 DUMP_TYPE_DONGLE_HOST_EVENT,
409 DUMP_TYPE_RESUMED_UNKNOWN,
410 DUMP_TYPE_TRANS_ID_MISMATCH,
411 DUMP_TYPE_HANG_ON_IFACE_OP_FAIL,
412 #ifdef SUPPORT_LINKDOWN_RECOVERY
413 DUMP_TYPE_READ_SHM_FAIL
414 #endif /* SUPPORT_LINKDOWN_RECOVERY */
415 };
416
417 enum dhd_hang_reason {
418 HANG_REASON_MASK = 0x8000,
419 HANG_REASON_IOCTL_RESP_TIMEOUT = 0x8001,
420 HANG_REASON_DONGLE_TRAP = 0x8002,
421 HANG_REASON_D3_ACK_TIMEOUT = 0x8003,
422 HANG_REASON_BUS_DOWN = 0x8004,
423 HANG_REASON_MSGBUF_LIVELOCK = 0x8006,
424 HANG_REASON_IFACE_OP_FAILURE = 0x8007,
425 HANG_REASON_HT_AVAIL_ERROR = 0x8008,
426 HANG_REASON_PCIE_RC_LINK_UP_FAIL = 0x8009,
427 HANG_REASON_PCIE_PKTID_ERROR = 0x800A,
428 HANG_REASON_PCIE_LINK_DOWN = 0x8805,
429 HANG_REASON_INVALID_EVENT_OR_DATA = 0x8806,
430 HANG_REASON_UNKNOWN = 0x8807,
431 HANG_REASON_MAX = 0x8808
432 };
433
434 enum dhd_rsdb_scan_features {
435 /* Downgraded scan feature for AP active */
436 RSDB_SCAN_DOWNGRADED_AP_SCAN = 0x01,
437 /* Downgraded scan feature for P2P Discovery */
438 RSDB_SCAN_DOWNGRADED_P2P_DISC_SCAN = 0x02,
439 /* Enable channel pruning for ROAM SCAN */
440 RSDB_SCAN_DOWNGRADED_CH_PRUNE_ROAM = 0x10,
441 /* Enable channel pruning for any SCAN */
442 RSDB_SCAN_DOWNGRADED_CH_PRUNE_ALL = 0x20
443 };
444
445 /* Packet alignment for most efficient SDIO (can change based on platform) */
446 #ifndef DHD_SDALIGN
447 #define DHD_SDALIGN 32
448 #endif
449
450 /**
451 * DMA-able buffer parameters
452 * - dmaaddr_t is 32bits on a 32bit host.
453 * dhd_dma_buf::pa may not be used as a sh_addr_t, bcm_addr64_t or uintptr
454 * - dhd_dma_buf::_alloced is ONLY for freeing a DMA-able buffer.
455 */
456 typedef struct dhd_dma_buf {
457 void *va; /* virtual address of buffer */
458 uint32 len; /* user requested buffer length */
459 dmaaddr_t pa; /* physical address of buffer */
460 void *dmah; /* dma mapper handle */
461 void *secdma; /* secure dma sec_cma_info handle */
462 uint32 _alloced; /* actual size of buffer allocated with align and pad */
463 } dhd_dma_buf_t;
464
465 /* host reordering packts logic */
466 /* followed the structure to hold the reorder buffers (void **p) */
467 typedef struct reorder_info {
468 void **p;
469 uint8 flow_id;
470 uint8 cur_idx;
471 uint8 exp_idx;
472 uint8 max_idx;
473 uint8 pend_pkts;
474 } reorder_info_t;
475
476 #ifdef DHDTCPACK_SUPPRESS
477
478 enum {
479 /* TCPACK suppress off */
480 TCPACK_SUP_OFF,
481 /* Replace TCPACK in txq when new coming one has higher ACK number. */
482 TCPACK_SUP_REPLACE,
483 /* TCPACK_SUP_REPLACE + delayed TCPACK TX unless ACK to PSH DATA.
484 * This will give benefits to Half-Duplex bus interface(e.g. SDIO) that
485 * 1. we are able to read TCP DATA packets first from the bus
486 * 2. TCPACKs that don't need to hurry delivered remains longer in TXQ so can be suppressed.
487 */
488 TCPACK_SUP_DELAYTX,
489 TCPACK_SUP_HOLD,
490 TCPACK_SUP_LAST_MODE
491 };
492
493 #ifdef BCMSDIO
494 #define TCPACK_SUP_DEFAULT TCPACK_SUP_DELAYTX
495 #elif defined(BCMPCIE)
496 #define TCPACK_SUP_DEFAULT TCPACK_SUP_HOLD
497 #else
498 #define TCPACK_SUP_DEFAULT TCPACK_SUP_OFF
499 #endif /* BCMSDIO */
500 #endif /* DHDTCPACK_SUPPRESS */
501
502 #if defined(TRAFFIC_MGMT_DWM)
503 #define DHD_DWM_TBL_SIZE 57
504 /* DSCP WMM AC Mapping macros and structures */
505 #define DHD_TRF_MGMT_DWM_FILTER_BIT 0x8
506 #define DHD_TRF_MGMT_DWM_PRIO_BITS 0x7
507 #define DHD_TRF_MGMT_DWM_FAVORED_BIT 0x10
508 #define DHD_TRF_MGMT_DWM_PRIO(dwm_tbl_entry) ((dwm_tbl_entry) & DHD_TRF_MGMT_DWM_PRIO_BITS)
509 #define DHD_TRF_MGMT_DWM_IS_FAVORED_SET(dwm_tbl_entry) \
510 ((dwm_tbl_entry) & DHD_TRF_MGMT_DWM_FAVORED_BIT)
511 #define DHD_TRF_MGMT_DWM_SET_FAVORED(dwm_tbl_entry) \
512 ((dwm_tbl_entry) |= DHD_TRF_MGMT_DWM_FAVORED_BIT)
513 #define DHD_TRF_MGMT_DWM_IS_FILTER_SET(dwm_tbl_entry) \
514 ((dwm_tbl_entry) & DHD_TRF_MGMT_DWM_FILTER_BIT)
515 #define DHD_TRF_MGMT_DWM_SET_FILTER(dwm_tbl_entry) \
516 ((dwm_tbl_entry) |= DHD_TRF_MGMT_DWM_FILTER_BIT)
517
518 typedef struct {
519 uint8 dhd_dwm_enabled;
520 uint8 dhd_dwm_tbl[DHD_DWM_TBL_SIZE];
521 } dhd_trf_mgmt_dwm_tbl_t;
522 #endif
523
524 #define DHD_NULL_CHK_AND_RET(cond) \
525 if (!cond) { \
526 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
527 return; \
528 }
529
530 #define DHD_NULL_CHK_AND_RET_VAL(cond, value) \
531 if (!cond) { \
532 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
533 return value; \
534 }
535
536 #define DHD_NULL_CHK_AND_GOTO(cond, label) \
537 if (!cond) { \
538 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
539 goto label; \
540 }
541
542 /*
543 * Accumulating the queue lengths of all flowring queues in a parent object,
544 * to assert flow control, when the cummulative queue length crosses an upper
545 * threshold defined on a parent object. Upper threshold may be maintained
546 * at a station level, at an interface level, or at a dhd instance.
547 *
548 * cumm_ctr_t abstraction:
549 * cumm_ctr_t abstraction may be enhanced to use an object with a hysterisis
550 * pause on/off threshold callback.
551 * All macros use the address of the cummulative length in the parent objects.
552 *
553 * BCM_GMAC3 builds use a single perimeter lock, as opposed to a per queue lock.
554 * Cummulative counters in parent objects may be updated without spinlocks.
555 *
556 * In non BCM_GMAC3, if a cummulative queue length is desired across all flows
557 * belonging to either of (a station, or an interface or a dhd instance), then
558 * an atomic operation is required using an atomic_t cummulative counters or
559 * using a spinlock. BCM_ROUTER_DHD uses the Linux atomic_t construct.
560 */
561
562 /* Cummulative length not supported. */
563 typedef uint32 cumm_ctr_t;
564 #define DHD_CUMM_CTR_PTR(clen) ((cumm_ctr_t*)(clen))
565 #define DHD_CUMM_CTR(clen) *(DHD_CUMM_CTR_PTR(clen)) /* accessor */
566 #define DHD_CUMM_CTR_READ(clen) DHD_CUMM_CTR(clen) /* read access */
567 #define DHD_CUMM_CTR_INIT(clen) \
568 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
569 #define DHD_CUMM_CTR_INCR(clen) \
570 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
571 #define DHD_CUMM_CTR_DECR(clen) \
572 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
573
574 #if defined(WLTDLS) && defined(PCIE_FULL_DONGLE)
575 struct tdls_peer_node {
576 uint8 addr[ETHER_ADDR_LEN];
577 struct tdls_peer_node *next;
578 };
579 typedef struct tdls_peer_node tdls_peer_node_t;
580 typedef struct {
581 tdls_peer_node_t *node;
582 uint8 tdls_peer_count;
583 } tdls_peer_tbl_t;
584 #endif /* defined(WLTDLS) && defined(PCIE_FULL_DONGLE) */
585
586 #ifdef DHD_LOG_DUMP
587 /* below structure describe ring buffer. */
588 struct dhd_log_dump_buf
589 {
590 spinlock_t lock;
591 unsigned int enable;
592 unsigned int wraparound;
593 unsigned long max;
594 unsigned int remain;
595 char* present;
596 char* front;
597 char* buffer;
598 };
599
600 #define DHD_LOG_DUMP_MAX_TEMP_BUFFER_SIZE 256
601 extern void dhd_log_dump_write(int type, const char *fmt, ...);
602 extern char *dhd_log_dump_get_timestamp(void);
603 #endif /* DHD_LOG_DUMP */
604
605 #if defined(CUSTOMER_HW2)
606 #define DHD_COMMON_DUMP_PATH "/data/misc/wifi/"
607 #else
608 #define DHD_COMMON_DUMP_PATH "/installmedia/"
609 #endif
610
611 struct cntry_locales_custom {
612 char iso_abbrev[WLC_CNTRY_BUF_SZ]; /* ISO 3166-1 country abbreviation */
613 char custom_locale[WLC_CNTRY_BUF_SZ]; /* Custom firmware locale */
614 int32 custom_locale_rev; /* Custom local revisin default -1 */
615 };
616
617 #ifdef REPORT_FATAL_TIMEOUTS
618 typedef struct timeout_info {
619 void *scan_timer_lock;
620 void *join_timer_lock;
621 void *cmd_timer_lock;
622 void *bus_timer_lock;
623 uint32 scan_timeout_val;
624 uint32 join_timeout_val;
625 uint32 cmd_timeout_val;
626 uint32 bus_timeout_val;
627 bool scan_timer_active;
628 bool join_timer_active;
629 bool cmd_timer_active;
630 bool bus_timer_active;
631 osl_timer_t *scan_timer;
632 osl_timer_t *join_timer;
633 osl_timer_t *cmd_timer;
634 osl_timer_t *bus_timer;
635 uint16 cmd_request_id;
636 uint32 cmd;
637 uint32 cmd_join_error;
638 } timeout_info_t;
639 #endif /* REPORT_FATAL_TIMEOUTS */
640
641 #ifdef HOFFLOAD_MODULES
642 /* Metadata structure containing module information */
643 struct module_metadata {
644 void *data; /* module data */
645 uint32_t size; /* module size */
646 u64 data_addr; /* address of module data in host */
647 };
648 #endif
649
650 #ifdef DMAMAP_STATS
651 typedef struct dmamap_stats {
652 uint64 txdata;
653 uint64 txdata_sz;
654 uint64 rxdata;
655 uint64 rxdata_sz;
656 uint64 ioctl_rx;
657 uint64 ioctl_rx_sz;
658 uint64 event_rx;
659 uint64 event_rx_sz;
660 uint64 info_rx;
661 uint64 info_rx_sz;
662 uint64 tsbuf_rx;
663 uint64 tsbuf_rx_sz;
664 } dma_stats_t;
665 #endif /* DMAMAP_STATS */
666
667 /* Common structure for module and instance linkage */
668 typedef struct dhd_pub {
669 /* Linkage ponters */
670 osl_t *osh; /* OSL handle */
671 struct dhd_bus *bus; /* Bus module handle */
672 struct dhd_prot *prot; /* Protocol module handle */
673 struct dhd_info *info; /* Info module handle */
674 struct dhd_dbg *dbg; /* Debugability module handle */
675
676 /* to NDIS developer, the structure dhd_common is redundant,
677 * please do NOT merge it back from other branches !!!
678 */
679
680 #ifdef BCMDBUS
681 struct dbus_pub *dbus;
682 #endif /* BCMDBUS */
683
684 /* Internal dhd items */
685 bool up; /* Driver up/down (to OS) */
686 #ifdef WL_CFG80211
687 spinlock_t up_lock; /* Synchronization with CFG80211 down */
688 #endif /* WL_CFG80211 */
689 bool txoff; /* Transmit flow-controlled */
690 bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
691 enum dhd_bus_state busstate;
692 uint dhd_bus_busy_state; /* Bus busy state */
693 uint hdrlen; /* Total DHD header length (proto + bus) */
694 uint maxctl; /* Max size rxctl request from proto to bus */
695 uint rxsz; /* Rx buffer size bus module should use */
696 uint8 wme_dp; /* wme discard priority */
697
698 /* Dongle media info */
699 bool iswl; /* Dongle-resident driver is wl */
700 ulong drv_version; /* Version of dongle-resident driver */
701 struct ether_addr mac; /* MAC address obtained from dongle */
702 dngl_stats_t dstats; /* Stats for dongle-based data */
703
704 /* Additional stats for the bus level */
705 ulong tx_packets; /* Data packets sent to dongle */
706 ulong tx_dropped; /* Data packets dropped in dhd */
707 ulong tx_multicast; /* Multicast data packets sent to dongle */
708 ulong tx_errors; /* Errors in sending data to dongle */
709 ulong tx_ctlpkts; /* Control packets sent to dongle */
710 ulong tx_ctlerrs; /* Errors sending control frames to dongle */
711 ulong rx_packets; /* Packets sent up the network interface */
712 ulong rx_multicast; /* Multicast packets sent up the network interface */
713 ulong rx_errors; /* Errors processing rx data packets */
714 ulong rx_ctlpkts; /* Control frames processed from dongle */
715 ulong rx_ctlerrs; /* Errors in processing rx control frames */
716 ulong rx_dropped; /* Packets dropped locally (no memory) */
717 ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
718 ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
719 ulong rx_pktgetfail; /* Number of PKTGET failures in DHD on RX */
720 ulong tx_pktgetfail; /* Number of PKTGET failures in DHD on TX */
721 ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
722 ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
723 ulong fc_packets; /* Number of flow control pkts recvd */
724
725 #ifdef DMAMAP_STATS
726 /* DMA Mapping statistics */
727 dma_stats_t dma_stats;
728 #endif /* DMAMAP_STATS */
729
730 /* Last error return */
731 int bcmerror;
732 uint tickcnt;
733
734 /* Last error from dongle */
735 int dongle_error;
736
737 uint8 country_code[WLC_CNTRY_BUF_SZ];
738
739 /* Suspend disable flag and "in suspend" flag */
740 int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
741 int in_suspend; /* flag set to 1 when early suspend called */
742 #ifdef PNO_SUPPORT
743 int pno_enable; /* pno status : "1" is pno enable */
744 int pno_suspend; /* pno suspend status : "1" is pno suspended */
745 #endif /* PNO_SUPPORT */
746 /* DTIM skip value, default 0(or 1) means wake each DTIM
747 * 3 means skip 2 DTIMs and wake up 3rd DTIM(9th beacon when AP DTIM is 3)
748 */
749 int suspend_bcn_li_dtim; /* bcn_li_dtim value in suspend mode */
750 #ifdef PKT_FILTER_SUPPORT
751 int early_suspended; /* Early suspend status */
752 int dhcp_in_progress; /* DHCP period */
753 #endif
754
755 /* Pkt filter defination */
756 char * pktfilter[100];
757 int pktfilter_count;
758
759 wl_country_t dhd_cspec; /* Current Locale info */
760 #ifdef CUSTOM_COUNTRY_CODE
761 uint dhd_cflags;
762 #endif /* CUSTOM_COUNTRY_CODE */
763 #if defined(DHD_BLOB_EXISTENCE_CHECK)
764 bool is_blob; /* Checking for existance of Blob file */
765 #endif /* DHD_BLOB_EXISTENCE_CHECK */
766 bool force_country_change;
767 char eventmask[WL_EVENTING_MASK_LEN];
768 int op_mode; /* STA, HostAPD, WFD, SoftAP */
769
770 /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
771 * For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
772 * see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
773 */
774 /* #define WL_ENABLE_P2P_IF 1 */
775
776 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
777 struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
778 struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
779 #endif
780
781 #ifdef PROP_TXSTATUS
782 bool wlfc_enabled;
783 int wlfc_mode;
784 void* wlfc_state;
785 /*
786 Mode in which the dhd flow control shall operate. Must be set before
787 traffic starts to the device.
788 0 - Do not do any proptxtstatus flow control
789 1 - Use implied credit from a packet status
790 2 - Use explicit credit
791 3 - Only AMPDU hostreorder used. no wlfc.
792 */
793 uint8 proptxstatus_mode;
794 bool proptxstatus_txoff;
795 bool proptxstatus_module_ignore;
796 bool proptxstatus_credit_ignore;
797 bool proptxstatus_txstatus_ignore;
798
799 bool wlfc_rxpkt_chk;
800 #ifdef LIMIT_BORROW
801 bool wlfc_borrow_allowed;
802 #endif /* LIMIT_BORROW */
803 /*
804 * implement below functions in each platform if needed.
805 */
806 /* platform specific function whether to skip flow control */
807 bool (*skip_fc)(void * dhdp, uint8 ifx);
808 /* platform specific function for wlfc_enable and wlfc_deinit */
809 void (*plat_init)(void *dhd);
810 void (*plat_deinit)(void *dhd);
811 #ifdef DHD_WLFC_THREAD
812 bool wlfc_thread_go;
813 struct task_struct* wlfc_thread;
814 wait_queue_head_t wlfc_wqhead;
815 #endif /* DHD_WLFC_THREAD */
816 #endif /* PROP_TXSTATUS */
817 #ifdef PNO_SUPPORT
818 void *pno_state;
819 #endif
820 #ifdef RTT_SUPPORT
821 void *rtt_state;
822 bool rtt_supported;
823 #endif
824 bool dongle_isolation;
825 bool is_pcie_watchdog_reset;
826 bool dongle_trap_occured; /* flag for sending HANG event to upper layer */
827 bool iovar_timeout_occured; /* flag to indicate iovar resumed on timeout */
828 #ifdef PCIE_FULL_DONGLE
829 bool d3ack_timeout_occured; /* flag to indicate d3ack resumed on timeout */
830 #endif /* PCIE_FULL_DONGLE */
831 #ifdef BT_OVER_SDIO
832 bool is_bt_recovery_required;
833 #endif
834 int hang_was_sent;
835 int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
836 int txcnt_timeout; /* counter txcnt timeout to send HANG */
837 #ifdef BCMPCIE
838 int d3ackcnt_timeout; /* counter d3ack timeout to send HANG */
839 #endif /* BCMPCIE */
840 bool hang_report; /* enable hang report by default */
841 uint16 hang_reason; /* reason codes for HANG event */
842 #if defined(DHD_HANG_SEND_UP_TEST)
843 uint req_hang_type;
844 #endif /* DHD_HANG_SEND_UP_TEST */
845 #if defined(CONFIG_BCM_DETECT_CONSECUTIVE_HANG)
846 uint hang_counts;
847 #endif /* CONFIG_BCM_DETECT_CONSECUTIVE_HANG */
848 #ifdef WLMEDIA_HTSF
849 uint8 htsfdlystat_sz; /* Size of delay stats, max 255B */
850 #endif
851 #ifdef WLTDLS
852 bool tdls_enable;
853 #endif
854 struct reorder_info *reorder_bufs[WLHOST_REORDERDATA_MAXFLOWS];
855 #define WLC_IOCTL_MAXBUF_FWCAP 512
856 char fw_capabilities[WLC_IOCTL_MAXBUF_FWCAP];
857 #define MAXSKBPEND 1024
858 void *skbbuf[MAXSKBPEND];
859 uint32 store_idx;
860 uint32 sent_idx;
861 #ifdef DHDTCPACK_SUPPRESS
862 uint8 tcpack_sup_mode; /* TCPACK suppress mode */
863 void *tcpack_sup_module; /* TCPACK suppress module */
864 uint32 tcpack_sup_ratio;
865 uint32 tcpack_sup_delay;
866 #endif /* DHDTCPACK_SUPPRESS */
867 #if defined(ARP_OFFLOAD_SUPPORT)
868 uint32 arp_version;
869 #endif
870 #ifdef DEBUG_DPC_THREAD_WATCHDOG
871 bool dhd_bug_on;
872 #endif /* DEBUG_DPC_THREAD_WATCHDOG */
873 #ifdef CUSTOM_SET_CPUCORE
874 struct task_struct * current_dpc;
875 struct task_struct * current_rxf;
876 int chan_isvht80;
877 #endif /* CUSTOM_SET_CPUCORE */
878
879
880 void *sta_pool; /* pre-allocated pool of sta objects */
881 void *staid_allocator; /* allocator of sta indexes */
882 #ifdef PCIE_FULL_DONGLE
883 bool flow_rings_inited; /* set this flag after initializing flow rings */
884 #endif /* PCIE_FULL_DONGLE */
885 void *flowid_allocator; /* unique flowid allocator */
886 void *flow_ring_table; /* flow ring table, include prot and bus info */
887 void *if_flow_lkup; /* per interface flowid lkup hash table */
888 void *flowid_lock; /* per os lock for flowid info protection */
889 void *flowring_list_lock; /* per os lock for flowring list protection */
890 uint32 num_flow_rings;
891 cumm_ctr_t cumm_ctr; /* cumm queue length placeholder */
892 cumm_ctr_t l2cumm_ctr; /* level 2 cumm queue length placeholder */
893 uint32 d2h_sync_mode; /* D2H DMA completion sync mode */
894 uint8 flow_prio_map[NUMPRIO];
895 uint8 flow_prio_map_type;
896 char enable_log[MAX_EVENT];
897 bool dma_d2h_ring_upd_support;
898 bool dma_h2d_ring_upd_support;
899 bool dma_ring_upd_overwrite; /* host overwrites support setting */
900
901 bool idma_enable;
902 uint idma_inited;
903 bool idma_retention_ds; /* Implicit DMA memory retention */
904
905 bool ifrm_enable; /* implicit frm enable */
906 uint ifrm_inited; /* implicit frm init */
907
908 #ifdef DHD_WMF
909 bool wmf_ucast_igmp;
910 #ifdef DHD_IGMP_UCQUERY
911 bool wmf_ucast_igmp_query;
912 #endif
913 #ifdef DHD_UCAST_UPNP
914 bool wmf_ucast_upnp;
915 #endif
916 #endif /* DHD_WMF */
917 #if defined(TRAFFIC_MGMT_DWM)
918 dhd_trf_mgmt_dwm_tbl_t dhd_tm_dwm_tbl;
919 #endif
920 #ifdef DHD_L2_FILTER
921 unsigned long l2_filter_cnt; /* for L2_FILTER ARP table timeout */
922 #endif /* DHD_L2_FILTER */
923 #ifdef DHD_SSSR_DUMP
924 bool sssr_inited;
925 sssr_reg_info_t sssr_reg_info;
926 uint8 *sssr_mempool;
927 uint *sssr_d11_before[MAX_NUM_D11CORES];
928 uint *sssr_d11_after[MAX_NUM_D11CORES];
929 bool sssr_d11_outofreset[MAX_NUM_D11CORES];
930 uint *sssr_vasip_buf_before;
931 uint *sssr_vasip_buf_after;
932 #endif /* DHD_SSSR_DUMP */
933 uint8 *soc_ram;
934 uint32 soc_ram_length;
935 uint32 memdump_type;
936 #ifdef DHD_FW_COREDUMP
937 uint32 memdump_enabled;
938 bool memdump_success;
939 #endif /* DHD_FW_COREDUMP */
940 #ifdef PCIE_FULL_DONGLE
941 #ifdef WLTDLS
942 tdls_peer_tbl_t peer_tbl;
943 #endif /* WLTDLS */
944 uint8 tx_in_progress;
945 #endif /* PCIE_FULL_DONGLE */
946 #ifdef DHD_ULP
947 void *dhd_ulp;
948 #endif
949 #ifdef CACHE_FW_IMAGES
950 char *cached_fw;
951 int cached_fw_length;
952 char *cached_nvram;
953 int cached_nvram_length;
954 char *cached_clm;
955 int cached_clm_length;
956 #endif
957 #ifdef WLTDLS
958 uint32 tdls_mode;
959 #endif
960 #ifdef GSCAN_SUPPORT
961 bool lazy_roam_enable;
962 #endif
963 #if defined(PKT_FILTER_SUPPORT) && defined(APF)
964 bool apf_set;
965 #endif /* PKT_FILTER_SUPPORT && APF */
966 #ifdef DHD_WET
967 void *wet_info;
968 #endif
969 bool h2d_phase_supported;
970 bool force_dongletrap_on_bad_h2d_phase;
971 uint32 dongle_trap_data;
972 bool cto_enable; /* enable PCIE CTO Prevention and recovery */
973 uint32 cto_threshold; /* PCIE CTO timeout threshold */
974 bool fw_download_done;
975 trap_t last_trap_info; /* trap info from the last trap */
976 uint8 rand_mac_oui[DOT11_OUI_LEN];
977 #ifdef DHD_LOSSLESS_ROAMING
978 uint8 dequeue_prec_map;
979 uint8 prio_8021x;
980 #endif
981 #ifdef REPORT_FATAL_TIMEOUTS
982 timeout_info_t *timeout_info;
983 #endif /* REPORT_FATAL_TIMEOUTS */
984 /* timesync link */
985 struct dhd_ts *ts;
986 bool d2h_hostrdy_supported;
987 #if defined(DBG_PKT_MON) || defined(DHD_PKT_LOGGING)
988 bool d11_tx_status;
989 #endif /* DBG_PKT_MON || DHD_PKT_LOGGING */
990 uint16 ndo_version; /* ND offload version supported */
991 #ifdef NDO_CONFIG_SUPPORT
992 bool ndo_enable; /* ND offload feature enable */
993 bool ndo_host_ip_overflow; /* # of host ip addr exceed FW capacity */
994 uint32 ndo_max_host_ip; /* # of host ip addr supported by FW */
995 #endif /* NDO_CONFIG_SUPPORT */
996 #if defined(DHD_EFI) && defined(DHD_LOG_DUMP)
997 uint8 log_capture_enable;
998 #endif /* DHD_EFI && DHD_LOG_DUMP */
999 bool max_dtim_enable; /* use MAX bcn_li_dtim value in suspend mode */
1000 #ifdef PCIE_OOB
1001 bool d2h_no_oob_dw;
1002 #endif /* PCIE_OOB */
1003 #ifdef PCIE_INB_DW
1004 bool d2h_inband_dw;
1005 enum dhd_bus_ds_state ds_state;
1006 #endif /* PCIE_INB_DW */
1007 #ifdef CUSTOM_SET_ANTNPM
1008 uint32 mimo_ant_set;
1009 #endif /* CUSTOM_SET_ANTNPM */
1010 #ifdef CUSTOM_SET_OCLOFF
1011 bool ocl_off;
1012 #endif /* CUSTOM_SET_OCLOFF */
1013 #ifdef HOFFLOAD_MODULES
1014 struct module_metadata hmem;
1015 #endif
1016 bool wbtext_support;
1017 #ifdef DUMP_IOCTL_IOV_LIST
1018 /* dump iovar list */
1019 dll_t dump_iovlist_head;
1020 uint8 dump_iovlist_len;
1021 #endif /* DUMP_IOCTL_IOV_LIST */
1022 #ifdef DHD_DEBUG
1023 /* memwaste feature */
1024 dll_t mw_list_head; /* memwaste list head */
1025 uint32 mw_id; /* memwaste list unique id */
1026 #endif /* DHD_DEBUG */
1027 #ifdef WLTDLS
1028 spinlock_t tdls_lock;
1029 #endif /* WLTDLS */
1030 #ifdef WLADPS_SEAK_AP_WAR
1031 uint32 disabled_adps;
1032 #endif /* WLADPS_SEAK_AP_WAR */
1033 bool ext_trap_data_supported;
1034 uint32 *extended_trap_data;
1035 #ifdef DHD_PKT_LOGGING
1036 struct dhd_pktlog *pktlog;
1037 #endif /* DHD_PKT_LOGGING */
1038 #if defined(STAT_REPORT)
1039 void *stat_report_info;
1040 #endif
1041 #ifdef CSI_SUPPORT
1042 struct list_head csi_list;
1043 int csi_count;
1044 #endif /* CSI_SUPPORT */
1045 char *clm_path; /* module_param: path to clm vars file */
1046 char *conf_path; /* module_param: path to config vars file */
1047 struct dhd_conf *conf; /* Bus module handle */
1048 void *adapter; /* adapter information, interrupt, fw path etc. */
1049 void *event_params;
1050 #ifdef BCMDBUS
1051 bool dhd_remove;
1052 #endif /* BCMDBUS */
1053 #ifdef WL_ESCAN
1054 struct wl_escan_info *escan;
1055 #endif
1056 #if defined(WL_WIRELESS_EXT)
1057 void *wext_info;
1058 #endif
1059 #ifdef WL_EXT_IAPSTA
1060 void *iapsta_params;
1061 #endif
1062 int hostsleep;
1063 #ifdef SENDPROB
1064 bool recv_probereq;
1065 #endif
1066 #ifdef HOST_TPUT_TEST
1067 struct osl_timespec bus_ts;
1068 struct osl_timespec net_ts;
1069 uint32 net_len;
1070 #endif
1071 } dhd_pub_t;
1072
1073 typedef struct {
1074 uint rxwake;
1075 uint rcwake;
1076 #ifdef DHD_WAKE_RX_STATUS
1077 uint rx_bcast;
1078 uint rx_arp;
1079 uint rx_mcast;
1080 uint rx_multi_ipv6;
1081 uint rx_icmpv6;
1082 uint rx_icmpv6_ra;
1083 uint rx_icmpv6_na;
1084 uint rx_icmpv6_ns;
1085 uint rx_multi_ipv4;
1086 uint rx_multi_other;
1087 uint rx_ucast;
1088 #endif /* DHD_WAKE_RX_STATUS */
1089 #ifdef DHD_WAKE_EVENT_STATUS
1090 uint rc_event[WLC_E_LAST];
1091 #endif /* DHD_WAKE_EVENT_STATUS */
1092 } wake_counts_t;
1093
1094 #if defined(PCIE_FULL_DONGLE)
1095
1096 /* Packet Tag for PCIE Full Dongle DHD */
1097 typedef struct dhd_pkttag_fd {
1098 uint16 flowid; /* Flowring Id */
1099 uint16 dataoff; /* start of packet */
1100 uint16 dma_len; /* pkt len for DMA_MAP/UNMAP */
1101 dmaaddr_t pa; /* physical address */
1102 void *dmah; /* dma mapper handle */
1103 void *secdma; /* secure dma sec_cma_info handle */
1104 } dhd_pkttag_fd_t;
1105
1106 /* Packet Tag for DHD PCIE Full Dongle */
1107 #define DHD_PKTTAG_FD(pkt) ((dhd_pkttag_fd_t *)(PKTTAG(pkt)))
1108
1109 #define DHD_PKT_GET_FLOWID(pkt) ((DHD_PKTTAG_FD(pkt))->flowid)
1110 #define DHD_PKT_SET_FLOWID(pkt, pkt_flowid) \
1111 DHD_PKTTAG_FD(pkt)->flowid = (uint16)(pkt_flowid)
1112
1113 #define DHD_PKT_GET_DATAOFF(pkt) ((DHD_PKTTAG_FD(pkt))->dataoff)
1114 #define DHD_PKT_SET_DATAOFF(pkt, pkt_dataoff) \
1115 DHD_PKTTAG_FD(pkt)->dataoff = (uint16)(pkt_dataoff)
1116
1117 #define DHD_PKT_GET_DMA_LEN(pkt) ((DHD_PKTTAG_FD(pkt))->dma_len)
1118 #define DHD_PKT_SET_DMA_LEN(pkt, pkt_dma_len) \
1119 DHD_PKTTAG_FD(pkt)->dma_len = (uint16)(pkt_dma_len)
1120
1121 #define DHD_PKT_GET_PA(pkt) ((DHD_PKTTAG_FD(pkt))->pa)
1122 #define DHD_PKT_SET_PA(pkt, pkt_pa) \
1123 DHD_PKTTAG_FD(pkt)->pa = (dmaaddr_t)(pkt_pa)
1124
1125 #define DHD_PKT_GET_DMAH(pkt) ((DHD_PKTTAG_FD(pkt))->dmah)
1126 #define DHD_PKT_SET_DMAH(pkt, pkt_dmah) \
1127 DHD_PKTTAG_FD(pkt)->dmah = (void *)(pkt_dmah)
1128
1129 #define DHD_PKT_GET_SECDMA(pkt) ((DHD_PKTTAG_FD(pkt))->secdma)
1130 #define DHD_PKT_SET_SECDMA(pkt, pkt_secdma) \
1131 DHD_PKTTAG_FD(pkt)->secdma = (void *)(pkt_secdma)
1132 #endif /* PCIE_FULL_DONGLE */
1133
1134 #if defined(BCMWDF)
1135 typedef struct {
1136 dhd_pub_t *dhd_pub;
1137 } dhd_workitem_context_t;
1138
1139 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(dhd_workitem_context_t, dhd_get_dhd_workitem_context)
1140 #endif /* (BCMWDF) */
1141
1142 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
1143
1144 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
1145 #define _DHD_PM_RESUME_WAIT(a, b) do {\
1146 int retry = 0; \
1147 SMP_RD_BARRIER_DEPENDS(); \
1148 while (dhd_mmc_suspend && retry++ != b) { \
1149 SMP_RD_BARRIER_DEPENDS(); \
1150 wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
1151 } \
1152 } while (0)
1153 #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
1154 #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
1155 #define DHD_PM_RESUME_RETURN_ERROR(a) do { \
1156 if (dhd_mmc_suspend) { \
1157 printf("%s[%d]: mmc is still in suspend state!!!\n", \
1158 __FUNCTION__, __LINE__); \
1159 return a; \
1160 } \
1161 } while (0)
1162 #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
1163
1164 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
1165 #define SPINWAIT_SLEEP(a, exp, us) do { \
1166 uint countdown = (us) + 9999; \
1167 while ((exp) && (countdown >= 10000)) { \
1168 wait_event_interruptible_timeout(a, FALSE, 1); \
1169 countdown -= 10000; \
1170 } \
1171 } while (0)
1172
1173 #else
1174
1175 #define DHD_PM_RESUME_WAIT_INIT(a)
1176 #define DHD_PM_RESUME_WAIT(a)
1177 #define DHD_PM_RESUME_WAIT_FOREVER(a)
1178 #define DHD_PM_RESUME_RETURN_ERROR(a)
1179 #define DHD_PM_RESUME_RETURN
1180
1181 #define DHD_SPINWAIT_SLEEP_INIT(a)
1182 #define SPINWAIT_SLEEP(a, exp, us) do { \
1183 uint countdown = (us) + 9; \
1184 while ((exp) && (countdown >= 10)) { \
1185 OSL_DELAY(10); \
1186 countdown -= 10; \
1187 } \
1188 } while (0)
1189
1190 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
1191
1192 #ifndef OSL_SLEEP
1193 #define OSL_SLEEP(ms) OSL_DELAY(ms*1000)
1194 #endif /* OSL_SLEEP */
1195
1196 #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
1197
1198 #ifdef PNO_SUPPORT
1199 int dhd_pno_clean(dhd_pub_t *dhd);
1200 #endif /* PNO_SUPPORT */
1201
1202 #ifdef HOFFLOAD_MODULES
1203 void dhd_linux_get_modfw_address(dhd_pub_t *dhd);
1204 #endif
1205
1206 /*
1207 * Wake locks are an Android power management concept. They are used by applications and services
1208 * to request CPU resources.
1209 */
1210 extern int dhd_os_wake_lock(dhd_pub_t *pub);
1211 extern int dhd_os_wake_unlock(dhd_pub_t *pub);
1212 extern int dhd_os_wake_lock_waive(dhd_pub_t *pub);
1213 extern int dhd_os_wake_lock_restore(dhd_pub_t *pub);
1214 extern void dhd_event_wake_lock(dhd_pub_t *pub);
1215 extern void dhd_event_wake_unlock(dhd_pub_t *pub);
1216 extern void dhd_pm_wake_lock_timeout(dhd_pub_t *pub, int val);
1217 extern void dhd_pm_wake_unlock(dhd_pub_t *pub);
1218 extern void dhd_txfl_wake_lock_timeout(dhd_pub_t *pub, int val);
1219 extern void dhd_txfl_wake_unlock(dhd_pub_t *pub);
1220 extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
1221 extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
1222 extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
1223 extern int dhd_os_wake_lock_ctrl_timeout_cancel(dhd_pub_t *pub);
1224 extern int dhd_os_wd_wake_lock(dhd_pub_t *pub);
1225 extern int dhd_os_wd_wake_unlock(dhd_pub_t *pub);
1226 extern void dhd_os_wake_lock_init(struct dhd_info *dhd);
1227 extern void dhd_os_wake_lock_destroy(struct dhd_info *dhd);
1228 #ifdef DHD_USE_SCAN_WAKELOCK
1229 extern void dhd_os_scan_wake_lock_timeout(dhd_pub_t *pub, int val);
1230 extern void dhd_os_scan_wake_unlock(dhd_pub_t *pub);
1231 #endif /* BCMPCIE_SCAN_WAKELOCK */
1232
MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)1233 inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
1234 {
1235 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1236 mutex_init(&dhdp->wl_softap_lock);
1237 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
1238 }
1239
MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)1240 inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
1241 {
1242 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1243 mutex_lock(&dhdp->wl_softap_lock);
1244 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
1245 }
1246
MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)1247 inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
1248 {
1249 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1250 mutex_unlock(&dhdp->wl_softap_lock);
1251 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
1252 }
1253
1254 #define PRINT_CALL_INFO(str)
1255 #define PRINT_CALL_INFO_TIMEOUT(str, val)
1256 #define DHD_OS_WAKE_LOCK(pub) \
1257 do { \
1258 PRINT_CALL_INFO("call wakelock"); \
1259 dhd_os_wake_lock(pub); \
1260 } while (0)
1261 #define DHD_OS_WAKE_UNLOCK(pub) \
1262 do { \
1263 PRINT_CALL_INFO("call wake_unlock"); \
1264 dhd_os_wake_unlock(pub); \
1265 } while (0)
1266 #define DHD_EVENT_WAKE_LOCK(pub) \
1267 do { \
1268 PRINT_CALL_INFO("call event_wake lock"); \
1269 dhd_event_wake_lock(pub); \
1270 } while (0)
1271 #define DHD_EVENT_WAKE_UNLOCK(pub) \
1272 do { \
1273 PRINT_CALL_INFO("call event_wake unlock"); \
1274 dhd_event_wake_unlock(pub); \
1275 } while (0)
1276 #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) \
1277 do { \
1278 PRINT_CALL_INFO("call pm_wake_timeout enable"); \
1279 dhd_pm_wake_lock_timeout(pub, val); \
1280 } while (0)
1281 #define DHD_PM_WAKE_UNLOCK(pub) \
1282 do { \
1283 PRINT_CALL_INFO("call pm_wake unlock"); \
1284 dhd_pm_wake_unlock(pub); \
1285 } while (0)
1286 #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) \
1287 do { \
1288 PRINT_CALL_INFO("call pm_wake_timeout enable"); \
1289 dhd_txfl_wake_lock_timeout(pub, val); \
1290 } while (0)
1291 #define DHD_TXFL_WAKE_UNLOCK(pub) \
1292 do { \
1293 PRINT_CALL_INFO("call pm_wake unlock"); \
1294 dhd_txfl_wake_unlock(pub); \
1295 } while (0)
1296 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) \
1297 do { \
1298 PRINT_CALL_INFO("call wake_lock_timeout"); \
1299 dhd_os_wake_lock_timeout(pub); \
1300 } while (0)
1301 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
1302 do { \
1303 PRINT_CALL_INFO_TIMEOUT("call wake_lock_rx_timeout_enable", val); \
1304 dhd_os_wake_lock_rx_timeout_enable(pub, val); \
1305 } while (0)
1306 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
1307 do { \
1308 PRINT_CALL_INFO_TIMEOUT("call wake_lock_ctrl_timeout_enable", val); \
1309 dhd_os_wake_lock_ctrl_timeout_enable(pub, val); \
1310 } while (0)
1311 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
1312 do { \
1313 PRINT_CALL_INFO("call wake_lock_ctrl_timeout_cancel"); \
1314 dhd_os_wake_lock_ctrl_timeout_cancel(pub); \
1315 } while (0)
1316 #define DHD_OS_WAKE_LOCK_WAIVE(pub) \
1317 do { \
1318 PRINT_CALL_INFO("call wake_lock_waive"); \
1319 dhd_os_wake_lock_waive(pub); \
1320 } while (0)
1321 #define DHD_OS_WAKE_LOCK_RESTORE(pub) \
1322 do { \
1323 PRINT_CALL_INFO("call wake_lock_restore"); \
1324 dhd_os_wake_lock_restore(pub); \
1325 } while (0)
1326 #define DHD_OS_WAKE_LOCK_INIT(dhd) \
1327 do { \
1328 PRINT_CALL_INFO("call wake_lock_init"); \
1329 dhd_os_wake_lock_init(dhd); \
1330 } while (0)
1331 #define DHD_OS_WAKE_LOCK_DESTROY(dhd) \
1332 do { \
1333 PRINT_CALL_INFO("call wake_lock_destroy"); \
1334 dhd_os_wake_lock_destroy(dhd); \
1335 } while (0)
1336
1337 #define DHD_OS_WD_WAKE_LOCK(pub) dhd_os_wd_wake_lock(pub)
1338 #define DHD_OS_WD_WAKE_UNLOCK(pub) dhd_os_wd_wake_unlock(pub)
1339
1340 #ifdef DHD_USE_SCAN_WAKELOCK
1341 #ifdef DHD_DEBUG_SCAN_WAKELOCK
1342 #define PRINT_SCAN_CALL(str) printf("%s: %s %d\n", \
1343 str, __FUNCTION__, __LINE__)
1344 #else
1345 #define PRINT_SCAN_CALL(str)
1346 #endif /* DHD_DEBUG_SCAN_WAKELOCK */
1347 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) \
1348 do { \
1349 PRINT_SCAN_CALL("call wake_lock_scan"); \
1350 dhd_os_scan_wake_lock_timeout(pub, val); \
1351 } while (0)
1352 #define DHD_OS_SCAN_WAKE_UNLOCK(pub) \
1353 do { \
1354 PRINT_SCAN_CALL("call wake_unlock_scan"); \
1355 dhd_os_scan_wake_unlock(pub); \
1356 } while (0)
1357 #else
1358 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val)
1359 #define DHD_OS_SCAN_WAKE_UNLOCK(pub)
1360 #endif /* DHD_USE_SCAN_WAKELOCK */
1361
1362 #ifdef BCMPCIE_OOB_HOST_WAKE
1363 #define OOB_WAKE_LOCK_TIMEOUT 500
1364 extern void dhd_os_oob_irq_wake_lock_timeout(dhd_pub_t *pub, int val);
1365 extern void dhd_os_oob_irq_wake_unlock(dhd_pub_t *pub);
1366 #define DHD_OS_OOB_IRQ_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_oob_irq_wake_lock_timeout(pub, val)
1367 #define DHD_OS_OOB_IRQ_WAKE_UNLOCK(pub) dhd_os_oob_irq_wake_unlock(pub)
1368 #endif /* BCMPCIE_OOB_HOST_WAKE */
1369
1370 #define DHD_PACKET_TIMEOUT_MS 500
1371 #define DHD_EVENT_TIMEOUT_MS 1500
1372 #define SCAN_WAKE_LOCK_TIMEOUT 10000
1373 #define MAX_TX_TIMEOUT 500
1374
1375 /* Enum for IOCTL recieved status */
1376 typedef enum dhd_ioctl_recieved_status
1377 {
1378 IOCTL_WAIT = 0,
1379 IOCTL_RETURN_ON_SUCCESS,
1380 IOCTL_RETURN_ON_TRAP,
1381 IOCTL_RETURN_ON_BUS_STOP,
1382 IOCTL_RETURN_ON_ERROR
1383 } dhd_ioctl_recieved_status_t;
1384
1385 /* interface operations (register, remove) should be atomic, use this lock to prevent race
1386 * condition among wifi on/off and interface operation functions
1387 */
1388 void dhd_net_if_lock(struct net_device *dev);
1389 void dhd_net_if_unlock(struct net_device *dev);
1390 #if defined(MULTIPLE_SUPPLICANT)
1391 extern void wl_android_post_init(void); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe
1392 #endif
1393
1394 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && defined(MULTIPLE_SUPPLICANT)
1395 extern struct mutex _dhd_mutex_lock_;
1396 #define DHD_MUTEX_IS_LOCK_RETURN() \
1397 if (mutex_is_locked(&_dhd_mutex_lock_) != 0) { \
1398 printf("%s : probe is already running! return.\n", __FUNCTION__); \
1399 return 0; \
1400 }
1401 #define DHD_MUTEX_LOCK() \
1402 do { \
1403 if (mutex_is_locked(&_dhd_mutex_lock_) == 0) { \
1404 DHD_PRINT("%s : no mutex held. set lock\n", __FUNCTION__); \
1405 } else { \
1406 DHD_PRINT("%s : mutex is locked!. wait for unlocking\n", __FUNCTION__); \
1407 } \
1408 mutex_lock(&_dhd_mutex_lock_); \
1409 } while (0)
1410 #define DHD_MUTEX_UNLOCK() \
1411 do { \
1412 mutex_unlock(&_dhd_mutex_lock_); \
1413 DHD_PRINT("%s : the lock is released.\n", __FUNCTION__); \
1414 } while (0)
1415 #else
1416 #define DHD_MUTEX_IS_LOCK_RETURN(a) do {} while (0)
1417 #define DHD_MUTEX_LOCK(a) do {} while (0)
1418 #define DHD_MUTEX_UNLOCK(a) do {} while (0)
1419 #endif
1420
1421 typedef enum dhd_attach_states
1422 {
1423 DHD_ATTACH_STATE_INIT = 0x0,
1424 DHD_ATTACH_STATE_NET_ALLOC = 0x1,
1425 DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
1426 DHD_ATTACH_STATE_ADD_IF = 0x4,
1427 DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
1428 DHD_ATTACH_STATE_WL_ATTACH = 0x10,
1429 DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
1430 DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
1431 DHD_ATTACH_STATE_CFG80211 = 0x80,
1432 DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
1433 DHD_ATTACH_TIMESYNC_ATTACH_DONE = 0x200,
1434 DHD_ATTACH_LOGTRACE_INIT = 0x400,
1435 DHD_ATTACH_STATE_LB_ATTACH_DONE = 0x800,
1436 DHD_ATTACH_STATE_DONE = 0x1000
1437 } dhd_attach_states_t;
1438
1439 /* Value -1 means we are unsuccessful in creating the kthread. */
1440 #define DHD_PID_KT_INVALID -1
1441 /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
1442 #define DHD_PID_KT_TL_INVALID -2
1443
1444 /*
1445 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
1446 */
1447
1448 /* Indication from bus module regarding presence/insertion of dongle.
1449 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
1450 * Returned structure should have bus and prot pointers filled in.
1451 * bus_hdrlen specifies required headroom for bus module header.
1452 */
1453 extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen
1454 #ifdef BCMDBUS
1455 , void *adapter
1456 #endif
1457 );
1458 #if defined(WLP2P) && defined(WL_CFG80211)
1459 /* To allow attach/detach calls corresponding to p2p0 interface */
1460 extern int dhd_attach_p2p(dhd_pub_t *);
1461 extern int dhd_detach_p2p(dhd_pub_t *);
1462 #endif /* WLP2P && WL_CFG80211 */
1463 extern int dhd_register_if(dhd_pub_t *dhdp, int idx, bool need_rtnl_lock);
1464
1465 /* Indication from bus module regarding removal/absence of dongle */
1466 extern void dhd_detach(dhd_pub_t *dhdp);
1467 extern void dhd_free(dhd_pub_t *dhdp);
1468 extern void dhd_clear(dhd_pub_t *dhdp);
1469
1470 /* Indication from bus module to change flow-control state */
1471 extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
1472
1473 /* Store the status of a connection attempt for later retrieval by an iovar */
1474 extern void dhd_store_conn_status(uint32 event, uint32 status, uint32 reason);
1475
1476 extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
1477
1478 extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
1479
1480 /* Return pointer to interface name */
1481 extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
1482
1483 #ifdef DHD_UCODE_DOWNLOAD
1484 /* Returns the ucode path */
1485 extern char *dhd_get_ucode_path(dhd_pub_t *dhdp);
1486 #endif /* DHD_UCODE_DOWNLOAD */
1487
1488 /* Request scheduling of the bus dpc */
1489 extern void dhd_sched_dpc(dhd_pub_t *dhdp);
1490
1491 /* Notify tx completion */
1492 extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
1493
1494 #define WIFI_FEATURE_INFRA 0x0001 /* Basic infrastructure mode */
1495 #define WIFI_FEATURE_INFRA_5G 0x0002 /* Support for 5 GHz Band */
1496 #define WIFI_FEATURE_HOTSPOT 0x0004 /* Support for GAS/ANQP */
1497 #define WIFI_FEATURE_P2P 0x0008 /* Wifi-Direct */
1498 #define WIFI_FEATURE_SOFT_AP 0x0010 /* Soft AP */
1499 #define WIFI_FEATURE_GSCAN 0x0020 /* Google-Scan APIs */
1500 #define WIFI_FEATURE_NAN 0x0040 /* Neighbor Awareness Networking */
1501 #define WIFI_FEATURE_D2D_RTT 0x0080 /* Device-to-device RTT */
1502 #define WIFI_FEATURE_D2AP_RTT 0x0100 /* Device-to-AP RTT */
1503 #define WIFI_FEATURE_BATCH_SCAN 0x0200 /* Batched Scan (legacy) */
1504 #define WIFI_FEATURE_PNO 0x0400 /* Preferred network offload */
1505 #define WIFI_FEATURE_ADDITIONAL_STA 0x0800 /* Support for two STAs */
1506 #define WIFI_FEATURE_TDLS 0x1000 /* Tunnel directed link setup */
1507 #define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 /* Support for TDLS off channel */
1508 #define WIFI_FEATURE_EPR 0x4000 /* Enhanced power reporting */
1509 #define WIFI_FEATURE_AP_STA 0x8000 /* Support for AP STA Concurrency */
1510 #define WIFI_FEATURE_LINKSTAT 0x10000 /* Support for Linkstats */
1511 #define WIFI_FEATURE_LOGGER 0x20000 /* WiFi Logger */
1512 #define WIFI_FEATURE_HAL_EPNO 0x40000 /* WiFi PNO enhanced */
1513 #define WIFI_FEATURE_RSSI_MONITOR 0x80000 /* RSSI Monitor */
1514 #define WIFI_FEATURE_MKEEP_ALIVE 0x100000 /* WiFi mkeep_alive */
1515 #define WIFI_FEATURE_CONFIG_NDO 0x200000 /* ND offload configure */
1516 #define WIFI_FEATURE_TX_TRANSMIT_POWER 0x400000 /* Capture Tx transmit power levels */
1517 #define WIFI_FEATURE_INVALID 0xFFFFFFFF /* Invalid Feature */
1518
1519 #define MAX_FEATURE_SET_CONCURRRENT_GROUPS 3
1520
1521 extern int dhd_dev_get_feature_set(struct net_device *dev);
1522 extern int dhd_dev_get_feature_set_matrix(struct net_device *dev, int num);
1523 extern int dhd_dev_cfg_rand_mac_oui(struct net_device *dev, uint8 *oui);
1524 #ifdef CUSTOM_FORCE_NODFS_FLAG
1525 extern int dhd_dev_set_nodfs(struct net_device *dev, uint nodfs);
1526 #endif /* CUSTOM_FORCE_NODFS_FLAG */
1527
1528 #ifdef NDO_CONFIG_SUPPORT
1529 #ifndef NDO_MAX_HOST_IP_ENTRIES
1530 #define NDO_MAX_HOST_IP_ENTRIES 10
1531 #endif /* NDO_MAX_HOST_IP_ENTRIES */
1532 extern int dhd_dev_ndo_cfg(struct net_device *dev, u8 enable);
1533 extern int dhd_dev_ndo_update_inet6addr(struct net_device * dev);
1534 #endif /* NDO_CONFIG_SUPPORT */
1535 extern int dhd_set_rand_mac_oui(dhd_pub_t *dhd);
1536 #ifdef GSCAN_SUPPORT
1537 extern int dhd_dev_set_lazy_roam_cfg(struct net_device *dev,
1538 wlc_roam_exp_params_t *roam_param);
1539 extern int dhd_dev_lazy_roam_enable(struct net_device *dev, uint32 enable);
1540 extern int dhd_dev_set_lazy_roam_bssid_pref(struct net_device *dev,
1541 wl_bssid_pref_cfg_t *bssid_pref, uint32 flush);
1542 extern int dhd_dev_set_blacklist_bssid(struct net_device *dev, maclist_t *blacklist,
1543 uint32 len, uint32 flush);
1544 extern int dhd_dev_set_whitelist_ssid(struct net_device *dev, wl_ssid_whitelist_t *whitelist,
1545 uint32 len, uint32 flush);
1546 #endif /* GSCAN_SUPPORT */
1547
1548 /* OS independent layer functions */
1549 extern void dhd_os_dhdiovar_lock(dhd_pub_t *pub);
1550 extern void dhd_os_dhdiovar_unlock(dhd_pub_t *pub);
1551 extern int dhd_os_proto_block(dhd_pub_t * pub);
1552 extern int dhd_os_proto_unblock(dhd_pub_t * pub);
1553 extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition);
1554 extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
1555 extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
1556 extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
1557 extern void dhd_os_ioctl_resp_lock(dhd_pub_t * pub);
1558 extern void dhd_os_ioctl_resp_unlock(dhd_pub_t * pub);
1559 #ifdef PCIE_FULL_DONGLE
1560 extern void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason);
1561 #else
dhd_wakeup_ioctl_event(dhd_pub_t * pub,dhd_ioctl_recieved_status_t reason)1562 static INLINE void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason)
1563 { printf("%s is NOT implemented for SDIO", __FUNCTION__); return; }
1564 #endif
1565 #ifdef SHOW_LOGTRACE
1566 extern int dhd_os_read_file(void *file, char *buf, uint32 size);
1567 extern int dhd_os_seek_file(void *file, int64 offset);
1568 #endif /* SHOW_LOGTRACE */
1569
1570 extern void
1571 dhd_pcie_dump_core_regs(dhd_pub_t * pub, uint32 index, uint32 first_addr, uint32 last_addr);
1572 extern void wl_dhdpcie_dump_regs(void * context);
1573
1574 #define DHD_OS_IOCTL_RESP_LOCK(x)
1575 #define DHD_OS_IOCTL_RESP_UNLOCK(x)
1576
1577
1578 extern int dhd_os_get_image_block(char * buf, int len, void * image);
1579 extern int dhd_os_get_image_size(void * image);
1580 #if defined(BT_OVER_SDIO)
1581 extern int dhd_os_gets_image(dhd_pub_t *pub, char *str, int len, void *image);
1582 extern void dhdsdio_bus_usr_cnt_inc(dhd_pub_t *pub);
1583 extern void dhdsdio_bus_usr_cnt_dec(dhd_pub_t *pub);
1584 #endif /* (BT_OVER_SDIO) */
1585 extern void * dhd_os_open_image(char * filename);
1586 extern void dhd_os_close_image(void * image);
1587 extern void dhd_os_wd_timer(void *bus, uint wdtick);
1588 #ifdef DHD_PCIE_RUNTIMEPM
1589 extern void dhd_os_runtimepm_timer(void *bus, uint tick);
1590 #endif /* DHD_PCIE_RUNTIMEPM */
1591 extern void dhd_os_sdlock(dhd_pub_t * pub);
1592 extern void dhd_os_sdunlock(dhd_pub_t * pub);
1593 extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
1594 extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
1595 extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
1596 extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
1597 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
1598 extern void dhd_os_tracelog(const char *format, ...);
1599 #ifdef DHDTCPACK_SUPPRESS
1600 extern unsigned long dhd_os_tcpacklock(dhd_pub_t *pub);
1601 extern void dhd_os_tcpackunlock(dhd_pub_t *pub, unsigned long flags);
1602 #endif /* DHDTCPACK_SUPPRESS */
1603
1604 extern int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr);
1605 extern int dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff);
1606 extern int dhd_custom_get_mac_address(void *adapter, unsigned char *buf);
1607 #if defined(CUSTOM_COUNTRY_CODE)
1608 extern void get_customized_country_code(void *adapter, char *country_iso_code,
1609 wl_country_t *cspec, u32 flags);
1610 #else
1611 extern void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec);
1612 #endif /* CUSTOM_COUNTRY_CODE */
1613 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
1614 extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
1615 extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
1616 extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
1617 extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
1618 extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
1619 extern bool dhd_os_check_if_up(dhd_pub_t *pub);
1620 extern int dhd_os_check_wakelock(dhd_pub_t *pub);
1621 extern int dhd_os_check_wakelock_all(dhd_pub_t *pub);
1622 extern int dhd_get_instance(dhd_pub_t *pub);
1623 #ifdef CUSTOM_SET_CPUCORE
1624 extern void dhd_set_cpucore(dhd_pub_t *dhd, int set);
1625 #endif /* CUSTOM_SET_CPUCORE */
1626
1627 #if defined(KEEP_ALIVE)
1628 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
1629 #endif /* KEEP_ALIVE */
1630
1631 #if defined(DHD_FW_COREDUMP)
1632 void dhd_schedule_memdump(dhd_pub_t *dhdp, uint8 *buf, uint32 size);
1633 #endif /* DHD_FW_COREDUMP */
1634
1635 void dhd_schedule_sssr_dump(dhd_pub_t *dhdp);
1636
1637 #ifdef SUPPORT_AP_POWERSAVE
1638 extern int dhd_set_ap_powersave(dhd_pub_t *dhdp, int ifidx, int enable);
1639 #endif /* SUPPORT_AP_POWERSAVE */
1640
1641 #ifdef PKT_FILTER_SUPPORT
1642 #define DHD_UNICAST_FILTER_NUM 0
1643 #define DHD_BROADCAST_FILTER_NUM 1
1644 #define DHD_MULTICAST4_FILTER_NUM 2
1645 #define DHD_MULTICAST6_FILTER_NUM 3
1646 #define DHD_MDNS_FILTER_NUM 4
1647 #define DHD_ARP_FILTER_NUM 5
1648 #define DHD_BROADCAST_ARP_FILTER_NUM 6
1649 #define DHD_IP4BCAST_DROP_FILTER_NUM 7
1650 #define DISCARD_IPV4_MCAST "102 1 6 IP4_H:16 0xf0 0xe0"
1651 #define DISCARD_IPV6_MCAST "103 1 6 IP6_H:24 0xff 0xff"
1652 extern int dhd_os_enable_packet_filter(dhd_pub_t *dhdp, int val);
1653 extern void dhd_enable_packet_filter(int value, dhd_pub_t *dhd);
1654 extern int dhd_packet_filter_add_remove(dhd_pub_t *dhdp, int add_remove, int num);
1655 extern int net_os_enable_packet_filter(struct net_device *dev, int val);
1656 extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
1657 extern int net_os_set_suspend_bcn_li_dtim(struct net_device *dev, int val);
1658 #endif /* PKT_FILTER_SUPPORT */
1659
1660
1661 #if defined(BCMPCIE)
1662 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd, int *dtim_period, int *bcn_interval);
1663 #else
1664 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
1665 #endif /* OEM_ANDROID && BCMPCIE */
1666
1667 extern bool dhd_support_sta_mode(dhd_pub_t *dhd);
1668 extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
1669
1670 #ifdef RSSI_MONITOR_SUPPORT
1671 extern int dhd_dev_set_rssi_monitor_cfg(struct net_device *dev, int start,
1672 int8 max_rssi, int8 min_rssi);
1673 #endif /* RSSI_MONITOR_SUPPORT */
1674
1675 #ifdef DHDTCPACK_SUPPRESS
1676 extern int dhd_dev_set_tcpack_sup_mode_cfg(struct net_device *dev, uint8 enable);
1677 #endif /* DHDTCPACK_SUPPRESS */
1678
1679 #define DHD_RSSI_MONITOR_EVT_VERSION 1
1680 typedef struct {
1681 uint8 version;
1682 int8 cur_rssi;
1683 struct ether_addr BSSID;
1684 } dhd_rssi_monitor_evt_t;
1685
1686 typedef struct {
1687 uint32 limit; /* Expiration time (usec) */
1688 uint32 increment; /* Current expiration increment (usec) */
1689 uint32 elapsed; /* Current elapsed time (usec) */
1690 uint32 tick; /* O/S tick time (usec) */
1691 } dhd_timeout_t;
1692
1693 #ifdef SHOW_LOGTRACE
1694 typedef struct {
1695 int num_fmts;
1696 char **fmts;
1697 char *raw_fmts;
1698 char *raw_sstr;
1699 uint32 fmts_size;
1700 uint32 raw_fmts_size;
1701 uint32 raw_sstr_size;
1702 uint32 ramstart;
1703 uint32 rodata_start;
1704 uint32 rodata_end;
1705 char *rom_raw_sstr;
1706 uint32 rom_raw_sstr_size;
1707 uint32 rom_ramstart;
1708 uint32 rom_rodata_start;
1709 uint32 rom_rodata_end;
1710 } dhd_event_log_t;
1711 #endif /* SHOW_LOGTRACE */
1712
1713 #ifdef KEEP_ALIVE
1714 extern int dhd_dev_start_mkeep_alive(dhd_pub_t *dhd_pub, uint8 mkeep_alive_id, uint8 *ip_pkt,
1715 uint16 ip_pkt_len, uint8* src_mac_addr, uint8* dst_mac_addr, uint32 period_msec);
1716 extern int dhd_dev_stop_mkeep_alive(dhd_pub_t *dhd_pub, uint8 mkeep_alive_id);
1717 #endif /* KEEP_ALIVE */
1718
1719 #if defined(PKT_FILTER_SUPPORT) && defined(APF)
1720 /*
1721 * As per Google's current implementation, there will be only one APF filter.
1722 * Therefore, userspace doesn't bother about filter id and because of that
1723 * DHD has to manage the filter id.
1724 */
1725 #define PKT_FILTER_APF_ID 200
1726 #define DHD_APF_LOCK(ndev) dhd_apf_lock(ndev)
1727 #define DHD_APF_UNLOCK(ndev) dhd_apf_unlock(ndev)
1728
1729 extern void dhd_apf_lock(struct net_device *dev);
1730 extern void dhd_apf_unlock(struct net_device *dev);
1731 extern int dhd_dev_apf_get_version(struct net_device *ndev, uint32 *version);
1732 extern int dhd_dev_apf_get_max_len(struct net_device *ndev, uint32 *max_len);
1733 extern int dhd_dev_apf_add_filter(struct net_device *ndev, u8* program,
1734 uint32 program_len);
1735 extern int dhd_dev_apf_enable_filter(struct net_device *ndev);
1736 extern int dhd_dev_apf_disable_filter(struct net_device *ndev);
1737 extern int dhd_dev_apf_delete_filter(struct net_device *ndev);
1738 #endif /* PKT_FILTER_SUPPORT && APF */
1739
1740 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
1741 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
1742
1743 extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
1744 extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
1745 extern struct net_device * dhd_idx2net(void *pub, int ifidx);
1746 extern int net_os_send_hang_message(struct net_device *dev);
1747 extern int net_os_send_hang_message_reason(struct net_device *dev, const char *string_num);
1748 extern bool dhd_wowl_cap(void *bus);
1749 extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
1750 wl_event_msg_t *, void **data_ptr, void *);
1751 extern int wl_process_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
1752 wl_event_msg_t *, void **data_ptr, void *);
1753 extern void wl_event_to_host_order(wl_event_msg_t * evt);
1754 extern int wl_host_event_get_data(void *pktdata, uint pktlen, bcm_event_msg_u_t *evu);
1755 extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
1756 extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
1757 int ifindex);
1758 extern int dhd_wl_ioctl_get_intiovar(dhd_pub_t *dhd_pub, char *name, uint *pval,
1759 int cmd, uint8 set, int ifidx);
1760 extern int dhd_wl_ioctl_set_intiovar(dhd_pub_t *dhd_pub, char *name, uint val,
1761 int cmd, uint8 set, int ifidx);
1762 extern void dhd_common_init(osl_t *osh);
1763
1764 extern int dhd_do_driver_init(struct net_device *net);
1765 extern int dhd_event_ifadd(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
1766 char *name, uint8 *mac);
1767 extern int dhd_event_ifdel(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
1768 char *name, uint8 *mac);
1769 extern int dhd_event_ifchange(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
1770 char *name, uint8 *mac);
1771 #ifdef DHD_UPDATE_INTF_MAC
1772 extern int dhd_op_if_update(dhd_pub_t *dhdpub, int ifidx);
1773 #endif /* DHD_UPDATE_INTF_MAC */
1774 extern struct net_device* dhd_allocate_if(dhd_pub_t *dhdpub, int ifidx, const char *name,
1775 uint8 *mac, uint8 bssidx, bool need_rtnl_lock, const char *dngl_name);
1776 extern int dhd_remove_if(dhd_pub_t *dhdpub, int ifidx, bool need_rtnl_lock);
1777 extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
1778 extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
1779 extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
1780 extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
1781
1782 /* Send packet to dongle via data channel */
1783 extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
1784
1785 /* send up locally generated event */
1786 extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
1787 /* Send event to host */
1788 extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
1789 #ifdef LOG_INTO_TCPDUMP
1790 extern void dhd_sendup_log(dhd_pub_t *dhdp, void *data, int len);
1791 #endif /* LOG_INTO_TCPDUMP */
1792 extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
1793 extern uint dhd_bus_status(dhd_pub_t *dhdp);
1794 extern int dhd_bus_start(dhd_pub_t *dhdp);
1795 extern int dhd_bus_suspend(dhd_pub_t *dhdpub);
1796 extern int dhd_bus_resume(dhd_pub_t *dhdpub, int stage);
1797 extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
1798 extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
1799 extern bool dhd_is_associated(dhd_pub_t *dhd, uint8 ifidx, int *retval);
1800 #if defined(BCMSDIO) || defined(BCMPCIE)
1801 extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
1802 extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
1803 extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
1804 #endif /* defined(BCMSDIO) || defined(BCMPCIE) */
1805 int dhd_bus_get_fw_mode(dhd_pub_t *dhdp);
1806
1807 #if defined(KEEP_ALIVE)
1808 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
1809 #endif /* KEEP_ALIVE */
1810
1811 /* OS spin lock API */
1812 extern void *dhd_os_spin_lock_init(osl_t *osh);
1813 extern void dhd_os_spin_lock_deinit(osl_t *osh, void *lock);
1814 extern unsigned long dhd_os_spin_lock(void *lock);
1815 void dhd_os_spin_unlock(void *lock, unsigned long flags);
1816
1817 #ifdef DHD_EFI
1818 extern int dhd_os_ds_enter_wait(dhd_pub_t * pub, uint * condition);
1819 extern int dhd_os_ds_enter_wake(dhd_pub_t * pub);
1820 #else
dhd_os_ds_enter_wait(dhd_pub_t * pub,uint * condition)1821 static INLINE int dhd_os_ds_enter_wait(dhd_pub_t * pub, uint * condition)
1822 { printf("%s is Not supported for this platform", __FUNCTION__); return 0; }
dhd_os_ds_enter_wake(dhd_pub_t * pub)1823 static INLINE int dhd_os_ds_enter_wake(dhd_pub_t * pub)
1824 { return 0; }
1825 #endif /* DHD_EFI */
1826
1827 #ifdef PCIE_INB_DW
1828 extern int dhd_os_ds_exit_wait(dhd_pub_t * pub, uint * condition);
1829 extern int dhd_os_ds_exit_wake(dhd_pub_t * pub);
1830 #endif /* PCIE_INB_DW */
1831 extern int dhd_os_busbusy_wake(dhd_pub_t * pub);
1832 extern int dhd_os_busbusy_wait_condition(dhd_pub_t *pub, uint *var, uint condition);
1833 extern int dhd_os_busbusy_wait_negation(dhd_pub_t * pub, uint * condition);
1834 extern int dhd_os_d3ack_wait(dhd_pub_t * pub, uint * condition);
1835 extern int dhd_os_d3ack_wake(dhd_pub_t * pub);
1836
1837 /*
1838 * Manage sta objects in an interface. Interface is identified by an ifindex and
1839 * sta(s) within an interfaces are managed using a MacAddress of the sta.
1840 */
1841 struct dhd_sta;
1842 extern bool dhd_sta_associated(dhd_pub_t *dhdp, uint32 bssidx, uint8 *mac);
1843 extern struct dhd_sta *dhd_find_sta(void *pub, int ifidx, void *ea);
1844 extern struct dhd_sta *dhd_findadd_sta(void *pub, int ifidx, void *ea);
1845 extern void dhd_del_all_sta(void *pub, int ifidx);
1846 extern void dhd_del_sta(void *pub, int ifidx, void *ea);
1847 extern int dhd_get_ap_isolate(dhd_pub_t *dhdp, uint32 idx);
1848 extern int dhd_set_ap_isolate(dhd_pub_t *dhdp, uint32 idx, int val);
1849 #if defined(BCM_GMAC3)
1850 extern int dhd_set_dev_def(dhd_pub_t *dhdp, uint32 idx, int val);
1851 #endif
1852 extern int dhd_bssidx2idx(dhd_pub_t *dhdp, uint32 bssidx);
1853 extern struct net_device *dhd_linux_get_primary_netdev(dhd_pub_t *dhdp);
1854
1855 extern bool dhd_is_concurrent_mode(dhd_pub_t *dhd);
1856 int dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *param_buf, uint param_len,
1857 char *res_buf, uint res_len, int set);
1858 extern int dhd_getiovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf,
1859 uint cmd_len, char **resptr, uint resp_len);
1860
1861 #ifdef DHD_MCAST_REGEN
1862 extern int dhd_get_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx);
1863 extern int dhd_set_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx, int val);
1864 #endif
1865 typedef enum cust_gpio_modes {
1866 WLAN_RESET_ON,
1867 WLAN_RESET_OFF,
1868 WLAN_POWER_ON,
1869 WLAN_POWER_OFF
1870 } cust_gpio_modes_t;
1871
1872 typedef struct dmaxref_mem_map {
1873 dhd_dma_buf_t *srcmem;
1874 dhd_dma_buf_t *dstmem;
1875 } dmaxref_mem_map_t;
1876
1877 extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
1878 extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
1879 /*
1880 * Insmod parameters for debug/test
1881 */
1882
1883 /* Watchdog timer interval */
1884 extern uint dhd_watchdog_ms;
1885 extern bool dhd_os_wd_timer_enabled(void *bus);
1886 #ifdef DHD_PCIE_RUNTIMEPM
1887 extern uint dhd_runtimepm_ms;
1888 #endif /* DHD_PCIE_RUNTIMEPM */
1889
1890 /* Console output poll interval */
1891 extern uint dhd_console_ms;
1892 extern uint android_msg_level;
1893 extern uint config_msg_level;
1894 extern uint sd_msglevel;
1895 extern uint dump_msg_level;
1896 #ifdef BCMDBUS
1897 extern uint dbus_msglevel;
1898 #endif /* BCMDBUS */
1899 #ifdef WL_WIRELESS_EXT
1900 extern uint iw_msg_level;
1901 #endif
1902 #ifdef WL_CFG80211
1903 extern uint wl_dbg_level;
1904 #endif
1905
1906 #ifdef DHD_LOAD_CHIPALIVE
1907 /* Use for SDIO reconnect */
1908 extern uint dhd_chip_alive;
1909 #endif
1910
1911 extern uint dhd_slpauto;
1912
1913 /* Use interrupts */
1914 extern uint dhd_intr;
1915
1916 /* Use polling */
1917 extern uint dhd_poll;
1918
1919 /* ARP offload agent mode */
1920 extern uint dhd_arp_mode;
1921
1922 /* ARP offload enable */
1923 extern uint dhd_arp_enable;
1924
1925 /* Pkt filte enable control */
1926 extern uint dhd_pkt_filter_enable;
1927
1928 /* Pkt filter init setup */
1929 extern uint dhd_pkt_filter_init;
1930
1931 /* Pkt filter mode control */
1932 extern uint dhd_master_mode;
1933
1934 /* Roaming mode control */
1935 extern uint dhd_roam_disable;
1936
1937 /* Roaming mode control */
1938 extern uint dhd_radio_up;
1939
1940 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
1941 extern int dhd_idletime;
1942 #ifdef DHD_USE_IDLECOUNT
1943 #define DHD_IDLETIME_TICKS 5
1944 #else
1945 #define DHD_IDLETIME_TICKS 1
1946 #endif /* DHD_USE_IDLECOUNT */
1947
1948 /* SDIO Drive Strength */
1949 extern uint dhd_sdiod_drive_strength;
1950
1951 /* triggers bcm_bprintf to print to kernel log */
1952 extern bool bcm_bprintf_bypass;
1953
1954 /* Override to force tx queueing all the time */
1955 extern uint dhd_force_tx_queueing;
1956
1957 /* Default bcn_timeout value is 4 */
1958 #define DEFAULT_BCN_TIMEOUT_VALUE 4
1959 #ifndef CUSTOM_BCN_TIMEOUT_SETTING
1960 #define CUSTOM_BCN_TIMEOUT_SETTING DEFAULT_BCN_TIMEOUT_VALUE
1961 #endif
1962
1963 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
1964 #define DEFAULT_KEEP_ALIVE_VALUE 55000 /* msec */
1965 #ifndef CUSTOM_KEEP_ALIVE_SETTING
1966 #define CUSTOM_KEEP_ALIVE_SETTING DEFAULT_KEEP_ALIVE_VALUE
1967 #endif /* DEFAULT_KEEP_ALIVE_VALUE */
1968
1969 #define NULL_PKT_STR "null_pkt"
1970
1971 /* hooks for custom glom setting option via Makefile */
1972 #define DEFAULT_GLOM_VALUE -1
1973 #ifndef CUSTOM_GLOM_SETTING
1974 #define CUSTOM_GLOM_SETTING DEFAULT_GLOM_VALUE
1975 #endif
1976 #define WL_AUTO_ROAM_TRIGGER -75
1977 /* hooks for custom Roaming Trigger setting via Makefile */
1978 #define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
1979 #define DEFAULT_ROAM_TRIGGER_SETTING -1
1980 #ifndef CUSTOM_ROAM_TRIGGER_SETTING
1981 #define CUSTOM_ROAM_TRIGGER_SETTING DEFAULT_ROAM_TRIGGER_VALUE
1982 #endif
1983
1984 /* hooks for custom Roaming Romaing setting via Makefile */
1985 #define DEFAULT_ROAM_DELTA_VALUE 10 /* dBm default roam delta all band */
1986 #define DEFAULT_ROAM_DELTA_SETTING -1
1987 #ifndef CUSTOM_ROAM_DELTA_SETTING
1988 #define CUSTOM_ROAM_DELTA_SETTING DEFAULT_ROAM_DELTA_VALUE
1989 #endif
1990
1991 /* hooks for custom PNO Event wake lock to guarantee enough time
1992 for the Platform to detect Event before system suspended
1993 */
1994 #define DEFAULT_PNO_EVENT_LOCK_xTIME 2 /* multiplay of DHD_PACKET_TIMEOUT_MS */
1995 #ifndef CUSTOM_PNO_EVENT_LOCK_xTIME
1996 #define CUSTOM_PNO_EVENT_LOCK_xTIME DEFAULT_PNO_EVENT_LOCK_xTIME
1997 #endif
1998 /* hooks for custom dhd_dpc_prio setting option via Makefile */
1999 #define DEFAULT_DHP_DPC_PRIO 1
2000 #ifndef CUSTOM_DPC_PRIO_SETTING
2001 #define CUSTOM_DPC_PRIO_SETTING DEFAULT_DHP_DPC_PRIO
2002 #endif
2003
2004 #ifndef CUSTOM_LISTEN_INTERVAL
2005 #define CUSTOM_LISTEN_INTERVAL LISTEN_INTERVAL
2006 #endif /* CUSTOM_LISTEN_INTERVAL */
2007
2008 #define DEFAULT_SUSPEND_BCN_LI_DTIM 3
2009 #ifndef CUSTOM_SUSPEND_BCN_LI_DTIM
2010 #define CUSTOM_SUSPEND_BCN_LI_DTIM DEFAULT_SUSPEND_BCN_LI_DTIM
2011 #endif
2012
2013 #ifndef BCN_TIMEOUT_IN_SUSPEND
2014 #define BCN_TIMEOUT_IN_SUSPEND 6 /* bcn timeout value in suspend mode */
2015 #endif
2016
2017 #ifndef CUSTOM_RXF_PRIO_SETTING
2018 #define CUSTOM_RXF_PRIO_SETTING MAX((CUSTOM_DPC_PRIO_SETTING - 1), 1)
2019 #endif
2020
2021 #define DEFAULT_WIFI_TURNOFF_DELAY 0
2022 #define WIFI_TURNOFF_DELAY DEFAULT_WIFI_TURNOFF_DELAY
2023
2024 #define DEFAULT_WIFI_TURNON_DELAY 200
2025 #ifndef WIFI_TURNON_DELAY
2026 #define WIFI_TURNON_DELAY DEFAULT_WIFI_TURNON_DELAY
2027 #endif /* WIFI_TURNON_DELAY */
2028
2029 #ifdef BCMSDIO
2030 #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 10 /* msec */
2031 #else
2032 #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 0 /* msec */
2033 #endif
2034 #ifndef CUSTOM_DHD_WATCHDOG_MS
2035 #define CUSTOM_DHD_WATCHDOG_MS DEFAULT_DHD_WATCHDOG_INTERVAL_MS
2036 #endif /* DEFAULT_DHD_WATCHDOG_INTERVAL_MS */
2037
2038 #define DEFAULT_ASSOC_RETRY_MAX 3
2039 #ifndef CUSTOM_ASSOC_RETRY_MAX
2040 #define CUSTOM_ASSOC_RETRY_MAX DEFAULT_ASSOC_RETRY_MAX
2041 #endif /* DEFAULT_ASSOC_RETRY_MAX */
2042
2043 #if defined(BCMSDIO) || defined(DISABLE_FRAMEBURST)
2044 #define DEFAULT_FRAMEBURST_SET 0
2045 #else
2046 #define DEFAULT_FRAMEBURST_SET 1
2047 #endif /* BCMSDIO */
2048
2049 #ifndef CUSTOM_FRAMEBURST_SET
2050 #define CUSTOM_FRAMEBURST_SET DEFAULT_FRAMEBURST_SET
2051 #endif /* CUSTOM_FRAMEBURST_SET */
2052
2053 #ifdef WLTDLS
2054 #ifndef CUSTOM_TDLS_IDLE_MODE_SETTING
2055 #define CUSTOM_TDLS_IDLE_MODE_SETTING 60000 /* 60sec to tear down TDLS of not active */
2056 #endif
2057 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_HIGH
2058 #define CUSTOM_TDLS_RSSI_THRESHOLD_HIGH -70 /* rssi threshold for establishing TDLS link */
2059 #endif
2060 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_LOW
2061 #define CUSTOM_TDLS_RSSI_THRESHOLD_LOW -80 /* rssi threshold for tearing down TDLS link */
2062 #endif
2063 #endif /* WLTDLS */
2064
2065 #if defined(VSDB) || defined(ROAM_ENABLE)
2066 #define DEFAULT_BCN_TIMEOUT 8
2067 #else
2068 #define DEFAULT_BCN_TIMEOUT 4
2069 #endif
2070
2071 #ifndef CUSTOM_BCN_TIMEOUT
2072 #define CUSTOM_BCN_TIMEOUT DEFAULT_BCN_TIMEOUT
2073 #endif
2074
2075 #define MAX_DTIM_SKIP_BEACON_INTERVAL 100 /* max allowed associated AP beacon for DTIM skip */
2076 #ifndef MAX_DTIM_ALLOWED_INTERVAL
2077 #define MAX_DTIM_ALLOWED_INTERVAL 600 /* max allowed total beacon interval for DTIM skip */
2078 #endif
2079
2080 #ifndef MIN_DTIM_FOR_ROAM_THRES_EXTEND
2081 #define MIN_DTIM_FOR_ROAM_THRES_EXTEND 600 /* minimum dtim interval to extend roam threshold */
2082 #endif
2083
2084 #define NO_DTIM_SKIP 1
2085 #ifdef SDTEST
2086 /* Echo packet generator (SDIO), pkts/s */
2087 extern uint dhd_pktgen;
2088
2089 /* Echo packet len (0 => sawtooth, max 1800) */
2090 extern uint dhd_pktgen_len;
2091 #define MAX_PKTGEN_LEN 1800
2092 #endif
2093
2094
2095 /* optionally set by a module_param_string() */
2096 #define MOD_PARAM_PATHLEN 2048
2097 #define MOD_PARAM_INFOLEN 512
2098 #define MOD_PARAM_SRLEN 64
2099
2100 #ifdef SOFTAP
2101 extern char fw_path2[MOD_PARAM_PATHLEN];
2102 #endif
2103
2104 #ifdef DHD_LEGACY_FILE_PATH
2105 #define PLATFORM_PATH "/data/"
2106 #elif defined(PLATFORM_SLP)
2107 #define PLATFORM_PATH "/opt/etc/"
2108 #else
2109 #define PLATFORM_PATH "/data/misc/conn/"
2110 #endif /* DHD_LEGACY_FILE_PATH */
2111
2112 /* Flag to indicate if we should download firmware on driver load */
2113 extern uint dhd_download_fw_on_driverload;
2114 #ifndef BCMDBUS
2115 extern int allow_delay_fwdl;
2116 #endif /* !BCMDBUS */
2117
2118 extern int dhd_process_cid_mac(dhd_pub_t *dhdp, bool prepost);
2119 extern int dhd_write_file(const char *filepath, char *buf, int buf_len);
2120 extern int dhd_read_file(const char *filepath, char *buf, int buf_len);
2121 extern int dhd_write_file_and_check(const char *filepath, char *buf, int buf_len);
2122
2123 #ifdef READ_MACADDR
2124 extern int dhd_set_macaddr_from_file(dhd_pub_t *dhdp);
2125 #else
dhd_set_macaddr_from_file(dhd_pub_t * dhdp)2126 static INLINE int dhd_set_macaddr_from_file(dhd_pub_t *dhdp) { return 0; }
2127 #endif /* READ_MACADDR */
2128 #ifdef WRITE_MACADDR
2129 extern int dhd_write_macaddr(struct ether_addr *mac);
2130 #else
dhd_write_macaddr(struct ether_addr * mac)2131 static INLINE int dhd_write_macaddr(struct ether_addr *mac) { return 0; }
2132 #endif /* WRITE_MACADDR */
dhd_check_module_cid(dhd_pub_t * dhdp)2133 static INLINE int dhd_check_module_cid(dhd_pub_t *dhdp) { return 0; }
2134 #ifdef GET_MAC_FROM_OTP
2135 extern int dhd_check_module_mac(dhd_pub_t *dhdp);
2136 #else
dhd_check_module_mac(dhd_pub_t * dhdp)2137 static INLINE int dhd_check_module_mac(dhd_pub_t *dhdp) { return 0; }
2138 #endif /* GET_MAC_FROM_OTP */
2139
2140 #if defined(READ_MACADDR) || defined(WRITE_MACADDR) || defined(GET_MAC_FROM_OTP)
2141 #define DHD_USE_CISINFO
2142 #endif
2143
2144 #ifdef DHD_USE_CISINFO
2145 int dhd_read_cis(dhd_pub_t *dhdp);
2146 void dhd_clear_cis(dhd_pub_t *dhdp);
2147 #else
dhd_read_cis(dhd_pub_t * dhdp)2148 static INLINE int dhd_read_cis(dhd_pub_t *dhdp) { return 0; }
dhd_clear_cis(dhd_pub_t * dhdp)2149 static INLINE void dhd_clear_cis(dhd_pub_t *dhdp) { }
2150 #endif /* DHD_USE_CISINFO */
2151
2152 #define IBSS_COALESCE_DEFAULT 1
2153 #define IBSS_INITIAL_SCAN_ALLOWED_DEFAULT 1
2154
2155
2156 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
2157 extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
2158
2159 #define IFLOCK_INIT(lock) *lock = 0
2160 #define IFLOCK(lock) while (InterlockedCompareExchange((lock), 1, 0)) \
2161 NdisStallExecution(1);
2162 #define IFUNLOCK(lock) InterlockedExchange((lock), 0)
2163 #define IFLOCK_FREE(lock)
2164 #define FW_SUPPORTED(dhd, capa) ((strstr(dhd->fw_capabilities, " " #capa " ") != NULL))
2165 #ifdef ARP_OFFLOAD_SUPPORT
2166 #define MAX_IPV4_ENTRIES 8
2167 void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
2168 void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
2169
2170 /* dhd_commn arp offload wrapers */
2171 void dhd_aoe_hostip_clr(dhd_pub_t *dhd, int idx);
2172 void dhd_aoe_arp_clr(dhd_pub_t *dhd, int idx);
2173 int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen, int idx);
2174 void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr, int idx);
2175 #endif /* ARP_OFFLOAD_SUPPORT */
2176 #ifdef WLTDLS
2177 int dhd_tdls_enable(struct net_device *dev, bool tdls_on, bool auto_on, struct ether_addr *mac);
2178 int dhd_tdls_set_mode(dhd_pub_t *dhd, bool wfd_mode);
2179 #ifdef PCIE_FULL_DONGLE
2180 int dhd_tdls_update_peer_info(dhd_pub_t *dhdp, wl_event_msg_t *event);
2181 int dhd_tdls_event_handler(dhd_pub_t *dhd_pub, wl_event_msg_t *event);
2182 int dhd_free_tdls_peer_list(dhd_pub_t *dhd_pub);
2183 #endif /* PCIE_FULL_DONGLE */
2184 #endif /* WLTDLS */
2185
2186 /* Neighbor Discovery Offload Support */
2187 extern int dhd_ndo_enable(dhd_pub_t * dhd, int ndo_enable);
2188 int dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipaddr, int idx);
2189 int dhd_ndo_remove_ip(dhd_pub_t *dhd, int idx);
2190
2191 /* Enhanced ND offload support */
2192 uint16 dhd_ndo_get_version(dhd_pub_t *dhdp);
2193 int dhd_ndo_add_ip_with_type(dhd_pub_t *dhdp, char *ipv6addr, uint8 type, int idx);
2194 int dhd_ndo_remove_ip_by_addr(dhd_pub_t *dhdp, char *ipv6addr, int idx);
2195 int dhd_ndo_remove_ip_by_type(dhd_pub_t *dhdp, uint8 type, int idx);
2196 int dhd_ndo_unsolicited_na_filter_enable(dhd_pub_t *dhdp, int enable);
2197
2198 /* ioctl processing for nl80211 */
2199 int dhd_ioctl_process(dhd_pub_t *pub, int ifidx, struct dhd_ioctl *ioc, void *data_buf);
2200
2201 void dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path,
2202 char *pclm_path, char *pconf_path);
2203 void dhd_set_bus_state(void *bus, uint32 state);
2204
2205 /* Remove proper pkts(either one no-frag pkt or whole fragmented pkts) */
2206 typedef int (*f_droppkt_t)(dhd_pub_t *dhdp, int prec, void* p, bool bPktInQ);
2207 extern bool dhd_prec_drop_pkts(dhd_pub_t *dhdp, struct pktq *pq, int prec, f_droppkt_t fn);
2208
2209 #ifdef PROP_TXSTATUS
2210 int dhd_os_wlfc_block(dhd_pub_t *pub);
2211 int dhd_os_wlfc_unblock(dhd_pub_t *pub);
2212 extern const uint8 prio2fifo[];
2213 #endif /* PROP_TXSTATUS */
2214
2215 int dhd_os_socram_dump(struct net_device *dev, uint32 *dump_size);
2216 int dhd_os_get_socram_dump(struct net_device *dev, char **buf, uint32 *size);
2217 int dhd_common_socram_dump(dhd_pub_t *dhdp);
2218
2219 int dhd_os_get_version(struct net_device *dev, bool dhd_ver, char **buf, uint32 size);
2220
2221 uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_if_fail);
2222 void dhd_os_prefree(dhd_pub_t *dhdpub, void *addr, uint size);
2223
2224 #if defined(CONFIG_DHD_USE_STATIC_BUF)
2225 #define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, FALSE)
2226 #define DHD_OS_PREFREE(dhdpub, addr, size) dhd_os_prefree(dhdpub, addr, size)
2227 #else
2228 #define DHD_OS_PREALLOC(dhdpub, section, size) MALLOC(dhdpub->osh, size)
2229 #define DHD_OS_PREFREE(dhdpub, addr, size) MFREE(dhdpub->osh, addr, size)
2230 #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
2231
2232 #ifdef USE_WFA_CERT_CONF
2233 enum {
2234 SET_PARAM_BUS_TXGLOM_MODE,
2235 SET_PARAM_ROAMOFF,
2236 #ifdef USE_WL_FRAMEBURST
2237 SET_PARAM_FRAMEBURST,
2238 #endif /* USE_WL_FRAMEBURST */
2239 #ifdef USE_WL_TXBF
2240 SET_PARAM_TXBF,
2241 #endif /* USE_WL_TXBF */
2242 #ifdef PROP_TXSTATUS
2243 SET_PARAM_PROPTX,
2244 SET_PARAM_PROPTXMODE,
2245 #endif /* PROP_TXSTATUS */
2246 PARAM_LAST_VALUE
2247 };
2248 extern int sec_get_param_wfa_cert(dhd_pub_t *dhd, int mode, uint* read_val);
2249 #endif /* USE_WFA_CERT_CONF */
2250
2251 #define dhd_add_flowid(pub, ifidx, ac_prio, ea, flowid) do {} while (0)
2252 #define dhd_del_flowid(pub, ifidx, flowid) do {} while (0)
2253 bool dhd_wet_chainable(dhd_pub_t *dhdp);
2254
2255 extern unsigned long dhd_os_general_spin_lock(dhd_pub_t *pub);
2256 extern void dhd_os_general_spin_unlock(dhd_pub_t *pub, unsigned long flags);
2257
2258 /** Miscellaenous DHD Spin Locks */
2259
2260 /* Disable router 3GMAC bypass path perimeter lock */
2261 #define DHD_PERIM_LOCK(dhdp) do {} while (0)
2262 #define DHD_PERIM_UNLOCK(dhdp) do {} while (0)
2263 #define DHD_PERIM_LOCK_ALL(processor_id) do {} while (0)
2264 #define DHD_PERIM_UNLOCK_ALL(processor_id) do {} while (0)
2265
2266 /* Enable DHD general spin lock/unlock */
2267 #define DHD_GENERAL_LOCK(dhdp, flags) \
2268 (flags) = dhd_os_general_spin_lock(dhdp)
2269 #define DHD_GENERAL_UNLOCK(dhdp, flags) \
2270 dhd_os_general_spin_unlock((dhdp), (flags))
2271
2272 /* Enable DHD timer spin lock/unlock */
2273 #define DHD_TIMER_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2274 #define DHD_TIMER_UNLOCK(lock, flags) dhd_os_spin_unlock(lock, (flags))
2275
2276 /* Enable DHD flowring spin lock/unlock */
2277 #define DHD_FLOWRING_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2278 #define DHD_FLOWRING_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2279
2280 /* Enable DHD common flowring info spin lock/unlock */
2281 #define DHD_FLOWID_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2282 #define DHD_FLOWID_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2283
2284 /* Enable DHD common flowring list spin lock/unlock */
2285 #define DHD_FLOWRING_LIST_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2286 #define DHD_FLOWRING_LIST_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2287
2288 #define DHD_SPIN_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2289 #define DHD_SPIN_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2290
2291 #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2292 #define DHD_BUS_INB_DW_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2293
2294 /* Enable DHD TDLS peer list spin lock/unlock */
2295 #ifdef WLTDLS
2296 #define DHD_TDLS_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2297 #define DHD_TDLS_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2298 #endif /* WLTDLS */
2299
2300 #ifdef DBG_PKT_MON
2301 /* Enable DHD PKT MON spin lock/unlock */
2302 #define DHD_PKT_MON_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2303 #define DHD_PKT_MON_UNLOCK(lock, flags) dhd_os_spin_unlock(lock, (flags))
2304 #endif /* DBG_PKT_MON */
2305
2306 #define DHD_LINUX_GENERAL_LOCK(dhdp, flags) DHD_GENERAL_LOCK(dhdp, flags)
2307 #define DHD_LINUX_GENERAL_UNLOCK(dhdp, flags) DHD_GENERAL_UNLOCK(dhdp, flags)
2308
2309 extern void dhd_dump_to_kernelog(dhd_pub_t *dhdp);
2310
2311 #ifdef BCMDBUS
2312 extern uint dhd_get_rxsz(dhd_pub_t *pub);
2313 extern void dhd_set_path(dhd_pub_t *pub);
2314 extern void dhd_bus_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
2315 extern void dhd_bus_clearcounts(dhd_pub_t *dhdp);
2316 #endif /* BCMDBUS */
2317
2318 #ifdef DHD_L2_FILTER
2319 extern int dhd_get_parp_status(dhd_pub_t *dhdp, uint32 idx);
2320 extern int dhd_set_parp_status(dhd_pub_t *dhdp, uint32 idx, int val);
2321 extern int dhd_get_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx);
2322 extern int dhd_set_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx, int val);
2323 extern int dhd_get_block_ping_status(dhd_pub_t *dhdp, uint32 idx);
2324 extern int dhd_set_block_ping_status(dhd_pub_t *dhdp, uint32 idx, int val);
2325 extern int dhd_get_grat_arp_status(dhd_pub_t *dhdp, uint32 idx);
2326 extern int dhd_set_grat_arp_status(dhd_pub_t *dhdp, uint32 idx, int val);
2327 #endif /* DHD_L2_FILTER */
2328
2329
2330 typedef struct wl_io_pport {
2331 dhd_pub_t *dhd_pub;
2332 uint ifidx;
2333 } wl_io_pport_t;
2334
2335 typedef struct wl_evt_pport {
2336 dhd_pub_t *dhd_pub;
2337 int *ifidx;
2338 void *pktdata;
2339 uint data_len;
2340 void **data_ptr;
2341 void *raw_event;
2342 } wl_evt_pport_t;
2343
2344 extern void *dhd_pub_shim(dhd_pub_t *dhd_pub);
2345 #ifdef DHD_FW_COREDUMP
2346 void* dhd_get_fwdump_buf(dhd_pub_t *dhd_pub, uint32 length);
2347 #endif /* DHD_FW_COREDUMP */
2348
2349 #if defined(SET_RPS_CPUS)
2350 int dhd_rps_cpus_enable(struct net_device *net, int enable);
2351 int custom_rps_map_set(struct netdev_rx_queue *queue, char *buf, size_t len);
2352 void custom_rps_map_clear(struct netdev_rx_queue *queue);
2353 #define PRIMARY_INF 0
2354 #define VIRTUAL_INF 1
2355 #if defined(CONFIG_MACH_UNIVERSAL5433) || defined(CONFIG_MACH_UNIVERSAL7420) || \
2356 defined(CONFIG_SOC_EXYNOS8890)
2357 #define RPS_CPUS_MASK "10"
2358 #define RPS_CPUS_MASK_P2P "10"
2359 #define RPS_CPUS_MASK_IBSS "10"
2360 #define RPS_CPUS_WLAN_CORE_ID 4
2361 #else
2362 #define RPS_CPUS_MASK "6"
2363 #define RPS_CPUS_MASK_P2P "6"
2364 #define RPS_CPUS_MASK_IBSS "6"
2365 #endif /* CONFIG_MACH_UNIVERSAL5433 || CONFIG_MACH_UNIVERSAL7420 || CONFIG_SOC_EXYNOS8890 */
2366 #endif
2367
2368 int dhd_get_download_buffer(dhd_pub_t *dhd, char *file_path, download_type_t component,
2369 char ** buffer, int *length);
2370
2371 void dhd_free_download_buffer(dhd_pub_t *dhd, void *buffer, int length);
2372
2373 int dhd_download_blob(dhd_pub_t *dhd, unsigned char *image,
2374 uint32 len, char *iovar);
2375
2376 int dhd_apply_default_clm(dhd_pub_t *dhd, char *clm_path);
2377
2378 #ifdef SHOW_LOGTRACE
2379 int dhd_parse_logstrs_file(osl_t *osh, char *raw_fmts, int logstrs_size,
2380 dhd_event_log_t *event_log);
2381 int dhd_parse_map_file(osl_t *osh, void *file, uint32 *ramstart,
2382 uint32 *rodata_start, uint32 *rodata_end);
2383 #ifdef PCIE_FULL_DONGLE
2384 int dhd_event_logtrace_infobuf_pkt_process(dhd_pub_t *dhdp, void *pktbuf,
2385 dhd_event_log_t *event_data);
2386 #endif /* PCIE_FULL_DONGLE */
2387 #endif /* SHOW_LOGTRACE */
2388
2389 #define dhd_is_device_removed(x) FALSE
2390 #define dhd_os_ind_firmware_stall(x)
2391
2392 #if defined(DHD_FW_COREDUMP)
2393 extern void dhd_get_memdump_info(dhd_pub_t *dhd);
2394 #endif /* defined(DHD_FW_COREDUMP) */
2395 #ifdef BCMASSERT_LOG
2396 extern void dhd_get_assert_info(dhd_pub_t *dhd);
2397 #else
dhd_get_assert_info(dhd_pub_t * dhd)2398 static INLINE void dhd_get_assert_info(dhd_pub_t *dhd) { }
2399 #endif /* BCMASSERT_LOG */
2400
2401 #define DMAXFER_FREE(dhdp, dmap) dhd_schedule_dmaxfer_free(dhdp, dmap);
2402
2403 #if defined(PCIE_FULL_DONGLE)
2404 extern void dmaxfer_free_prev_dmaaddr(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
2405 void dhd_schedule_dmaxfer_free(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
2406 #endif /* PCIE_FULL_DONGLE */
2407
2408 #define DHD_LB_STATS_NOOP do { /* noop */ } while (0)
2409 #if defined(DHD_LB_STATS)
2410 #include <bcmutils.h>
2411 extern void dhd_lb_stats_init(dhd_pub_t *dhd);
2412 extern void dhd_lb_stats_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
2413 extern void dhd_lb_stats_update_napi_histo(dhd_pub_t *dhdp, uint32 count);
2414 extern void dhd_lb_stats_update_txc_histo(dhd_pub_t *dhdp, uint32 count);
2415 extern void dhd_lb_stats_update_rxc_histo(dhd_pub_t *dhdp, uint32 count);
2416 extern void dhd_lb_stats_txc_percpu_cnt_incr(dhd_pub_t *dhdp);
2417 extern void dhd_lb_stats_rxc_percpu_cnt_incr(dhd_pub_t *dhdp);
2418 #define DHD_LB_STATS_INIT(dhdp) dhd_lb_stats_init(dhdp)
2419 #define DHD_LB_STATS_DEINIT(dhdp) dhd_lb_stats_deinit(dhdp)
2420 /* Reset is called from common layer so it takes dhd_pub_t as argument */
2421 #define DHD_LB_STATS_RESET(dhdp) dhd_lb_stats_init(dhdp)
2422 #define DHD_LB_STATS_CLR(x) (x) = 0U
2423 #define DHD_LB_STATS_INCR(x) (x) = (x) + 1
2424 #define DHD_LB_STATS_ADD(x, c) (x) = (x) + (c)
2425 #define DHD_LB_STATS_PERCPU_ARR_INCR(x) \
2426 { \
2427 int cpu = get_cpu(); put_cpu(); \
2428 DHD_LB_STATS_INCR(x[cpu]); \
2429 }
2430 #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhdp, x) dhd_lb_stats_update_napi_histo(dhdp, x)
2431 #define DHD_LB_STATS_UPDATE_TXC_HISTO(dhdp, x) dhd_lb_stats_update_txc_histo(dhdp, x)
2432 #define DHD_LB_STATS_UPDATE_RXC_HISTO(dhdp, x) dhd_lb_stats_update_rxc_histo(dhdp, x)
2433 #define DHD_LB_STATS_TXC_PERCPU_CNT_INCR(dhdp) dhd_lb_stats_txc_percpu_cnt_incr(dhdp)
2434 #define DHD_LB_STATS_RXC_PERCPU_CNT_INCR(dhdp) dhd_lb_stats_rxc_percpu_cnt_incr(dhdp)
2435 #else /* !DHD_LB_STATS */
2436 #define DHD_LB_STATS_INIT(dhdp) DHD_LB_STATS_NOOP
2437 #define DHD_LB_STATS_DEINIT(dhdp) DHD_LB_STATS_NOOP
2438 #define DHD_LB_STATS_RESET(dhdp) DHD_LB_STATS_NOOP
2439 #define DHD_LB_STATS_CLR(x) DHD_LB_STATS_NOOP
2440 #define DHD_LB_STATS_INCR(x) DHD_LB_STATS_NOOP
2441 #define DHD_LB_STATS_ADD(x, c) DHD_LB_STATS_NOOP
2442 #define DHD_LB_STATS_PERCPU_ARR_INCR(x) DHD_LB_STATS_NOOP
2443 #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhd, x) DHD_LB_STATS_NOOP
2444 #define DHD_LB_STATS_UPDATE_TXC_HISTO(dhd, x) DHD_LB_STATS_NOOP
2445 #define DHD_LB_STATS_UPDATE_RXC_HISTO(dhd, x) DHD_LB_STATS_NOOP
2446 #define DHD_LB_STATS_TXC_PERCPU_CNT_INCR(dhdp) DHD_LB_STATS_NOOP
2447 #define DHD_LB_STATS_RXC_PERCPU_CNT_INCR(dhdp) DHD_LB_STATS_NOOP
2448 #endif /* !DHD_LB_STATS */
2449
2450 #ifdef DHD_SSSR_DUMP
2451 #define DHD_SSSR_MEMPOOL_SIZE (1024 * 1024) /* 1MB size */
2452 extern int dhd_sssr_mempool_init(dhd_pub_t *dhd);
2453 extern void dhd_sssr_mempool_deinit(dhd_pub_t *dhd);
2454 extern int dhd_sssr_dump_init(dhd_pub_t *dhd);
2455 extern void dhd_sssr_dump_deinit(dhd_pub_t *dhd);
2456 #define DHD_SSSR_MEMPOOL_INIT(dhdp) dhd_sssr_mempool_init(dhdp)
2457 #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) dhd_sssr_mempool_deinit(dhdp)
2458 #define DHD_SSSR_DUMP_INIT(dhdp) dhd_sssr_dump_init(dhdp)
2459 #define DHD_SSSR_DUMP_DEINIT(dhdp) dhd_sssr_dump_deinit(dhdp)
2460 #else
2461 #define DHD_SSSR_MEMPOOL_INIT(dhdp) do { /* noop */ } while (0)
2462 #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) do { /* noop */ } while (0)
2463 #define DHD_SSSR_DUMP_INIT(dhdp) do { /* noop */ } while (0)
2464 #define DHD_SSSR_DUMP_DEINIT(dhdp) do { /* noop */ } while (0)
2465 #endif /* DHD_SSSR_DUMP */
2466
2467 #ifdef SHOW_LOGTRACE
2468 void dhd_get_read_buf_ptr(dhd_pub_t *dhd_pub, trace_buf_info_t *read_buf_info);
2469 #endif /* SHOW_LOGTRACE */
2470
2471 #ifdef BCMPCIE
2472 extern int dhd_prot_debug_info_print(dhd_pub_t *dhd);
2473 #else
2474 #define dhd_prot_debug_info_print(x)
2475 #endif /* BCMPCIE */
2476
2477 extern bool dhd_prot_is_cmpl_ring_empty(dhd_pub_t *dhd, void *prot_info);
2478
2479 bool dhd_fw_download_status(dhd_pub_t * dhd_pub);
2480
2481 /* Bitmask used for Join Timeout */
2482 #define WLC_SSID_MASK 0x01
2483 #define WLC_WPA_MASK 0x02
2484
2485 extern int dhd_start_join_timer(dhd_pub_t *pub);
2486 extern int dhd_stop_join_timer(dhd_pub_t *pub);
2487 extern int dhd_start_scan_timer(dhd_pub_t *pub);
2488 extern int dhd_stop_scan_timer(dhd_pub_t *pub);
2489 extern int dhd_start_cmd_timer(dhd_pub_t *pub);
2490 extern int dhd_stop_cmd_timer(dhd_pub_t *pub);
2491 extern int dhd_start_bus_timer(dhd_pub_t *pub);
2492 extern int dhd_stop_bus_timer(dhd_pub_t *pub);
2493 extern uint16 dhd_get_request_id(dhd_pub_t *pub);
2494 extern int dhd_set_request_id(dhd_pub_t *pub, uint16 id, uint32 cmd);
2495 extern void dhd_set_join_error(dhd_pub_t *pub, uint32 mask);
2496 extern void dhd_clear_join_error(dhd_pub_t *pub, uint32 mask);
2497 extern void dhd_get_scan_to_val(dhd_pub_t *pub, uint32 *to_val);
2498 extern void dhd_set_scan_to_val(dhd_pub_t *pub, uint32 to_val);
2499 extern void dhd_get_join_to_val(dhd_pub_t *pub, uint32 *to_val);
2500 extern void dhd_set_join_to_val(dhd_pub_t *pub, uint32 to_val);
2501 extern void dhd_get_cmd_to_val(dhd_pub_t *pub, uint32 *to_val);
2502 extern void dhd_set_cmd_to_val(dhd_pub_t *pub, uint32 to_val);
2503 extern void dhd_get_bus_to_val(dhd_pub_t *pub, uint32 *to_val);
2504 extern void dhd_set_bus_to_val(dhd_pub_t *pub, uint32 to_val);
2505 extern int dhd_start_timesync_timer(dhd_pub_t *pub);
2506 extern int dhd_stop_timesync_timer(dhd_pub_t *pub);
2507
2508 #ifdef DHD_PKTID_AUDIT_ENABLED
2509 void dhd_pktid_error_handler(dhd_pub_t *dhdp);
2510 #endif /* DHD_PKTID_AUDIT_ENABLED */
2511
2512 #ifdef DHD_PCIE_RUNTIMEPM
2513 extern bool dhd_runtimepm_state(dhd_pub_t *dhd);
2514 extern bool dhd_runtime_bus_wake(struct dhd_bus *bus, bool wait, void *func_addr);
2515 extern bool dhdpcie_runtime_bus_wake(dhd_pub_t *dhdp, bool wait, void *func_addr);
2516 extern void dhdpcie_block_runtime_pm(dhd_pub_t *dhdp);
2517 extern bool dhdpcie_is_resume_done(dhd_pub_t *dhdp);
2518 extern void dhd_runtime_pm_disable(dhd_pub_t *dhdp);
2519 extern void dhd_runtime_pm_enable(dhd_pub_t *dhdp);
2520 /* Disable the Runtime PM and wake up if the bus is already in suspend */
2521 #define DHD_DISABLE_RUNTIME_PM(dhdp) \
2522 do { \
2523 dhd_runtime_pm_disable(dhdp); \
2524 } while (0);
2525
2526 /* Enable the Runtime PM */
2527 #define DHD_ENABLE_RUNTIME_PM(dhdp) \
2528 do { \
2529 dhd_runtime_pm_enable(dhdp); \
2530 } while (0);
2531 #else
2532 #define DHD_DISABLE_RUNTIME_PM(dhdp)
2533 #define DHD_ENABLE_RUNTIME_PM(dhdp)
2534 #endif /* DHD_PCIE_RUNTIMEPM */
2535
2536 /*
2537 * Enable this macro if you want to track the calls to wake lock
2538 * This records can be printed using the following command
2539 * cat /sys/bcm-dhd/wklock_trace
2540 * DHD_TRACE_WAKE_LOCK supports over linux 2.6.0 version
2541 */
2542 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
2543 #undef DHD_TRACE_WAKE_LOCK
2544 #endif /* KERNEL_VER < KERNEL_VERSION(2, 6, 0) */
2545
2546 #if defined(DHD_TRACE_WAKE_LOCK)
2547 void dhd_wk_lock_stats_dump(dhd_pub_t *dhdp);
2548 #endif
2549
2550 extern bool dhd_query_bus_erros(dhd_pub_t *dhdp);
2551
2552 extern void init_dhd_timeouts(dhd_pub_t *pub);
2553 extern void deinit_dhd_timeouts(dhd_pub_t *pub);
2554
2555 typedef enum timeout_resons {
2556 DHD_REASON_COMMAND_TO,
2557 DHD_REASON_JOIN_TO,
2558 DHD_REASON_SCAN_TO,
2559 DHD_REASON_OQS_TO
2560 } timeout_reasons_t;
2561
2562 #if defined(PCIE_OOB) || defined(PCIE_INB_DW)
2563 extern int dhd_bus_set_device_wake(struct dhd_bus *bus, bool val);
2564 #endif /* defined(PCIE_OOB) || defined(PCIE_INB_DW) */
2565
2566 #ifdef DHD_EFI
2567 extern void dhd_schedule_reset(dhd_pub_t *dhdp);
2568 #else
dhd_schedule_reset(dhd_pub_t * dhdp)2569 static INLINE void dhd_schedule_reset(dhd_pub_t *dhdp) {;}
2570 #endif
2571
2572 #ifdef ENABLE_TEMP_THROTTLING
2573 #ifndef TEMP_THROTTLE_CONTROL_BIT
2574 #define TEMP_THROTTLE_CONTROL_BIT 0xd
2575 #endif
2576 #endif /* ENABLE_TEMP_THROTTLING */
2577
2578 int dhd_send_msg_to_daemon(struct sk_buff *skb, void *data, int size);
2579 #ifdef REPORT_FATAL_TIMEOUTS
2580 void dhd_send_trap_to_fw_for_timeout(dhd_pub_t * pub, timeout_reasons_t reason);
2581 #endif
2582
2583 #if defined(CONFIG_64BIT)
2584 #define DHD_SUPPORT_64BIT
2585 #elif defined(DHD_EFI)
2586 #define DHD_SUPPORT_64BIT
2587 /* by default disabled for other platforms, can enable appropriate macro to enable 64 bit support */
2588 #endif /* (linux || LINUX) && CONFIG_64BIT */
2589
2590 #ifdef SET_PCIE_IRQ_CPU_CORE
2591 extern void dhd_set_irq_cpucore(dhd_pub_t *dhdp, int set);
2592 extern void set_irq_cpucore(unsigned int irq, int set);
2593 #endif /* SET_PCIE_IRQ_CPU_CORE */
2594 #if defined(DHD_HANG_SEND_UP_TEST)
2595 extern void dhd_make_hang_with_reason(struct net_device *dev, const char *string_num);
2596 #endif /* DHD_HANG_SEND_UP_TEST */
2597
2598 #if defined(DHD_BLOB_EXISTENCE_CHECK)
2599 extern void dhd_set_blob_support(dhd_pub_t *dhdp, char *fw_path);
2600 #endif /* DHD_BLOB_EXISTENCE_CHECK */
2601
2602 #ifdef DHD_WAKE_STATUS
2603 wake_counts_t* dhd_get_wakecount(dhd_pub_t *dhdp);
2604 #endif /* DHD_WAKE_STATUS */
2605
2606 #ifdef BCM_ASLR_HEAP
2607 extern uint32 dhd_get_random_number(void);
2608 #endif /* BCM_ASLR_HEAP */
2609 #endif /* _dhd_h_ */
2610