bfca7496365a9897078152f22dbf83db25a49bd5
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / drivers / net / wireless / bcmdhd4361 / 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-2019, Broadcom.
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 798183 2019-01-07 09:51:58Z $
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 <linux/fs.h>
50 #include <linux/proc_fs.h>
51 #include <asm/uaccess.h>
52 #include <asm/unaligned.h>
53 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_HAS_WAKELOCK)
54 #include <linux/wakelock.h>
55 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined (CONFIG_HAS_WAKELOCK) */
56 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
57 #include <linux/sched/types.h>
58 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */
59 /* The kernel threading is sdio-specific */
60 struct task_struct;
61 struct sched_param;
62 #if defined(BT_OVER_SDIO)
63 #include <dhd_bt_interface.h>
64 #endif /* defined (BT_OVER_SDIO) */
65 int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
66 int get_scheduler_policy(struct task_struct *p);
67 #define MAX_EVENT 16
68
69 #define ALL_INTERFACES 0xff
70
71 #include <wlioctl.h>
72 #include <dhdioctl.h>
73 #include <wlfc_proto.h>
74 #include <hnd_armtrap.h>
75 #if defined(DUMP_IOCTL_IOV_LIST) || defined(DHD_DEBUG)
76 #include <bcmutils.h>
77 #endif /* DUMP_IOCTL_IOV_LIST || DHD_DEBUG */
78
79 #if defined(BCMWDF)
80 #include <wdf.h>
81 #include <WdfMiniport.h>
82 #endif /* (BCMWDF) */
83
84 #ifdef WL_CFGVENDOR_SEND_HANG_EVENT
85 #include <rte_ioctl.h>
86 #endif /* WL_CFGVENDOR_SEND_HANG_EVENT */
87
88 #ifdef DHD_ERPOM
89 #include <pom.h>
90 #endif /* DHD_ERPOM */
91
92 #include <dngl_stats.h>
93
94 #ifdef DEBUG_DPC_THREAD_WATCHDOG
95 #define MAX_RESCHED_CNT 600
96 #endif /* DEBUG_DPC_THREAD_WATCHDOG */
97
98 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) && LINUX_VERSION_CODE < \
99 KERNEL_VERSION(3, 18, 0) || defined(CONFIG_BCMDHD_VENDOR_EXT))
100 #define WL_VENDOR_EXT_SUPPORT
101 #endif /* 3.18 > KERNEL_VER >= 3.14 || defined(CONFIG_BCMDHD_VENDOR_EXT) */
102
103 #if defined(KEEP_ALIVE)
104 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
105 #define KEEP_ALIVE_PERIOD 55000
106 #define NULL_PKT_STR "null_pkt"
107 #endif /* KEEP_ALIVE */
108
109 /* Forward decls */
110 struct dhd_bus;
111 struct dhd_prot;
112 struct dhd_info;
113 struct dhd_ioctl;
114 struct dhd_dbg;
115 struct dhd_ts;
116
117 /* The level of bus communication with the dongle */
118 enum dhd_bus_state {
119 DHD_BUS_DOWN, /* Not ready for frame transfers */
120 DHD_BUS_LOAD, /* Download access only (CPU reset) */
121 DHD_BUS_DATA, /* Ready for frame transfers */
122 DHD_BUS_SUSPEND, /* Bus has been suspended */
123 DHD_BUS_DOWN_IN_PROGRESS, /* Bus going Down */
124 };
125
126 /* The level of bus communication with the dongle */
127 enum dhd_bus_devreset_type {
128 DHD_BUS_DEVRESET_ON = 0, /* ON */
129 DHD_BUS_DEVRESET_OFF = 1, /* OFF */
130 DHD_BUS_DEVRESET_FLR = 2, /* FLR */
131 DHD_BUS_DEVRESET_FLR_FORCE_FAIL = 3, /* FLR FORCE FAIL */
132 DHD_BUS_DEVRESET_QUIESCE = 4, /* FLR */
133 };
134
135 /*
136 * Bit fields to Indicate clean up process that wait till they are finished.
137 * Future synchronizable processes can add their bit filed below and update
138 * their functionalities accordingly
139 */
140 #define DHD_BUS_BUSY_IN_TX 0x01
141 #define DHD_BUS_BUSY_IN_SEND_PKT 0x02
142 #define DHD_BUS_BUSY_IN_DPC 0x04
143 #define DHD_BUS_BUSY_IN_WD 0x08
144 #define DHD_BUS_BUSY_IN_IOVAR 0x10
145 #define DHD_BUS_BUSY_IN_DHD_IOVAR 0x20
146 #define DHD_BUS_BUSY_SUSPEND_IN_PROGRESS 0x40
147 #define DHD_BUS_BUSY_RESUME_IN_PROGRESS 0x80
148 #define DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS 0x100
149 #define DHD_BUS_BUSY_RPM_SUSPEND_DONE 0x200
150 #define DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS 0x400
151 #define DHD_BUS_BUSY_RPM_ALL (DHD_BUS_BUSY_RPM_SUSPEND_DONE | \
152 DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS | \
153 DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
154 #define DHD_BUS_BUSY_IN_CHECKDIED 0x800
155 #define DHD_BUS_BUSY_IN_MEMDUMP 0x1000
156 #define DHD_BUS_BUSY_IN_SSSRDUMP 0x2000
157 #define DHD_BUS_BUSY_IN_LOGDUMP 0x4000
158
159 #define DHD_BUS_BUSY_SET_IN_TX(dhdp) \
160 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_TX
161 #define DHD_BUS_BUSY_SET_IN_SEND_PKT(dhdp) \
162 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SEND_PKT
163 #define DHD_BUS_BUSY_SET_IN_DPC(dhdp) \
164 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DPC
165 #define DHD_BUS_BUSY_SET_IN_WD(dhdp) \
166 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_WD
167 #define DHD_BUS_BUSY_SET_IN_IOVAR(dhdp) \
168 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_IOVAR
169 #define DHD_BUS_BUSY_SET_IN_DHD_IOVAR(dhdp) \
170 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DHD_IOVAR
171 #define DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(dhdp) \
172 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
173 #define DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(dhdp) \
174 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RESUME_IN_PROGRESS
175 #define DHD_BUS_BUSY_SET_RPM_SUSPEND_IN_PROGRESS(dhdp) \
176 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
177 #define DHD_BUS_BUSY_SET_RPM_SUSPEND_DONE(dhdp) \
178 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_DONE
179 #define DHD_BUS_BUSY_SET_RPM_RESUME_IN_PROGRESS(dhdp) \
180 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
181 #define DHD_BUS_BUSY_SET_IN_CHECKDIED(dhdp) \
182 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_CHECKDIED
183 #define DHD_BUS_BUSY_SET_IN_MEMDUMP(dhdp) \
184 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_MEMDUMP
185 #define DHD_BUS_BUSY_SET_IN_SSSRDUMP(dhdp) \
186 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SSSRDUMP
187 #define DHD_BUS_BUSY_SET_IN_LOGDUMP(dhdp) \
188 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_LOGDUMP
189
190 #define DHD_BUS_BUSY_CLEAR_IN_TX(dhdp) \
191 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_TX
192 #define DHD_BUS_BUSY_CLEAR_IN_SEND_PKT(dhdp) \
193 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SEND_PKT
194 #define DHD_BUS_BUSY_CLEAR_IN_DPC(dhdp) \
195 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DPC
196 #define DHD_BUS_BUSY_CLEAR_IN_WD(dhdp) \
197 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_WD
198 #define DHD_BUS_BUSY_CLEAR_IN_IOVAR(dhdp) \
199 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_IOVAR
200 #define DHD_BUS_BUSY_CLEAR_IN_DHD_IOVAR(dhdp) \
201 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DHD_IOVAR
202 #define DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(dhdp) \
203 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
204 #define DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(dhdp) \
205 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RESUME_IN_PROGRESS
206 #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_IN_PROGRESS(dhdp) \
207 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
208 #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_DONE(dhdp) \
209 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_DONE
210 #define DHD_BUS_BUSY_CLEAR_RPM_RESUME_IN_PROGRESS(dhdp) \
211 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
212 #define DHD_BUS_BUSY_CLEAR_IN_CHECKDIED(dhdp) \
213 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_CHECKDIED
214 #define DHD_BUS_BUSY_CLEAR_IN_MEMDUMP(dhdp) \
215 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_MEMDUMP
216 #define DHD_BUS_BUSY_CLEAR_IN_SSSRDUMP(dhdp) \
217 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SSSRDUMP
218 #define DHD_BUS_BUSY_CLEAR_IN_LOGDUMP(dhdp) \
219 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_LOGDUMP
220
221 #define DHD_BUS_BUSY_CHECK_IN_TX(dhdp) \
222 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_TX)
223 #define DHD_BUS_BUSY_CHECK_IN_SEND_PKT(dhdp) \
224 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SEND_PKT)
225 #define DHD_BUS_BUSY_CHECK_IN_DPC(dhdp) \
226 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DPC)
227 #define DHD_BUS_BUSY_CHECK_IN_WD(dhdp) \
228 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_WD)
229 #define DHD_BUS_BUSY_CHECK_IN_IOVAR(dhdp) \
230 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_IOVAR)
231 #define DHD_BUS_BUSY_CHECK_IN_DHD_IOVAR(dhdp) \
232 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DHD_IOVAR)
233 #define DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) \
234 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_SUSPEND_IN_PROGRESS)
235 #define DHD_BUS_BUSY_CHECK_RESUME_IN_PROGRESS(dhdp) \
236 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RESUME_IN_PROGRESS)
237 #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp) \
238 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS)
239 #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_DONE(dhdp) \
240 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_DONE)
241 #define DHD_BUS_BUSY_CHECK_RPM_RESUME_IN_PROGRESS(dhdp) \
242 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
243 #define DHD_BUS_BUSY_CHECK_RPM_ALL(dhdp) \
244 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_ALL)
245 #define DHD_BUS_BUSY_CHECK_IN_CHECKDIED(dhdp) \
246 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_CHECKDIED)
247 #define DHD_BUS_BUSY_CHECK_IN_MEMDUMP(dhdp) \
248 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_MEMDUMP)
249 #define DHD_BUS_BUSY_CHECK_IN_SSSRDUMP(dhdp) \
250 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SSSRDUMP)
251 #define DHD_BUS_BUSY_CHECK_IN_LOGDUMP(dhdp) \
252 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_LOGDUMP)
253 #define DHD_BUS_BUSY_CHECK_IDLE(dhdp) \
254 ((dhdp)->dhd_bus_busy_state == 0)
255
256 #define DHD_BUS_CHECK_SUSPEND_OR_SUSPEND_IN_PROGRESS(dhdp) \
257 ((dhdp)->busstate == DHD_BUS_SUSPEND || DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp))
258
259 #define DHD_BUS_CHECK_ANY_SUSPEND_IN_PROGRESS(dhdp) \
260 (DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) || \
261 DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp))
262
263 #define DHD_BUS_CHECK_DOWN_OR_DOWN_IN_PROGRESS(dhdp) \
264 ((dhdp)->busstate == DHD_BUS_DOWN || (dhdp)->busstate == DHD_BUS_DOWN_IN_PROGRESS)
265
266 #define MAX_MTU_SZ (1600u)
267
268 /* (u64)result = (u64)dividend / (u64)divisor */
269 #define DIV_U64_BY_U64(dividend, divisor) div64_u64(dividend, divisor)
270
271 /* (u64)result = (u64)dividend / (u32)divisor */
272 #define DIV_U64_BY_U32(dividend, divisor) div_u64(dividend, divisor)
273
274 /* Be careful while using this, as it divides dividend also
275 * (u32)remainder = (u64)dividend % (u32)divisor
276 * (u64)dividend = (u64)dividend / (u32)divisor
277 */
278 #define DIV_AND_MOD_U64_BY_U32(dividend, divisor) do_div(dividend, divisor)
279
280 /* (u32)remainder = (u64)dividend % (u32)divisor */
281 #define MOD_U64_BY_U32(dividend, divisor) ({ \
282 uint64 temp_dividend = (dividend); \
283 uint32 rem = DIV_AND_MOD_U64_BY_U32(temp_dividend, (divisor)); \
284 rem; \
285 })
286
287 #define SEC_USEC_FMT \
288 "%5llu.%06u"
289
290 /* t: time in nano second */
291 #define GET_SEC_USEC(t) \
292 DIV_U64_BY_U32(t, NSEC_PER_SEC), \
293 ((uint32)(MOD_U64_BY_U32(t, NSEC_PER_SEC) / (uint32)NSEC_PER_USEC))
294
295 /* Download Types */
296 typedef enum download_type {
297 FW,
298 NVRAM,
299 CLM_BLOB,
300 TXCAP_BLOB,
301 #if defined(DHD_USE_CLMINFO_PARSER)
302 CLMINFO,
303 #endif /* DHD_USE_CLMINFO_PARSER */
304 DOWNLOAD_TYPE_LAST
305 } download_type_t;
306
307 /* For supporting multiple interfaces */
308 #define DHD_MAX_IFS 16
309 #define DHD_MAX_STATIC_IFS 1
310 #define DHD_DEL_IF -0xE
311 #define DHD_BAD_IF -0xF
312 #define DHD_DUMMY_INFO_IF 0xDEAF /* Hack i/f to handle events from INFO Ring */
313 #define DHD_EVENT_IF DHD_DUMMY_INFO_IF
314
315 enum dhd_op_flags {
316 /* Firmware requested operation mode */
317 DHD_FLAG_STA_MODE = (1 << (0)), /* STA only */
318 DHD_FLAG_HOSTAP_MODE = (1 << (1)), /* SOFTAP only */
319 DHD_FLAG_P2P_MODE = (1 << (2)), /* P2P Only */
320 /* STA + P2P */
321 DHD_FLAG_CONCURR_SINGLE_CHAN_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_P2P_MODE),
322 /* STA + SoftAP */
323 DHD_FLAG_CONCURR_STA_HOSTAP_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_HOSTAP_MODE),
324 DHD_FLAG_CONCURR_MULTI_CHAN_MODE = (1 << (4)), /* STA + P2P */
325 /* Current P2P mode for P2P connection */
326 DHD_FLAG_P2P_GC_MODE = (1 << (5)),
327 DHD_FLAG_P2P_GO_MODE = (1 << (6)),
328 DHD_FLAG_MBSS_MODE = (1 << (7)), /* MBSS in future */
329 DHD_FLAG_IBSS_MODE = (1 << (8)),
330 DHD_FLAG_MFG_MODE = (1 << (9)),
331 DHD_FLAG_RSDB_MODE = (1 << (10)),
332 DHD_FLAG_MP2P_MODE = (1 << (11))
333 };
334
335 #define DHD_OPMODE_SUPPORTED(dhd, opmode_flag) \
336 (dhd ? ((((dhd_pub_t *)dhd)->op_mode) & opmode_flag) : -1)
337 #define DHD_OPMODE_STA_SOFTAP_CONCURR(dhd) \
338 (dhd ? (((((dhd_pub_t *)dhd)->op_mode) & DHD_FLAG_CONCURR_STA_HOSTAP_MODE) == \
339 DHD_FLAG_CONCURR_STA_HOSTAP_MODE) : 0)
340
341 /* Max sequential TX/RX Control timeouts to set HANG event */
342 #ifndef MAX_CNTL_TX_TIMEOUT
343 #define MAX_CNTL_TX_TIMEOUT 2
344 #endif /* MAX_CNTL_TX_TIMEOUT */
345 #ifndef MAX_CNTL_RX_TIMEOUT
346 #define MAX_CNTL_RX_TIMEOUT 1
347 #endif /* MAX_CNTL_RX_TIMEOUT */
348
349 #define DHD_SCAN_ASSOC_ACTIVE_TIME 40 /* ms: Embedded default Active setting from DHD */
350 #define DHD_SCAN_UNASSOC_ACTIVE_TIME 80 /* ms: Embedded def. Unassoc Active setting from DHD */
351 #define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD */
352 #define DHD_SCAN_HOME_TIME 45 /* ms: Embedded default Home time setting from DHD */
353 #define DHD_SCAN_HOME_AWAY_TIME 100 /* ms: Embedded default Home Away time setting from DHD */
354
355 #ifndef POWERUP_MAX_RETRY
356 #define POWERUP_MAX_RETRY 3 /* how many times we retry to power up the chip */
357 #endif // endif
358 #ifndef POWERUP_WAIT_MS
359 #define POWERUP_WAIT_MS 2000 /* ms: time out in waiting wifi to come up */
360 #endif // endif
361 /*
362 * MAX_NVRAMBUF_SIZE determines the size of the Buffer in the DHD that holds
363 * the NVRAM data. That is the size of the buffer pointed by bus->vars
364 * This also needs to be increased to 16K to support NVRAM size higher than 8K
365 */
366 #define MAX_NVRAMBUF_SIZE (16 * 1024) /* max nvram buf size */
367 #define MAX_CLM_BUF_SIZE (48 * 1024) /* max clm blob size */
368 #define MAX_TXCAP_BUF_SIZE (16 * 1024) /* max txcap blob size */
369 #define MAX_CLMINFO_BUF_SIZE (4 * 1024) /* max clminfo buf size */
370 #ifdef DHD_DEBUG
371 #define DHD_JOIN_MAX_TIME_DEFAULT 10000 /* ms: Max time out for joining AP */
372 #define DHD_SCAN_DEF_TIMEOUT 10000 /* ms: Max time out for scan in progress */
373 #endif // endif
374
375 #ifndef CONFIG_BCMDHD_CLM_PATH
376 #if defined(CUSTOMER_HW4) && defined(PLATFORM_SLP)
377 #define CONFIG_BCMDHD_CLM_PATH "/lib/firmware/bcmdhd_clm.blob"
378 #else
379 #define CONFIG_BCMDHD_CLM_PATH "/etc/wifi/bcmdhd_clm.blob"
380 #endif /* CUSTOMER_HW4 && PLATFORM_SLP */
381 #endif /* CONFIG_BCMDHD_CLM_PATH */
382 #define WL_CCODE_NULL_COUNTRY "#n"
383
384 #define FW_VER_STR_LEN 128
385 #define CLM_VER_STR_LEN 128
386 #define BUS_API_REV_STR_LEN 128
387 extern char bus_api_revision[];
388
389 enum dhd_bus_wake_state {
390 WAKE_LOCK_OFF,
391 WAKE_LOCK_PRIV,
392 WAKE_LOCK_DPC,
393 WAKE_LOCK_IOCTL,
394 WAKE_LOCK_DOWNLOAD,
395 WAKE_LOCK_TMOUT,
396 WAKE_LOCK_WATCHDOG,
397 WAKE_LOCK_LINK_DOWN_TMOUT,
398 WAKE_LOCK_PNO_FIND_TMOUT,
399 WAKE_LOCK_SOFTAP_SET,
400 WAKE_LOCK_SOFTAP_STOP,
401 WAKE_LOCK_SOFTAP_START,
402 WAKE_LOCK_SOFTAP_THREAD
403 };
404
405 enum dhd_prealloc_index {
406 DHD_PREALLOC_PROT = 0,
407 DHD_PREALLOC_RXBUF,
408 DHD_PREALLOC_DATABUF,
409 DHD_PREALLOC_OSL_BUF,
410 #if defined(STATIC_WL_PRIV_STRUCT)
411 DHD_PREALLOC_WIPHY_ESCAN0 = 5,
412 #ifdef DUAL_ESCAN_RESULT_BUFFER
413 DHD_PREALLOC_WIPHY_ESCAN1,
414 #endif /* DUAL_ESCAN_RESULT_BUFFER */
415 #endif /* STATIC_WL_PRIV_STRUCT */
416 DHD_PREALLOC_DHD_INFO = 7,
417 DHD_PREALLOC_DHD_WLFC_INFO = 8,
418 DHD_PREALLOC_IF_FLOW_LKUP = 9,
419 /* 10 */
420 DHD_PREALLOC_MEMDUMP_RAM = 11,
421 DHD_PREALLOC_DHD_WLFC_HANGER = 12,
422 DHD_PREALLOC_PKTID_MAP = 13,
423 DHD_PREALLOC_PKTID_MAP_IOCTL = 14,
424 DHD_PREALLOC_DHD_LOG_DUMP_BUF = 15,
425 DHD_PREALLOC_DHD_LOG_DUMP_BUF_EX = 16,
426 DHD_PREALLOC_DHD_PKTLOG_DUMP_BUF = 17
427 };
428
429 enum dhd_dongledump_mode {
430 DUMP_DISABLED = 0,
431 DUMP_MEMONLY,
432 DUMP_MEMFILE,
433 DUMP_MEMFILE_BUGON,
434 DUMP_MEMFILE_MAX
435 };
436
437 enum dhd_dongledump_type {
438 DUMP_TYPE_RESUMED_ON_TIMEOUT = 1,
439 DUMP_TYPE_D3_ACK_TIMEOUT,
440 DUMP_TYPE_DONGLE_TRAP,
441 DUMP_TYPE_MEMORY_CORRUPTION,
442 DUMP_TYPE_PKTID_AUDIT_FAILURE,
443 DUMP_TYPE_PKTID_INVALID,
444 DUMP_TYPE_SCAN_TIMEOUT,
445 DUMP_TYPE_SCAN_BUSY,
446 DUMP_TYPE_BY_SYSDUMP,
447 DUMP_TYPE_BY_LIVELOCK,
448 DUMP_TYPE_AP_LINKUP_FAILURE,
449 DUMP_TYPE_AP_ABNORMAL_ACCESS,
450 DUMP_TYPE_CFG_VENDOR_TRIGGERED,
451 DUMP_TYPE_RESUMED_ON_TIMEOUT_TX,
452 DUMP_TYPE_RESUMED_ON_TIMEOUT_RX,
453 DUMP_TYPE_RESUMED_ON_INVALID_RING_RDWR,
454 DUMP_TYPE_TRANS_ID_MISMATCH,
455 DUMP_TYPE_IFACE_OP_FAILURE,
456 #ifdef DEBUG_DNGL_INIT_FAIL
457 DUMP_TYPE_DONGLE_INIT_FAILURE,
458 #endif /* DEBUG_DNGL_INIT_FAIL */
459 #ifdef SUPPORT_LINKDOWN_RECOVERY
460 DUMP_TYPE_READ_SHM_FAIL,
461 #endif /* SUPPORT_LINKDOWN_RECOVERY */
462 DUMP_TYPE_DONGLE_HOST_EVENT,
463 DUMP_TYPE_SMMU_FAULT,
464 DUMP_TYPE_RESUMED_UNKNOWN,
465 #ifdef DHD_ERPOM
466 DUMP_TYPE_DUE_TO_BT,
467 #endif /* DHD_ERPOM */
468 DUMP_TYPE_BY_USER
469 };
470
471 enum dhd_hang_reason {
472 HANG_REASON_MASK = 0x8000,
473 HANG_REASON_IOCTL_RESP_TIMEOUT = 0x8001,
474 HANG_REASON_DONGLE_TRAP = 0x8002,
475 HANG_REASON_D3_ACK_TIMEOUT = 0x8003,
476 HANG_REASON_BUS_DOWN = 0x8004,
477 HANG_REASON_MSGBUF_LIVELOCK = 0x8006,
478 HANG_REASON_IFACE_DEL_FAILURE = 0x8007,
479 HANG_REASON_HT_AVAIL_ERROR = 0x8008,
480 HANG_REASON_PCIE_RC_LINK_UP_FAIL = 0x8009,
481 HANG_REASON_PCIE_PKTID_ERROR = 0x800A,
482 HANG_REASON_IFACE_ADD_FAILURE = 0x800B,
483 HANG_REASON_IOCTL_RESP_TIMEOUT_SCHED_ERROR = 0x800C,
484 HANG_REASON_D3_ACK_TIMEOUT_SCHED_ERROR = 0x800D,
485 HANG_REASON_PCIE_LINK_DOWN = 0x8805,
486 HANG_REASON_INVALID_EVENT_OR_DATA = 0x8806,
487 HANG_REASON_UNKNOWN = 0x8807,
488 HANG_REASON_MAX = 0x8808
489 };
490
491 #define WLC_E_DEAUTH_MAX_REASON 0x0FFF
492
493 enum dhd_rsdb_scan_features {
494 /* Downgraded scan feature for AP active */
495 RSDB_SCAN_DOWNGRADED_AP_SCAN = 0x01,
496 /* Downgraded scan feature for P2P Discovery */
497 RSDB_SCAN_DOWNGRADED_P2P_DISC_SCAN = 0x02,
498 /* Enable channel pruning for ROAM SCAN */
499 RSDB_SCAN_DOWNGRADED_CH_PRUNE_ROAM = 0x10,
500 /* Enable channel pruning for any SCAN */
501 RSDB_SCAN_DOWNGRADED_CH_PRUNE_ALL = 0x20
502 };
503
504 #define VENDOR_SEND_HANG_EXT_INFO_LEN (800 + 1)
505 #define VENDOR_SEND_HANG_EXT_INFO_VER 20170905
506 #define HANG_INFO_TRAP_T_NAME_MAX 6
507 #define HANG_INFO_TRAP_T_REASON_IDX 0
508 #define HANG_INFO_TRAP_T_SUBTYPE_IDX 2
509 #define HANG_INFO_TRAP_T_OFFSET_IDX 3
510 #define HANG_INFO_TRAP_T_EPC_IDX 4
511 #define HANG_FIELD_STR_MAX_LEN 9
512 #define HANG_FIELD_CNT_MAX 69
513 #define HANG_FIELD_IF_FAILURE_CNT 10
514 #define HANG_FIELD_IOCTL_RESP_TIMEOUT_CNT 8
515 #define HANG_FIELD_TRAP_T_STACK_CNT_MAX 16
516 #define HANG_FIELD_MISMATCH_CNT 10
517 #define HANG_INFO_BIGDATA_KEY_STACK_CNT 4
518
519 #define DEBUG_DUMP_TIME_BUF_LEN (16 + 1)
520 /* delimiter between values */
521 #define HANG_KEY_DEL ' '
522 #define HANG_RAW_DEL '_'
523
524 enum dhd_eapol_message_type {
525 EAPOL_4WAY_M1 = 1,
526 EAPOL_4WAY_M2,
527 EAPOL_4WAY_M3,
528 EAPOL_4WAY_M4
529 };
530
531 /* Packet alignment for most efficient SDIO (can change based on platform) */
532 #ifndef DHD_SDALIGN
533 #define DHD_SDALIGN 32
534 #endif // endif
535
536 #define DHD_TX_CONTEXT_MASK 0xff
537 #define DHD_TX_START_XMIT 0x01
538 #define DHD_TX_SEND_PKT 0x02
539 #define DHD_IF_SET_TX_ACTIVE(ifp, context) \
540 ifp->tx_paths_active |= context;
541 #define DHD_IF_CLR_TX_ACTIVE(ifp, context) \
542 ifp->tx_paths_active &= ~context;
543 #define DHD_IF_IS_TX_ACTIVE(ifp) \
544 (ifp->tx_paths_active)
545 /**
546 * DMA-able buffer parameters
547 * - dmaaddr_t is 32bits on a 32bit host.
548 * dhd_dma_buf::pa may not be used as a sh_addr_t, bcm_addr64_t or uintptr
549 * - dhd_dma_buf::_alloced is ONLY for freeing a DMA-able buffer.
550 */
551 typedef struct dhd_dma_buf {
552 void *va; /* virtual address of buffer */
553 uint32 len; /* user requested buffer length */
554 dmaaddr_t pa; /* physical address of buffer */
555 void *dmah; /* dma mapper handle */
556 void *secdma; /* secure dma sec_cma_info handle */
557 uint32 _alloced; /* actual size of buffer allocated with align and pad */
558 } dhd_dma_buf_t;
559
560 /* host reordering packts logic */
561 /* followed the structure to hold the reorder buffers (void **p) */
562 typedef struct reorder_info {
563 void **p;
564 uint8 flow_id;
565 uint8 cur_idx;
566 uint8 exp_idx;
567 uint8 max_idx;
568 uint8 pend_pkts;
569 } reorder_info_t;
570
571 /* throughput test packet format */
572 typedef struct tput_pkt {
573 /* header */
574 uint8 mac_sta[ETHER_ADDR_LEN];
575 uint8 mac_ap[ETHER_ADDR_LEN];
576 uint16 pkt_type;
577 uint8 PAD[2];
578 /* data */
579 uint32 crc32;
580 uint32 pkt_id;
581 uint32 num_pkts;
582 } tput_pkt_t;
583
584 typedef enum {
585 TPUT_PKT_TYPE_NORMAL,
586 TPUT_PKT_TYPE_STOP
587 } tput_pkt_type_t;
588
589 #define TPUT_TEST_MAX_PAYLOAD 1500
590 #define TPUT_TEST_WAIT_TIMEOUT_DEFAULT 5000
591
592 #ifdef DHDTCPACK_SUPPRESS
593
594 enum {
595 /* TCPACK suppress off */
596 TCPACK_SUP_OFF,
597 /* Replace TCPACK in txq when new coming one has higher ACK number. */
598 TCPACK_SUP_REPLACE,
599 /* TCPACK_SUP_REPLACE + delayed TCPACK TX unless ACK to PSH DATA.
600 * This will give benefits to Half-Duplex bus interface(e.g. SDIO) that
601 * 1. we are able to read TCP DATA packets first from the bus
602 * 2. TCPACKs that don't need to hurry delivered remains longer in TXQ so can be suppressed.
603 */
604 TCPACK_SUP_DELAYTX,
605 TCPACK_SUP_HOLD,
606 TCPACK_SUP_LAST_MODE
607 };
608 #endif /* DHDTCPACK_SUPPRESS */
609
610 #define DHD_NULL_CHK_AND_RET(cond) \
611 if (!cond) { \
612 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
613 return; \
614 }
615
616 #define DHD_NULL_CHK_AND_RET_VAL(cond, value) \
617 if (!cond) { \
618 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
619 return value; \
620 }
621
622 #define DHD_NULL_CHK_AND_GOTO(cond, label) \
623 if (!cond) { \
624 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
625 goto label; \
626 }
627
628 /*
629 * Accumulating the queue lengths of all flowring queues in a parent object,
630 * to assert flow control, when the cummulative queue length crosses an upper
631 * threshold defined on a parent object. Upper threshold may be maintained
632 * at a station level, at an interface level, or at a dhd instance.
633 *
634 * cumm_ctr_t abstraction:
635 * cumm_ctr_t abstraction may be enhanced to use an object with a hysterisis
636 * pause on/off threshold callback.
637 * All macros use the address of the cummulative length in the parent objects.
638 *
639 * BCM_GMAC3 builds use a single perimeter lock, as opposed to a per queue lock.
640 * Cummulative counters in parent objects may be updated without spinlocks.
641 *
642 * In non BCM_GMAC3, if a cummulative queue length is desired across all flows
643 * belonging to either of (a station, or an interface or a dhd instance), then
644 * an atomic operation is required using an atomic_t cummulative counters or
645 * using a spinlock. BCM_ROUTER_DHD uses the Linux atomic_t construct.
646 */
647
648 /* Cummulative length not supported. */
649 typedef uint32 cumm_ctr_t;
650 #define DHD_CUMM_CTR_PTR(clen) ((cumm_ctr_t*)(clen))
651 #define DHD_CUMM_CTR(clen) *(DHD_CUMM_CTR_PTR(clen)) /* accessor */
652 #define DHD_CUMM_CTR_READ(clen) DHD_CUMM_CTR(clen) /* read access */
653 #define DHD_CUMM_CTR_INIT(clen) \
654 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
655 #define DHD_CUMM_CTR_INCR(clen) \
656 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
657 #define DHD_CUMM_CTR_DECR(clen) \
658 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
659
660 #if defined(WLTDLS) && defined(PCIE_FULL_DONGLE)
661 struct tdls_peer_node {
662 uint8 addr[ETHER_ADDR_LEN];
663 struct tdls_peer_node *next;
664 };
665 typedef struct tdls_peer_node tdls_peer_node_t;
666 typedef struct {
667 tdls_peer_node_t *node;
668 uint8 tdls_peer_count;
669 } tdls_peer_tbl_t;
670 #endif /* defined(WLTDLS) && defined(PCIE_FULL_DONGLE) */
671
672 #ifdef DHD_LOG_DUMP
673 #define LOG_DUMP_MAGIC 0xDEB3DEB3
674 #define HEALTH_CHK_BUF_SIZE 256
675
676 #ifdef DEBUGABILITY_ECNTRS_LOGGING
677 #define ECNTR_RING_ID 0xECDB
678 #define ECNTR_RING_NAME "ewp_ecntr_ring"
679 #endif /* DEBUGABILITY_ECNTRS_LOGGING */
680
681 #if defined(DEBUGABILITY) && defined(DEBUGABILITY_ECNTRS_LOGGING)
682 #error "Duplicate rings will be created since both the features are enabled"
683 #endif /* DEBUGABILITY && DEBUGABILITY_ECNTRS_LOGGING */
684
685 typedef enum {
686 LOG_DUMP_SECTION_GENERAL = 0,
687 LOG_DUMP_SECTION_ECNTRS,
688 LOG_DUMP_SECTION_SPECIAL,
689 LOG_DUMP_SECTION_DHD_DUMP,
690 LOG_DUMP_SECTION_EXT_TRAP,
691 LOG_DUMP_SECTION_HEALTH_CHK,
692 LOG_DUMP_SECTION_PRESERVE,
693 LOG_DUMP_SECTION_COOKIE,
694 LOG_DUMP_SECTION_FLOWRING
695 } log_dump_section_type_t;
696
697 /* Each section in the debug_dump log file shall begin with a header */
698 typedef struct {
699 uint32 magic; /* 0xDEB3DEB3 */
700 uint32 type; /* of type log_dump_section_type_t */
701 uint64 timestamp;
702 uint32 length; /* length of the section that follows */
703 uint32 pad;
704 } log_dump_section_hdr_t;
705
706 /* below structure describe ring buffer. */
707 struct dhd_log_dump_buf
708 {
709 spinlock_t lock;
710 void *dhd_pub;
711 unsigned int enable;
712 unsigned int wraparound;
713 unsigned long max;
714 unsigned int remain;
715 char* present;
716 char* front;
717 char* buffer;
718 };
719
720 #define DHD_LOG_DUMP_MAX_TEMP_BUFFER_SIZE 256
721 #define DHD_LOG_DUMP_MAX_TAIL_FLUSH_SIZE (80 * 1024)
722
723 extern void dhd_log_dump_write(int type, char *binary_data,
724 int binary_len, const char *fmt, ...);
725 extern char *dhd_log_dump_get_timestamp(void);
726 bool dhd_log_dump_ecntr_enabled(void);
727 #endif /* DHD_LOG_DUMP */
728
729 /* DEBUG_DUMP SUB COMMAND */
730 enum {
731 CMD_DEFAULT,
732 CMD_UNWANTED,
733 CMD_DISCONNECTED,
734 CMD_MAX
735 };
736
737 #define DHD_LOG_DUMP_TS_MULTIPLIER_VALUE 60
738 #define DHD_LOG_DUMP_TS_FMT_YYMMDDHHMMSSMSMS "%02d%02d%02d%02d%02d%02d%04d"
739 #define DHD_DEBUG_DUMP_TYPE "debug_dump_FORUSER"
740 #define DHD_DUMP_SUBSTR_UNWANTED "_unwanted"
741 #define DHD_DUMP_SUBSTR_DISCONNECTED "_disconnected"
742
743 extern void get_debug_dump_time(char *str);
744 extern void clear_debug_dump_time(char *str);
745 #if defined(WL_CFGVENDOR_SEND_HANG_EVENT) || defined(DHD_PKT_LOGGING)
746 extern void copy_debug_dump_time(char *dest, char *src);
747 #endif /* WL_CFGVENDOR_SEND_HANG_EVENT || DHD_PKT_LOGGING */
748
749 #define WL_MAX_PRESERVE_BUFFER 8
750 #define FW_LOGSET_MASK_ALL 0xFF
751
752 #ifdef WL_MONITOR
753 #define MONPKT_EXTRA_LEN 48u
754 #endif /* WL_MONITOR */
755
756 #define DHDIF_FWDER(dhdif) FALSE
757
758 #if defined(CUSTOMER_HW4)
759 #if defined(ANDROID_PLATFORM_VERSION)
760 #if (ANDROID_PLATFORM_VERSION >= 9)
761 #ifdef DHD_COMMON_DUMP_PATH
762 #undef DHD_COMMON_DUMP_PATH
763 #endif /* DHD_COMMON_DUMP_PATH */
764 #if defined(BCM4361_CHIP) || defined(BCM4359_CHIP) || defined(BCM43456_CHIP)
765 #define DHD_COMMON_DUMP_PATH "/data/log/wifi/"
766 #else
767 #define DHD_COMMON_DUMP_PATH "/data/vendor/log/wifi/"
768 #endif /* BCM4361_CHIP || BCM4359_CHIP || BCM43456_CHIP */
769 #endif /* ANDROID_PLATFORM_VERSION >= 9 */
770 #endif /* ANDROID_PLATFORM_VERSION */
771 #ifndef DHD_COMMON_DUMP_PATH
772 #define DHD_COMMON_DUMP_PATH "/data/media/wifi/log/"
773 #endif /* !DHD_COMMON_DUMP_PATH */
774 #else
775 #define DHD_COMMON_DUMP_PATH "/installmedia/"
776 #endif /* CUSTOMER_HW4 */
777
778 struct cntry_locales_custom {
779 char iso_abbrev[WLC_CNTRY_BUF_SZ]; /* ISO 3166-1 country abbreviation */
780 char custom_locale[WLC_CNTRY_BUF_SZ]; /* Custom firmware locale */
781 int32 custom_locale_rev; /* Custom local revisin default -1 */
782 };
783
784 int dhd_send_msg_to_daemon(struct sk_buff *skb, void *data, int size);
785
786 #ifdef DMAMAP_STATS
787 typedef struct dmamap_stats {
788 uint64 txdata;
789 uint64 txdata_sz;
790 uint64 rxdata;
791 uint64 rxdata_sz;
792 uint64 ioctl_rx;
793 uint64 ioctl_rx_sz;
794 uint64 event_rx;
795 uint64 event_rx_sz;
796 uint64 info_rx;
797 uint64 info_rx_sz;
798 uint64 tsbuf_rx;
799 uint64 tsbuf_rx_sz;
800 } dma_stats_t;
801 #endif /* DMAMAP_STATS */
802
803 /* see wlfc_proto.h for tx status details */
804 #define DHD_MAX_TX_STATUS_MSGS 9u
805
806 #ifdef TX_STATUS_LATENCY_STATS
807 typedef struct dhd_if_tx_status_latency {
808 /* total number of tx_status received on this interface */
809 uint64 num_tx_status;
810 /* cumulative tx_status latency for this interface */
811 uint64 cum_tx_status_latency;
812 } dhd_if_tx_status_latency_t;
813 #endif /* TX_STATUS_LATENCY_STATS */
814
815 /**
816 * Common structure for module and instance linkage.
817 * Instantiated once per hardware (dongle) instance that this DHD manages.
818 */
819 typedef struct dhd_pub {
820 /* Linkage ponters */
821 osl_t *osh; /* OSL handle */
822 struct dhd_bus *bus; /* Bus module handle */
823 struct dhd_prot *prot; /* Protocol module handle */
824 struct dhd_info *info; /* Info module handle */
825 struct dhd_dbg *dbg; /* Debugability module handle */
826
827 /* to NDIS developer, the structure dhd_common is redundant,
828 * please do NOT merge it back from other branches !!!
829 */
830
831 /* Internal dhd items */
832 bool up; /* Driver up/down (to OS) */
833 #ifdef WL_CFG80211
834 spinlock_t up_lock; /* Synchronization with CFG80211 down */
835 #endif /* WL_CFG80211 */
836 bool txoff; /* Transmit flow-controlled */
837 bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
838 enum dhd_bus_state busstate;
839 uint dhd_bus_busy_state; /* Bus busy state */
840 uint hdrlen; /* Total DHD header length (proto + bus) */
841 uint maxctl; /* Max size rxctl request from proto to bus */
842 uint rxsz; /* Rx buffer size bus module should use */
843 uint8 wme_dp; /* wme discard priority */
844
845 /* Dongle media info */
846 bool iswl; /* Dongle-resident driver is wl */
847 ulong drv_version; /* Version of dongle-resident driver */
848 struct ether_addr mac; /* MAC address obtained from dongle */
849 dngl_stats_t dstats; /* Stats for dongle-based data */
850
851 /* Additional stats for the bus level */
852 ulong tx_packets; /* Data packets sent to dongle */
853 ulong tx_dropped; /* Data packets dropped in dhd */
854 ulong tx_multicast; /* Multicast data packets sent to dongle */
855 ulong tx_errors; /* Errors in sending data to dongle */
856 ulong tx_ctlpkts; /* Control packets sent to dongle */
857 ulong tx_ctlerrs; /* Errors sending control frames to dongle */
858 ulong rx_packets; /* Packets sent up the network interface */
859 ulong rx_multicast; /* Multicast packets sent up the network interface */
860 ulong rx_errors; /* Errors processing rx data packets */
861 ulong rx_ctlpkts; /* Control frames processed from dongle */
862 ulong rx_ctlerrs; /* Errors in processing rx control frames */
863 ulong rx_dropped; /* Packets dropped locally (no memory) */
864 ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
865 ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
866 ulong rx_pktgetfail; /* Number of PKTGET failures in DHD on RX */
867 ulong tx_pktgetfail; /* Number of PKTGET failures in DHD on TX */
868 ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
869 ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
870 ulong fc_packets; /* Number of flow control pkts recvd */
871 ulong tx_big_packets; /* Dropped data packets that are larger than MAX_MTU_SZ */
872 #ifdef DMAMAP_STATS
873 /* DMA Mapping statistics */
874 dma_stats_t dma_stats;
875 #endif /* DMAMAP_STATS */
876
877 /* Last error return */
878 int bcmerror;
879 uint tickcnt;
880
881 /* Last error from dongle */
882 int dongle_error;
883
884 uint8 country_code[WLC_CNTRY_BUF_SZ];
885
886 /* Suspend disable flag and "in suspend" flag */
887 int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
888 int in_suspend; /* flag set to 1 when early suspend called */
889 #ifdef PNO_SUPPORT
890 int pno_enable; /* pno status : "1" is pno enable */
891 int pno_suspend; /* pno suspend status : "1" is pno suspended */
892 #endif /* PNO_SUPPORT */
893 /* DTIM skip value, default 0(or 1) means wake each DTIM
894 * 3 means skip 2 DTIMs and wake up 3rd DTIM(9th beacon when AP DTIM is 3)
895 */
896 int suspend_bcn_li_dtim; /* bcn_li_dtim value in suspend mode */
897 #ifdef PKT_FILTER_SUPPORT
898 int early_suspended; /* Early suspend status */
899 int dhcp_in_progress; /* DHCP period */
900 #endif // endif
901
902 /* Pkt filter defination */
903 char * pktfilter[100];
904 int pktfilter_count;
905
906 wl_country_t dhd_cspec; /* Current Locale info */
907 #ifdef CUSTOM_COUNTRY_CODE
908 uint dhd_cflags;
909 #endif /* CUSTOM_COUNTRY_CODE */
910 #if defined(DHD_BLOB_EXISTENCE_CHECK)
911 bool is_blob; /* Checking for existance of Blob file */
912 #endif /* DHD_BLOB_EXISTENCE_CHECK */
913 bool force_country_change;
914 char eventmask[WL_EVENTING_MASK_LEN];
915 int op_mode; /* STA, HostAPD, WFD, SoftAP */
916
917 /* Set this to 1 to use a seperate interface (p2p0) for p2p operations.
918 * For ICS MR1 releases it should be disable to be compatable with ICS MR1 Framework
919 * see target dhd-cdc-sdmmc-panda-cfg80211-icsmr1-gpl-debug in Makefile
920 */
921 /* #define WL_ENABLE_P2P_IF 1 */
922
923 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
924 struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
925 struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
926 #endif // endif
927
928 #ifdef PROP_TXSTATUS
929 bool wlfc_enabled;
930 int wlfc_mode;
931 void* wlfc_state;
932 /*
933 Mode in which the dhd flow control shall operate. Must be set before
934 traffic starts to the device.
935 0 - Do not do any proptxtstatus flow control
936 1 - Use implied credit from a packet status
937 2 - Use explicit credit
938 3 - Only AMPDU hostreorder used. no wlfc.
939 */
940 uint8 proptxstatus_mode;
941 bool proptxstatus_txoff;
942 bool proptxstatus_module_ignore;
943 bool proptxstatus_credit_ignore;
944 bool proptxstatus_txstatus_ignore;
945
946 bool wlfc_rxpkt_chk;
947 #ifdef LIMIT_BORROW
948 bool wlfc_borrow_allowed;
949 #endif /* LIMIT_BORROW */
950 /*
951 * implement below functions in each platform if needed.
952 */
953 /* platform specific function whether to skip flow control */
954 bool (*skip_fc)(void * dhdp, uint8 ifx);
955 /* platform specific function for wlfc_enable and wlfc_deinit */
956 void (*plat_init)(void *dhd);
957 void (*plat_deinit)(void *dhd);
958 #ifdef DHD_WLFC_THREAD
959 bool wlfc_thread_go;
960 struct task_struct* wlfc_thread;
961 wait_queue_head_t wlfc_wqhead;
962 #endif /* DHD_WLFC_THREAD */
963 #endif /* PROP_TXSTATUS */
964 #ifdef PNO_SUPPORT
965 void *pno_state;
966 #endif // endif
967 #ifdef RTT_SUPPORT
968 void *rtt_state;
969 #endif // endif
970 #ifdef ROAM_AP_ENV_DETECTION
971 bool roam_env_detection;
972 #endif // endif
973 bool dongle_isolation;
974 bool is_pcie_watchdog_reset;
975 bool dongle_trap_occured; /* flag for sending HANG event to upper layer */
976 bool iovar_timeout_occured; /* flag to indicate iovar resumed on timeout */
977 bool is_sched_error; /* flag to indicate timeout due to scheduling issue */
978 #ifdef PCIE_FULL_DONGLE
979 bool d3ack_timeout_occured; /* flag to indicate d3ack resumed on timeout */
980 #endif /* PCIE_FULL_DONGLE */
981 #ifdef BT_OVER_SDIO
982 bool is_bt_recovery_required;
983 #endif // endif
984 #ifdef DHD_MAP_LOGGING
985 bool smmu_fault_occurred; /* flag to indicate SMMU Fault */
986 #endif /* DHD_MAP_LOGGING */
987 int hang_was_sent;
988 int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
989 int txcnt_timeout; /* counter txcnt timeout to send HANG */
990 #ifdef BCMPCIE
991 int d3ackcnt_timeout; /* counter d3ack timeout to send HANG */
992 #endif /* BCMPCIE */
993 bool hang_report; /* enable hang report by default */
994 uint16 hang_reason; /* reason codes for HANG event */
995 #if defined(DHD_HANG_SEND_UP_TEST)
996 uint req_hang_type;
997 #endif /* DHD_HANG_SEND_UP_TEST */
998 #if defined(CONFIG_BCM_DETECT_CONSECUTIVE_HANG)
999 uint hang_counts;
1000 #endif /* CONFIG_BCM_DETECT_CONSECUTIVE_HANG */
1001 #ifdef WLTDLS
1002 bool tdls_enable;
1003 #endif // endif
1004 struct reorder_info *reorder_bufs[WLHOST_REORDERDATA_MAXFLOWS];
1005 #define WLC_IOCTL_MAXBUF_FWCAP 1024
1006 char fw_capabilities[WLC_IOCTL_MAXBUF_FWCAP];
1007 #define MAXSKBPEND 1024
1008 void *skbbuf[MAXSKBPEND];
1009 uint32 store_idx;
1010 uint32 sent_idx;
1011 #ifdef DHDTCPACK_SUPPRESS
1012 uint8 tcpack_sup_mode; /* TCPACK suppress mode */
1013 void *tcpack_sup_module; /* TCPACK suppress module */
1014 uint32 tcpack_sup_ratio;
1015 uint32 tcpack_sup_delay;
1016 #endif /* DHDTCPACK_SUPPRESS */
1017 #if defined(ARP_OFFLOAD_SUPPORT)
1018 uint32 arp_version;
1019 #endif // endif
1020 #if defined(BCMSUP_4WAY_HANDSHAKE)
1021 bool fw_4way_handshake; /* Whether firmware will to do the 4way handshake. */
1022 #endif // endif
1023 #ifdef DEBUG_DPC_THREAD_WATCHDOG
1024 bool dhd_bug_on;
1025 #endif /* DEBUG_DPC_THREAD_WATCHDOG */
1026 #ifdef CUSTOM_SET_CPUCORE
1027 struct task_struct * current_dpc;
1028 struct task_struct * current_rxf;
1029 int chan_isvht80;
1030 #endif /* CUSTOM_SET_CPUCORE */
1031 #ifdef ARGOS_CPU_SCHEDULER
1032 cpumask_var_t default_cpu_mask;
1033 cpumask_var_t dpc_affinity_cpu_mask;
1034 cpumask_var_t rxf_affinity_cpu_mask;
1035 bool affinity_isdpc;
1036 bool affinity_isrxf;
1037 #endif /* ARGOS_CPU_SCHEDULER */
1038
1039 void *sta_pool; /* pre-allocated pool of sta objects */
1040 void *staid_allocator; /* allocator of sta indexes */
1041 #ifdef PCIE_FULL_DONGLE
1042 bool flow_rings_inited; /* set this flag after initializing flow rings */
1043 #endif /* PCIE_FULL_DONGLE */
1044 void *flowid_allocator; /* unique flowid allocator */
1045 void *flow_ring_table; /* flow ring table, include prot and bus info */
1046 void *if_flow_lkup; /* per interface flowid lkup hash table */
1047 void *flowid_lock; /* per os lock for flowid info protection */
1048 void *flowring_list_lock; /* per os lock for flowring list protection */
1049 uint32 num_flow_rings;
1050 cumm_ctr_t cumm_ctr; /* cumm queue length placeholder */
1051 cumm_ctr_t l2cumm_ctr; /* level 2 cumm queue length placeholder */
1052 uint32 d2h_sync_mode; /* D2H DMA completion sync mode */
1053 uint8 flow_prio_map[NUMPRIO];
1054 uint8 flow_prio_map_type;
1055 char enable_log[MAX_EVENT];
1056 bool dma_d2h_ring_upd_support;
1057 bool dma_h2d_ring_upd_support;
1058 bool dma_ring_upd_overwrite; /* host overwrites support setting */
1059
1060 bool idma_enable;
1061 uint idma_inited;
1062
1063 bool ifrm_enable; /* implicit frm enable */
1064 uint ifrm_inited; /* implicit frm init */
1065
1066 bool dar_enable; /* use DAR registers */
1067 uint dar_inited;
1068
1069 bool fast_delete_ring_support; /* fast delete ring supported */
1070
1071 #ifdef DHD_L2_FILTER
1072 unsigned long l2_filter_cnt; /* for L2_FILTER ARP table timeout */
1073 #endif /* DHD_L2_FILTER */
1074 #ifdef DHD_SSSR_DUMP
1075 bool sssr_inited;
1076 sssr_reg_info_v1_t sssr_reg_info;
1077 uint8 *sssr_mempool;
1078 uint *sssr_d11_before[MAX_NUM_D11CORES];
1079 uint *sssr_d11_after[MAX_NUM_D11CORES];
1080 bool sssr_d11_outofreset[MAX_NUM_D11CORES];
1081 uint *sssr_dig_buf_before;
1082 uint *sssr_dig_buf_after;
1083 #endif /* DHD_SSSR_DUMP */
1084 uint8 *soc_ram;
1085 uint32 soc_ram_length;
1086 uint32 memdump_type;
1087 #ifdef DHD_FW_COREDUMP
1088 uint32 memdump_enabled;
1089 #ifdef DHD_DEBUG_UART
1090 bool memdump_success;
1091 #endif /* DHD_DEBUG_UART */
1092 #endif /* DHD_FW_COREDUMP */
1093 #ifdef PCIE_FULL_DONGLE
1094 #ifdef WLTDLS
1095 tdls_peer_tbl_t peer_tbl;
1096 #endif /* WLTDLS */
1097 uint8 tx_in_progress;
1098 #endif /* PCIE_FULL_DONGLE */
1099 #ifdef DHD_ULP
1100 void *dhd_ulp;
1101 #endif // endif
1102 #if defined(KEEP_KR_REGREV) || defined(KEEP_JP_REGREV)
1103 char vars_ccode[WLC_CNTRY_BUF_SZ];
1104 uint vars_regrev;
1105 #endif /* KEEP_KR_REGREV || KEEP_JP_REGREV */
1106 #ifdef WLTDLS
1107 uint32 tdls_mode;
1108 #endif // endif
1109 #ifdef GSCAN_SUPPORT
1110 bool lazy_roam_enable;
1111 #endif // endif
1112 #if defined(PKT_FILTER_SUPPORT) && defined(APF)
1113 bool apf_set;
1114 #endif /* PKT_FILTER_SUPPORT && APF */
1115 void *macdbg_info;
1116 #ifdef DHD_WET
1117 void *wet_info;
1118 #endif // endif
1119 bool h2d_phase_supported;
1120 bool force_dongletrap_on_bad_h2d_phase;
1121 uint32 dongle_trap_data;
1122 bool fw_download_done;
1123 trap_t last_trap_info; /* trap info from the last trap */
1124 uint8 rand_mac_oui[DOT11_OUI_LEN];
1125 #ifdef DHD_LOSSLESS_ROAMING
1126 uint8 dequeue_prec_map;
1127 uint8 prio_8021x;
1128 #endif // endif
1129 #ifdef WL_NATOE
1130 struct dhd_nfct_info *nfct;
1131 spinlock_t nfct_lock;
1132 #endif /* WL_NATOE */
1133 /* timesync link */
1134 struct dhd_ts *ts;
1135 bool d2h_hostrdy_supported;
1136 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
1137 atomic_t block_bus;
1138 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
1139 #if defined(DBG_PKT_MON) || defined(DHD_PKT_LOGGING)
1140 bool d11_tx_status;
1141 #endif /* DBG_PKT_MON || DHD_PKT_LOGGING */
1142 uint16 ndo_version; /* ND offload version supported */
1143 #ifdef NDO_CONFIG_SUPPORT
1144 bool ndo_enable; /* ND offload feature enable */
1145 bool ndo_host_ip_overflow; /* # of host ip addr exceed FW capacity */
1146 uint32 ndo_max_host_ip; /* # of host ip addr supported by FW */
1147 #endif /* NDO_CONFIG_SUPPORT */
1148 #if defined(DHD_LOG_DUMP)
1149 /* buffer to hold 'dhd dump' data before dumping to file */
1150 uint8 *concise_dbg_buf;
1151 uint64 last_file_posn;
1152 int logdump_periodic_flush;
1153 /* ecounter debug ring */
1154 #ifdef DEBUGABILITY_ECNTRS_LOGGING
1155 void *ecntr_dbg_ring;
1156 #endif // endif
1157 #ifdef DNGL_EVENT_SUPPORT
1158 uint8 health_chk_event_data[HEALTH_CHK_BUF_SIZE];
1159 #endif // endif
1160 void *logdump_cookie;
1161 #endif /* DHD_LOG_DUMP */
1162 uint32 dhd_console_ms; /** interval for polling the dongle for console (log) messages */
1163 bool ext_trap_data_supported;
1164 uint32 *extended_trap_data;
1165 #ifdef DUMP_IOCTL_IOV_LIST
1166 /* dump iovar list */
1167 dll_t dump_iovlist_head;
1168 uint8 dump_iovlist_len;
1169 #endif /* DUMP_IOCTL_IOV_LIST */
1170 #ifdef CUSTOM_SET_ANTNPM
1171 uint32 mimo_ant_set;
1172 #endif /* CUSTOM_SET_ANTNPM */
1173 #ifdef CUSTOM_SET_OCLOFF
1174 bool ocl_off;
1175 #endif /* CUSTOM_SET_OCLOFF */
1176 #ifdef DHD_DEBUG
1177 /* memwaste feature */
1178 dll_t mw_list_head; /* memwaste list head */
1179 uint32 mw_id; /* memwaste list unique id */
1180 #endif /* DHD_DEBUG */
1181 #ifdef WLTDLS
1182 spinlock_t tdls_lock;
1183 #endif /* WLTDLS */
1184 uint pcie_txs_metadata_enable;
1185 uint wbtext_policy; /* wbtext policy of dongle */
1186 bool wbtext_support; /* for product policy only */
1187 #ifdef SHOW_LOGTRACE
1188 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1189 struct mutex dhd_trace_lock;
1190 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) */
1191 #endif /* SHOW_LOGTRACE */
1192
1193 bool max_dtim_enable; /* use MAX bcn_li_dtim value in suspend mode */
1194 tput_test_t tput_data;
1195 uint64 tput_start_ts;
1196 uint64 tput_stop_ts;
1197 #ifdef WL_MONITOR
1198 bool monitor_enable;
1199 #endif // endif
1200 #ifdef DHD_PKT_LOGGING
1201 struct dhd_pktlog *pktlog;
1202 char debug_dump_time_pktlog_str[DEBUG_DUMP_TIME_BUF_LEN];
1203 #endif /* DHD_PKT_LOGGING */
1204 uint dhd_watchdog_ms_backup;
1205 void *event_log_filter;
1206 #ifdef WL_CFGVENDOR_SEND_HANG_EVENT
1207 char *hang_info;
1208 int hang_info_cnt;
1209 char debug_dump_time_hang_str[DEBUG_DUMP_TIME_BUF_LEN];
1210 #endif /* WL_CFGVENDOR_SEND_HANG_EVENT */
1211 char debug_dump_time_str[DEBUG_DUMP_TIME_BUF_LEN];
1212 uint32 logset_prsrv_mask;
1213 bool wl_event_enabled;
1214 bool logtrace_pkt_sendup;
1215 #ifdef DHD_DUMP_MNGR
1216 struct _dhd_dump_file_manage *dump_file_manage;
1217 #endif /* DHD_DUMP_MNGR */
1218 int debug_dump_subcmd;
1219 wait_queue_head_t tx_completion_wait;
1220 uint32 batch_tx_pkts_cmpl;
1221 uint32 batch_tx_num_pkts;
1222 #ifdef DHD_ERPOM
1223 bool enable_erpom;
1224 pom_func_handler_t pom_wlan_handler;
1225 int (*pom_func_register)(pom_func_handler_t *func);
1226 int (*pom_func_deregister)(pom_func_handler_t *func);
1227 int (*pom_toggle_reg_on)(uchar func_id, uchar reason);
1228 #endif /* DHD_ERPOM */
1229 #ifdef SUPPORT_SET_TID
1230 uint8 tid_mode;
1231 uint32 target_uid;
1232 uint8 target_tid;
1233 #endif /* SUPPORT_SET_TID */
1234 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1235 struct mutex ndev_op_sync;
1236 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) */
1237 #ifdef DYNAMIC_MUMIMO_CONTROL
1238 uint8 reassoc_mumimo_sw;
1239 uint8 murx_block_eapol;
1240 #endif /* DYNAMIC_MUMIMO_CONTROL */
1241 #ifdef DHD_USE_CLMINFO_PARSER
1242 bool is_clm_mult_regrev; /* Checking for CLM single/multiple regrev */
1243 #endif /* DHD_USE_CLMINFO_PARSER */
1244 } dhd_pub_t;
1245
1246 typedef struct {
1247 uint rxwake;
1248 uint rcwake;
1249 #ifdef DHD_WAKE_RX_STATUS
1250 uint rx_bcast;
1251 uint rx_arp;
1252 uint rx_mcast;
1253 uint rx_multi_ipv6;
1254 uint rx_icmpv6;
1255 uint rx_icmpv6_ra;
1256 uint rx_icmpv6_na;
1257 uint rx_icmpv6_ns;
1258 uint rx_multi_ipv4;
1259 uint rx_multi_other;
1260 uint rx_ucast;
1261 #endif /* DHD_WAKE_RX_STATUS */
1262 #ifdef DHD_WAKE_EVENT_STATUS
1263 uint rc_event[WLC_E_LAST];
1264 #endif /* DHD_WAKE_EVENT_STATUS */
1265 } wake_counts_t;
1266
1267 #if defined(PCIE_FULL_DONGLE)
1268
1269 /* Packet Tag for PCIE Full Dongle DHD */
1270 typedef struct dhd_pkttag_fd {
1271 uint16 flowid; /* Flowring Id */
1272 uint16 ifid;
1273 #ifndef DHD_PCIE_PKTID
1274 uint16 dma_len; /* pkt len for DMA_MAP/UNMAP */
1275 dmaaddr_t pa; /* physical address */
1276 void *dmah; /* dma mapper handle */
1277 void *secdma; /* secure dma sec_cma_info handle */
1278 #endif /* !DHD_PCIE_PKTID */
1279 #ifdef TX_STATUS_LATENCY_STATS
1280 uint64 q_time_us; /* time when tx pkt queued to flowring */
1281 #endif /* TX_STATUS_LATENCY_STATS */
1282 } dhd_pkttag_fd_t;
1283
1284 /* Packet Tag for DHD PCIE Full Dongle */
1285 #define DHD_PKTTAG_FD(pkt) ((dhd_pkttag_fd_t *)(PKTTAG(pkt)))
1286
1287 #define DHD_PKT_GET_FLOWID(pkt) ((DHD_PKTTAG_FD(pkt))->flowid)
1288 #define DHD_PKT_SET_FLOWID(pkt, pkt_flowid) \
1289 DHD_PKTTAG_FD(pkt)->flowid = (uint16)(pkt_flowid)
1290
1291 #define DHD_PKT_GET_DATAOFF(pkt) ((DHD_PKTTAG_FD(pkt))->dataoff)
1292 #define DHD_PKT_SET_DATAOFF(pkt, pkt_dataoff) \
1293 DHD_PKTTAG_FD(pkt)->dataoff = (uint16)(pkt_dataoff)
1294
1295 #define DHD_PKT_GET_DMA_LEN(pkt) ((DHD_PKTTAG_FD(pkt))->dma_len)
1296 #define DHD_PKT_SET_DMA_LEN(pkt, pkt_dma_len) \
1297 DHD_PKTTAG_FD(pkt)->dma_len = (uint16)(pkt_dma_len)
1298
1299 #define DHD_PKT_GET_PA(pkt) ((DHD_PKTTAG_FD(pkt))->pa)
1300 #define DHD_PKT_SET_PA(pkt, pkt_pa) \
1301 DHD_PKTTAG_FD(pkt)->pa = (dmaaddr_t)(pkt_pa)
1302
1303 #define DHD_PKT_GET_DMAH(pkt) ((DHD_PKTTAG_FD(pkt))->dmah)
1304 #define DHD_PKT_SET_DMAH(pkt, pkt_dmah) \
1305 DHD_PKTTAG_FD(pkt)->dmah = (void *)(pkt_dmah)
1306
1307 #define DHD_PKT_GET_SECDMA(pkt) ((DHD_PKTTAG_FD(pkt))->secdma)
1308 #define DHD_PKT_SET_SECDMA(pkt, pkt_secdma) \
1309 DHD_PKTTAG_FD(pkt)->secdma = (void *)(pkt_secdma)
1310
1311 #ifdef TX_STATUS_LATENCY_STATS
1312 #define DHD_PKT_GET_QTIME(pkt) ((DHD_PKTTAG_FD(pkt))->q_time_us)
1313 #define DHD_PKT_SET_QTIME(pkt, pkt_q_time_us) \
1314 DHD_PKTTAG_FD(pkt)->q_time_us = (uint64)(pkt_q_time_us)
1315 #endif /* TX_STATUS_LATENCY_STATS */
1316 #endif /* PCIE_FULL_DONGLE */
1317
1318 #if defined(BCMWDF)
1319 typedef struct {
1320 dhd_pub_t *dhd_pub;
1321 } dhd_workitem_context_t;
1322
1323 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(dhd_workitem_context_t, dhd_get_dhd_workitem_context)
1324 #endif /* (BCMWDF) */
1325
1326 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP)
1327
1328 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
1329 #define _DHD_PM_RESUME_WAIT(a, b) do {\
1330 int retry = 0; \
1331 SMP_RD_BARRIER_DEPENDS(); \
1332 while (dhd_mmc_suspend && retry++ != b) { \
1333 SMP_RD_BARRIER_DEPENDS(); \
1334 wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
1335 } \
1336 } while (0)
1337 #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
1338 #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
1339 #define DHD_PM_RESUME_RETURN_ERROR(a) do { \
1340 if (dhd_mmc_suspend) { \
1341 printf("%s[%d]: mmc is still in suspend state!!!\n", \
1342 __FUNCTION__, __LINE__); \
1343 return a; \
1344 } \
1345 } while (0)
1346 #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
1347
1348 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
1349 #define SPINWAIT_SLEEP(a, exp, us) do { \
1350 uint countdown = (us) + 9999; \
1351 while ((exp) && (countdown >= 10000)) { \
1352 wait_event_interruptible_timeout(a, FALSE, 1); \
1353 countdown -= 10000; \
1354 } \
1355 } while (0)
1356
1357 #else
1358
1359 #define DHD_PM_RESUME_WAIT_INIT(a)
1360 #define DHD_PM_RESUME_WAIT(a)
1361 #define DHD_PM_RESUME_WAIT_FOREVER(a)
1362 #define DHD_PM_RESUME_RETURN_ERROR(a)
1363 #define DHD_PM_RESUME_RETURN
1364
1365 #define DHD_SPINWAIT_SLEEP_INIT(a)
1366 #define SPINWAIT_SLEEP(a, exp, us) do { \
1367 uint countdown = (us) + 9; \
1368 while ((exp) && (countdown >= 10)) { \
1369 OSL_DELAY(10); \
1370 countdown -= 10; \
1371 } \
1372 } while (0)
1373
1374 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) && defined(CONFIG_PM_SLEEP) */
1375
1376 #ifndef OSL_SLEEP
1377 #define OSL_SLEEP(ms) OSL_DELAY(ms*1000)
1378 #endif /* OSL_SLEEP */
1379
1380 #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
1381
1382 #ifdef PNO_SUPPORT
1383 int dhd_pno_clean(dhd_pub_t *dhd);
1384 #endif /* PNO_SUPPORT */
1385
1386 /*
1387 * Wake locks are an Android power management concept. They are used by applications and services
1388 * to request CPU resources.
1389 */
1390 extern int dhd_os_wake_lock(dhd_pub_t *pub);
1391 extern int dhd_os_wake_unlock(dhd_pub_t *pub);
1392 extern int dhd_os_wake_lock_waive(dhd_pub_t *pub);
1393 extern int dhd_os_wake_lock_restore(dhd_pub_t *pub);
1394 extern void dhd_event_wake_lock(dhd_pub_t *pub);
1395 extern void dhd_event_wake_unlock(dhd_pub_t *pub);
1396 extern void dhd_pm_wake_lock_timeout(dhd_pub_t *pub, int val);
1397 extern void dhd_pm_wake_unlock(dhd_pub_t *pub);
1398 extern void dhd_txfl_wake_lock_timeout(dhd_pub_t *pub, int val);
1399 extern void dhd_txfl_wake_unlock(dhd_pub_t *pub);
1400 extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
1401 extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
1402 extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
1403 extern int dhd_os_wake_lock_ctrl_timeout_cancel(dhd_pub_t *pub);
1404 extern int dhd_os_wd_wake_lock(dhd_pub_t *pub);
1405 extern int dhd_os_wd_wake_unlock(dhd_pub_t *pub);
1406 extern void dhd_os_wake_lock_init(struct dhd_info *dhd);
1407 extern void dhd_os_wake_lock_destroy(struct dhd_info *dhd);
1408 #ifdef DHD_USE_SCAN_WAKELOCK
1409 extern void dhd_os_scan_wake_lock_timeout(dhd_pub_t *pub, int val);
1410 extern void dhd_os_scan_wake_unlock(dhd_pub_t *pub);
1411 #endif /* BCMPCIE_SCAN_WAKELOCK */
1412
1413 inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
1414 {
1415 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1416 mutex_init(&dhdp->wl_softap_lock);
1417 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
1418 }
1419
1420 inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
1421 {
1422 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1423 mutex_lock(&dhdp->wl_softap_lock);
1424 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
1425 }
1426
1427 inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
1428 {
1429 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
1430 mutex_unlock(&dhdp->wl_softap_lock);
1431 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
1432 }
1433
1434 #ifdef DHD_DEBUG_WAKE_LOCK
1435 #define DHD_OS_WAKE_LOCK(pub) \
1436 do { \
1437 printf("call wake_lock: %s %d\n", \
1438 __FUNCTION__, __LINE__); \
1439 dhd_os_wake_lock(pub); \
1440 } while (0)
1441 #define DHD_OS_WAKE_UNLOCK(pub) \
1442 do { \
1443 printf("call wake_unlock: %s %d\n", \
1444 __FUNCTION__, __LINE__); \
1445 dhd_os_wake_unlock(pub); \
1446 } while (0)
1447 #define DHD_EVENT_WAKE_LOCK(pub) \
1448 do { \
1449 printf("call event wake_lock: %s %d\n", \
1450 __FUNCTION__, __LINE__); \
1451 dhd_event_wake_lock(pub); \
1452 } while (0)
1453 #define DHD_EVENT_WAKE_UNLOCK(pub) \
1454 do { \
1455 printf("call event wake_unlock: %s %d\n", \
1456 __FUNCTION__, __LINE__); \
1457 dhd_event_wake_unlock(pub); \
1458 } while (0)
1459 #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) \
1460 do { \
1461 printf("call pm_wake_timeout enable\n"); \
1462 dhd_pm_wake_lock_timeout(pub, val); \
1463 } while (0)
1464 #define DHD_PM_WAKE_UNLOCK(pub) \
1465 do { \
1466 printf("call pm_wake unlock\n"); \
1467 dhd_pm_wake_unlock(pub); \
1468 } while (0)
1469 #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) \
1470 do { \
1471 printf("call pm_wake_timeout enable\n"); \
1472 dhd_txfl_wake_lock_timeout(pub, val); \
1473 } while (0)
1474 #define DHD_TXFL_WAKE_UNLOCK(pub) \
1475 do { \
1476 printf("call pm_wake unlock\n"); \
1477 dhd_txfl_wake_unlock(pub); \
1478 } while (0)
1479 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) \
1480 do { \
1481 printf("call wake_lock_timeout: %s %d\n", \
1482 __FUNCTION__, __LINE__); \
1483 dhd_os_wake_lock_timeout(pub); \
1484 } while (0)
1485 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
1486 do { \
1487 printf("call wake_lock_rx_timeout_enable[%d]: %s %d\n", \
1488 val, __FUNCTION__, __LINE__); \
1489 dhd_os_wake_lock_rx_timeout_enable(pub, val); \
1490 } while (0)
1491 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
1492 do { \
1493 printf("call wake_lock_ctrl_timeout_enable[%d]: %s %d\n", \
1494 val, __FUNCTION__, __LINE__); \
1495 dhd_os_wake_lock_ctrl_timeout_enable(pub, val); \
1496 } while (0)
1497 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
1498 do { \
1499 printf("call wake_lock_ctrl_timeout_cancel: %s %d\n", \
1500 __FUNCTION__, __LINE__); \
1501 dhd_os_wake_lock_ctrl_timeout_cancel(pub); \
1502 } while (0)
1503 #define DHD_OS_WAKE_LOCK_WAIVE(pub) \
1504 do { \
1505 printf("call wake_lock_waive: %s %d\n", \
1506 __FUNCTION__, __LINE__); \
1507 dhd_os_wake_lock_waive(pub); \
1508 } while (0)
1509 #define DHD_OS_WAKE_LOCK_RESTORE(pub) \
1510 do { \
1511 printf("call wake_lock_restore: %s %d\n", \
1512 __FUNCTION__, __LINE__); \
1513 dhd_os_wake_lock_restore(pub); \
1514 } while (0)
1515 #define DHD_OS_WAKE_LOCK_INIT(dhd) \
1516 do { \
1517 printf("call wake_lock_init: %s %d\n", \
1518 __FUNCTION__, __LINE__); \
1519 dhd_os_wake_lock_init(dhd); \
1520 } while (0)
1521 #define DHD_OS_WAKE_LOCK_DESTROY(dhd) \
1522 do { \
1523 printf("call wake_lock_destroy: %s %d\n", \
1524 __FUNCTION__, __LINE__); \
1525 dhd_os_wake_lock_destroy(dhd); \
1526 } while (0)
1527 #else
1528 #define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
1529 #define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
1530 #define DHD_EVENT_WAKE_LOCK(pub) dhd_event_wake_lock(pub)
1531 #define DHD_EVENT_WAKE_UNLOCK(pub) dhd_event_wake_unlock(pub)
1532 #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) dhd_pm_wake_lock_timeout(pub, val)
1533 #define DHD_PM_WAKE_UNLOCK(pub) dhd_pm_wake_unlock(pub)
1534 #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) dhd_txfl_wake_lock_timeout(pub, val)
1535 #define DHD_TXFL_WAKE_UNLOCK(pub) dhd_txfl_wake_unlock(pub)
1536 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
1537 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
1538 dhd_os_wake_lock_rx_timeout_enable(pub, val)
1539 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
1540 dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
1541 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
1542 dhd_os_wake_lock_ctrl_timeout_cancel(pub)
1543 #define DHD_OS_WAKE_LOCK_WAIVE(pub) dhd_os_wake_lock_waive(pub)
1544 #define DHD_OS_WAKE_LOCK_RESTORE(pub) dhd_os_wake_lock_restore(pub)
1545 #define DHD_OS_WAKE_LOCK_INIT(dhd) dhd_os_wake_lock_init(dhd);
1546 #define DHD_OS_WAKE_LOCK_DESTROY(dhd) dhd_os_wake_lock_destroy(dhd);
1547 #endif /* DHD_DEBUG_WAKE_LOCK */
1548
1549 #define DHD_OS_WD_WAKE_LOCK(pub) dhd_os_wd_wake_lock(pub)
1550 #define DHD_OS_WD_WAKE_UNLOCK(pub) dhd_os_wd_wake_unlock(pub)
1551
1552 #ifdef DHD_USE_SCAN_WAKELOCK
1553 #ifdef DHD_DEBUG_SCAN_WAKELOCK
1554 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) \
1555 do { \
1556 printf("call wake_lock_scan: %s %d\n", \
1557 __FUNCTION__, __LINE__); \
1558 dhd_os_scan_wake_lock_timeout(pub, val); \
1559 } while (0)
1560 #define DHD_OS_SCAN_WAKE_UNLOCK(pub) \
1561 do { \
1562 printf("call wake_unlock_scan: %s %d\n", \
1563 __FUNCTION__, __LINE__); \
1564 dhd_os_scan_wake_unlock(pub); \
1565 } while (0)
1566 #else
1567 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_scan_wake_lock_timeout(pub, val)
1568 #define DHD_OS_SCAN_WAKE_UNLOCK(pub) dhd_os_scan_wake_unlock(pub)
1569 #endif /* DHD_DEBUG_SCAN_WAKELOCK */
1570 #else
1571 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val)
1572 #define DHD_OS_SCAN_WAKE_UNLOCK(pub)
1573 #endif /* DHD_USE_SCAN_WAKELOCK */
1574
1575 #ifdef BCMPCIE_OOB_HOST_WAKE
1576 #define OOB_WAKE_LOCK_TIMEOUT 500
1577 extern void dhd_os_oob_irq_wake_lock_timeout(dhd_pub_t *pub, int val);
1578 extern void dhd_os_oob_irq_wake_unlock(dhd_pub_t *pub);
1579 extern int dhdpcie_get_oob_irq_num(struct dhd_bus *bus);
1580 #define DHD_OS_OOB_IRQ_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_oob_irq_wake_lock_timeout(pub, val)
1581 #define DHD_OS_OOB_IRQ_WAKE_UNLOCK(pub) dhd_os_oob_irq_wake_unlock(pub)
1582 #endif /* BCMPCIE_OOB_HOST_WAKE */
1583
1584 #define DHD_PACKET_TIMEOUT_MS 500
1585 #define DHD_EVENT_TIMEOUT_MS 1500
1586 #define SCAN_WAKE_LOCK_TIMEOUT 10000
1587 #define MAX_TX_TIMEOUT 500
1588
1589 /* Enum for IOCTL recieved status */
1590 typedef enum dhd_ioctl_recieved_status
1591 {
1592 IOCTL_WAIT = 0,
1593 IOCTL_RETURN_ON_SUCCESS,
1594 IOCTL_RETURN_ON_TRAP,
1595 IOCTL_RETURN_ON_BUS_STOP,
1596 IOCTL_RETURN_ON_ERROR
1597 } dhd_ioctl_recieved_status_t;
1598
1599 /* interface operations (register, remove) should be atomic, use this lock to prevent race
1600 * condition among wifi on/off and interface operation functions
1601 */
1602 void dhd_net_if_lock(struct net_device *dev);
1603 void dhd_net_if_unlock(struct net_device *dev);
1604
1605 #if defined(MULTIPLE_SUPPLICANT)
1606 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && defined(BCMSDIO)
1607 extern struct mutex _dhd_sdio_mutex_lock_;
1608 #endif // endif
1609 #endif /* MULTIPLE_SUPPLICANT */
1610
1611 typedef enum dhd_attach_states
1612 {
1613 DHD_ATTACH_STATE_INIT = 0x0,
1614 DHD_ATTACH_STATE_NET_ALLOC = 0x1,
1615 DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
1616 DHD_ATTACH_STATE_ADD_IF = 0x4,
1617 DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
1618 DHD_ATTACH_STATE_WL_ATTACH = 0x10,
1619 DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
1620 DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
1621 DHD_ATTACH_STATE_CFG80211 = 0x80,
1622 DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
1623 DHD_ATTACH_TIMESYNC_ATTACH_DONE = 0x200,
1624 DHD_ATTACH_LOGTRACE_INIT = 0x400,
1625 DHD_ATTACH_STATE_LB_ATTACH_DONE = 0x800,
1626 DHD_ATTACH_STATE_DONE = 0x1000
1627 } dhd_attach_states_t;
1628
1629 /* Value -1 means we are unsuccessful in creating the kthread. */
1630 #define DHD_PID_KT_INVALID -1
1631 /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
1632 #define DHD_PID_KT_TL_INVALID -2
1633
1634 /* default reporting period */
1635 #define ECOUNTERS_DEFAULT_PERIOD 0
1636
1637 /* default number of reports. '0' indicates forever */
1638 #define ECOUNTERS_NUM_REPORTS 0
1639
1640 typedef struct ecounters_cfg {
1641 uint16 type;
1642 uint16 if_slice_idx;
1643 uint16 stats_rep;
1644 } ecounters_cfg_t;
1645
1646 typedef struct event_ecounters_cfg {
1647 uint16 event_id;
1648 uint16 type;
1649 uint16 if_slice_idx;
1650 uint16 stats_rep;
1651 } event_ecounters_cfg_t;
1652
1653 typedef struct ecountersv2_xtlv_list_elt {
1654 /* Not quite the exact bcm_xtlv_t type as data could be pointing to other pieces in
1655 * memory at the time of parsing arguments.
1656 */
1657 uint16 id;
1658 uint16 len;
1659 uint8 *data;
1660 struct ecountersv2_xtlv_list_elt *next;
1661 } ecountersv2_xtlv_list_elt_t;
1662
1663 typedef struct ecountersv2_processed_xtlv_list_elt {
1664 uint8 *data;
1665 struct ecountersv2_processed_xtlv_list_elt *next;
1666 } ecountersv2_processed_xtlv_list_elt;
1667
1668 /*
1669 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
1670 */
1671
1672 /* Indication from bus module regarding presence/insertion of dongle.
1673 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
1674 * Returned structure should have bus and prot pointers filled in.
1675 * bus_hdrlen specifies required headroom for bus module header.
1676 */
1677 extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen);
1678 extern int dhd_attach_net(dhd_pub_t *dhdp, bool need_rtnl_lock);
1679 #if defined(WLP2P) && defined(WL_CFG80211)
1680 /* To allow attach/detach calls corresponding to p2p0 interface */
1681 extern int dhd_attach_p2p(dhd_pub_t *);
1682 extern int dhd_detach_p2p(dhd_pub_t *);
1683 #endif /* WLP2P && WL_CFG80211 */
1684 extern int dhd_register_if(dhd_pub_t *dhdp, int idx, bool need_rtnl_lock);
1685
1686 /* Indication from bus module regarding removal/absence of dongle */
1687 extern void dhd_detach(dhd_pub_t *dhdp);
1688 extern void dhd_free(dhd_pub_t *dhdp);
1689 extern void dhd_clear(dhd_pub_t *dhdp);
1690
1691 /* Indication from bus module to change flow-control state */
1692 extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
1693
1694 /* Store the status of a connection attempt for later retrieval by an iovar */
1695 extern void dhd_store_conn_status(uint32 event, uint32 status, uint32 reason);
1696
1697 extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
1698
1699 extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
1700
1701 /* Return pointer to interface name */
1702 extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
1703
1704 #ifdef DHD_UCODE_DOWNLOAD
1705 /* Returns the ucode path */
1706 extern char *dhd_get_ucode_path(dhd_pub_t *dhdp);
1707 #endif /* DHD_UCODE_DOWNLOAD */
1708
1709 /* Request scheduling of the bus dpc */
1710 extern void dhd_sched_dpc(dhd_pub_t *dhdp);
1711
1712 /* Notify tx completion */
1713 extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
1714
1715 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
1716 extern void dhd_bus_wakeup_work(dhd_pub_t *dhdp);
1717 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
1718
1719 #define WIFI_FEATURE_INFRA 0x0001 /* Basic infrastructure mode */
1720 #define WIFI_FEATURE_INFRA_5G 0x0002 /* Support for 5 GHz Band */
1721 #define WIFI_FEATURE_HOTSPOT 0x0004 /* Support for GAS/ANQP */
1722 #define WIFI_FEATURE_P2P 0x0008 /* Wifi-Direct */
1723 #define WIFI_FEATURE_SOFT_AP 0x0010 /* Soft AP */
1724 #define WIFI_FEATURE_GSCAN 0x0020 /* Google-Scan APIs */
1725 #define WIFI_FEATURE_NAN 0x0040 /* Neighbor Awareness Networking */
1726 #define WIFI_FEATURE_D2D_RTT 0x0080 /* Device-to-device RTT */
1727 #define WIFI_FEATURE_D2AP_RTT 0x0100 /* Device-to-AP RTT */
1728 #define WIFI_FEATURE_BATCH_SCAN 0x0200 /* Batched Scan (legacy) */
1729 #define WIFI_FEATURE_PNO 0x0400 /* Preferred network offload */
1730 #define WIFI_FEATURE_ADDITIONAL_STA 0x0800 /* Support for two STAs */
1731 #define WIFI_FEATURE_TDLS 0x1000 /* Tunnel directed link setup */
1732 #define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 /* Support for TDLS off channel */
1733 #define WIFI_FEATURE_EPR 0x4000 /* Enhanced power reporting */
1734 #define WIFI_FEATURE_AP_STA 0x8000 /* Support for AP STA Concurrency */
1735 #define WIFI_FEATURE_LINKSTAT 0x10000 /* Support for Linkstats */
1736 #define WIFI_FEATURE_LOGGER 0x20000 /* WiFi Logger */
1737 #define WIFI_FEATURE_HAL_EPNO 0x40000 /* WiFi PNO enhanced */
1738 #define WIFI_FEATURE_RSSI_MONITOR 0x80000 /* RSSI Monitor */
1739 #define WIFI_FEATURE_MKEEP_ALIVE 0x100000 /* WiFi mkeep_alive */
1740 #define WIFI_FEATURE_CONFIG_NDO 0x200000 /* ND offload configure */
1741 #define WIFI_FEATURE_TX_TRANSMIT_POWER 0x400000 /* Capture Tx transmit power levels */
1742 #define WIFI_FEATURE_CONTROL_ROAMING 0x800000 /* Enable/Disable firmware roaming */
1743 #define WIFI_FEATURE_FILTER_IE 0x1000000 /* Probe req ie filter */
1744 #define WIFI_FEATURE_SCAN_RAND 0x2000000 /* Support MAC & Prb SN randomization */
1745 #define WIFI_FEATURE_INVALID 0xFFFFFFFF /* Invalid Feature */
1746
1747 #define MAX_FEATURE_SET_CONCURRRENT_GROUPS 3
1748
1749 extern int dhd_dev_get_feature_set(struct net_device *dev);
1750 extern int dhd_dev_get_feature_set_matrix(struct net_device *dev, int num);
1751 extern int dhd_dev_cfg_rand_mac_oui(struct net_device *dev, uint8 *oui);
1752 #ifdef CUSTOM_FORCE_NODFS_FLAG
1753 extern int dhd_dev_set_nodfs(struct net_device *dev, uint nodfs);
1754 #endif /* CUSTOM_FORCE_NODFS_FLAG */
1755 #ifdef NDO_CONFIG_SUPPORT
1756 #ifndef NDO_MAX_HOST_IP_ENTRIES
1757 #define NDO_MAX_HOST_IP_ENTRIES 10
1758 #endif /* NDO_MAX_HOST_IP_ENTRIES */
1759
1760 extern int dhd_dev_ndo_cfg(struct net_device *dev, u8 enable);
1761 extern int dhd_dev_ndo_update_inet6addr(struct net_device * dev);
1762 #endif /* NDO_CONFIG_SUPPORT */
1763 extern int dhd_set_rand_mac_oui(dhd_pub_t *dhd);
1764 #ifdef GSCAN_SUPPORT
1765 extern int dhd_dev_set_lazy_roam_cfg(struct net_device *dev,
1766 wlc_roam_exp_params_t *roam_param);
1767 extern int dhd_dev_lazy_roam_enable(struct net_device *dev, uint32 enable);
1768 extern int dhd_dev_set_lazy_roam_bssid_pref(struct net_device *dev,
1769 wl_bssid_pref_cfg_t *bssid_pref, uint32 flush);
1770 #endif /* GSCAN_SUPPORT */
1771 #if defined(GSCAN_SUPPORT) || defined(ROAMEXP_SUPPORT)
1772 extern int dhd_dev_set_blacklist_bssid(struct net_device *dev, maclist_t *blacklist,
1773 uint32 len, uint32 flush);
1774 extern int dhd_dev_set_whitelist_ssid(struct net_device *dev, wl_ssid_whitelist_t *whitelist,
1775 uint32 len, uint32 flush);
1776 #endif /* GSCAN_SUPPORT || ROAMEXP_SUPPORT */
1777
1778 /* OS independent layer functions */
1779 extern void dhd_os_dhdiovar_lock(dhd_pub_t *pub);
1780 extern void dhd_os_dhdiovar_unlock(dhd_pub_t *pub);
1781 void dhd_os_logdump_lock(dhd_pub_t *pub);
1782 void dhd_os_logdump_unlock(dhd_pub_t *pub);
1783 extern int dhd_os_proto_block(dhd_pub_t * pub);
1784 extern int dhd_os_proto_unblock(dhd_pub_t * pub);
1785 extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition);
1786 extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
1787 extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
1788 extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
1789 extern void dhd_os_ioctl_resp_lock(dhd_pub_t * pub);
1790 extern void dhd_os_ioctl_resp_unlock(dhd_pub_t * pub);
1791 #ifdef PCIE_FULL_DONGLE
1792 extern void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason);
1793 #else
1794 static INLINE void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason)
1795 { printf("%s is NOT implemented for SDIO", __FUNCTION__); return; }
1796 #endif // endif
1797 #ifdef SHOW_LOGTRACE
1798 extern int dhd_os_read_file(void *file, char *buf, uint32 size);
1799 extern int dhd_os_seek_file(void *file, int64 offset);
1800 #endif /* SHOW_LOGTRACE */
1801 int dhd_os_write_file_posn(void *fp, unsigned long *posn,
1802 void *buf, unsigned long buflen);
1803
1804 extern void
1805 dhd_pcie_dump_core_regs(dhd_pub_t * pub, uint32 index, uint32 first_addr, uint32 last_addr);
1806 extern void wl_dhdpcie_dump_regs(void * context);
1807
1808 extern int dhd_os_get_image_block(char * buf, int len, void * image);
1809 extern int dhd_os_get_image_size(void * image);
1810 #if defined(BT_OVER_SDIO)
1811 extern int dhd_os_gets_image(dhd_pub_t *pub, char *str, int len, void *image);
1812 extern void dhdsdio_bus_usr_cnt_inc(dhd_pub_t *pub);
1813 extern void dhdsdio_bus_usr_cnt_dec(dhd_pub_t *pub);
1814 #endif /* (BT_OVER_SDIO) */
1815 extern void *dhd_os_open_image1(dhd_pub_t *pub, char *filename); /* rev1 function signature */
1816 extern void dhd_os_close_image1(dhd_pub_t *pub, void *image);
1817 extern void dhd_os_wd_timer(void *bus, uint wdtick);
1818 #ifdef DHD_PCIE_RUNTIMEPM
1819 extern void dhd_os_runtimepm_timer(void *bus, uint tick);
1820 #endif /* DHD_PCIE_RUNTIMEPM */
1821 extern void dhd_os_sdlock(dhd_pub_t * pub);
1822 extern void dhd_os_sdunlock(dhd_pub_t * pub);
1823 extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
1824 extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
1825 extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
1826 extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
1827 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
1828 extern void dhd_os_tracelog(const char *format, ...);
1829 #ifdef DHDTCPACK_SUPPRESS
1830 extern unsigned long dhd_os_tcpacklock(dhd_pub_t *pub);
1831 extern void dhd_os_tcpackunlock(dhd_pub_t *pub, unsigned long flags);
1832 #endif /* DHDTCPACK_SUPPRESS */
1833
1834 extern int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr);
1835 extern int dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff);
1836 extern int dhd_custom_get_mac_address(void *adapter, unsigned char *buf);
1837 #if defined(CUSTOM_COUNTRY_CODE)
1838 extern void get_customized_country_code(void *adapter, char *country_iso_code,
1839 wl_country_t *cspec, u32 flags);
1840 #else
1841 extern void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec);
1842 #endif /* CUSTOM_COUNTRY_CODE */
1843 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
1844 extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
1845 extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
1846 extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
1847 extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
1848 extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
1849 extern bool dhd_os_check_if_up(dhd_pub_t *pub);
1850 extern int dhd_os_check_wakelock(dhd_pub_t *pub);
1851 extern int dhd_os_check_wakelock_all(dhd_pub_t *pub);
1852 extern int dhd_get_instance(dhd_pub_t *pub);
1853 #ifdef CUSTOM_SET_CPUCORE
1854 extern void dhd_set_cpucore(dhd_pub_t *dhd, int set);
1855 #endif /* CUSTOM_SET_CPUCORE */
1856
1857 #if defined(KEEP_ALIVE)
1858 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
1859 #endif /* KEEP_ALIVE */
1860
1861 #if defined(DHD_FW_COREDUMP)
1862 void dhd_schedule_memdump(dhd_pub_t *dhdp, uint8 *buf, uint32 size);
1863 #endif /* DHD_FW_COREDUMP */
1864
1865 void dhd_schedule_sssr_dump(dhd_pub_t *dhdp);
1866
1867 #ifdef PKT_FILTER_SUPPORT
1868 #define DHD_UNICAST_FILTER_NUM 0
1869 #define DHD_BROADCAST_FILTER_NUM 1
1870 #define DHD_MULTICAST4_FILTER_NUM 2
1871 #define DHD_MULTICAST6_FILTER_NUM 3
1872 #define DHD_MDNS_FILTER_NUM 4
1873 #define DHD_ARP_FILTER_NUM 5
1874 #define DHD_BROADCAST_ARP_FILTER_NUM 6
1875 #define DHD_IP4BCAST_DROP_FILTER_NUM 7
1876 #define DHD_LLC_STP_DROP_FILTER_NUM 8
1877 #define DHD_LLC_XID_DROP_FILTER_NUM 9
1878 #define DISCARD_IPV4_MCAST "102 1 6 IP4_H:16 0xf0 0xe0"
1879 #define DISCARD_IPV6_MCAST "103 1 6 IP6_H:24 0xff 0xff"
1880 #define DISCARD_IPV4_BCAST "107 1 6 IP4_H:16 0xffffffff 0xffffffff"
1881 #define DISCARD_LLC_STP "108 1 6 ETH_H:14 0xFFFFFFFFFFFF 0xAAAA0300000C"
1882 #define DISCARD_LLC_XID "109 1 6 ETH_H:14 0xFFFFFF 0x0001AF"
1883 extern int dhd_os_enable_packet_filter(dhd_pub_t *dhdp, int val);
1884 extern void dhd_enable_packet_filter(int value, dhd_pub_t *dhd);
1885 extern int dhd_packet_filter_add_remove(dhd_pub_t *dhdp, int add_remove, int num);
1886 extern int net_os_enable_packet_filter(struct net_device *dev, int val);
1887 extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
1888
1889 #define MAX_PKTFLT_BUF_SIZE 2048
1890 #define MAX_PKTFLT_FIXED_PATTERN_SIZE 32
1891 #define MAX_PKTFLT_FIXED_BUF_SIZE \
1892 (WL_PKT_FILTER_FIXED_LEN + MAX_PKTFLT_FIXED_PATTERN_SIZE * 2)
1893 #endif /* PKT_FILTER_SUPPORT */
1894
1895 #if defined(BCMPCIE)
1896 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd, int *dtim_period, int *bcn_interval);
1897 #else
1898 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
1899 #endif /* OEM_ANDROID && BCMPCIE */
1900
1901 extern bool dhd_support_sta_mode(dhd_pub_t *dhd);
1902 extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
1903
1904 #ifdef RSSI_MONITOR_SUPPORT
1905 extern int dhd_dev_set_rssi_monitor_cfg(struct net_device *dev, int start,
1906 int8 max_rssi, int8 min_rssi);
1907 #endif /* RSSI_MONITOR_SUPPORT */
1908
1909 #ifdef DHDTCPACK_SUPPRESS
1910 int dhd_dev_set_tcpack_sup_mode_cfg(struct net_device *dev, uint8 enable);
1911 #endif /* DHDTCPACK_SUPPRESS */
1912
1913 #define DHD_RSSI_MONITOR_EVT_VERSION 1
1914 typedef struct {
1915 uint8 version;
1916 int8 cur_rssi;
1917 struct ether_addr BSSID;
1918 } dhd_rssi_monitor_evt_t;
1919
1920 typedef struct {
1921 uint32 limit; /* Expiration time (usec) */
1922 uint32 increment; /* Current expiration increment (usec) */
1923 uint32 elapsed; /* Current elapsed time (usec) */
1924 uint32 tick; /* O/S tick time (usec) */
1925 } dhd_timeout_t;
1926
1927 #ifdef SHOW_LOGTRACE
1928 typedef struct {
1929 int num_fmts;
1930 char **fmts;
1931 char *raw_fmts;
1932 char *raw_sstr;
1933 uint32 fmts_size;
1934 uint32 raw_fmts_size;
1935 uint32 raw_sstr_size;
1936 uint32 ramstart;
1937 uint32 rodata_start;
1938 uint32 rodata_end;
1939 char *rom_raw_sstr;
1940 uint32 rom_raw_sstr_size;
1941 uint32 rom_ramstart;
1942 uint32 rom_rodata_start;
1943 uint32 rom_rodata_end;
1944 } dhd_event_log_t;
1945 #endif /* SHOW_LOGTRACE */
1946
1947 #if defined(DHD_NON_DMA_M2M_CORRUPTION)
1948 #define PCIE_DMAXFER_LPBK_LENGTH 4096
1949 typedef struct dhd_pcie_dmaxfer_lpbk {
1950 union {
1951 uint32 length;
1952 uint32 status;
1953 } u;
1954 uint32 srcdelay;
1955 uint32 destdelay;
1956 uint32 lpbkmode;
1957 uint32 wait;
1958 uint32 core;
1959 } dhd_pcie_dmaxfer_lpbk_t;
1960 #endif /* DHD_NON_DMA_M2M_CORRUPTION */
1961 enum d11_lpbk_type {
1962 M2M_DMA_LPBK = 0,
1963 D11_LPBK = 1,
1964 BMC_LPBK = 2,
1965 M2M_NON_DMA_LPBK = 3,
1966 D11_HOST_MEM_LPBK = 4,
1967 BMC_HOST_MEM_LPBK = 5,
1968 MAX_LPBK = 6
1969 };
1970
1971 #ifdef KEEP_ALIVE
1972 extern int dhd_dev_start_mkeep_alive(dhd_pub_t *dhd_pub, uint8 mkeep_alive_id, uint8 *ip_pkt,
1973 uint16 ip_pkt_len, uint8* src_mac_addr, uint8* dst_mac_addr, uint32 period_msec);
1974 extern int dhd_dev_stop_mkeep_alive(dhd_pub_t *dhd_pub, uint8 mkeep_alive_id);
1975 #endif /* KEEP_ALIVE */
1976
1977 #if defined(PKT_FILTER_SUPPORT) && defined(APF)
1978 /*
1979 * As per Google's current implementation, there will be only one APF filter.
1980 * Therefore, userspace doesn't bother about filter id and because of that
1981 * DHD has to manage the filter id.
1982 */
1983 #define PKT_FILTER_APF_ID 200
1984 #define DHD_APF_LOCK(ndev) dhd_apf_lock(ndev)
1985 #define DHD_APF_UNLOCK(ndev) dhd_apf_unlock(ndev)
1986
1987 extern void dhd_apf_lock(struct net_device *dev);
1988 extern void dhd_apf_unlock(struct net_device *dev);
1989 extern int dhd_dev_apf_get_version(struct net_device *ndev, uint32 *version);
1990 extern int dhd_dev_apf_get_max_len(struct net_device *ndev, uint32 *max_len);
1991 extern int dhd_dev_apf_add_filter(struct net_device *ndev, u8* program,
1992 uint32 program_len);
1993 extern int dhd_dev_apf_enable_filter(struct net_device *ndev);
1994 extern int dhd_dev_apf_disable_filter(struct net_device *ndev);
1995 extern int dhd_dev_apf_delete_filter(struct net_device *ndev);
1996 #endif /* PKT_FILTER_SUPPORT && APF */
1997
1998 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
1999 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
2000
2001 extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
2002 extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
2003 extern struct net_device * dhd_idx2net(void *pub, int ifidx);
2004 extern int net_os_send_hang_message(struct net_device *dev);
2005 extern int net_os_send_hang_message_reason(struct net_device *dev, const char *string_num);
2006 extern bool dhd_wowl_cap(void *bus);
2007 extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
2008 wl_event_msg_t *, void **data_ptr, void *);
2009 extern int wl_process_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
2010 wl_event_msg_t *, void **data_ptr, void *);
2011 extern void wl_event_to_host_order(wl_event_msg_t * evt);
2012 extern int wl_host_event_get_data(void *pktdata, uint pktlen, bcm_event_msg_u_t *evu);
2013 extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
2014 extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
2015 int ifindex);
2016 extern int dhd_wl_ioctl_get_intiovar(dhd_pub_t *dhd_pub, char *name, uint *pval,
2017 int cmd, uint8 set, int ifidx);
2018 extern int dhd_wl_ioctl_set_intiovar(dhd_pub_t *dhd_pub, char *name, uint val,
2019 int cmd, uint8 set, int ifidx);
2020 extern void dhd_common_init(osl_t *osh);
2021
2022 extern int dhd_do_driver_init(struct net_device *net);
2023 extern int dhd_event_ifadd(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
2024 char *name, uint8 *mac);
2025 extern int dhd_event_ifdel(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
2026 char *name, uint8 *mac);
2027 extern int dhd_event_ifchange(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
2028 char *name, uint8 *mac);
2029 extern struct net_device* dhd_allocate_if(dhd_pub_t *dhdpub, int ifidx, const char *name,
2030 uint8 *mac, uint8 bssidx, bool need_rtnl_lock, const char *dngl_name);
2031 extern int dhd_remove_if(dhd_pub_t *dhdpub, int ifidx, bool need_rtnl_lock);
2032 #ifdef WL_STATIC_IF
2033 extern s32 dhd_update_iflist_info(dhd_pub_t *dhdp, struct net_device *ndev, int ifidx,
2034 uint8 *mac, uint8 bssidx, const char *dngl_name, int if_state);
2035 #endif /* WL_STATIC_IF */
2036 extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
2037 extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
2038 extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
2039 extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
2040
2041 #ifdef WL_NATOE
2042 extern int dhd_natoe_ct_event(dhd_pub_t *dhd, char *data);
2043 #endif /* WL_NATOE */
2044
2045 /* Send packet to dongle via data channel */
2046 extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
2047
2048 /* send up locally generated event */
2049 extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
2050 /* Send event to host */
2051 extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
2052 #ifdef LOG_INTO_TCPDUMP
2053 extern void dhd_sendup_log(dhd_pub_t *dhdp, void *data, int len);
2054 #endif /* LOG_INTO_TCPDUMP */
2055 extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
2056 extern uint dhd_bus_status(dhd_pub_t *dhdp);
2057 extern int dhd_bus_start(dhd_pub_t *dhdp);
2058 extern int dhd_bus_suspend(dhd_pub_t *dhdpub);
2059 extern int dhd_bus_resume(dhd_pub_t *dhdpub, int stage);
2060 extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
2061 extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
2062 extern bool dhd_is_associated(dhd_pub_t *dhd, uint8 ifidx, int *retval);
2063 #if defined(BCMSDIO) || defined(BCMPCIE)
2064 extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
2065 extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
2066 extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
2067 #endif /* defined(BCMSDIO) || defined(BCMPCIE) */
2068 int dhd_bus_get_fw_mode(dhd_pub_t *dhdp);
2069
2070 #if defined(KEEP_ALIVE)
2071 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
2072 #endif /* KEEP_ALIVE */
2073
2074 /* OS spin lock API */
2075 extern void *dhd_os_spin_lock_init(osl_t *osh);
2076 extern void dhd_os_spin_lock_deinit(osl_t *osh, void *lock);
2077 extern unsigned long dhd_os_spin_lock(void *lock);
2078 void dhd_os_spin_unlock(void *lock, unsigned long flags);
2079
2080 /* linux is defined for DHD EFI builds also,
2081 * since its cross-compiled for EFI from linux.
2082 * dbgring_lock apis are meant only for linux
2083 * to use mutexes, other OSes will continue to
2084 * use dhd_os_spin_lock
2085 */
2086 void *dhd_os_dbgring_lock_init(osl_t *osh);
2087 void dhd_os_dbgring_lock_deinit(osl_t *osh, void *mtx);
2088 unsigned long dhd_os_dbgring_lock(void *lock);
2089 void dhd_os_dbgring_unlock(void *lock, unsigned long flags);
2090
2091 static INLINE int dhd_os_tput_test_wait(dhd_pub_t *pub, uint *condition,
2092 uint timeout_ms)
2093 { return 0; }
2094 static INLINE int dhd_os_tput_test_wake(dhd_pub_t * pub)
2095 { return 0; }
2096
2097 extern int dhd_os_busbusy_wait_negation(dhd_pub_t * pub, uint * condition);
2098 extern int dhd_os_busbusy_wake(dhd_pub_t * pub);
2099 extern void dhd_os_tx_completion_wake(dhd_pub_t *dhd);
2100 extern int dhd_os_busbusy_wait_condition(dhd_pub_t *pub, uint *var, uint condition);
2101 int dhd_os_busbusy_wait_bitmask(dhd_pub_t *pub, uint *var,
2102 uint bitmask, uint condition);
2103 extern int dhd_os_d3ack_wait(dhd_pub_t * pub, uint * condition);
2104 extern int dhd_os_d3ack_wake(dhd_pub_t * pub);
2105 extern int dhd_os_dmaxfer_wait(dhd_pub_t *pub, uint *condition);
2106 extern int dhd_os_dmaxfer_wake(dhd_pub_t *pub);
2107
2108 /*
2109 * Manage sta objects in an interface. Interface is identified by an ifindex and
2110 * sta(s) within an interfaces are managed using a MacAddress of the sta.
2111 */
2112 struct dhd_sta;
2113 extern bool dhd_sta_associated(dhd_pub_t *dhdp, uint32 bssidx, uint8 *mac);
2114 extern struct dhd_sta *dhd_find_sta(void *pub, int ifidx, void *ea);
2115 extern struct dhd_sta *dhd_findadd_sta(void *pub, int ifidx, void *ea);
2116 extern void dhd_del_all_sta(void *pub, int ifidx);
2117 extern void dhd_del_sta(void *pub, int ifidx, void *ea);
2118 extern int dhd_get_ap_isolate(dhd_pub_t *dhdp, uint32 idx);
2119 extern int dhd_set_ap_isolate(dhd_pub_t *dhdp, uint32 idx, int val);
2120 extern int dhd_bssidx2idx(dhd_pub_t *dhdp, uint32 bssidx);
2121 extern struct net_device *dhd_linux_get_primary_netdev(dhd_pub_t *dhdp);
2122
2123 extern bool dhd_is_concurrent_mode(dhd_pub_t *dhd);
2124 int dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *param_buf, uint param_len,
2125 char *res_buf, uint res_len, int set);
2126 extern int dhd_getiovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf,
2127 uint cmd_len, char **resptr, uint resp_len);
2128
2129 #ifdef DHD_MCAST_REGEN
2130 extern int dhd_get_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx);
2131 extern int dhd_set_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx, int val);
2132 #endif // endif
2133 typedef enum cust_gpio_modes {
2134 WLAN_RESET_ON,
2135 WLAN_RESET_OFF,
2136 WLAN_POWER_ON,
2137 WLAN_POWER_OFF
2138 } cust_gpio_modes_t;
2139
2140 typedef struct dmaxref_mem_map {
2141 dhd_dma_buf_t *srcmem;
2142 dhd_dma_buf_t *dstmem;
2143 } dmaxref_mem_map_t;
2144
2145 extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
2146 extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
2147
2148 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
2149 extern void dhd_flush_rx_tx_wq(dhd_pub_t *dhdp);
2150 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
2151
2152 /*
2153 * Insmod parameters for debug/test
2154 */
2155
2156 /* Watchdog timer interval */
2157 extern uint dhd_watchdog_ms;
2158 #ifdef DHD_PCIE_RUNTIMEPM
2159 extern uint dhd_runtimepm_ms;
2160 #endif /* DHD_PCIE_RUNTIMEPM */
2161
2162 /** Default console output poll interval */
2163 extern uint dhd_console_ms;
2164
2165 #if defined(DHD_DEBUG)
2166 extern uint wl_msg_level;
2167 #endif /* defined(DHD_DEBUG) */
2168
2169 extern uint dhd_slpauto;
2170
2171 /* Use interrupts */
2172 extern uint dhd_intr;
2173
2174 /* Use polling */
2175 extern uint dhd_poll;
2176
2177 /* ARP offload agent mode */
2178 extern uint dhd_arp_mode;
2179
2180 /* ARP offload enable */
2181 extern uint dhd_arp_enable;
2182
2183 /* Pkt filte enable control */
2184 extern uint dhd_pkt_filter_enable;
2185
2186 /* Pkt filter init setup */
2187 extern uint dhd_pkt_filter_init;
2188
2189 /* Pkt filter mode control */
2190 extern uint dhd_master_mode;
2191
2192 /* Roaming mode control */
2193 extern uint dhd_roam_disable;
2194
2195 /* Roaming mode control */
2196 extern uint dhd_radio_up;
2197
2198 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
2199 extern int dhd_idletime;
2200 #ifdef DHD_USE_IDLECOUNT
2201 #define DHD_IDLETIME_TICKS 5
2202 #else
2203 #define DHD_IDLETIME_TICKS 1
2204 #endif /* DHD_USE_IDLECOUNT */
2205
2206 /* SDIO Drive Strength */
2207 extern uint dhd_sdiod_drive_strength;
2208
2209 /* triggers bcm_bprintf to print to kernel log */
2210 extern bool bcm_bprintf_bypass;
2211
2212 /* Override to force tx queueing all the time */
2213 extern uint dhd_force_tx_queueing;
2214
2215 /* Default bcn_timeout value is 4 */
2216 #define DEFAULT_BCN_TIMEOUT_VALUE 4
2217 #ifndef CUSTOM_BCN_TIMEOUT_SETTING
2218 #define CUSTOM_BCN_TIMEOUT_SETTING DEFAULT_BCN_TIMEOUT_VALUE
2219 #endif // endif
2220
2221 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
2222 #define DEFAULT_KEEP_ALIVE_VALUE 55000 /* msec */
2223 #ifndef CUSTOM_KEEP_ALIVE_SETTING
2224 #define CUSTOM_KEEP_ALIVE_SETTING DEFAULT_KEEP_ALIVE_VALUE
2225 #endif /* DEFAULT_KEEP_ALIVE_VALUE */
2226
2227 #define NULL_PKT_STR "null_pkt"
2228
2229 /* hooks for custom glom setting option via Makefile */
2230 #define DEFAULT_GLOM_VALUE -1
2231 #ifndef CUSTOM_GLOM_SETTING
2232 #define CUSTOM_GLOM_SETTING DEFAULT_GLOM_VALUE
2233 #endif // endif
2234 #define WL_AUTO_ROAM_TRIGGER -75
2235 /* hooks for custom Roaming Trigger setting via Makefile */
2236 #define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
2237 #define DEFAULT_ROAM_TRIGGER_SETTING -1
2238 #ifndef CUSTOM_ROAM_TRIGGER_SETTING
2239 #define CUSTOM_ROAM_TRIGGER_SETTING DEFAULT_ROAM_TRIGGER_VALUE
2240 #endif // endif
2241
2242 /* hooks for custom Roaming Romaing setting via Makefile */
2243 #define DEFAULT_ROAM_DELTA_VALUE 10 /* dBm default roam delta all band */
2244 #define DEFAULT_ROAM_DELTA_SETTING -1
2245 #ifndef CUSTOM_ROAM_DELTA_SETTING
2246 #define CUSTOM_ROAM_DELTA_SETTING DEFAULT_ROAM_DELTA_VALUE
2247 #endif // endif
2248
2249 /* hooks for custom PNO Event wake lock to guarantee enough time
2250 for the Platform to detect Event before system suspended
2251 */
2252 #define DEFAULT_PNO_EVENT_LOCK_xTIME 2 /* multiplay of DHD_PACKET_TIMEOUT_MS */
2253 #ifndef CUSTOM_PNO_EVENT_LOCK_xTIME
2254 #define CUSTOM_PNO_EVENT_LOCK_xTIME DEFAULT_PNO_EVENT_LOCK_xTIME
2255 #endif // endif
2256 /* hooks for custom dhd_dpc_prio setting option via Makefile */
2257 #define DEFAULT_DHP_DPC_PRIO 1
2258 #ifndef CUSTOM_DPC_PRIO_SETTING
2259 #define CUSTOM_DPC_PRIO_SETTING DEFAULT_DHP_DPC_PRIO
2260 #endif // endif
2261
2262 #ifndef CUSTOM_LISTEN_INTERVAL
2263 #define CUSTOM_LISTEN_INTERVAL LISTEN_INTERVAL
2264 #endif /* CUSTOM_LISTEN_INTERVAL */
2265
2266 #define DEFAULT_SUSPEND_BCN_LI_DTIM 3
2267 #ifndef CUSTOM_SUSPEND_BCN_LI_DTIM
2268 #define CUSTOM_SUSPEND_BCN_LI_DTIM DEFAULT_SUSPEND_BCN_LI_DTIM
2269 #endif // endif
2270
2271 #ifndef BCN_TIMEOUT_IN_SUSPEND
2272 #define BCN_TIMEOUT_IN_SUSPEND 6 /* bcn timeout value in suspend mode */
2273 #endif // endif
2274
2275 #ifndef CUSTOM_RXF_PRIO_SETTING
2276 #define CUSTOM_RXF_PRIO_SETTING MAX((CUSTOM_DPC_PRIO_SETTING - 1), 1)
2277 #endif // endif
2278
2279 #define DEFAULT_WIFI_TURNOFF_DELAY 0
2280 #ifndef WIFI_TURNOFF_DELAY
2281 #define WIFI_TURNOFF_DELAY DEFAULT_WIFI_TURNOFF_DELAY
2282 #endif /* WIFI_TURNOFF_DELAY */
2283
2284 #define DEFAULT_WIFI_TURNON_DELAY 200
2285 #ifndef WIFI_TURNON_DELAY
2286 #define WIFI_TURNON_DELAY DEFAULT_WIFI_TURNON_DELAY
2287 #endif /* WIFI_TURNON_DELAY */
2288
2289 #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 10 /* msec */
2290 #ifndef CUSTOM_DHD_WATCHDOG_MS
2291 #define CUSTOM_DHD_WATCHDOG_MS DEFAULT_DHD_WATCHDOG_INTERVAL_MS
2292 #endif /* DEFAULT_DHD_WATCHDOG_INTERVAL_MS */
2293
2294 #define DEFAULT_ASSOC_RETRY_MAX 3
2295 #ifndef CUSTOM_ASSOC_RETRY_MAX
2296 #define CUSTOM_ASSOC_RETRY_MAX DEFAULT_ASSOC_RETRY_MAX
2297 #endif /* DEFAULT_ASSOC_RETRY_MAX */
2298
2299 #if defined(BCMSDIO) || defined(DISABLE_FRAMEBURST)
2300 #define DEFAULT_FRAMEBURST_SET 0
2301 #else
2302 #define DEFAULT_FRAMEBURST_SET 1
2303 #endif /* BCMSDIO */
2304
2305 #ifndef CUSTOM_FRAMEBURST_SET
2306 #define CUSTOM_FRAMEBURST_SET DEFAULT_FRAMEBURST_SET
2307 #endif /* CUSTOM_FRAMEBURST_SET */
2308
2309 #ifdef WLTDLS
2310 #ifndef CUSTOM_TDLS_IDLE_MODE_SETTING
2311 #define CUSTOM_TDLS_IDLE_MODE_SETTING 60000 /* 60sec to tear down TDLS of not active */
2312 #endif // endif
2313 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_HIGH
2314 #define CUSTOM_TDLS_RSSI_THRESHOLD_HIGH -70 /* rssi threshold for establishing TDLS link */
2315 #endif // endif
2316 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_LOW
2317 #define CUSTOM_TDLS_RSSI_THRESHOLD_LOW -80 /* rssi threshold for tearing down TDLS link */
2318 #endif // endif
2319 #ifndef CUSTOM_TDLS_PCKTCNT_THRESHOLD_HIGH
2320 #define CUSTOM_TDLS_PCKTCNT_THRESHOLD_HIGH 100 /* pkt/sec threshold for establishing TDLS link */
2321 #endif // endif
2322 #ifndef CUSTOM_TDLS_PCKTCNT_THRESHOLD_LOW
2323 #define CUSTOM_TDLS_PCKTCNT_THRESHOLD_LOW 10 /* pkt/sec threshold for tearing down TDLS link */
2324 #endif // endif
2325 #endif /* WLTDLS */
2326
2327 #if defined(VSDB) || defined(ROAM_ENABLE)
2328 #define DEFAULT_BCN_TIMEOUT 8
2329 #else
2330 #define DEFAULT_BCN_TIMEOUT 4
2331 #endif /* CUSTOMER_HW4 && (VSDB || ROAM_ENABLE) */
2332
2333 #ifndef CUSTOM_BCN_TIMEOUT
2334 #define CUSTOM_BCN_TIMEOUT DEFAULT_BCN_TIMEOUT
2335 #endif // endif
2336
2337 #define MAX_DTIM_SKIP_BEACON_INTERVAL 100 /* max allowed associated AP beacon for DTIM skip */
2338 #ifndef MAX_DTIM_ALLOWED_INTERVAL
2339 #define MAX_DTIM_ALLOWED_INTERVAL 600 /* max allowed total beacon interval for DTIM skip */
2340 #endif // endif
2341
2342 #ifndef MIN_DTIM_FOR_ROAM_THRES_EXTEND
2343 #define MIN_DTIM_FOR_ROAM_THRES_EXTEND 600 /* minimum dtim interval to extend roam threshold */
2344 #endif // endif
2345
2346 #define NO_DTIM_SKIP 1
2347 #ifdef SDTEST
2348 /* Echo packet generator (SDIO), pkts/s */
2349 extern uint dhd_pktgen;
2350
2351 /* Echo packet len (0 => sawtooth, max 1800) */
2352 extern uint dhd_pktgen_len;
2353 #define MAX_PKTGEN_LEN 1800
2354 #endif // endif
2355
2356 /* optionally set by a module_param_string() */
2357 #define MOD_PARAM_PATHLEN 2048
2358 #define MOD_PARAM_INFOLEN 512
2359 #define MOD_PARAM_SRLEN 64
2360
2361 #ifdef SOFTAP
2362 extern char fw_path2[MOD_PARAM_PATHLEN];
2363 #endif // endif
2364
2365 #if defined(ANDROID_PLATFORM_VERSION)
2366 #if (ANDROID_PLATFORM_VERSION < 7)
2367 #define DHD_LEGACY_FILE_PATH
2368 #define VENDOR_PATH "/system"
2369 #elif (ANDROID_PLATFORM_VERSION == 7)
2370 #define VENDOR_PATH "/system"
2371 #elif (ANDROID_PLATFORM_VERSION >= 8)
2372 #define VENDOR_PATH "/vendor"
2373 #endif /* ANDROID_PLATFORM_VERSION < 7 */
2374 #else
2375 #define VENDOR_PATH ""
2376 #endif /* ANDROID_PLATFORM_VERSION */
2377
2378 #if defined(ANDROID_PLATFORM_VERSION)
2379 #if (ANDROID_PLATFORM_VERSION < 9)
2380 #ifdef WL_STATIC_IF
2381 #undef WL_STATIC_IF
2382 #endif /* WL_STATIC_IF */
2383 #ifdef WL_STATIC_IFNAME_PREFIX
2384 #undef WL_STATIC_IFNAME_PREFIX
2385 #endif /* WL_STATIC_IFNAME_PREFIX */
2386 #endif /* ANDROID_PLATFORM_VERSION < 9 */
2387 #endif /* ANDROID_PLATFORM_VERSION */
2388
2389 #if defined(DHD_LEGACY_FILE_PATH)
2390 #define PLATFORM_PATH "/data/"
2391 #elif defined(PLATFORM_SLP)
2392 #define PLATFORM_PATH "/opt/etc/"
2393 #else
2394 #if defined(ANDROID_PLATFORM_VERSION)
2395 #if (ANDROID_PLATFORM_VERSION >= 9)
2396 #define PLATFORM_PATH "/data/vendor/conn/"
2397 #define DHD_MAC_ADDR_EXPORT
2398 #if !defined(CONFIG_BCM4359)
2399 #define DHD_ADPS_BAM_EXPORT
2400 #endif /* CONFIG_BCM4359 */
2401 #define DHD_EXPORT_CNTL_FILE
2402 #define DHD_SOFTAP_DUAL_IF_INFO
2403 /* ANDROID P(9.0) and later, always use single nvram file */
2404 #ifndef DHD_USE_SINGLE_NVRAM_FILE
2405 #define DHD_USE_SINGLE_NVRAM_FILE
2406 #endif /* !DHD_USE_SINGLE_NVRAM_FILE */
2407 #else
2408 #define PLATFORM_PATH "/data/misc/conn/"
2409 #endif /* ANDROID_PLATFORM_VERSION >= 9 */
2410 #else
2411 #define PLATFORM_PATH "/data/misc/conn/"
2412 #endif /* ANDROID_PLATFORM_VERSION */
2413 #endif /* DHD_LEGACY_FILE_PATH */
2414
2415 #ifdef DHD_MAC_ADDR_EXPORT
2416 extern struct ether_addr sysfs_mac_addr;
2417 #endif /* DHD_MAC_ADDR_EXPORT */
2418
2419 /* Flag to indicate if we should download firmware on driver load */
2420 extern uint dhd_download_fw_on_driverload;
2421 extern int allow_delay_fwdl;
2422
2423 extern int dhd_process_cid_mac(dhd_pub_t *dhdp, bool prepost);
2424 extern int dhd_write_file(const char *filepath, char *buf, int buf_len);
2425 extern int dhd_read_file(const char *filepath, char *buf, int buf_len);
2426 extern int dhd_write_file_and_check(const char *filepath, char *buf, int buf_len);
2427
2428 #ifdef READ_MACADDR
2429 extern int dhd_set_macaddr_from_file(dhd_pub_t *dhdp);
2430 #else
2431 static INLINE int dhd_set_macaddr_from_file(dhd_pub_t *dhdp) { return 0; }
2432 #endif /* READ_MACADDR */
2433 #ifdef WRITE_MACADDR
2434 extern int dhd_write_macaddr(struct ether_addr *mac);
2435 #else
2436 static INLINE int dhd_write_macaddr(struct ether_addr *mac) { return 0; }
2437 #endif /* WRITE_MACADDR */
2438 #ifdef USE_CID_CHECK
2439 #define MAX_VNAME_LEN 64
2440 #ifdef DHD_EXPORT_CNTL_FILE
2441 extern char cidinfostr[MAX_VNAME_LEN];
2442 #endif /* DHD_EXPORT_CNTL_FILE */
2443 extern int dhd_check_module_cid(dhd_pub_t *dhdp);
2444 extern char *dhd_get_cid_info(unsigned char *vid, int vid_length);
2445 #else
2446 static INLINE int dhd_check_module_cid(dhd_pub_t *dhdp) { return 0; }
2447 #endif /* USE_CID_CHECK */
2448 #ifdef GET_MAC_FROM_OTP
2449 extern int dhd_check_module_mac(dhd_pub_t *dhdp);
2450 #else
2451 static INLINE int dhd_check_module_mac(dhd_pub_t *dhdp) { return 0; }
2452 #endif /* GET_MAC_FROM_OTP */
2453
2454 #if defined(READ_MACADDR) || defined(WRITE_MACADDR) || defined(USE_CID_CHECK) || \
2455 defined(GET_MAC_FROM_OTP)
2456 #define DHD_USE_CISINFO
2457 #endif /* READ_MACADDR || WRITE_MACADDR || USE_CID_CHECK || GET_MAC_FROM_OTP */
2458
2459 #ifdef DHD_USE_CISINFO
2460 int dhd_read_cis(dhd_pub_t *dhdp);
2461 void dhd_clear_cis(dhd_pub_t *dhdp);
2462 #if defined(SUPPORT_MULTIPLE_MODULE_CIS) && defined(USE_CID_CHECK)
2463 bool dhd_check_module(char *module_name);
2464 extern int dhd_check_module_b85a(void);
2465 extern int dhd_check_module_b90(void);
2466 #define BCM4359_MODULE_TYPE_B90B 1
2467 #define BCM4359_MODULE_TYPE_B90S 2
2468 #endif /* defined(SUPPORT_MULTIPLE_MODULE_CIS) && defined(USE_CID_CHECK) */
2469 #if defined(SUPPORT_BCM4361_MIXED_MODULES) && defined(USE_CID_CHECK)
2470 extern int dhd_check_module_bcm4361(char *module_type, int index, bool *is_murata_fem);
2471 #endif /* defined(SUPPORT_BCM4361_MIXED_MODULES) && defined(USE_CID_CHECK) */
2472 #else
2473 static INLINE int dhd_read_cis(dhd_pub_t *dhdp) { return 0; }
2474 static INLINE void dhd_clear_cis(dhd_pub_t *dhdp) { }
2475 #endif /* DHD_USE_CISINFO */
2476
2477 #if defined(WL_CFG80211) && defined(SUPPORT_DEEP_SLEEP)
2478 /* Flags to indicate if we distingish power off policy when
2479 * user set the memu "Keep Wi-Fi on during sleep" to "Never"
2480 */
2481 extern int trigger_deep_sleep;
2482 int dhd_deepsleep(struct net_device *dev, int flag);
2483 #endif /* WL_CFG80211 && SUPPORT_DEEP_SLEEP */
2484
2485 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
2486 extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
2487
2488 #define IFLOCK_INIT(lock) *lock = 0
2489 #define IFLOCK(lock) while (InterlockedCompareExchange((lock), 1, 0)) \
2490 NdisStallExecution(1);
2491 #define IFUNLOCK(lock) InterlockedExchange((lock), 0)
2492 #define IFLOCK_FREE(lock)
2493 #define FW_SUPPORTED(dhd, capa) ((strstr(dhd->fw_capabilities, " " #capa " ") != NULL))
2494 #ifdef ARP_OFFLOAD_SUPPORT
2495 #define MAX_IPV4_ENTRIES 8
2496 void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
2497 void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
2498
2499 /* dhd_commn arp offload wrapers */
2500 void dhd_aoe_hostip_clr(dhd_pub_t *dhd, int idx);
2501 void dhd_aoe_arp_clr(dhd_pub_t *dhd, int idx);
2502 int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen, int idx);
2503 void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr, int idx);
2504 #endif /* ARP_OFFLOAD_SUPPORT */
2505 #ifdef WLTDLS
2506 int dhd_tdls_enable(struct net_device *dev, bool tdls_on, bool auto_on, struct ether_addr *mac);
2507 int dhd_tdls_set_mode(dhd_pub_t *dhd, bool wfd_mode);
2508 #ifdef PCIE_FULL_DONGLE
2509 int dhd_tdls_update_peer_info(dhd_pub_t *dhdp, wl_event_msg_t *event);
2510 int dhd_tdls_event_handler(dhd_pub_t *dhd_pub, wl_event_msg_t *event);
2511 int dhd_free_tdls_peer_list(dhd_pub_t *dhd_pub);
2512 #endif /* PCIE_FULL_DONGLE */
2513 #endif /* WLTDLS */
2514
2515 /* Neighbor Discovery Offload Support */
2516 extern int dhd_ndo_enable(dhd_pub_t * dhd, int ndo_enable);
2517 int dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipaddr, int idx);
2518 int dhd_ndo_remove_ip(dhd_pub_t *dhd, int idx);
2519
2520 /* Enhanced ND offload support */
2521 uint16 dhd_ndo_get_version(dhd_pub_t *dhdp);
2522 int dhd_ndo_add_ip_with_type(dhd_pub_t *dhdp, char *ipv6addr, uint8 type, int idx);
2523 int dhd_ndo_remove_ip_by_addr(dhd_pub_t *dhdp, char *ipv6addr, int idx);
2524 int dhd_ndo_remove_ip_by_type(dhd_pub_t *dhdp, uint8 type, int idx);
2525 int dhd_ndo_unsolicited_na_filter_enable(dhd_pub_t *dhdp, int enable);
2526
2527 /* ioctl processing for nl80211 */
2528 int dhd_ioctl_process(dhd_pub_t *pub, int ifidx, struct dhd_ioctl *ioc, void *data_buf);
2529
2530 #if defined(SUPPORT_MULTIPLE_REVISION)
2531 extern int
2532 concate_revision(struct dhd_bus *bus, char *fwpath, char *nvpath);
2533 #endif /* SUPPORT_MULTIPLE_REVISION */
2534 void dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path);
2535 void dhd_set_bus_state(void *bus, uint32 state);
2536
2537 /* Remove proper pkts(either one no-frag pkt or whole fragmented pkts) */
2538 typedef int (*f_droppkt_t)(dhd_pub_t *dhdp, int prec, void* p, bool bPktInQ);
2539 extern bool dhd_prec_drop_pkts(dhd_pub_t *dhdp, struct pktq *pq, int prec, f_droppkt_t fn);
2540
2541 #ifdef PROP_TXSTATUS
2542 int dhd_os_wlfc_block(dhd_pub_t *pub);
2543 int dhd_os_wlfc_unblock(dhd_pub_t *pub);
2544 extern const uint8 prio2fifo[];
2545 #endif /* PROP_TXSTATUS */
2546
2547 int dhd_os_socram_dump(struct net_device *dev, uint32 *dump_size);
2548 int dhd_os_get_socram_dump(struct net_device *dev, char **buf, uint32 *size);
2549 int dhd_common_socram_dump(dhd_pub_t *dhdp);
2550
2551 int dhd_dump(dhd_pub_t *dhdp, char *buf, int buflen);
2552
2553 int dhd_os_get_version(struct net_device *dev, bool dhd_ver, char **buf, uint32 size);
2554
2555 uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_if_fail);
2556 void dhd_os_prefree(dhd_pub_t *dhdpub, void *addr, uint size);
2557
2558 #if defined(CONFIG_DHD_USE_STATIC_BUF)
2559 #define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, FALSE)
2560 #define DHD_OS_PREFREE(dhdpub, addr, size) dhd_os_prefree(dhdpub, addr, size)
2561 #else
2562 #define DHD_OS_PREALLOC(dhdpub, section, size) MALLOC(dhdpub->osh, size)
2563 #define DHD_OS_PREFREE(dhdpub, addr, size) MFREE(dhdpub->osh, addr, size)
2564 #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
2565
2566 #ifdef USE_WFA_CERT_CONF
2567 enum {
2568 SET_PARAM_BUS_TXGLOM_MODE,
2569 SET_PARAM_ROAMOFF,
2570 #ifdef USE_WL_FRAMEBURST
2571 SET_PARAM_FRAMEBURST,
2572 #endif /* USE_WL_FRAMEBURST */
2573 #ifdef USE_WL_TXBF
2574 SET_PARAM_TXBF,
2575 #endif /* USE_WL_TXBF */
2576 #ifdef PROP_TXSTATUS
2577 SET_PARAM_PROPTX,
2578 SET_PARAM_PROPTXMODE,
2579 #endif /* PROP_TXSTATUS */
2580 PARAM_LAST_VALUE
2581 };
2582 extern int sec_get_param_wfa_cert(dhd_pub_t *dhd, int mode, uint* read_val);
2583 #ifdef DHD_EXPORT_CNTL_FILE
2584 #define VALUENOTSET 0xFFFFFFFFu
2585 extern uint32 bus_txglom;
2586 extern uint32 roam_off;
2587 #ifdef USE_WL_FRAMEBURST
2588 extern uint32 frameburst;
2589 #endif /* USE_WL_FRAMEBURST */
2590 #ifdef USE_WL_TXBF
2591 extern uint32 txbf;
2592 #endif /* USE_WL_TXBF */
2593 #ifdef PROP_TXSTATUS
2594 extern uint32 proptx;
2595 #endif /* PROP_TXSTATUS */
2596 #endif /* DHD_EXPORT_CNTL_FILE */
2597 #endif /* USE_WFA_CERT_CONF */
2598
2599 #define dhd_add_flowid(pub, ifidx, ac_prio, ea, flowid) do {} while (0)
2600 #define dhd_del_flowid(pub, ifidx, flowid) do {} while (0)
2601 bool dhd_wet_chainable(dhd_pub_t *dhdp);
2602
2603 extern unsigned long dhd_os_general_spin_lock(dhd_pub_t *pub);
2604 extern void dhd_os_general_spin_unlock(dhd_pub_t *pub, unsigned long flags);
2605
2606 /** Miscellaenous DHD Spin Locks */
2607
2608 /* Disable router 3GMAC bypass path perimeter lock */
2609 #define DHD_PERIM_LOCK(dhdp) do {} while (0)
2610 #define DHD_PERIM_UNLOCK(dhdp) do {} while (0)
2611 #define DHD_PERIM_LOCK_ALL(processor_id) do {} while (0)
2612 #define DHD_PERIM_UNLOCK_ALL(processor_id) do {} while (0)
2613
2614 /* Enable DHD general spin lock/unlock */
2615 #define DHD_GENERAL_LOCK(dhdp, flags) \
2616 (flags) = dhd_os_general_spin_lock(dhdp)
2617 #define DHD_GENERAL_UNLOCK(dhdp, flags) \
2618 dhd_os_general_spin_unlock((dhdp), (flags))
2619
2620 /* Enable DHD timer spin lock/unlock */
2621 #define DHD_TIMER_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2622 #define DHD_TIMER_UNLOCK(lock, flags) dhd_os_spin_unlock(lock, (flags))
2623
2624 /* Enable DHD flowring spin lock/unlock */
2625 #define DHD_FLOWRING_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2626 #define DHD_FLOWRING_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2627
2628 /* Enable DHD common flowring info spin lock/unlock */
2629 #define DHD_FLOWID_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2630 #define DHD_FLOWID_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2631
2632 /* Enable DHD common flowring list spin lock/unlock */
2633 #define DHD_FLOWRING_LIST_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2634 #define DHD_FLOWRING_LIST_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2635
2636 #define DHD_SPIN_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2637 #define DHD_SPIN_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2638
2639 #define DHD_RING_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2640 #define DHD_RING_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2641
2642 #define DHD_BUS_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2643 #define DHD_BUS_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2644
2645 #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2646 #define DHD_BUS_INB_DW_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2647
2648 /* Enable DHD TDLS peer list spin lock/unlock */
2649 #ifdef WLTDLS
2650 #define DHD_TDLS_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2651 #define DHD_TDLS_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2652 #endif /* WLTDLS */
2653
2654 #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2655 #define DHD_BUS_INB_DW_UNLOCK(lock, flags) dhd_os_spin_unlock((lock), (flags))
2656
2657 #ifdef DBG_PKT_MON
2658 /* Enable DHD PKT MON spin lock/unlock */
2659 #define DHD_PKT_MON_LOCK(lock, flags) (flags) = dhd_os_spin_lock(lock)
2660 #define DHD_PKT_MON_UNLOCK(lock, flags) dhd_os_spin_unlock(lock, (flags))
2661 #endif /* DBG_PKT_MON */
2662
2663 #define DHD_LINUX_GENERAL_LOCK(dhdp, flags) DHD_GENERAL_LOCK(dhdp, flags)
2664 #define DHD_LINUX_GENERAL_UNLOCK(dhdp, flags) DHD_GENERAL_UNLOCK(dhdp, flags)
2665
2666 /* linux is defined for DHD EFI builds also,
2667 * since its cross-compiled for EFI from linux
2668 */
2669 #define DHD_DBG_RING_LOCK_INIT(osh) dhd_os_dbgring_lock_init(osh)
2670 #define DHD_DBG_RING_LOCK_DEINIT(osh, lock) dhd_os_dbgring_lock_deinit(osh, (lock))
2671 #define DHD_DBG_RING_LOCK(lock, flags) (flags) = dhd_os_dbgring_lock(lock)
2672 #define DHD_DBG_RING_UNLOCK(lock, flags) dhd_os_dbgring_unlock((lock), flags)
2673
2674 extern void dhd_dump_to_kernelog(dhd_pub_t *dhdp);
2675
2676 extern void dhd_print_tasklet_status(dhd_pub_t *dhd);
2677
2678 #ifdef DHD_L2_FILTER
2679 extern int dhd_get_parp_status(dhd_pub_t *dhdp, uint32 idx);
2680 extern int dhd_set_parp_status(dhd_pub_t *dhdp, uint32 idx, int val);
2681 extern int dhd_get_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx);
2682 extern int dhd_set_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx, int val);
2683 extern int dhd_get_block_ping_status(dhd_pub_t *dhdp, uint32 idx);
2684 extern int dhd_set_block_ping_status(dhd_pub_t *dhdp, uint32 idx, int val);
2685 extern int dhd_get_grat_arp_status(dhd_pub_t *dhdp, uint32 idx);
2686 extern int dhd_set_grat_arp_status(dhd_pub_t *dhdp, uint32 idx, int val);
2687 extern int dhd_get_block_tdls_status(dhd_pub_t *dhdp, uint32 idx);
2688 extern int dhd_set_block_tdls_status(dhd_pub_t *dhdp, uint32 idx, int val);
2689 #endif /* DHD_L2_FILTER */
2690
2691 typedef struct wl_io_pport {
2692 dhd_pub_t *dhd_pub;
2693 uint ifidx;
2694 } wl_io_pport_t;
2695
2696 typedef struct wl_evt_pport {
2697 dhd_pub_t *dhd_pub;
2698 int *ifidx;
2699 void *pktdata;
2700 uint data_len;
2701 void **data_ptr;
2702 void *raw_event;
2703 } wl_evt_pport_t;
2704
2705 extern void *dhd_pub_shim(dhd_pub_t *dhd_pub);
2706 #ifdef DHD_FW_COREDUMP
2707 void* dhd_get_fwdump_buf(dhd_pub_t *dhd_pub, uint32 length);
2708 #endif /* DHD_FW_COREDUMP */
2709
2710 #if defined(SET_RPS_CPUS) || defined(ARGOS_RPS_CPU_CTL)
2711 int dhd_rps_cpus_enable(struct net_device *net, int enable);
2712 int custom_rps_map_set(struct netdev_rx_queue *queue, char *buf, size_t len);
2713 void custom_rps_map_clear(struct netdev_rx_queue *queue);
2714 #define PRIMARY_INF 0
2715 #define VIRTUAL_INF 1
2716 #if defined(CONFIG_MACH_UNIVERSAL5433) || defined(CONFIG_MACH_UNIVERSAL7420) || \
2717 defined(CONFIG_SOC_EXYNOS8890)
2718 #define RPS_CPUS_MASK "10"
2719 #define RPS_CPUS_MASK_P2P "10"
2720 #define RPS_CPUS_MASK_IBSS "10"
2721 #define RPS_CPUS_WLAN_CORE_ID 4
2722 #else
2723 #define RPS_CPUS_MASK "6"
2724 #define RPS_CPUS_MASK_P2P "6"
2725 #define RPS_CPUS_MASK_IBSS "6"
2726 #endif /* CONFIG_MACH_UNIVERSAL5433 || CONFIG_MACH_UNIVERSAL7420 || CONFIG_SOC_EXYNOS8890 */
2727 #endif /* SET_RPS_CPUS || ARGOS_RPS_CPU_CTL */
2728
2729 int dhd_get_download_buffer(dhd_pub_t *dhd, char *file_path, download_type_t component,
2730 char ** buffer, int *length);
2731
2732 void dhd_free_download_buffer(dhd_pub_t *dhd, void *buffer, int length);
2733
2734 int dhd_download_blob(dhd_pub_t *dhd, unsigned char *buf,
2735 uint32 len, char *iovar);
2736
2737 int dhd_download_blob_cached(dhd_pub_t *dhd, char *file_path,
2738 uint32 len, char *iovar);
2739
2740 int dhd_apply_default_txcap(dhd_pub_t *dhd, char *txcap_path);
2741 int dhd_apply_default_clm(dhd_pub_t *dhd, char *clm_path);
2742 #ifdef DHD_USE_CLMINFO_PARSER
2743 int dhd_get_clminfo(dhd_pub_t *dhd, char *clm_path);
2744 #define NUM_OF_COUNTRYS 150
2745 #endif /* DHD_USE_CLMINFO_PARSER */
2746
2747 #ifdef SHOW_LOGTRACE
2748 int dhd_parse_logstrs_file(osl_t *osh, char *raw_fmts, int logstrs_size,
2749 dhd_event_log_t *event_log);
2750 int dhd_parse_map_file(osl_t *osh, void *file, uint32 *ramstart,
2751 uint32 *rodata_start, uint32 *rodata_end);
2752 #ifdef PCIE_FULL_DONGLE
2753 int dhd_event_logtrace_infobuf_pkt_process(dhd_pub_t *dhdp, void *pktbuf,
2754 dhd_event_log_t *event_data);
2755 #endif /* PCIE_FULL_DONGLE */
2756 #endif /* SHOW_LOGTRACE */
2757
2758 #define dhd_is_device_removed(x) FALSE
2759 #define dhd_os_ind_firmware_stall(x)
2760
2761 #if defined(DHD_FW_COREDUMP)
2762 extern void dhd_get_memdump_info(dhd_pub_t *dhd);
2763 #endif /* defined(DHD_FW_COREDUMP) */
2764 #ifdef BCMASSERT_LOG
2765 extern void dhd_get_assert_info(dhd_pub_t *dhd);
2766 #else
2767 static INLINE void dhd_get_assert_info(dhd_pub_t *dhd) { }
2768 #endif /* BCMASSERT_LOG */
2769
2770 #define DMAXFER_FREE(dhdp, dmap) dhd_schedule_dmaxfer_free(dhdp, dmap);
2771
2772 #if defined(PCIE_FULL_DONGLE)
2773 extern void dmaxfer_free_prev_dmaaddr(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
2774 void dhd_schedule_dmaxfer_free(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
2775 #endif /* PCIE_FULL_DONGLE */
2776
2777 #define DHD_LB_STATS_NOOP do { /* noop */ } while (0)
2778 #if defined(DHD_LB_STATS)
2779 #include <bcmutils.h>
2780 extern void dhd_lb_stats_init(dhd_pub_t *dhd);
2781 extern void dhd_lb_stats_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
2782 extern void dhd_lb_stats_update_napi_histo(dhd_pub_t *dhdp, uint32 count);
2783 extern void dhd_lb_stats_update_txc_histo(dhd_pub_t *dhdp, uint32 count);
2784 extern void dhd_lb_stats_update_rxc_histo(dhd_pub_t *dhdp, uint32 count);
2785 extern void dhd_lb_stats_txc_percpu_cnt_incr(dhd_pub_t *dhdp);
2786 extern void dhd_lb_stats_rxc_percpu_cnt_incr(dhd_pub_t *dhdp);
2787 #define DHD_LB_STATS_INIT(dhdp) dhd_lb_stats_init(dhdp)
2788 #define DHD_LB_STATS_DEINIT(dhdp) dhd_lb_stats_deinit(dhdp)
2789 /* Reset is called from common layer so it takes dhd_pub_t as argument */
2790 #define DHD_LB_STATS_RESET(dhdp) dhd_lb_stats_init(dhdp)
2791 #define DHD_LB_STATS_CLR(x) (x) = 0U
2792 #define DHD_LB_STATS_INCR(x) (x) = (x) + 1
2793 #define DHD_LB_STATS_ADD(x, c) (x) = (x) + (c)
2794 #define DHD_LB_STATS_PERCPU_ARR_INCR(x) \
2795 { \
2796 int cpu = get_cpu(); put_cpu(); \
2797 DHD_LB_STATS_INCR(x[cpu]); \
2798 }
2799 #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhdp, x) dhd_lb_stats_update_napi_histo(dhdp, x)
2800 #define DHD_LB_STATS_UPDATE_TXC_HISTO(dhdp, x) dhd_lb_stats_update_txc_histo(dhdp, x)
2801 #define DHD_LB_STATS_UPDATE_RXC_HISTO(dhdp, x) dhd_lb_stats_update_rxc_histo(dhdp, x)
2802 #define DHD_LB_STATS_TXC_PERCPU_CNT_INCR(dhdp) dhd_lb_stats_txc_percpu_cnt_incr(dhdp)
2803 #define DHD_LB_STATS_RXC_PERCPU_CNT_INCR(dhdp) dhd_lb_stats_rxc_percpu_cnt_incr(dhdp)
2804 #else /* !DHD_LB_STATS */
2805 #define DHD_LB_STATS_INIT(dhdp) DHD_LB_STATS_NOOP
2806 #define DHD_LB_STATS_DEINIT(dhdp) DHD_LB_STATS_NOOP
2807 #define DHD_LB_STATS_RESET(dhdp) DHD_LB_STATS_NOOP
2808 #define DHD_LB_STATS_CLR(x) DHD_LB_STATS_NOOP
2809 #define DHD_LB_STATS_INCR(x) DHD_LB_STATS_NOOP
2810 #define DHD_LB_STATS_ADD(x, c) DHD_LB_STATS_NOOP
2811 #define DHD_LB_STATS_PERCPU_ARR_INCR(x) DHD_LB_STATS_NOOP
2812 #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhd, x) DHD_LB_STATS_NOOP
2813 #define DHD_LB_STATS_UPDATE_TXC_HISTO(dhd, x) DHD_LB_STATS_NOOP
2814 #define DHD_LB_STATS_UPDATE_RXC_HISTO(dhd, x) DHD_LB_STATS_NOOP
2815 #define DHD_LB_STATS_TXC_PERCPU_CNT_INCR(dhdp) DHD_LB_STATS_NOOP
2816 #define DHD_LB_STATS_RXC_PERCPU_CNT_INCR(dhdp) DHD_LB_STATS_NOOP
2817 #endif /* !DHD_LB_STATS */
2818 #ifdef DHD_LB_IRQSET
2819 extern void dhd_irq_set_affinity(dhd_pub_t *dhdp);
2820 #endif /* DHD_LB_IRQSET */
2821
2822 #ifdef DHD_SSSR_DUMP
2823 #define DHD_SSSR_MEMPOOL_SIZE (1024 * 1024) /* 1MB size */
2824 extern int dhd_sssr_mempool_init(dhd_pub_t *dhd);
2825 extern void dhd_sssr_mempool_deinit(dhd_pub_t *dhd);
2826 extern int dhd_sssr_dump_init(dhd_pub_t *dhd);
2827 extern void dhd_sssr_dump_deinit(dhd_pub_t *dhd);
2828 #define DHD_SSSR_MEMPOOL_INIT(dhdp) dhd_sssr_mempool_init(dhdp)
2829 #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) dhd_sssr_mempool_deinit(dhdp)
2830 #define DHD_SSSR_DUMP_INIT(dhdp) dhd_sssr_dump_init(dhdp)
2831 #define DHD_SSSR_DUMP_DEINIT(dhdp) dhd_sssr_dump_deinit(dhdp)
2832 #else
2833 #define DHD_SSSR_MEMPOOL_INIT(dhdp) do { /* noop */ } while (0)
2834 #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) do { /* noop */ } while (0)
2835 #define DHD_SSSR_DUMP_INIT(dhdp) do { /* noop */ } while (0)
2836 #define DHD_SSSR_DUMP_DEINIT(dhdp) do { /* noop */ } while (0)
2837 #endif /* DHD_SSSR_DUMP */
2838
2839 #ifdef SHOW_LOGTRACE
2840 void dhd_get_read_buf_ptr(dhd_pub_t *dhd_pub, trace_buf_info_t *read_buf_info);
2841 #endif /* SHOW_LOGTRACE */
2842
2843 #ifdef BCMPCIE
2844 extern int dhd_prot_debug_info_print(dhd_pub_t *dhd);
2845 extern bool dhd_bus_skip_clm(dhd_pub_t *dhdp);
2846 extern void dhd_pcie_dump_rc_conf_space_cap(dhd_pub_t *dhd);
2847 extern bool dhd_pcie_dump_int_regs(dhd_pub_t *dhd);
2848 #else
2849 #define dhd_prot_debug_info_print(x)
2850 static INLINE bool dhd_bus_skip_clm(dhd_pub_t *dhd_pub)
2851 { return 0; }
2852 #endif /* BCMPCIE */
2853
2854 bool dhd_fw_download_status(dhd_pub_t * dhd_pub);
2855 void dhd_show_kirqstats(dhd_pub_t *dhd);
2856
2857 /* Bitmask used for Join Timeout */
2858 #define WLC_SSID_MASK 0x01
2859 #define WLC_WPA_MASK 0x02
2860
2861 extern int dhd_start_join_timer(dhd_pub_t *pub);
2862 extern int dhd_stop_join_timer(dhd_pub_t *pub);
2863 extern int dhd_start_scan_timer(dhd_pub_t *pub, bool is_escan);
2864 extern int dhd_stop_scan_timer(dhd_pub_t *pub, bool is_escan, uint16 sync_id);
2865 extern int dhd_start_cmd_timer(dhd_pub_t *pub);
2866 extern int dhd_stop_cmd_timer(dhd_pub_t *pub);
2867 extern int dhd_start_bus_timer(dhd_pub_t *pub);
2868 extern int dhd_stop_bus_timer(dhd_pub_t *pub);
2869 extern uint16 dhd_get_request_id(dhd_pub_t *pub);
2870 extern int dhd_set_request_id(dhd_pub_t *pub, uint16 id, uint32 cmd);
2871 extern void dhd_set_join_error(dhd_pub_t *pub, uint32 mask);
2872 extern void dhd_clear_join_error(dhd_pub_t *pub, uint32 mask);
2873 extern void dhd_get_scan_to_val(dhd_pub_t *pub, uint32 *to_val);
2874 extern void dhd_set_scan_to_val(dhd_pub_t *pub, uint32 to_val);
2875 extern void dhd_get_join_to_val(dhd_pub_t *pub, uint32 *to_val);
2876 extern void dhd_set_join_to_val(dhd_pub_t *pub, uint32 to_val);
2877 extern void dhd_get_cmd_to_val(dhd_pub_t *pub, uint32 *to_val);
2878 extern void dhd_set_cmd_to_val(dhd_pub_t *pub, uint32 to_val);
2879 extern void dhd_get_bus_to_val(dhd_pub_t *pub, uint32 *to_val);
2880 extern void dhd_set_bus_to_val(dhd_pub_t *pub, uint32 to_val);
2881 extern int dhd_start_timesync_timer(dhd_pub_t *pub);
2882 extern int dhd_stop_timesync_timer(dhd_pub_t *pub);
2883
2884 #ifdef DHD_PKTID_AUDIT_ENABLED
2885 void dhd_pktid_error_handler(dhd_pub_t *dhdp);
2886 #endif /* DHD_PKTID_AUDIT_ENABLED */
2887
2888 #ifdef DHD_MAP_PKTID_LOGGING
2889 extern void dhd_pktid_logging_dump(dhd_pub_t *dhdp);
2890 #endif /* DHD_MAP_PKTID_LOGGING */
2891
2892 #ifdef DHD_PCIE_RUNTIMEPM
2893 extern bool dhd_runtimepm_state(dhd_pub_t *dhd);
2894 extern bool dhd_runtime_bus_wake(struct dhd_bus *bus, bool wait, void *func_addr);
2895 extern bool dhdpcie_runtime_bus_wake(dhd_pub_t *dhdp, bool wait, void *func_addr);
2896 extern void dhdpcie_block_runtime_pm(dhd_pub_t *dhdp);
2897 extern bool dhdpcie_is_resume_done(dhd_pub_t *dhdp);
2898 extern void dhd_runtime_pm_disable(dhd_pub_t *dhdp);
2899 extern void dhd_runtime_pm_enable(dhd_pub_t *dhdp);
2900 /* Disable the Runtime PM and wake up if the bus is already in suspend */
2901 #define DHD_DISABLE_RUNTIME_PM(dhdp) \
2902 do { \
2903 dhd_runtime_pm_disable(dhdp); \
2904 } while (0);
2905
2906 /* Enable the Runtime PM */
2907 #define DHD_ENABLE_RUNTIME_PM(dhdp) \
2908 do { \
2909 dhd_runtime_pm_enable(dhdp); \
2910 } while (0);
2911 #else
2912 #define DHD_DISABLE_RUNTIME_PM(dhdp)
2913 #define DHD_ENABLE_RUNTIME_PM(dhdp)
2914 #endif /* DHD_PCIE_RUNTIMEPM */
2915
2916 extern bool dhd_prot_is_cmpl_ring_empty(dhd_pub_t *dhd, void *prot_info);
2917 extern void dhd_prot_dump_ring_ptrs(void *prot_info);
2918
2919 /*
2920 * Enable this macro if you want to track the calls to wake lock
2921 * This records can be printed using the following command
2922 * cat /sys/bcm-dhd/wklock_trace
2923 * DHD_TRACE_WAKE_LOCK supports over linux 2.6.0 version
2924 */
2925 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0))
2926 #undef DHD_TRACE_WAKE_LOCK
2927 #endif /* KERNEL_VER < KERNEL_VERSION(2, 6, 0) */
2928
2929 #if defined(DHD_TRACE_WAKE_LOCK)
2930 void dhd_wk_lock_stats_dump(dhd_pub_t *dhdp);
2931 #endif // endif
2932
2933 extern bool dhd_query_bus_erros(dhd_pub_t *dhdp);
2934
2935 #if defined(CONFIG_64BIT)
2936 #define DHD_SUPPORT_64BIT
2937 #endif /* (linux || LINUX) && CONFIG_64BIT */
2938
2939 #if defined(DHD_ERPOM)
2940 extern void dhd_schedule_reset(dhd_pub_t *dhdp);
2941 #else
2942 static INLINE void dhd_schedule_reset(dhd_pub_t *dhdp) {;}
2943 #endif // endif
2944
2945 extern void init_dhd_timeouts(dhd_pub_t *pub);
2946 extern void deinit_dhd_timeouts(dhd_pub_t *pub);
2947
2948 typedef enum timeout_resons {
2949 DHD_REASON_COMMAND_TO,
2950 DHD_REASON_JOIN_TO,
2951 DHD_REASON_SCAN_TO,
2952 DHD_REASON_OQS_TO
2953 } timeout_reasons_t;
2954
2955 extern void dhd_prhex(const char *msg, volatile uchar *buf, uint nbytes, uint8 dbg_level);
2956 int dhd_tput_test(dhd_pub_t *dhd, tput_test_t *tput_data);
2957 void dhd_tput_test_rx(dhd_pub_t *dhd, void *pkt);
2958 static INLINE int dhd_get_max_txbufs(dhd_pub_t *dhdp)
2959 { return -1; }
2960
2961 #ifdef FILTER_IE
2962 int dhd_read_from_file(dhd_pub_t *dhd);
2963 int dhd_parse_filter_ie(dhd_pub_t *dhd, uint8 *buf);
2964 int dhd_get_filter_ie_count(dhd_pub_t *dhd, uint8 *buf);
2965 int dhd_parse_oui(dhd_pub_t *dhd, uint8 *inbuf, uint8 *oui, int len);
2966 int dhd_check_valid_ie(dhd_pub_t *dhdp, uint8 *buf, int len);
2967 #endif /* FILTER_IE */
2968
2969 uint16 dhd_prot_get_ioctl_trans_id(dhd_pub_t *dhdp);
2970
2971 #ifdef SET_PCIE_IRQ_CPU_CORE
2972 enum {
2973 PCIE_IRQ_AFFINITY_OFF = 0,
2974 PCIE_IRQ_AFFINITY_BIG_CORE_ANY,
2975 PCIE_IRQ_AFFINITY_BIG_CORE_EXYNOS,
2976 PCIE_IRQ_AFFINITY_LAST
2977 };
2978 extern void dhd_set_irq_cpucore(dhd_pub_t *dhdp, int affinity_cmd);
2979 #endif /* SET_PCIE_IRQ_CPU_CORE */
2980 #if defined(DHD_HANG_SEND_UP_TEST)
2981 extern void dhd_make_hang_with_reason(struct net_device *dev, const char *string_num);
2982 #endif /* DHD_HANG_SEND_UP_TEST */
2983
2984 #ifdef DHD_WAKE_STATUS
2985 wake_counts_t* dhd_get_wakecount(dhd_pub_t *dhdp);
2986 #endif /* DHD_WAKE_STATUS */
2987 extern int dhd_get_random_bytes(uint8 *buf, uint len);
2988 #if defined(DHD_BLOB_EXISTENCE_CHECK)
2989 extern void dhd_set_blob_support(dhd_pub_t *dhdp, char *fw_path);
2990 #endif /* DHD_BLOB_EXISTENCE_CHECK */
2991
2992 /* configuration of ecounters. API's tp start/stop. currently supported only for linux */
2993 extern int dhd_start_ecounters(dhd_pub_t *dhd);
2994 extern int dhd_stop_ecounters(dhd_pub_t *dhd);
2995 extern int dhd_start_event_ecounters(dhd_pub_t *dhd);
2996 extern int dhd_stop_event_ecounters(dhd_pub_t *dhd);
2997
2998 int dhd_get_preserve_log_numbers(dhd_pub_t *dhd, uint32 *logset_mask);
2999
3000 #ifdef DHD_LOG_DUMP
3001 void dhd_schedule_log_dump(dhd_pub_t *dhdp, void *type);
3002 void dhd_log_dump_trigger(dhd_pub_t *dhdp, int subcmd);
3003 int dhd_log_dump_ring_to_file(dhd_pub_t *dhdp, void *ring_ptr, void *file,
3004 unsigned long *file_posn, log_dump_section_hdr_t *sec_hdr);
3005 int dhd_log_dump_cookie_to_file(dhd_pub_t *dhdp, void *fp, unsigned long *f_pos);
3006 int dhd_logdump_cookie_init(dhd_pub_t *dhdp, uint8 *buf, uint32 buf_size);
3007 void dhd_logdump_cookie_deinit(dhd_pub_t *dhdp);
3008 void dhd_logdump_cookie_save(dhd_pub_t *dhdp, char *cookie, char *type);
3009 int dhd_logdump_cookie_get(dhd_pub_t *dhdp, char *ret_cookie, uint32 buf_size);
3010 int dhd_logdump_cookie_count(dhd_pub_t *dhdp);
3011 #endif /* DHD_LOG_DUMP */
3012
3013 #define DHD_PCIE_CONFIG_SAVE(bus) pci_save_state(bus->dev)
3014 #define DHD_PCIE_CONFIG_RESTORE(bus) pci_restore_state(bus->dev)
3015
3016 #ifdef BIGDATA_SOFTAP
3017 void dhd_schedule_gather_ap_stadata(void *bcm_cfg, void *ndev, const wl_event_msg_t *e);
3018 #endif /* BIGDATA_SOFTAP */
3019
3020 typedef struct dhd_pkt_parse {
3021 uint32 proto; /* Network layer protocol */
3022 uint32 t1; /* n-tuple */
3023 uint32 t2;
3024 } dhd_pkt_parse_t;
3025
3026 /* ========= RING API functions : exposed to others ============= */
3027 #define DHD_RING_TYPE_FIXED 1
3028 uint32 dhd_ring_get_hdr_size(void);
3029 void *dhd_ring_init(uint8 *buf, uint32 buf_size, uint32 elem_size, uint32 elem_cnt);
3030 void dhd_ring_deinit(void *_ring);
3031 void *dhd_ring_get_first(void *_ring);
3032 void dhd_ring_free_first(void *_ring);
3033 void *dhd_ring_get_last(void *_ring);
3034 void *dhd_ring_get_next(void *_ring, void *cur);
3035 void *dhd_ring_get_prev(void *_ring, void *cur);
3036 void *dhd_ring_get_empty(void *_ring);
3037 int dhd_ring_get_cur_size(void *_ring);
3038 void dhd_ring_lock(void *ring, void *fist_ptr, void *last_ptr);
3039 void dhd_ring_lock_free(void *ring);
3040 void *dhd_ring_lock_get_first(void *_ring);
3041 void *dhd_ring_lock_get_last(void *_ring);
3042 int dhd_ring_lock_get_count(void *_ring);
3043 void dhd_ring_lock_free_first(void *ring);
3044
3045 #define DHD_DUMP_TYPE_NAME_SIZE 32
3046 #define DHD_DUMP_FILE_PATH_SIZE 256
3047 #define DHD_DUMP_FILE_COUNT_MAX 5
3048 #define DHD_DUMP_TYPE_COUNT_MAX 10
3049
3050 #ifdef DHD_DUMP_MNGR
3051 typedef struct _DFM_elem {
3052 char type_name[DHD_DUMP_TYPE_NAME_SIZE];
3053 char file_path[DHD_DUMP_FILE_COUNT_MAX][DHD_DUMP_FILE_PATH_SIZE];
3054 int file_idx;
3055 } DFM_elem_t;
3056
3057 typedef struct _dhd_dump_file_manage {
3058 DFM_elem_t elems[DHD_DUMP_TYPE_COUNT_MAX];
3059 } dhd_dump_file_manage_t;
3060
3061 extern void dhd_dump_file_manage_enqueue(dhd_pub_t *dhd, char *dump_path, char *fname);
3062 #endif /* DHD_DUMP_MNGR */
3063 #ifdef DHD_8021X_DUMP
3064 extern void dhd_dump_eapol_4way_message(char *ifname, unsigned char *dump_data, bool direction);
3065 #endif /* DHD_8021X_DUMP */
3066
3067 #ifdef PKT_FILTER_SUPPORT
3068 extern void dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg);
3069 extern void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode);
3070 extern void dhd_pktfilter_offload_delete(dhd_pub_t *dhd, int id);
3071 #endif // endif
3072
3073 extern uint32 wlreg_l;
3074 extern uint32 wlreg_h;
3075
3076 extern uint32 wlreg_len_l;
3077 extern uint32 wlreg_len_h;
3078
3079 extern int dhd_get_host_whitelist_region(void *buf, uint len);
3080 #ifdef DHD_DUMP_PCIE_RINGS
3081 extern int dhd_d2h_h2d_ring_dump(dhd_pub_t *dhd, void *file, unsigned long *file_posn);
3082 #endif /* DHD_DUMP_PCIE_RINGS */
3083 #define HD_PREFIX_SIZE 2 /* hexadecimal prefix size */
3084 #define HD_BYTE_SIZE 2 /* hexadecimal byte size */
3085 extern void dhd_cleanup_if(struct net_device *net);
3086
3087 #ifdef SUPPORT_SET_TID
3088 enum dhd_set_tid_mode {
3089 /* Disalbe changing TID */
3090 SET_TID_OFF = 0,
3091 /* Change TID for all UDP frames */
3092 SET_TID_ALL_UDP,
3093 /* Change TID for UDP frames based on UID */
3094 SET_TID_BASED_ON_UID
3095 };
3096 extern void dhd_set_tid_based_on_uid(dhd_pub_t *dhdp, void *pkt);
3097 #endif /* SUPPORT_SET_TID */
3098
3099 int dhd_check_eapol_4way_message(char *dump_data);
3100 #ifdef DYNAMIC_MUMIMO_CONTROL
3101 #ifdef ARGOS_CPU_SCHEDULER
3102 void argos_config_mumimo_reset(void);
3103 #endif /* ARGOS_CPU_SCHEDULER */
3104 #endif /* DYNAMIC_MUMIMO_CONTROL */
3105
3106 #if defined(DHD_BLOB_EXISTENCE_CHECK) && defined(DHD_USE_CLMINFO_PARSER)
3107 #define CHECK_IS_BLOB(dhdp) (dhdp)->is_blob
3108 #define CHECK_IS_MULT_REGREV(dhdp) (dhdp)->is_clm_mult_regrev
3109 #elif defined(DHD_BLOB_EXISTENCE_CHECK) && !defined(DHD_USE_CLMINFO_PARSER)
3110 #define CHECK_IS_BLOB(dhdp) (dhdp)->is_blob
3111 #define CHECK_IS_MULT_REGREV(dhdp) FALSE
3112 #elif !defined(DHD_BLOB_EXISTENCE_CHECK) && defined(DHD_USE_CLMINFO_PARSER)
3113 #define CHECK_IS_BLOB(dhdp) TRUE
3114 #define CHECK_IS_MULT_REGREV(dhdp) (dhdp)->is_clm_mult_regrev
3115 #else /* !DHD_BLOB_EXISTENCE_CHECK && !DHD_USE_CLMINFO_PARSER */
3116 #define CHECK_IS_BLOB(dhdp) FALSE
3117 #define CHECK_IS_MULT_REGREV(dhdp) TRUE
3118 #endif /* DHD_BLOB_EXISTENCE_CHECK && DHD_USE_CLMINFO_PARSER */
3119
3120 #endif /* _dhd_h_ */