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