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