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) 2020, 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 *
24 * <<Broadcom-WL-IPTag/Open:>>
25 *
26 * $Id$
27 */
28
29 /****************
30 * Common types *
31 */
32
33 #ifndef _dhd_h_
34 #define _dhd_h_
35
36 #if defined(LINUX)
37 #include <linux/firmware.h>
38 #include <linux/init.h>
39 #include <linux/kernel.h>
40 #include <linux/slab.h>
41 #include <linux/skbuff.h>
42 #include <linux/netdevice.h>
43 #include <linux/etherdevice.h>
44 #include <linux/random.h>
45 #include <linux/spinlock.h>
46 #include <linux/ethtool.h>
47 #include <linux/proc_fs.h>
48 #include <asm/uaccess.h>
49 #include <asm/unaligned.h>
50 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
51 #include <uapi/linux/sched/types.h>
52 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
53 #include <linux/sched/types.h>
54 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) */
55 #ifdef DHD_BUZZZ_LOG_ENABLED
56 #include <dhd_buzzz.h>
57 #endif /* DHD_BUZZZ_LOG_ENABLED */
58 /* The kernel threading is sdio-specific */
59 struct task_struct;
60 struct sched_param;
61 #if defined(BT_OVER_SDIO)
62 #include <dhd_bt_interface.h>
63 #endif /* defined (BT_OVER_SDIO) */
64 int setScheduler(struct task_struct *p, int policy, struct sched_param *param);
65 int get_scheduler_policy(struct task_struct *p);
66 #else /* LINUX */
67 #define ENOMEM 1
68 #define EFAULT 2
69 #define EINVAL 3
70 #define EIO 4
71 #define ETIMEDOUT 5
72 #define ENODATA 6
73 #define EREMOTEIO 7
74 #define ENODEV 8
75 #define ERESTARTSYS 512
76 #endif /* LINUX */
77 #define MAX_EVENT 16
78
79 #define ALL_INTERFACES 0xff
80
81 /* H2D and D2H ring dump is enabled by default */
82 #ifdef PCIE_FULL_DONGLE
83 #define DHD_DUMP_PCIE_RINGS
84 #endif /* PCIE_FULL_DONGLE */
85
86 #include <osl.h>
87
88 #include <wlioctl.h>
89 #include <dhdioctl.h>
90 #include <wlfc_proto.h>
91 #include <hnd_armtrap.h>
92 #if defined(DUMP_IOCTL_IOV_LIST) || defined(DHD_DEBUG)
93 #include <bcmutils.h>
94 #endif /* DUMP_IOCTL_IOV_LIST || DHD_DEBUG */
95
96 #if defined(BCMWDF)
97 #include <wdf.h>
98 #include <WdfMiniport.h>
99 #endif /* (BCMWDF) */
100
101 #ifdef WL_CFGVENDOR_SEND_HANG_EVENT
102 #include <dnglioctl.h>
103 #endif /* WL_CFGVENDOR_SEND_HANG_EVENT */
104
105 #ifdef DHD_ERPOM
106 #include <pom.h>
107 #ifdef PCIE_OOB
108 /*
109 * Both ERPOM and PCIE_OOB depend on ftdi to programme GPIOs.
110 * Both features operating parallelly make the GPIOs go outof sync.
111 * So only one feature is expected to be present at a time.
112 */
113 #error "PCIE_OOB enabled"
114 #endif /* PCIE_OOB */
115 #endif /* DHD_ERPOM */
116
117 #include <dngl_stats.h>
118 #include <hnd_pktq.h>
119
120 #ifdef DEBUG_DPC_THREAD_WATCHDOG
121 #define MAX_RESCHED_CNT 600
122 #endif /* DEBUG_DPC_THREAD_WATCHDOG */
123
124 #if defined(LINUX) || defined(linux)
125 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) && LINUX_VERSION_CODE < \
126 KERNEL_VERSION(3, 18, 0) || defined(CONFIG_BCMDHD_VENDOR_EXT))
127 #define WL_VENDOR_EXT_SUPPORT
128 #endif /* 3.18 > KERNEL_VER >= 3.14 || defined(CONFIG_BCMDHD_VENDOR_EXT) */
129 #endif /* defined (LINUX) || defined(linux) */
130
131 #if defined(KEEP_ALIVE)
132 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
133 #define KEEP_ALIVE_PERIOD 55000
134 #define NULL_PKT_STR "null_pkt"
135 #endif /* KEEP_ALIVE */
136
137 /* By default enabled from here, later the WQ code will be removed */
138 #define DHD_USE_KTHREAD_FOR_LOGTRACE
139
140 /* Forward decls */
141 struct dhd_bus;
142 struct dhd_prot;
143 struct dhd_info;
144 struct dhd_ioctl;
145 struct dhd_dbg;
146 struct dhd_ts;
147 #ifdef DNGL_AXI_ERROR_LOGGING
148 struct dhd_axi_error_dump;
149 #endif /* DNGL_AXI_ERROR_LOGGING */
150
151 /* The level of bus communication with the dongle */
152 enum dhd_bus_state {
153 DHD_BUS_DOWN, /* Not ready for frame transfers */
154 DHD_BUS_LOAD, /* Download access only (CPU reset) */
155 DHD_BUS_DATA, /* Ready for frame transfers */
156 DHD_BUS_SUSPEND, /* Bus has been suspended */
157 DHD_BUS_DOWN_IN_PROGRESS, /* Bus going Down */
158 DHD_BUS_REMOVE, /* Bus has been removed */
159 };
160
161 /* The level of bus communication with the dongle */
162 enum dhd_bus_devreset_type {
163 DHD_BUS_DEVRESET_ON = 0, /* ON */
164 DHD_BUS_DEVRESET_OFF = 1, /* OFF */
165 DHD_BUS_DEVRESET_FLR = 2, /* FLR */
166 DHD_BUS_DEVRESET_FLR_FORCE_FAIL = 3, /* FLR FORCE FAIL */
167 DHD_BUS_DEVRESET_QUIESCE = 4, /* FLR */
168 };
169
170 /*
171 * Bit fields to Indicate clean up process that wait till they are finished.
172 * Future synchronizable processes can add their bit filed below and update
173 * their functionalities accordingly
174 */
175 #define DHD_BUS_BUSY_IN_TX 0x01
176 #define DHD_BUS_BUSY_IN_SEND_PKT 0x02
177 #define DHD_BUS_BUSY_IN_DPC 0x04
178 #define DHD_BUS_BUSY_IN_WD 0x08
179 #define DHD_BUS_BUSY_IN_IOVAR 0x10
180 #define DHD_BUS_BUSY_IN_DHD_IOVAR 0x20
181 #define DHD_BUS_BUSY_SUSPEND_IN_PROGRESS 0x40
182 #define DHD_BUS_BUSY_RESUME_IN_PROGRESS 0x80
183 #define DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS 0x100
184 #define DHD_BUS_BUSY_RPM_SUSPEND_DONE 0x200
185 #define DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS 0x400
186 #define DHD_BUS_BUSY_RPM_ALL (DHD_BUS_BUSY_RPM_SUSPEND_DONE | \
187 DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS | \
188 DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
189 #define DHD_BUS_BUSY_IN_CHECKDIED 0x800
190 #define DHD_BUS_BUSY_IN_MEMDUMP 0x1000
191 #define DHD_BUS_BUSY_IN_SSSRDUMP 0x2000
192 #define DHD_BUS_BUSY_IN_LOGDUMP 0x4000
193 #define DHD_BUS_BUSY_IN_HALDUMP 0x8000
194 #define DHD_BUS_BUSY_IN_NAPI 0x10000
195 #define DHD_BUS_BUSY_IN_DS_DEASSERT 0x20000
196
197 #define DHD_BUS_BUSY_SET_IN_TX(dhdp) \
198 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_TX
199 #define DHD_BUS_BUSY_SET_IN_SEND_PKT(dhdp) \
200 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SEND_PKT
201 #define DHD_BUS_BUSY_SET_IN_DPC(dhdp) \
202 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DPC
203 #define DHD_BUS_BUSY_SET_IN_WD(dhdp) \
204 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_WD
205 #define DHD_BUS_BUSY_SET_IN_IOVAR(dhdp) \
206 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_IOVAR
207 #define DHD_BUS_BUSY_SET_IN_DHD_IOVAR(dhdp) \
208 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DHD_IOVAR
209 #define DHD_BUS_BUSY_SET_SUSPEND_IN_PROGRESS(dhdp) \
210 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
211 #define DHD_BUS_BUSY_SET_RESUME_IN_PROGRESS(dhdp) \
212 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RESUME_IN_PROGRESS
213 #define DHD_BUS_BUSY_SET_RPM_SUSPEND_IN_PROGRESS(dhdp) \
214 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
215 #define DHD_BUS_BUSY_SET_RPM_SUSPEND_DONE(dhdp) \
216 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_SUSPEND_DONE
217 #define DHD_BUS_BUSY_SET_RPM_RESUME_IN_PROGRESS(dhdp) \
218 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
219 #define DHD_BUS_BUSY_SET_IN_CHECKDIED(dhdp) \
220 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_CHECKDIED
221 #define DHD_BUS_BUSY_SET_IN_MEMDUMP(dhdp) \
222 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_MEMDUMP
223 #define DHD_BUS_BUSY_SET_IN_SSSRDUMP(dhdp) \
224 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_SSSRDUMP
225 #define DHD_BUS_BUSY_SET_IN_LOGDUMP(dhdp) \
226 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_LOGDUMP
227 #define DHD_BUS_BUSY_SET_IN_HALDUMP(dhdp) \
228 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_HALDUMP
229 #define DHD_BUS_BUSY_SET_IN_NAPI(dhdp) \
230 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_NAPI
231 #define DHD_BUS_BUSY_SET_IN_DS_DEASSERT(dhdp) \
232 (dhdp)->dhd_bus_busy_state |= DHD_BUS_BUSY_IN_DS_DEASSERT
233
234 #define DHD_BUS_BUSY_CLEAR_IN_TX(dhdp) \
235 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_TX
236 #define DHD_BUS_BUSY_CLEAR_IN_SEND_PKT(dhdp) \
237 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SEND_PKT
238 #define DHD_BUS_BUSY_CLEAR_IN_DPC(dhdp) \
239 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DPC
240 #define DHD_BUS_BUSY_CLEAR_IN_WD(dhdp) \
241 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_WD
242 #define DHD_BUS_BUSY_CLEAR_IN_IOVAR(dhdp) \
243 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_IOVAR
244 #define DHD_BUS_BUSY_CLEAR_IN_DHD_IOVAR(dhdp) \
245 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DHD_IOVAR
246 #define DHD_BUS_BUSY_CLEAR_SUSPEND_IN_PROGRESS(dhdp) \
247 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_SUSPEND_IN_PROGRESS
248 #define DHD_BUS_BUSY_CLEAR_RESUME_IN_PROGRESS(dhdp) \
249 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RESUME_IN_PROGRESS
250 #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_IN_PROGRESS(dhdp) \
251 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS
252 #define DHD_BUS_BUSY_CLEAR_RPM_SUSPEND_DONE(dhdp) \
253 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_SUSPEND_DONE
254 #define DHD_BUS_BUSY_CLEAR_RPM_RESUME_IN_PROGRESS(dhdp) \
255 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS
256 #define DHD_BUS_BUSY_CLEAR_IN_CHECKDIED(dhdp) \
257 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_CHECKDIED
258 #define DHD_BUS_BUSY_CLEAR_IN_MEMDUMP(dhdp) \
259 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_MEMDUMP
260 #define DHD_BUS_BUSY_CLEAR_IN_SSSRDUMP(dhdp) \
261 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_SSSRDUMP
262 #define DHD_BUS_BUSY_CLEAR_IN_LOGDUMP(dhdp) \
263 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_LOGDUMP
264 #define DHD_BUS_BUSY_CLEAR_IN_HALDUMP(dhdp) \
265 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_HALDUMP
266 #define DHD_BUS_BUSY_CLEAR_IN_NAPI(dhdp) \
267 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_NAPI
268 #define DHD_BUS_BUSY_CLEAR_IN_DS_DEASSERT(dhdp) \
269 (dhdp)->dhd_bus_busy_state &= ~DHD_BUS_BUSY_IN_DS_DEASSERT
270
271 #define DHD_BUS_BUSY_CHECK_IN_TX(dhdp) \
272 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_TX)
273 #define DHD_BUS_BUSY_CHECK_IN_SEND_PKT(dhdp) \
274 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SEND_PKT)
275 #define DHD_BUS_BUSY_CHECK_IN_DPC(dhdp) \
276 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DPC)
277 #define DHD_BUS_BUSY_CHECK_IN_WD(dhdp) \
278 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_WD)
279 #define DHD_BUS_BUSY_CHECK_IN_IOVAR(dhdp) \
280 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_IOVAR)
281 #define DHD_BUS_BUSY_CHECK_IN_DHD_IOVAR(dhdp) \
282 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DHD_IOVAR)
283 #define DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) \
284 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_SUSPEND_IN_PROGRESS)
285 #define DHD_BUS_BUSY_CHECK_RESUME_IN_PROGRESS(dhdp) \
286 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RESUME_IN_PROGRESS)
287 #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp) \
288 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_IN_PROGRESS)
289 #define DHD_BUS_BUSY_CHECK_RPM_SUSPEND_DONE(dhdp) \
290 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_SUSPEND_DONE)
291 #define DHD_BUS_BUSY_CHECK_RPM_RESUME_IN_PROGRESS(dhdp) \
292 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_RESUME_IN_PROGRESS)
293 #define DHD_BUS_BUSY_CHECK_RPM_ALL(dhdp) \
294 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_RPM_ALL)
295 #define DHD_BUS_BUSY_CHECK_IN_CHECKDIED(dhdp) \
296 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_CHECKDIED)
297 #define DHD_BUS_BUSY_CHECK_IN_MEMDUMP(dhdp) \
298 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_MEMDUMP)
299 #define DHD_BUS_BUSY_CHECK_IN_SSSRDUMP(dhdp) \
300 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_SSSRDUMP)
301 #define DHD_BUS_BUSY_CHECK_IN_LOGDUMP(dhdp) \
302 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_LOGDUMP)
303 #define DHD_BUS_BUSY_CHECK_IN_HALDUMP(dhdp) \
304 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_HALDUMP)
305 #define DHD_BUS_BUSY_CHECK_IN_DS_DEASSERT(dhdp) \
306 ((dhdp)->dhd_bus_busy_state & DHD_BUS_BUSY_IN_DS_DEASSERT)
307 #define DHD_BUS_BUSY_CHECK_IDLE(dhdp) \
308 ((dhdp)->dhd_bus_busy_state == 0)
309
310 #define DHD_BUS_CHECK_SUSPEND_OR_SUSPEND_IN_PROGRESS(dhdp) \
311 ((dhdp)->busstate == DHD_BUS_SUSPEND || DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp))
312
313 #define DHD_BUS_CHECK_ANY_SUSPEND_IN_PROGRESS(dhdp) \
314 (DHD_BUS_BUSY_CHECK_SUSPEND_IN_PROGRESS(dhdp) || \
315 DHD_BUS_BUSY_CHECK_RPM_SUSPEND_IN_PROGRESS(dhdp))
316
317 #define DHD_BUS_CHECK_SUSPEND_OR_ANY_SUSPEND_IN_PROGRESS(dhdp) \
318 ((dhdp)->busstate == DHD_BUS_SUSPEND || DHD_BUS_CHECK_ANY_SUSPEND_IN_PROGRESS(dhdp))
319
320 #define DHD_BUS_CHECK_DOWN_OR_DOWN_IN_PROGRESS(dhdp) \
321 ((dhdp)->busstate == DHD_BUS_DOWN || (dhdp)->busstate == DHD_BUS_DOWN_IN_PROGRESS || \
322 (dhdp)->busstate == DHD_BUS_REMOVE)
323
324 #define DHD_BUS_CHECK_REMOVE(dhdp) \
325 ((dhdp)->busstate == DHD_BUS_REMOVE)
326
327 /* IOVar flags for common error checks */
328 #define DHD_IOVF_PWRREQ_BYPASS (1<<0) /* flags to prevent bp access during host sleep state */
329
330 #define MAX_MTU_SZ (1600u)
331
332 #ifdef PCIE_INB_DW
333 #define DHD_CHECK_CFG_IN_PROGRESS(dhdp) \
334 ((INBAND_DW_ENAB((dhdp)->bus)) ? dhd_check_cfg_in_progress(dhdp) : FALSE)
335 #else
336 #define DHD_CHECK_CFG_IN_PROGRESS(dhdp) FALSE
337 #endif /* PCIE_INB_DW */
338
339 #ifndef USEC_PER_SEC
340 #define USEC_PER_SEC (1000 * 1000)
341 #endif
342 #if (defined (LINUX) || defined(linux))
343 /* (u64)result = (u64)dividend / (u64)divisor */
344 #define DIV_U64_BY_U64(dividend, divisor) div64_u64(dividend, divisor)
345
346 /* (u64)result = (u64)dividend / (u32)divisor */
347 #define DIV_U64_BY_U32(dividend, divisor) div_u64(dividend, divisor)
348
349 /* Be careful while using this, as it divides dividend also
350 * (u32)remainder = (u64)dividend % (u32)divisor
351 * (u64)dividend = (u64)dividend / (u32)divisor
352 */
353 #define DIV_AND_MOD_U64_BY_U32(dividend, divisor) do_div(dividend, divisor)
354
355 /* (u32)remainder = (u64)dividend % (u32)divisor */
356 #define MOD_U64_BY_U32(dividend, divisor) ({ \
357 uint64 temp_dividend = (dividend); \
358 uint32 rem = DIV_AND_MOD_U64_BY_U32(temp_dividend, (divisor)); \
359 rem; \
360 })
361
362 #define SEC_USEC_FMT \
363 "%5llu.%06u"
364 #else
365 /* (u64)result = (u64)dividend / (u64)divisor */
366 #define DIV_U64_BY_U64(dividend, divisor) (uint64)(dividend) / (uint64)(divisor)
367
368 /* (u64)result = (u64)dividend / (u32)divisor */
369 #define DIV_U64_BY_U32(dividend, divisor) (uint64)(dividend) / (uint32)(divisor)
370
371 /* Be careful while using this, as it divides dividend also
372 * (u32)remainder = (u64)dividend % (u32)divisor
373 * (u64)dividend = (u64)dividend / (u32)divisor
374 */
375 #define DIV_AND_MOD_U64_BY_U32(dividend, divisor) ({ \
376 uint32 rem = (uint64)(dividend) % (uint32)(divisor); \
377 (dividend) = (uint64)(dividend) / (uint32)(divisor); \
378 rem; \
379 })
380
381 /* (u32)remainder = (u64)dividend % (u32)divisor */
382 #define MOD_U64_BY_U32(dividend, divisor) (uint32)((uint64)(dividend) % (uint32)(divisor))
383
384 #define SEC_USEC_FMT \
385 "%015llu.%06u"
386 #endif /* LINUX || linux */
387
388 /* t: time in nano second */
389 #define GET_SEC_USEC(t) \
390 DIV_U64_BY_U32(t, NSEC_PER_SEC), \
391 ((uint32)(MOD_U64_BY_U32(t, NSEC_PER_SEC) / (uint32)NSEC_PER_USEC))
392
393 /* Download Types */
394 typedef enum download_type {
395 FW,
396 NVRAM,
397 CLM_BLOB,
398 TXCAP_BLOB
399 } download_type_t;
400
401 #if defined(NDIS)
402 /* Firmware requested operation mode */
403 #define STA_MASK 0x0001
404 #define HOSTAPD_MASK 0x0002
405 #define WFD_MASK 0x0004
406 #define SOFTAP_FW_MASK 0x0008
407 #define P2P_GO_ENABLED 0x0010
408 #define P2P_GC_ENABLED 0x0020
409 #define CONCURENT_MASK 0x00F0
410 #endif /* #if defined(NDIS) */
411
412 /* For supporting multiple interfaces */
413 #define DHD_MAX_IFS 16
414 #ifndef DHD_MAX_STATIC_IFS
415 #define DHD_MAX_STATIC_IFS 1
416 #endif
417 #define DHD_DEL_IF -0xE
418 #define DHD_BAD_IF -0xF
419 #define DHD_DUMMY_INFO_IF 0xDEAF /* Hack i/f to handle events from INFO Ring */
420 /* XXX to avoid build error for NDIS for timebeing */
421 #define DHD_EVENT_IF DHD_DUMMY_INFO_IF
422
423 #if defined(LINUX) || defined(linux)
424 enum dhd_op_flags {
425 /* Firmware requested operation mode */
426 DHD_FLAG_STA_MODE = (1 << (0)), /* STA only */
427 DHD_FLAG_HOSTAP_MODE = (1 << (1)), /* SOFTAP only */
428 DHD_FLAG_P2P_MODE = (1 << (2)), /* P2P Only */
429 /* STA + P2P */
430 DHD_FLAG_CONCURR_SINGLE_CHAN_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_P2P_MODE),
431 /* STA + SoftAP */
432 DHD_FLAG_CONCURR_STA_HOSTAP_MODE = (DHD_FLAG_STA_MODE | DHD_FLAG_HOSTAP_MODE),
433 /* XXX MULTI_CHAN mode is meaningful only if it is conccurncy mode */
434 DHD_FLAG_CONCURR_MULTI_CHAN_MODE = (1 << (4)), /* STA + P2P */
435 /* Current P2P mode for P2P connection */
436 DHD_FLAG_P2P_GC_MODE = (1 << (5)),
437 DHD_FLAG_P2P_GO_MODE = (1 << (6)),
438 DHD_FLAG_MBSS_MODE = (1 << (7)), /* MBSS in future */
439 DHD_FLAG_IBSS_MODE = (1 << (8)),
440 DHD_FLAG_MFG_MODE = (1 << (9)),
441 DHD_FLAG_RSDB_MODE = (1 << (10)),
442 DHD_FLAG_MP2P_MODE = (1 << (11))
443 };
444 #endif /* defined (LINUX) || defined(linux) */
445
446 #if defined(BCMDONGLEHOST)
447 #define DHD_OPMODE_SUPPORTED(dhd, opmode_flag) \
448 (dhd ? ((((dhd_pub_t *)dhd)->op_mode) & opmode_flag) : -1)
449 #define DHD_OPMODE_STA_SOFTAP_CONCURR(dhd) \
450 (dhd ? (((((dhd_pub_t *)dhd)->op_mode) & DHD_FLAG_CONCURR_STA_HOSTAP_MODE) == \
451 DHD_FLAG_CONCURR_STA_HOSTAP_MODE) : 0)
452 #else
453 #define DHD_OPMODE_SUPPORTED(dhd, opmode_flag) -1
454 #define DHD_OPMODE_STA_SOFTAP_CONCURR(dhd) 0
455 #endif /* defined (BCMDONGLEHOST) */
456
457 /* Max sequential TX/RX Control timeouts to set HANG event */
458 #ifndef MAX_CNTL_TX_TIMEOUT
459 #define MAX_CNTL_TX_TIMEOUT 2
460 #endif /* MAX_CNTL_TX_TIMEOUT */
461 #ifndef MAX_CNTL_RX_TIMEOUT
462 #define MAX_CNTL_RX_TIMEOUT 1
463 #endif /* MAX_CNTL_RX_TIMEOUT */
464
465 #define DHD_SCAN_ASSOC_ACTIVE_TIME 40 /* ms: Embedded default Active setting from DHD */
466 #ifndef CUSTOM_SCAN_UNASSOC_ACTIVE_TIME
467 #define DHD_SCAN_UNASSOC_ACTIVE_TIME 80 /* ms: Embedded def. Unassoc Active setting from DHD */
468 #else
469 #define DHD_SCAN_UNASSOC_ACTIVE_TIME CUSTOM_SCAN_UNASSOC_ACTIVE_TIME
470 #endif /* CUSTOM_SCAN_UNASSOC_ACTIVE_TIME */
471 #define DHD_SCAN_HOME_TIME 45 /* ms: Embedded default Home time setting from DHD */
472 #define DHD_SCAN_HOME_AWAY_TIME 100 /* ms: Embedded default Home Away time setting from DHD */
473 #ifndef CUSTOM_SCAN_PASSIVE_TIME
474 #define DHD_SCAN_PASSIVE_TIME 130 /* ms: Embedded default Passive setting from DHD */
475 #else
476 #define DHD_SCAN_PASSIVE_TIME CUSTOM_SCAN_PASSIVE_TIME /* ms: Custom Passive setting from DHD */
477 #endif /* CUSTOM_SCAN_PASSIVE_TIME */
478
479 #ifndef POWERUP_MAX_RETRY
480 #define POWERUP_MAX_RETRY 3 /* how many times we retry to power up the chip */
481 #endif
482 #ifndef POWERUP_WAIT_MS
483 #define POWERUP_WAIT_MS 2000 /* ms: time out in waiting wifi to come up */
484 #endif
485 /*
486 * MAX_NVRAMBUF_SIZE determines the size of the Buffer in the DHD that holds
487 * the NVRAM data. That is the size of the buffer pointed by bus->vars
488 * This also needs to be increased to 24K to support NVRAM size higher than 16K
489 */
490 #define MAX_NVRAMBUF_SIZE (24 * 1024) /* max nvram buf size */
491 #define MAX_CLM_BUF_SIZE (48 * 1024) /* max clm blob size */
492 #define MAX_TXCAP_BUF_SIZE (16 * 1024) /* max txcap blob size */
493 #ifdef DHD_DEBUG
494 #define DHD_JOIN_MAX_TIME_DEFAULT 10000 /* ms: Max time out for joining AP */
495 #define DHD_SCAN_DEF_TIMEOUT 10000 /* ms: Max time out for scan in progress */
496 #endif /* DHD_DEBUG */
497
498 #ifndef CONFIG_BCMDHD_CLM_PATH
499 #ifdef OEM_ANDROID
500 #if defined(CUSTOMER_HW4) && defined(PLATFORM_SLP)
501 #define CONFIG_BCMDHD_CLM_PATH "/lib/firmware/bcmdhd_clm.blob"
502 #else
503 #define CONFIG_BCMDHD_CLM_PATH "/etc/wifi/bcmdhd_clm.blob"
504 #endif /* CUSTOMER_HW4 && PLATFORM_SLP */
505 #elif defined(LINUX) || defined(linux)
506 #define CONFIG_BCMDHD_CLM_PATH "/var/run/bcmdhd_clm.blob"
507 #else
508 /* clm download will fail on empty path */
509 #define CONFIG_BCMDHD_CLM_PATH ""
510 #endif /* OEM_ANDROID */
511 #endif /* CONFIG_BCMDHD_CLM_PATH */
512 #define WL_CCODE_NULL_COUNTRY "#n"
513
514 #ifdef DHD_EFI
515 #define FW_VER_STR_LEN 256
516 #else
517 #define FW_VER_STR_LEN 128
518 #endif
519 #define FWID_STR_LEN 256
520 #define CLM_VER_STR_LEN 128
521 #define BUS_API_REV_STR_LEN 128
522 #define FW_VER_STR "Version"
523 #define FWID_STR_1 "FWID: 01-"
524 #define FWID_STR_2 "FWID=01-"
525 extern char bus_api_revision[];
526
527 enum dhd_bus_wake_state {
528 WAKE_LOCK_OFF = 0,
529 WAKE_LOCK_PRIV = 1,
530 WAKE_LOCK_DPC = 2,
531 WAKE_LOCK_IOCTL = 3,
532 WAKE_LOCK_DOWNLOAD = 4,
533 WAKE_LOCK_TMOUT = 5,
534 WAKE_LOCK_WATCHDOG = 6,
535 WAKE_LOCK_LINK_DOWN_TMOUT = 7,
536 WAKE_LOCK_PNO_FIND_TMOUT = 8,
537 WAKE_LOCK_SOFTAP_SET = 9,
538 WAKE_LOCK_SOFTAP_STOP = 10,
539 WAKE_LOCK_SOFTAP_START = 11,
540 WAKE_LOCK_SOFTAP_THREAD = 12
541 };
542
543 enum {
544 EVENT_BUF_POOL_LOW = 32,
545 EVENT_BUF_POOL_MEDIUM = 64,
546 EVENT_BUF_POOL_HIGH = 128,
547 EVENT_BUF_POOL_HIGHEST = 256
548 };
549
550 #ifdef PCIE_INB_DW
551 enum dhd_bus_ds_state {
552 DW_DEVICE_DS_INVALID = -1,
553 DW_DEVICE_DS_DEV_SLEEP = 0,
554 DW_DEVICE_DS_DEV_SLEEP_PEND = 1,
555 DW_DEVICE_DS_DISABLED_WAIT = 2,
556 DW_DEVICE_DS_DEV_WAKE = 3,
557 DW_DEVICE_DS_ACTIVE = 4,
558 DW_DEVICE_HOST_SLEEP_WAIT = 5,
559 DW_DEVICE_HOST_SLEEP = 6,
560 DW_DEVICE_HOST_WAKE_WAIT = 7,
561 DW_DEVICE_DS_D3_INFORM_WAIT = 8
562 };
563 #endif /* PCIE_INB_DW */
564
565 enum dhd_prealloc_index {
566 DHD_PREALLOC_PROT = 0,
567 DHD_PREALLOC_RXBUF = 1,
568 DHD_PREALLOC_DATABUF = 2,
569 DHD_PREALLOC_OSL_BUF = 3,
570 DHD_PREALLOC_SKB_BUF = 4,
571 DHD_PREALLOC_WIPHY_ESCAN0 = 5,
572 DHD_PREALLOC_WIPHY_ESCAN1 = 6,
573 DHD_PREALLOC_DHD_INFO = 7,
574 DHD_PREALLOC_DHD_WLFC_INFO = 8,
575 DHD_PREALLOC_IF_FLOW_LKUP = 9,
576 /* 10 */
577 DHD_PREALLOC_MEMDUMP_RAM = 11,
578 DHD_PREALLOC_DHD_WLFC_HANGER = 12,
579 DHD_PREALLOC_PKTID_MAP = 13,
580 DHD_PREALLOC_PKTID_MAP_IOCTL = 14,
581 DHD_PREALLOC_DHD_LOG_DUMP_BUF = 15,
582 DHD_PREALLOC_DHD_LOG_DUMP_BUF_EX = 16,
583 DHD_PREALLOC_DHD_PKTLOG_DUMP_BUF = 17,
584 DHD_PREALLOC_STAT_REPORT_BUF = 18,
585 DHD_PREALLOC_WL_ESCAN = 19,
586 DHD_PREALLOC_FW_VERBOSE_RING = 20,
587 DHD_PREALLOC_FW_EVENT_RING = 21,
588 DHD_PREALLOC_DHD_EVENT_RING = 22,
589 DHD_PREALLOC_NAN_EVENT_RING = 23
590 };
591
592 enum dhd_dongledump_mode {
593 DUMP_DISABLED = 0,
594 DUMP_MEMONLY = 1,
595 DUMP_MEMFILE = 2,
596 DUMP_MEMFILE_BUGON = 3,
597 DUMP_MEMFILE_MAX = 4
598 };
599
600 enum dhd_dongledump_type {
601 DUMP_TYPE_RESUMED_ON_TIMEOUT = 1,
602 DUMP_TYPE_D3_ACK_TIMEOUT = 2,
603 DUMP_TYPE_DONGLE_TRAP = 3,
604 DUMP_TYPE_MEMORY_CORRUPTION = 4,
605 DUMP_TYPE_PKTID_AUDIT_FAILURE = 5,
606 DUMP_TYPE_PKTID_INVALID = 6,
607 DUMP_TYPE_SCAN_TIMEOUT = 7,
608 DUMP_TYPE_SCAN_BUSY = 8,
609 DUMP_TYPE_BY_SYSDUMP = 9,
610 DUMP_TYPE_BY_LIVELOCK = 10,
611 DUMP_TYPE_AP_LINKUP_FAILURE = 11,
612 DUMP_TYPE_AP_ABNORMAL_ACCESS = 12,
613 DUMP_TYPE_CFG_VENDOR_TRIGGERED = 13,
614 DUMP_TYPE_RESUMED_ON_TIMEOUT_TX = 14,
615 DUMP_TYPE_RESUMED_ON_TIMEOUT_RX = 15,
616 DUMP_TYPE_RESUMED_ON_INVALID_RING_RDWR = 16,
617 DUMP_TYPE_TRANS_ID_MISMATCH = 17,
618 DUMP_TYPE_IFACE_OP_FAILURE = 18,
619 DUMP_TYPE_DONGLE_INIT_FAILURE = 19,
620 DUMP_TYPE_READ_SHM_FAIL = 20,
621 DUMP_TYPE_DONGLE_HOST_EVENT = 21,
622 DUMP_TYPE_SMMU_FAULT = 22,
623 DUMP_TYPE_RESUMED_UNKNOWN = 23,
624 DUMP_TYPE_DUE_TO_BT = 24,
625 DUMP_TYPE_LOGSET_BEYOND_RANGE = 25,
626 DUMP_TYPE_BY_USER = 26,
627 DUMP_TYPE_CTO_RECOVERY = 27,
628 DUMP_TYPE_SEQUENTIAL_PRIVCMD_ERROR = 28,
629 DUMP_TYPE_PROXD_TIMEOUT = 29,
630 DUMP_TYPE_INBAND_DEVICE_WAKE_FAILURE = 30,
631 DUMP_TYPE_PKTID_POOL_DEPLETED = 31,
632 DUMP_TYPE_ESCAN_SYNCID_MISMATCH = 32,
633 DUMP_TYPE_INVALID_SHINFO_NRFRAGS = 33
634 };
635
636 enum dhd_hang_reason {
637 HANG_REASON_MASK = 0x8000,
638 HANG_REASON_IOCTL_RESP_TIMEOUT = 0x8001,
639 HANG_REASON_DONGLE_TRAP = 0x8002,
640 HANG_REASON_D3_ACK_TIMEOUT = 0x8003,
641 HANG_REASON_BUS_DOWN = 0x8004,
642 HANG_REASON_MSGBUF_LIVELOCK = 0x8006,
643 HANG_REASON_IFACE_DEL_FAILURE = 0x8007,
644 HANG_REASON_HT_AVAIL_ERROR = 0x8008,
645 HANG_REASON_PCIE_RC_LINK_UP_FAIL = 0x8009,
646 HANG_REASON_PCIE_PKTID_ERROR = 0x800A,
647 HANG_REASON_IFACE_ADD_FAILURE = 0x800B,
648 HANG_REASON_IOCTL_RESP_TIMEOUT_SCHED_ERROR = 0x800C,
649 HANG_REASON_D3_ACK_TIMEOUT_SCHED_ERROR = 0x800D,
650 HANG_REASON_SEQUENTIAL_PRIVCMD_ERROR = 0x800E,
651 HANG_REASON_SCAN_BUSY = 0x800F,
652 HANG_REASON_BSS_UP_FAILURE = 0x8010,
653 HANG_REASON_BSS_DOWN_FAILURE = 0x8011,
654 HANG_REASON_IOCTL_SUSPEND_ERROR = 0x8012,
655 HANG_REASON_ESCAN_SYNCID_MISMATCH = 0x8013,
656 HANG_REASON_PCIE_LINK_DOWN_RC_DETECT = 0x8805,
657 HANG_REASON_INVALID_EVENT_OR_DATA = 0x8806,
658 HANG_REASON_UNKNOWN = 0x8807,
659 HANG_REASON_PCIE_LINK_DOWN_EP_DETECT = 0x8808,
660 HANG_REASON_PCIE_CTO_DETECT = 0x8809,
661 HANG_REASON_MAX = 0x880A
662 };
663
664 #define WLC_E_DEAUTH_MAX_REASON 0x0FFF
665
666 enum dhd_rsdb_scan_features {
667 /* Downgraded scan feature for AP active */
668 RSDB_SCAN_DOWNGRADED_AP_SCAN = 0x01,
669 /* Downgraded scan feature for P2P Discovery */
670 RSDB_SCAN_DOWNGRADED_P2P_DISC_SCAN = 0x02,
671 /* Enable channel pruning for ROAM SCAN */
672 RSDB_SCAN_DOWNGRADED_CH_PRUNE_ROAM = 0x10,
673 /* Enable channel pruning for any SCAN */
674 RSDB_SCAN_DOWNGRADED_CH_PRUNE_ALL = 0x20
675 };
676
677 #define VENDOR_SEND_HANG_EXT_INFO_LEN (800 + 1)
678 #ifdef DHD_EWPR_VER2
679 #define VENDOR_SEND_HANG_EXT_INFO_VER 20181111
680 #else
681 #define VENDOR_SEND_HANG_EXT_INFO_VER 20170905
682 #endif /* DHD_EWPR_VER2 */
683
684 #define HANG_INFO_TRAP_T_NAME_MAX 6
685 #define HANG_INFO_TRAP_T_REASON_IDX 0
686 #define HANG_INFO_TRAP_T_SUBTYPE_IDX 2
687 #define HANG_INFO_TRAP_T_OFFSET_IDX 3
688 #define HANG_INFO_TRAP_T_EPC_IDX 4
689 #define HANG_FIELD_STR_MAX_LEN 9
690 #define HANG_FIELD_CNT_MAX 69
691 #define HANG_FIELD_IF_FAILURE_CNT 10
692 #define HANG_FIELD_IOCTL_RESP_TIMEOUT_CNT 8
693 #define HANG_FIELD_TRAP_T_STACK_CNT_MAX 16
694 #define HANG_FIELD_MISMATCH_CNT 10
695 #define HANG_INFO_BIGDATA_KEY_STACK_CNT 4
696
697 #define DEBUG_DUMP_TIME_BUF_LEN (16 + 1)
698 /* delimiter between values */
699 #define HANG_KEY_DEL ' '
700 #define HANG_RAW_DEL '_'
701
702 #ifdef DHD_EWPR_VER2
703 #define HANG_INFO_BIGDATA_EXTRA_KEY 4
704 #define HANG_INFO_TRAP_T_EXTRA_KEY_IDX 5
705 #endif
706
707 /* Packet alignment for most efficient SDIO (can change based on platform) */
708 #ifndef DHD_SDALIGN
709 #define DHD_SDALIGN 32
710 #endif
711
712 #define DHD_TX_CONTEXT_MASK 0xff
713 #define DHD_TX_START_XMIT 0x01
714 #define DHD_TX_SEND_PKT 0x02
715 #define DHD_IF_SET_TX_ACTIVE(ifp, context) \
716 ifp->tx_paths_active |= context;
717 #define DHD_IF_CLR_TX_ACTIVE(ifp, context) \
718 ifp->tx_paths_active &= ~context;
719 #define DHD_IF_IS_TX_ACTIVE(ifp) \
720 (ifp->tx_paths_active)
721 /**
722 * DMA-able buffer parameters
723 * - dmaaddr_t is 32bits on a 32bit host.
724 * dhd_dma_buf::pa may not be used as a sh_addr_t, bcm_addr64_t or uintptr
725 * - dhd_dma_buf::_alloced is ONLY for freeing a DMA-able buffer.
726 */
727 typedef struct dhd_dma_buf {
728 void *va; /* virtual address of buffer */
729 uint32 len; /* user requested buffer length */
730 dmaaddr_t pa; /* physical address of buffer */
731 void *dmah; /* dma mapper handle */
732 void *secdma; /* secure dma sec_cma_info handle */
733 uint32 _alloced; /* actual size of buffer allocated with align and pad */
734 } dhd_dma_buf_t;
735
736 /* host reordering packts logic */
737 /* followed the structure to hold the reorder buffers (void **p) */
738 typedef struct reorder_info {
739 void **p;
740 uint8 flow_id;
741 uint8 cur_idx;
742 uint8 exp_idx;
743 uint8 max_idx;
744 uint8 pend_pkts;
745 } reorder_info_t;
746
747 /* throughput test packet format */
748 typedef struct tput_pkt {
749 /* header */
750 uint8 mac_sta[ETHER_ADDR_LEN];
751 uint8 mac_ap[ETHER_ADDR_LEN];
752 uint16 pkt_type;
753 uint8 PAD[2];
754 /* data */
755 uint32 crc32;
756 uint32 pkt_id;
757 uint32 num_pkts;
758 } tput_pkt_t;
759
760 typedef enum {
761 TPUT_PKT_TYPE_NORMAL,
762 TPUT_PKT_TYPE_STOP
763 } tput_pkt_type_t;
764
765 #define TPUT_TEST_MAX_PAYLOAD 1500
766 #define TPUT_TEST_WAIT_TIMEOUT_DEFAULT 5000
767
768 #ifdef DHDTCPACK_SUPPRESS
769
770 enum {
771 /* TCPACK suppress off */
772 TCPACK_SUP_OFF,
773 /* Replace TCPACK in txq when new coming one has higher ACK number. */
774 TCPACK_SUP_REPLACE,
775 /* TCPACK_SUP_REPLACE + delayed TCPACK TX unless ACK to PSH DATA.
776 * This will give benefits to Half-Duplex bus interface(e.g. SDIO) that
777 * 1. we are able to read TCP DATA packets first from the bus
778 * 2. TCPACKs that don't need to hurry delivered remains longer in TXQ so can be suppressed.
779 */
780 TCPACK_SUP_DELAYTX,
781 TCPACK_SUP_HOLD,
782 TCPACK_SUP_LAST_MODE
783 };
784 #endif /* DHDTCPACK_SUPPRESS */
785
786 #if defined(BCM_ROUTER_DHD)
787 #define DHD_DWM_TBL_SIZE 57
788 /* DSCP WMM AC Mapping macros and structures */
789 #define DHD_TRF_MGMT_DWM_FILTER_BIT 0x8
790 #define DHD_TRF_MGMT_DWM_PRIO_BITS 0x7
791 #define DHD_TRF_MGMT_DWM_FAVORED_BIT 0x10
792 #define DHD_TRF_MGMT_DWM_PRIO(dwm_tbl_entry) ((dwm_tbl_entry) & DHD_TRF_MGMT_DWM_PRIO_BITS)
793 #define DHD_TRF_MGMT_DWM_IS_FAVORED_SET(dwm_tbl_entry) \
794 ((dwm_tbl_entry) & DHD_TRF_MGMT_DWM_FAVORED_BIT)
795 #define DHD_TRF_MGMT_DWM_SET_FAVORED(dwm_tbl_entry) \
796 ((dwm_tbl_entry) |= DHD_TRF_MGMT_DWM_FAVORED_BIT)
797 #define DHD_TRF_MGMT_DWM_IS_FILTER_SET(dwm_tbl_entry) \
798 ((dwm_tbl_entry) & DHD_TRF_MGMT_DWM_FILTER_BIT)
799 #define DHD_TRF_MGMT_DWM_SET_FILTER(dwm_tbl_entry) \
800 ((dwm_tbl_entry) |= DHD_TRF_MGMT_DWM_FILTER_BIT)
801
802 typedef struct {
803 uint8 dhd_dwm_enabled;
804 uint8 dhd_dwm_tbl[DHD_DWM_TBL_SIZE];
805 } dhd_trf_mgmt_dwm_tbl_t;
806 #endif /* for BCM_ROUTER_DHD */
807
808 #define DHD_NULL_CHK_AND_RET(cond) \
809 if (!cond) { \
810 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
811 return; \
812 }
813
814 #define DHD_NULL_CHK_AND_RET_VAL(cond, value) \
815 if (!cond) { \
816 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
817 return value; \
818 }
819
820 #define DHD_NULL_CHK_AND_GOTO(cond, label) \
821 if (!cond) { \
822 DHD_ERROR(("%s " #cond " is NULL\n", __FUNCTION__)); \
823 goto label; \
824 }
825
826 /*
827 * Accumulating the queue lengths of all flowring queues in a parent object,
828 * to assert flow control, when the cummulative queue length crosses an upper
829 * threshold defined on a parent object. Upper threshold may be maintained
830 * at a station level, at an interface level, or at a dhd instance.
831 *
832 * cumm_ctr_t abstraction:
833 * cumm_ctr_t abstraction may be enhanced to use an object with a hysterisis
834 * pause on/off threshold callback.
835 * All macros use the address of the cummulative length in the parent objects.
836 *
837 * Cummulative counters in parent objects may be updated without spinlocks.
838 *
839 * If a cummulative queue length is desired across all flows
840 * belonging to either of (a station, or an interface or a dhd instance), then
841 * an atomic operation is required using an atomic_t cummulative counters or
842 * using a spinlock. BCM_ROUTER_DHD uses the Linux atomic_t construct.
843 */
844 #if defined(BCM_ROUTER_DHD)
845
846 typedef atomic_t cumm_ctr_t; /* BCM_ROUTER_DHD Linux: atomic operations */
847 #define DHD_CUMM_CTR_PTR(clen) ((cumm_ctr_t*)(clen))
848 #define DHD_CUMM_CTR(clen) DHD_CUMM_CTR_PTR(clen) /* atomic accessor */
849 #define DHD_CUMM_CTR_READ(clen) atomic_read(DHD_CUMM_CTR(clen)) /* read */
850 #define DHD_CUMM_CTR_INIT(clen) \
851 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL)); \
852 atomic_set(DHD_CUMM_CTR(clen), 0);
853 #define DHD_CUMM_CTR_INCR(clen) \
854 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL)); \
855 atomic_add(1, DHD_CUMM_CTR(clen)); \
856 ASSERT(DHD_CUMM_CTR_READ(clen) != 0); /* ensure it does not wrap */
857 #define DHD_CUMM_CTR_DECR(clen) \
858 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL)); \
859 ASSERT(DHD_CUMM_CTR_READ(clen) > 0); \
860 atomic_sub(1, DHD_CUMM_CTR(clen));
861
862 #else /* ! BCM_ROUTER_DHD */
863
864 /* Cummulative length not supported. */
865 typedef uint32 cumm_ctr_t;
866 #define DHD_CUMM_CTR_PTR(clen) ((cumm_ctr_t*)(clen))
867 #define DHD_CUMM_CTR(clen) *(DHD_CUMM_CTR_PTR(clen)) /* accessor */
868 #define DHD_CUMM_CTR_READ(clen) DHD_CUMM_CTR(clen) /* read access */
869 #define DHD_CUMM_CTR_INIT(clen) \
870 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
871 #define DHD_CUMM_CTR_INCR(clen) \
872 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
873 #define DHD_CUMM_CTR_DECR(clen) \
874 ASSERT(DHD_CUMM_CTR_PTR(clen) != DHD_CUMM_CTR_PTR(NULL));
875
876 #endif /* ! BCM_ROUTER_DHD */
877
878 #if defined(WLTDLS) && defined(PCIE_FULL_DONGLE)
879 struct tdls_peer_node {
880 uint8 addr[ETHER_ADDR_LEN];
881 struct tdls_peer_node *next;
882 };
883 typedef struct tdls_peer_node tdls_peer_node_t;
884 typedef struct {
885 tdls_peer_node_t *node;
886 uint8 tdls_peer_count;
887 } tdls_peer_tbl_t;
888 #endif /* defined(WLTDLS) && defined(PCIE_FULL_DONGLE) */
889
890 typedef enum dhd_ring_id {
891 DEBUG_RING_ID_INVALID = 0x1,
892 FW_VERBOSE_RING_ID = 0x2,
893 DHD_EVENT_RING_ID = 0x3,
894 DRIVER_LOG_RING_ID = 0x4,
895 ROAM_STATS_RING_ID = 0x5,
896 BT_LOG_RING_ID = 0x6,
897 DEBUG_RING_ID_MAX = 0x7
898 } dhd_ring_id_t;
899
900 #ifdef DHD_LOG_DUMP
901 #define DUMP_SSSR_ATTR_START 2
902 #define DUMP_SSSR_ATTR_COUNT 10
903
904 typedef enum {
905 SSSR_C0_D11_BEFORE = 0,
906 SSSR_C0_D11_AFTER = 1,
907 SSSR_C1_D11_BEFORE = 2,
908 SSSR_C1_D11_AFTER = 3,
909 SSSR_C2_D11_BEFORE = 4,
910 SSSR_C2_D11_AFTER = 5,
911 SSSR_DIG_BEFORE = 6,
912 SSSR_DIG_AFTER = 7
913 } EWP_SSSR_DUMP;
914
915 typedef enum {
916 DLD_BUF_TYPE_GENERAL = 0,
917 DLD_BUF_TYPE_PRESERVE = 1,
918 DLD_BUF_TYPE_SPECIAL = 2,
919 DLD_BUF_TYPE_ECNTRS = 3,
920 DLD_BUF_TYPE_FILTER = 4,
921 DLD_BUF_TYPE_ALL = 5
922 } log_dump_type_t;
923
924 #ifdef DHD_DEBUGABILITY_LOG_DUMP_RING
925 struct dhd_dbg_ring_buf
926 {
927 void *dhd_pub;
928 };
929 #endif /* DHD_DEBUGABILITY_LOG_DUMP_RING */
930
931 #define LOG_DUMP_MAGIC 0xDEB3DEB3
932 #define HEALTH_CHK_BUF_SIZE 256
933 #ifdef EWP_ECNTRS_LOGGING
934 #define ECNTR_RING_ID 0xECDB
935 #define ECNTR_RING_NAME "ewp_ecntr_ring"
936 #endif /* EWP_ECNTRS_LOGGING */
937
938 #ifdef EWP_RTT_LOGGING
939 #define RTT_RING_ID 0xADCD
940 #define RTT_RING_NAME "ewp_rtt_ring"
941 #endif /* EWP_ECNTRS_LOGGING */
942
943 #ifdef EWP_BCM_TRACE
944 #define BCM_TRACE_RING_ID 0xBCBC
945 #define BCM_TRACE_RING_NAME "ewp_bcm_trace_ring"
946 #endif /* EWP_BCM_TRACE */
947
948 /*
949 * XXX: Always add new enums at the end to compatible with parser,
950 * also add new section in split_ret of EWP_config.py
951 */
952 typedef enum {
953 LOG_DUMP_SECTION_GENERAL = 0,
954 LOG_DUMP_SECTION_ECNTRS,
955 LOG_DUMP_SECTION_SPECIAL,
956 LOG_DUMP_SECTION_DHD_DUMP,
957 LOG_DUMP_SECTION_EXT_TRAP,
958 LOG_DUMP_SECTION_HEALTH_CHK,
959 LOG_DUMP_SECTION_PRESERVE,
960 LOG_DUMP_SECTION_COOKIE,
961 LOG_DUMP_SECTION_FLOWRING,
962 LOG_DUMP_SECTION_STATUS,
963 LOG_DUMP_SECTION_RTT,
964 LOG_DUMP_SECTION_BCM_TRACE
965 } log_dump_section_type_t;
966
967 /* Each section in the debug_dump log file shall begin with a header */
968 typedef struct {
969 uint32 magic; /* 0xDEB3DEB3 */
970 uint32 type; /* of type log_dump_section_type_t */
971 uint64 timestamp;
972 uint32 length; /* length of the section that follows */
973 } log_dump_section_hdr_t;
974
975 /* below structure describe ring buffer. */
976 struct dhd_log_dump_buf
977 {
978 #if defined(LINUX) || defined(linux) || defined(ANDROID) || defined(OEM_ANDROID)
979 spinlock_t lock;
980 #endif
981 void *dhd_pub;
982 unsigned int enable;
983 unsigned int wraparound;
984 unsigned long max;
985 unsigned int remain;
986 char* present;
987 char* front;
988 char* buffer;
989 };
990
991 #define DHD_LOG_DUMP_MAX_TEMP_BUFFER_SIZE 256
992 #define DHD_LOG_DUMP_MAX_TAIL_FLUSH_SIZE (80 * 1024)
993
994 extern void dhd_log_dump_write(int type, char *binary_data,
995 int binary_len, const char *fmt, ...);
996 #endif /* DHD_LOG_DUMP */
997
998 /* DEBUG_DUMP SUB COMMAND */
999 enum {
1000 CMD_DEFAULT,
1001 CMD_UNWANTED,
1002 CMD_DISCONNECTED,
1003 CMD_MAX
1004 };
1005
1006 #define DHD_LOG_DUMP_TS_MULTIPLIER_VALUE 60
1007 #define DHD_LOG_DUMP_TS_FMT_YYMMDDHHMMSSMSMS "%02d%02d%02d%02d%02d%02d%04d"
1008 #define DHD_LOG_DUMP_TS_FMT_YYMMDDHHMMSS "%02d%02d%02d%02d%02d%02d"
1009 #define DHD_DEBUG_DUMP_TYPE "debug_dump"
1010 #define DHD_DUMP_SUBSTR_UNWANTED "_unwanted"
1011 #define DHD_DUMP_SUBSTR_DISCONNECTED "_disconnected"
1012
1013 #ifdef DNGL_AXI_ERROR_LOGGING
1014 #define DHD_DUMP_AXI_ERROR_FILENAME "axi_error"
1015 #define DHD_DUMP_HAL_FILENAME_SUFFIX "_hal"
1016 #endif /* DNGL_AXI_ERROR_LOGGING */
1017
1018 extern void get_debug_dump_time(char *str);
1019 extern void clear_debug_dump_time(char *str);
1020 #if defined(WL_CFGVENDOR_SEND_HANG_EVENT) || defined(DHD_PKT_LOGGING)
1021 extern void copy_debug_dump_time(char *dest, char *src);
1022 #endif /* WL_CFGVENDOR_SEND_HANG_EVENT || DHD_PKT_LOGGING */
1023
1024 #define FW_LOGSET_MASK_ALL 0xFFFFu
1025
1026 #if defined(CUSTOMER_HW4)
1027 #ifndef DHD_COMMON_DUMP_PATH
1028 #define DHD_COMMON_DUMP_PATH "/data/log/wifi/"
1029 #endif /* !DHD_COMMON_DUMP_PATH */
1030 #elif defined(CUSTOMER_HW2_DEBUG)
1031 #define DHD_COMMON_DUMP_PATH PLATFORM_PATH
1032 #elif defined(BOARD_HIKEY)
1033 #define DHD_COMMON_DUMP_PATH "/data/misc/wifi/"
1034 #elif defined(OEM_ANDROID) && defined(__ARM_ARCH_7A__)
1035 #define DHD_COMMON_DUMP_PATH "/data/vendor/wifi/"
1036 #elif defined(OEM_ANDROID) /* For Brix Live Image */
1037 #define DHD_COMMON_DUMP_PATH "/installmedia/"
1038 #else /* Default */
1039 #define DHD_COMMON_DUMP_PATH "/root/"
1040 #endif /* CUSTOMER_HW4 */
1041
1042 #define DHD_MEMDUMP_LONGSTR_LEN 180
1043
1044 struct cntry_locales_custom {
1045 char iso_abbrev[WLC_CNTRY_BUF_SZ]; /* ISO 3166-1 country abbreviation */
1046 char custom_locale[WLC_CNTRY_BUF_SZ]; /* Custom firmware locale */
1047 int32 custom_locale_rev; /* Custom local revisin default -1 */
1048 };
1049
1050 #ifdef DHD_PKTTS
1051 #if defined(linux) || defined(LINUX)
1052 extern uint dhd_msgbuf_get_ipv6_id(void *pkt);
1053 #else
dhd_msgbuf_get_ipv6_id(void * pkt)1054 static INLINE uint dhd_msgbuf_get_ipv6_id(void *pkt) { return 0; }
1055 #endif /* linux || LINUX */
1056 int dhd_send_msg_to_ts(struct sk_buff *skb, void *data, int size);
1057 #endif /* DHD_PKTTS */
1058
1059 #if defined(LINUX) || defined(linux)
1060 int dhd_send_msg_to_daemon(struct sk_buff *skb, void *data, int size);
1061 #endif /* LINUX || linux */
1062 #ifdef REPORT_FATAL_TIMEOUTS
1063 typedef struct timeout_info {
1064 void *scan_timer_lock;
1065 void *join_timer_lock;
1066 void *cmd_timer_lock;
1067 void *bus_timer_lock;
1068 uint32 scan_timeout_val;
1069 uint32 join_timeout_val;
1070 uint32 cmd_timeout_val;
1071 uint32 bus_timeout_val;
1072 bool scan_timer_active;
1073 bool join_timer_active;
1074 bool cmd_timer_active;
1075 bool bus_timer_active;
1076 osl_timer_t *scan_timer;
1077 osl_timer_t *join_timer;
1078 osl_timer_t *cmd_timer;
1079 osl_timer_t *bus_timer;
1080 uint32 cmd_request_id;
1081 uint32 cmd;
1082 uint32 cmd_join_error;
1083 uint16 escan_syncid;
1084 bool escan_aborted;
1085 uint16 abort_syncid;
1086 } timeout_info_t;
1087 #endif /* REPORT_FATAL_TIMEOUTS */
1088
1089 #ifdef DMAMAP_STATS
1090 typedef struct dmamap_stats {
1091 uint64 txdata;
1092 uint64 txdata_sz;
1093 uint64 rxdata;
1094 uint64 rxdata_sz;
1095 uint64 ioctl_rx;
1096 uint64 ioctl_rx_sz;
1097 uint64 event_rx;
1098 uint64 event_rx_sz;
1099 uint64 info_rx;
1100 uint64 info_rx_sz;
1101 uint64 tsbuf_rx;
1102 uint64 tsbuf_rx_sz;
1103 } dma_stats_t;
1104 #endif /* DMAMAP_STATS */
1105
1106 #ifdef BT_OVER_PCIE
1107 enum dhd_bus_quiesce_state {
1108 DHD_QUIESCE_INIT = 0,
1109 REQUEST_BT_QUIESCE = 1,
1110 RESPONSE_BT_QUIESCE = 2,
1111 REQUEST_BT_RESUME = 3,
1112 RESPONSE_BT_RESUME = 4
1113 };
1114 #endif /* BT_OVER_PCIE */
1115
1116 /* see wlfc_proto.h for tx status details */
1117 #define DHD_MAX_TX_STATUS_MSGS 9u
1118
1119 #ifdef TX_STATUS_LATENCY_STATS
1120 typedef struct dhd_if_tx_status_latency {
1121 /* total number of tx_status received on this interface */
1122 uint64 num_tx_status;
1123 /* cumulative tx_status latency for this interface */
1124 uint64 cum_tx_status_latency;
1125 } dhd_if_tx_status_latency_t;
1126 #endif /* TX_STATUS_LATENCY_STATS */
1127
1128 #if defined(DHD_AWDL) && defined(AWDL_SLOT_STATS)
1129 #define AWDL_NUM_SLOTS 16u /* 0 to 15 are the AWDL slots FW operates on */
1130 #define AWDL_SLOT_MULT 4u /* AWDL slot information sent by FW is in multiples of 4 */
1131 typedef struct dhd_awdl_statistics {
1132 uint64 slot_start_time; /* AWDL slot start time in us */
1133 uint64 cum_slot_time; /* Cumulative time for which this AWDL slot was active */
1134 uint64 num_slots; /* Number of times this AWDL slot was active */
1135 uint64 cum_tx_status_latency; /* cum tx_status latency while this AWDL slot is active */
1136 uint64 num_tx_status; /* Num of AWDL(flowring with role as AWDL) tx status received */
1137 uint64 fw_cum_slot_time; /* Cumulative FW time for which this AWDL slot was active */
1138 uint32 fw_slot_start_time; /* AWDL slot start time sent by FW in us */
1139 #if defined(BCMDBG)
1140 uint32 tx_status[DHD_MAX_TX_STATUS_MSGS]; /* Dongle return val wrt TX packet sent out */
1141 #endif /* BCMDBG */
1142 } dhd_awdl_stats_t;
1143 #endif /* DHD_AWDL && AWDL_SLOT_STATS */
1144
1145 /* Bit in dhd_pub_t::gdb_proxy_stop_count set when firmware is stopped by GDB */
1146 #define GDB_PROXY_STOP_MASK 1
1147
1148 /* Enable Reserve STA flowrings only for Android */
1149 #if defined(OEM_ANDROID)
1150 #define DHD_LIMIT_MULTI_CLIENT_FLOWRINGS
1151 #endif /* OEM_ANDROID */
1152
1153 typedef enum {
1154 FW_UNLOADED = 0,
1155 FW_DOWNLOAD_IN_PROGRESS = 1,
1156 FW_DOWNLOAD_DONE = 2
1157 } fw_download_status_t;
1158
1159 #define PCIE_DB7_MAGIC_NUMBER_ISR_TRAP 0xdead0001
1160 #define PCIE_DB7_MAGIC_NUMBER_DPC_TRAP 0xdead0002
1161
1162 typedef struct dhd_db7_info {
1163 bool fw_db7w_trap;
1164 bool fw_db7w_trap_inprogress;
1165 uint32 db7_magic_number;
1166
1167 uint32 debug_db7_send_cnt;
1168 uint32 debug_db7_trap_cnt;
1169 uint32 debug_db7_timing_error_cnt;
1170 uint64 debug_db7_send_time;
1171 uint64 debug_db7_trap_time;
1172 uint64 debug_max_db7_dur;
1173 uint64 debug_max_db7_send_time;
1174 uint64 debug_max_db7_trap_time;
1175 } dhd_db7_info_t;
1176
1177 #ifdef BCMINTERNAL
1178 #ifdef DHD_FWTRACE
1179 typedef struct fwtrace_info fwtrace_info_t; /* forward declaration */
1180 #endif /* DHD_FWTRACE */
1181 #endif /* BCMINTERNAL */
1182
1183 typedef enum dhd_induce_error_states
1184 {
1185 DHD_INDUCE_ERROR_CLEAR = 0x0,
1186 DHD_INDUCE_IOCTL_TIMEOUT = 0x1,
1187 DHD_INDUCE_D3_ACK_TIMEOUT = 0x2,
1188 DHD_INDUCE_LIVELOCK = 0x3,
1189 DHD_INDUCE_DROP_OOB_IRQ = 0x4,
1190 DHD_INDUCE_DROP_AXI_SIG = 0x5,
1191 DHD_INDUCE_TX_BIG_PKT = 0x6,
1192 DHD_INDUCE_IOCTL_SUSPEND_ERROR = 0x7,
1193 /* Big hammer induction */
1194 DHD_INDUCE_BH_ON_FAIL_ONCE = 0x10,
1195 DHD_INDUCE_BH_ON_FAIL_ALWAYS = 0x11,
1196 DHD_INDUCE_BH_CBP_HANG = 0x12,
1197 DHD_INDUCE_ERROR_MAX
1198 } dhd_induce_error_states_t;
1199
1200 #ifdef DHD_HP2P
1201 #define MAX_TX_HIST_BIN 16
1202 #define MAX_RX_HIST_BIN 10
1203 #define MAX_HP2P_FLOWS 16
1204 #define HP2P_PRIO 7
1205 #define HP2P_PKT_THRESH 48
1206 #define HP2P_TIME_THRESH 200
1207 #define HP2P_PKT_EXPIRY 40
1208 #define HP2P_TIME_SCALE 32
1209
1210 typedef struct hp2p_info {
1211 void *dhd_pub;
1212 uint16 flowid;
1213 bool hrtimer_init;
1214 void *ring;
1215 struct hrtimer timer;
1216 uint64 num_pkt_limit;
1217 uint64 num_timer_limit;
1218 uint64 num_timer_start;
1219 uint64 tx_t0[MAX_TX_HIST_BIN];
1220 uint64 tx_t1[MAX_TX_HIST_BIN];
1221 uint64 rx_t0[MAX_RX_HIST_BIN];
1222 } hp2p_info_t;
1223 #endif /* DHD_HP2P */
1224
1225 #if defined(SHOW_LOGTRACE) && defined(DHD_USE_KTHREAD_FOR_LOGTRACE)
1226 /* Timestamps to trace dhd_logtrace_thread() */
1227 struct dhd_logtrace_thr_ts {
1228 uint64 entry_time;
1229 uint64 sem_down_time;
1230 uint64 flush_time;
1231 uint64 unexpected_break_time;
1232 uint64 complete_time;
1233 };
1234 #endif /* SHOW_LOGTRACE && DHD_USE_KTHREAD_FOR_LOGTRACE */
1235
1236 /**
1237 * Common structure for module and instance linkage.
1238 * Instantiated once per hardware (dongle) instance that this DHD manages.
1239 */
1240 typedef struct dhd_pub {
1241 /* Linkage ponters */
1242 osl_t *osh; /* OSL handle */
1243 struct dhd_bus *bus; /* Bus module handle */
1244 struct dhd_prot *prot; /* Protocol module handle */
1245 struct dhd_info *info; /* Info module handle */
1246 struct dhd_dbg *dbg; /* Debugability module handle */
1247 #if defined(SHOW_LOGTRACE) && defined(DHD_USE_KTHREAD_FOR_LOGTRACE)
1248 struct dhd_logtrace_thr_ts logtrace_thr_ts;
1249 #endif /* SHOW_LOGTRACE && DHD_USE_KTHREAD_FOR_LOGTRACE */
1250
1251 /* to NDIS developer, the structure dhd_common is redundant,
1252 * please do NOT merge it back from other branches !!!
1253 */
1254
1255 #ifdef BCMDBUS
1256 struct dbus_pub *dbus;
1257 #endif /* BCMDBUS */
1258
1259 /* Internal dhd items */
1260 bool up; /* Driver up/down (to OS) */
1261 #ifdef WL_CFG80211
1262 spinlock_t up_lock; /* Synchronization with CFG80211 down */
1263 #endif /* WL_CFG80211 */
1264 bool txoff; /* Transmit flow-controlled */
1265 bool dongle_reset; /* TRUE = DEVRESET put dongle into reset */
1266 enum dhd_bus_state busstate;
1267 uint dhd_bus_busy_state; /* Bus busy state */
1268 uint hdrlen; /* Total DHD header length (proto + bus) */
1269 uint maxctl; /* Max size rxctl request from proto to bus */
1270 uint rxsz; /* Rx buffer size bus module should use */
1271 uint8 wme_dp; /* wme discard priority */
1272 #ifdef DNGL_AXI_ERROR_LOGGING
1273 uint32 axierror_logbuf_addr;
1274 bool axi_error;
1275 struct dhd_axi_error_dump *axi_err_dump;
1276 #endif /* DNGL_AXI_ERROR_LOGGING */
1277 /* Dongle media info */
1278 bool iswl; /* Dongle-resident driver is wl */
1279 ulong drv_version; /* Version of dongle-resident driver */
1280 struct ether_addr mac; /* MAC address obtained from dongle */
1281 dngl_stats_t dstats; /* Stats for dongle-based data */
1282
1283 /* Additional stats for the bus level */
1284 ulong tx_packets; /* Data packets sent to dongle */
1285 ulong actual_tx_pkts; /* Actual data packets sent to dongle */
1286 ulong tot_txcpl; /* Total Tx completion received */
1287 ulong tx_dropped; /* Data packets dropped in dhd */
1288 ulong tx_multicast; /* Multicast data packets sent to dongle */
1289 ulong tx_errors; /* Errors in sending data to dongle */
1290 ulong tx_ctlpkts; /* Control packets sent to dongle */
1291 ulong tx_ctlerrs; /* Errors sending control frames to dongle */
1292 ulong rx_packets; /* Packets sent up the network interface */
1293 ulong rx_multicast; /* Multicast packets sent up the network interface */
1294 ulong rx_errors; /* Errors processing rx data packets */
1295 ulong rx_ctlpkts; /* Control frames processed from dongle */
1296 ulong rx_ctlerrs; /* Errors in processing rx control frames */
1297 ulong rx_dropped; /* Packets dropped locally (no memory) */
1298 ulong rx_flushed; /* Packets flushed due to unscheduled sendup thread */
1299 ulong wd_dpc_sched; /* Number of times dhd dpc scheduled by watchdog timer */
1300 ulong rx_pktgetfail; /* Number of PKTGET failures in DHD on RX */
1301 ulong tx_pktgetfail; /* Number of PKTGET failures in DHD on TX */
1302 ulong rx_readahead_cnt; /* Number of packets where header read-ahead was used. */
1303 ulong tx_realloc; /* Number of tx packets we had to realloc for headroom */
1304 ulong fc_packets; /* Number of flow control pkts recvd */
1305 ulong tx_big_packets; /* Dropped data packets that are larger than MAX_MTU_SZ */
1306 #ifdef DMAMAP_STATS
1307 /* DMA Mapping statistics */
1308 dma_stats_t dma_stats;
1309 #endif /* DMAMAP_STATS */
1310 #ifdef WL_MONITOR
1311 bool monitor_enable;
1312 #endif /* WL_MONITOR */
1313 /* Last error return */
1314 int bcmerror;
1315 uint tickcnt;
1316
1317 /* Last error from dongle */
1318 int dongle_error;
1319
1320 uint8 country_code[WLC_CNTRY_BUF_SZ];
1321
1322 /* Suspend disable flag and "in suspend" flag */
1323 int suspend_disable_flag; /* "1" to disable all extra powersaving during suspend */
1324 int in_suspend; /* flag set to 1 when early suspend called */
1325 #ifdef PNO_SUPPORT
1326 int pno_enable; /* pno status : "1" is pno enable */
1327 int pno_suspend; /* pno suspend status : "1" is pno suspended */
1328 #endif /* PNO_SUPPORT */
1329 /* DTIM skip value, default 0(or 1) means wake each DTIM
1330 * 3 means skip 2 DTIMs and wake up 3rd DTIM(9th beacon when AP DTIM is 3)
1331 */
1332 int suspend_bcn_li_dtim; /* bcn_li_dtim value in suspend mode */
1333 int early_suspended; /* Early suspend status */
1334 #ifdef PKT_FILTER_SUPPORT
1335 int dhcp_in_progress; /* DHCP period */
1336 #endif
1337
1338 /* Pkt filter defination */
1339 char * pktfilter[100];
1340 int pktfilter_count;
1341
1342 wl_country_t dhd_cspec; /* Current Locale info */
1343 #ifdef CUSTOM_COUNTRY_CODE
1344 uint dhd_cflags;
1345 #endif /* CUSTOM_COUNTRY_CODE */
1346 #if defined(DHD_BLOB_EXISTENCE_CHECK)
1347 bool is_blob; /* Checking for existance of Blob file */
1348 #endif /* DHD_BLOB_EXISTENCE_CHECK */
1349 bool force_country_change;
1350 int op_mode; /* STA, HostAPD, WFD, SoftAP */
1351
1352 #if defined(LINUX) || defined(linux)
1353 #if defined(OEM_ANDROID)
1354 struct mutex wl_start_stop_lock; /* lock/unlock for Android start/stop */
1355 struct mutex wl_softap_lock; /* lock/unlock for any SoftAP/STA settings */
1356 #endif /* defined(OEM_ANDROID) */
1357 #endif /* defined (LINUX) || defined(linux) */
1358
1359 #ifdef NDIS
1360 PDEVICE_OBJECT pdo;
1361 PDEVICE_OBJECT fdo;
1362 PDEVICE_OBJECT nextDeviceObj;
1363 #if defined(BCMWDF)
1364 WDFDEVICE wdfDevice;
1365 #endif /* (BCMWDF) */
1366 #endif /* NDIS */
1367 #ifdef PROP_TXSTATUS
1368 bool wlfc_enabled;
1369 int wlfc_mode;
1370 void* wlfc_state;
1371 /*
1372 Mode in which the dhd flow control shall operate. Must be set before
1373 traffic starts to the device.
1374 0 - Do not do any proptxtstatus flow control
1375 1 - Use implied credit from a packet status
1376 2 - Use explicit credit
1377 3 - Only AMPDU hostreorder used. no wlfc.
1378 */
1379 uint8 proptxstatus_mode;
1380 bool proptxstatus_txoff;
1381 bool proptxstatus_module_ignore;
1382 bool proptxstatus_credit_ignore;
1383 bool proptxstatus_txstatus_ignore;
1384
1385 bool wlfc_rxpkt_chk;
1386 #ifdef LIMIT_BORROW
1387 bool wlfc_borrow_allowed;
1388 #endif /* LIMIT_BORROW */
1389 /*
1390 * implement below functions in each platform if needed.
1391 */
1392 /* platform specific function whether to skip flow control */
1393 bool (*skip_fc)(void * dhdp, uint8 ifx);
1394 /* platform specific function for wlfc_enable and wlfc_deinit */
1395 void (*plat_init)(void *dhd);
1396 void (*plat_deinit)(void *dhd);
1397 #ifdef DHD_WLFC_THREAD
1398 bool wlfc_thread_go;
1399 #if defined(LINUX)
1400 struct task_struct* wlfc_thread;
1401 wait_queue_head_t wlfc_wqhead;
1402 #else
1403 #error "wlfc thread not enabled"
1404 #endif /* LINUX */
1405 #endif /* DHD_WLFC_THREAD */
1406 #endif /* PROP_TXSTATUS */
1407 #ifdef PNO_SUPPORT
1408 void *pno_state;
1409 #endif
1410 #ifdef RTT_SUPPORT
1411 void *rtt_state;
1412 bool rtt_supported;
1413 #endif
1414 #ifdef ROAM_AP_ENV_DETECTION
1415 bool roam_env_detection;
1416 #endif
1417 bool dongle_isolation;
1418 bool is_pcie_watchdog_reset;
1419
1420 /* Begin - Variables to track Bus Errors */
1421 bool dongle_trap_occured; /* flag for sending HANG event to upper layer */
1422 #ifdef BT_OVER_PCIE
1423 bool dongle_trap_due_to_bt; /* flag to indicate that dongle has trapped due to BT */
1424 #endif /* BT_OVER_PCIE */
1425 bool iovar_timeout_occured; /* flag to indicate iovar resumed on timeout */
1426 bool invalid_shinfo_nrfrags; /* flag to indicate invlaid shinfo nrfrags */
1427 bool is_sched_error; /* flag to indicate timeout due to scheduling issue */
1428 #ifdef PCIE_FULL_DONGLE
1429 bool d3ack_timeout_occured; /* flag to indicate d3ack resumed on timeout */
1430 bool livelock_occured; /* flag to indicate livelock occured */
1431 bool pktid_audit_failed; /* flag to indicate pktid audit failure */
1432 #endif /* PCIE_FULL_DONGLE */
1433 bool iface_op_failed; /* flag to indicate interface operation failed */
1434 bool scan_timeout_occurred; /* flag to indicate scan has timedout */
1435 bool scan_busy_occurred; /* flag to indicate scan busy occurred */
1436 #ifdef BT_OVER_SDIO
1437 bool is_bt_recovery_required;
1438 #endif
1439 bool smmu_fault_occurred; /* flag to indicate SMMU Fault */
1440 /*
1441 * Add any new variables to track Bus errors above
1442 * this line. Also ensure that the variable is
1443 * cleared from dhd_clear_bus_errors
1444 */
1445 /* End - Variables to track Bus Errors */
1446
1447 int hang_was_sent;
1448 int hang_was_pending;
1449 int rxcnt_timeout; /* counter rxcnt timeout to send HANG */
1450 int txcnt_timeout; /* counter txcnt timeout to send HANG */
1451 #ifdef BCMPCIE
1452 int d3ackcnt_timeout; /* counter d3ack timeout to send HANG */
1453 #endif /* BCMPCIE */
1454 bool hang_report; /* enable hang report by default */
1455 uint16 hang_reason; /* reason codes for HANG event */
1456 #if defined(DHD_HANG_SEND_UP_TEST)
1457 uint req_hang_type;
1458 #endif /* DHD_HANG_SEND_UP_TEST */
1459 #ifdef DHD_DETECT_CONSECUTIVE_MFG_HANG
1460 uint hang_count;
1461 #endif /* DHD_DETECT_CONSECUTIVE_MFG_HANG */
1462 #ifdef WLTDLS
1463 bool tdls_enable;
1464 #endif
1465 struct reorder_info *reorder_bufs[WLHOST_REORDERDATA_MAXFLOWS];
1466 #define WLC_IOCTL_MAXBUF_FWCAP 1024
1467 char fw_capabilities[WLC_IOCTL_MAXBUF_FWCAP];
1468 #define DHD_IOCTL_MAXBUF_DHDCAP 1024
1469 char dhd_capabilities[DHD_IOCTL_MAXBUF_DHDCAP];
1470 #define MAXSKBPEND 1024
1471 void *skbbuf[MAXSKBPEND];
1472 uint32 store_idx;
1473 uint32 sent_idx;
1474 #ifdef DHDTCPACK_SUPPRESS
1475 uint8 tcpack_sup_mode; /* TCPACK suppress mode */
1476 void *tcpack_sup_module; /* TCPACK suppress module */
1477 uint32 tcpack_sup_ratio;
1478 uint32 tcpack_sup_delay;
1479 #endif /* DHDTCPACK_SUPPRESS */
1480 #if defined(ARP_OFFLOAD_SUPPORT)
1481 uint32 arp_version;
1482 bool hmac_updated;
1483 #endif
1484 #if defined(BCMSUP_4WAY_HANDSHAKE)
1485 bool fw_4way_handshake; /* Whether firmware will to do the 4way handshake. */
1486 #endif
1487 #ifdef BCMINTERNAL
1488 bool loopback; /* 1- enable loopback of tx packets, 0 - disable */
1489 #endif /* BCMINTERNAL */
1490 #ifdef DEBUG_DPC_THREAD_WATCHDOG
1491 bool dhd_bug_on;
1492 #endif /* DEBUG_DPC_THREAD_WATCHDOG */
1493 #ifdef CUSTOM_SET_CPUCORE
1494 struct task_struct * current_dpc;
1495 struct task_struct * current_rxf;
1496 int chan_isvht80;
1497 #endif /* CUSTOM_SET_CPUCORE */
1498 void *sta_pool; /* pre-allocated pool of sta objects */
1499 void *staid_allocator; /* allocator of sta indexes */
1500 #ifdef PCIE_FULL_DONGLE
1501 bool flow_rings_inited; /* set this flag after initializing flow rings */
1502 #endif /* PCIE_FULL_DONGLE */
1503 void *flowid_allocator; /* unique flowid allocator */
1504 #if defined(DHD_HTPUT_TUNABLES)
1505 void *htput_flowid_allocator; /* unique htput flowid allocator */
1506 uint8 htput_client_flow_rings; /* current number of htput client flowrings */
1507 uint8 htput_flow_ring_start; /* start index of htput flow rings */
1508 #endif /* DHD_HTPUT_TUNABLES */
1509 void *flow_ring_table; /* flow ring table, include prot and bus info */
1510 void *if_flow_lkup; /* per interface flowid lkup hash table */
1511 void *flowid_lock; /* per os lock for flowid info protection */
1512 void *flowring_list_lock; /* per os lock for flowring list protection */
1513 uint8 max_multi_client_flow_rings;
1514 uint8 multi_client_flow_rings;
1515 uint32 num_h2d_rings; /* Max h2d rings including static and dynamic rings */
1516 uint32 max_tx_flowid; /* used to validate flowid */
1517 cumm_ctr_t cumm_ctr; /* cumm queue length placeholder */
1518 cumm_ctr_t l2cumm_ctr; /* level 2 cumm queue length placeholder */
1519 uint32 d2h_sync_mode; /* D2H DMA completion sync mode */
1520 uint8 flow_prio_map[NUMPRIO];
1521 uint8 flow_prio_map_type;
1522 char enable_log[MAX_EVENT];
1523 bool dma_d2h_ring_upd_support;
1524 bool dma_h2d_ring_upd_support;
1525 bool dma_ring_upd_overwrite; /* host overwrites support setting */
1526
1527 bool idma_enable;
1528 uint idma_inited;
1529
1530 bool ifrm_enable; /* implicit frm enable */
1531 uint ifrm_inited; /* implicit frm init */
1532
1533 bool dar_enable; /* use DAR registers */
1534 uint dar_inited;
1535
1536 bool fast_delete_ring_support; /* fast delete ring supported */
1537
1538 #ifdef DHD_WMF
1539 bool wmf_ucast_igmp;
1540 #ifdef DHD_IGMP_UCQUERY
1541 bool wmf_ucast_igmp_query;
1542 #endif
1543 #ifdef DHD_UCAST_UPNP
1544 bool wmf_ucast_upnp;
1545 #endif
1546 #endif /* DHD_WMF */
1547 #if defined(BCM_ROUTER_DHD)
1548 dhd_trf_mgmt_dwm_tbl_t dhd_tm_dwm_tbl;
1549 #endif /* BCM_ROUTER_DHD */
1550 #ifdef DHD_L2_FILTER
1551 unsigned long l2_filter_cnt; /* for L2_FILTER ARP table timeout */
1552 #endif /* DHD_L2_FILTER */
1553 #ifdef DHD_SSSR_DUMP
1554 bool sssr_inited;
1555 bool sssr_dump_collected; /* Flag to indicate sssr dump is collected */
1556 sssr_reg_info_cmn_t *sssr_reg_info;
1557 uint8 *sssr_mempool;
1558 #ifdef DHD_SSSR_DUMP_BEFORE_SR
1559 uint *sssr_d11_before[MAX_NUM_D11_CORES_WITH_SCAN];
1560 uint *sssr_dig_buf_before;
1561 #endif /* DHD_SSSR_DUMP_BEFORE_SR */
1562 uint *sssr_d11_after[MAX_NUM_D11_CORES_WITH_SCAN];
1563 bool sssr_d11_outofreset[MAX_NUM_D11_CORES_WITH_SCAN];
1564 uint *sssr_dig_buf_after;
1565 uint32 sssr_dump_mode;
1566 bool collect_sssr; /* Flag to indicate SSSR dump is required */
1567 bool fis_triggered;
1568 #endif /* DHD_SSSR_DUMP */
1569 #ifdef DHD_SDTC_ETB_DUMP
1570 etb_addr_info_t etb_addr_info;
1571 uint8 *sdtc_etb_mempool;
1572 bool sdtc_etb_inited;
1573 bool collect_sdtc; /* Flag to indicate SDTC dump is required */
1574 #endif /* DHD_SDTC_ETB_DUMP */
1575 uint8 *soc_ram;
1576 uint32 soc_ram_length;
1577 uint32 memdump_type;
1578 #ifdef DHD_COREDUMP
1579 char memdump_str[DHD_MEMDUMP_LONGSTR_LEN];
1580 #endif /* DHD_COREDUMP */
1581 #ifdef DHD_RND_DEBUG
1582 uint8 *rnd_buf;
1583 uint32 rnd_len;
1584 #endif /* DHD_RND_DEBUG */
1585 #ifdef DHD_FW_COREDUMP
1586 uint32 memdump_enabled;
1587 #ifdef DHD_DEBUG_UART
1588 bool memdump_success;
1589 #endif /* DHD_DEBUG_UART */
1590 #endif /* DHD_FW_COREDUMP */
1591 #ifdef PCIE_FULL_DONGLE
1592 #ifdef WLTDLS
1593 tdls_peer_tbl_t peer_tbl;
1594 #endif /* WLTDLS */
1595 #if defined(LINUX) || defined(linux)
1596 uint8 tx_in_progress;
1597 #endif /* LINUX || linux */
1598 #endif /* PCIE_FULL_DONGLE */
1599 #ifdef CACHE_FW_IMAGES
1600 char *cached_fw;
1601 int cached_fw_length;
1602 char *cached_nvram;
1603 int cached_nvram_length;
1604 char *cached_clm;
1605 int cached_clm_length;
1606 char *cached_txcap;
1607 int cached_txcap_length;
1608 #endif
1609 #ifdef KEEP_JP_REGREV
1610 /* XXX Needed by customer's request */
1611 char vars_ccode[WLC_CNTRY_BUF_SZ];
1612 uint vars_regrev;
1613 #endif /* KEEP_JP_REGREV */
1614 #ifdef WLTDLS
1615 uint32 tdls_mode;
1616 #endif
1617 #ifdef GSCAN_SUPPORT
1618 bool lazy_roam_enable;
1619 #endif
1620 #if defined(PKT_FILTER_SUPPORT) && defined(APF)
1621 bool apf_set;
1622 #endif /* PKT_FILTER_SUPPORT && APF */
1623 void *macdbg_info;
1624 #ifdef DHD_WET
1625 void *wet_info;
1626 #endif
1627 bool h2d_phase_supported;
1628 bool force_dongletrap_on_bad_h2d_phase;
1629 uint32 dongle_trap_data;
1630 fw_download_status_t fw_download_status;
1631 trap_t last_trap_info; /* trap info from the last trap */
1632 uint8 rand_mac_oui[DOT11_OUI_LEN];
1633 #ifdef DHD_LOSSLESS_ROAMING
1634 uint8 dequeue_prec_map;
1635 uint8 prio_8021x;
1636 #endif
1637 #ifdef WL_NATOE
1638 struct dhd_nfct_info *nfct;
1639 spinlock_t nfct_lock;
1640 #endif /* WL_NATOE */
1641 /* timesync link */
1642 struct dhd_ts *ts;
1643 bool d2h_hostrdy_supported;
1644 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
1645 atomic_t block_bus;
1646 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
1647 #if defined(DBG_PKT_MON) || defined(DHD_PKT_LOGGING)
1648 bool d11_tx_status;
1649 #endif /* DBG_PKT_MON || DHD_PKT_LOGGING */
1650 uint16 ndo_version; /* ND offload version supported */
1651 #ifdef NDO_CONFIG_SUPPORT
1652 bool ndo_enable; /* ND offload feature enable */
1653 bool ndo_host_ip_overflow; /* # of host ip addr exceed FW capacity */
1654 uint32 ndo_max_host_ip; /* # of host ip addr supported by FW */
1655 #endif /* NDO_CONFIG_SUPPORT */
1656 #if defined(DHD_LOG_DUMP)
1657 #if defined(DHD_EFI)
1658 uint8 log_capture_enable;
1659 #endif /* DHD_EFI */
1660 /* buffer to hold 'dhd dump' data before dumping to file */
1661 uint8 *concise_dbg_buf;
1662 uint64 last_file_posn;
1663 int logdump_periodic_flush;
1664 #ifdef EWP_ECNTRS_LOGGING
1665 void *ecntr_dbg_ring;
1666 #endif
1667 #ifdef EWP_RTT_LOGGING
1668 void *rtt_dbg_ring;
1669 #endif
1670 #ifdef EWP_BCM_TRACE
1671 void *bcm_trace_dbg_ring;
1672 #endif
1673 #ifdef DNGL_EVENT_SUPPORT
1674 uint8 health_chk_event_data[HEALTH_CHK_BUF_SIZE];
1675 #endif
1676 void *logdump_cookie;
1677 #endif /* DHD_LOG_DUMP */
1678 uint32 dhd_console_ms; /** interval for polling the dongle for console (log) messages */
1679 bool ext_trap_data_supported;
1680 uint32 *extended_trap_data;
1681 #ifdef DUMP_IOCTL_IOV_LIST
1682 /* dump iovar list */
1683 dll_t dump_iovlist_head;
1684 uint8 dump_iovlist_len;
1685 #endif /* DUMP_IOCTL_IOV_LIST */
1686 #ifdef REPORT_FATAL_TIMEOUTS
1687 timeout_info_t *timeout_info;
1688 uint16 esync_id; /* used to track escans */
1689 osl_atomic_t set_ssid_rcvd; /* to track if WLC_E_SET_SSID is received during join IOVAR */
1690 bool secure_join; /* field to note that the join is secure or not */
1691 #endif /* REPORT_FATAL_TIMEOUTS */
1692 #ifdef CUSTOM_SET_ANTNPM
1693 uint32 mimo_ant_set;
1694 #endif /* CUSTOM_SET_ANTNPM */
1695 #ifdef CUSTOM_SET_OCLOFF
1696 bool ocl_off;
1697 #endif /* CUSTOM_SET_OCLOFF */
1698 #ifdef DHD_DEBUG
1699 /* memwaste feature */
1700 dll_t mw_list_head; /* memwaste list head */
1701 uint32 mw_id; /* memwaste list unique id */
1702 #endif /* DHD_DEBUG */
1703 #ifdef WLTDLS
1704 spinlock_t tdls_lock;
1705 #endif /* WLTDLS */
1706 uint pcie_txs_metadata_enable;
1707 #ifdef BTLOG
1708 bool bt_logging;
1709 bool submit_count_WAR; /* submission count WAR */
1710 bool bt_logging_enabled;
1711 #endif /* BTLOG */
1712 uint wbtext_policy; /* wbtext policy of dongle */
1713 bool wbtext_support; /* for product policy only */
1714 #ifdef PCIE_OOB
1715 bool d2h_no_oob_dw;
1716 #endif /* PCIE_OOB */
1717 #ifdef PCIE_INB_DW
1718 bool d2h_inband_dw;
1719 enum dhd_bus_ds_state ds_state;
1720 #endif /* PCIE_INB_DW */
1721 bool max_dtim_enable; /* use MAX bcn_li_dtim value in suspend mode */
1722 #ifdef SNAPSHOT_UPLOAD
1723 bool snapshot_upload;
1724 #endif /* SNAPSHOT_UPLOAD */
1725 tput_test_t tput_data;
1726 uint64 tput_start_ts;
1727 uint64 tput_stop_ts;
1728 uint dhd_watchdog_ms_backup;
1729 bool wl_event_enabled;
1730 bool logtrace_pkt_sendup;
1731 #ifdef GDB_PROXY
1732 /* True if firmware runs under gdb control (this may cause timeouts at any point) */
1733 bool gdb_proxy_active;
1734 /* True if deadman_to shall be forced to 0 */
1735 bool gdb_proxy_nodeadman;
1736 /* Counter incremented at each firmware stop/go transition. LSB (GDB_PROXY_STOP_MASK)
1737 * is set when firmwar eis stopped, clear when running
1738 */
1739 uint32 gdb_proxy_stop_count;
1740 #endif /* GDB_PROXY */
1741 int debug_dump_subcmd;
1742 uint64 debug_dump_time_sec;
1743 bool hscb_enable;
1744 #if defined(DHD_AWDL)
1745 #if defined(AWDL_SLOT_STATS)
1746 dhd_awdl_stats_t awdl_stats[AWDL_NUM_SLOTS];
1747 uint8 awdl_tx_status_slot; /* Slot in which AWDL is active right now */
1748 void *awdl_stats_lock; /* Lock to protect against parallel AWDL stats updates */
1749 uint16 awdl_aw_counter;
1750 uint32 pkt_latency;
1751 #endif /* AWDL_SLOT_STATS */
1752 uint32 awdl_ifidx;
1753 uint16 awdl_seq;
1754 uint8 awdl_minext;
1755 uint8 awdl_presmode;
1756 bool awdl_llc_enabled;
1757 #endif /* DHD_AWDL */
1758 uint32 logset_prsrv_mask;
1759 #ifdef DHD_PKT_LOGGING
1760 struct dhd_pktlog *pktlog;
1761 char debug_dump_time_pktlog_str[DEBUG_DUMP_TIME_BUF_LEN];
1762 bool pktlog_debug;
1763 #endif /* DHD_PKT_LOGGING */
1764 #ifdef EWP_EDL
1765 bool dongle_edl_support;
1766 dhd_dma_buf_t edl_ring_mem;
1767 #endif /* EWP_EDL */
1768 #if defined (LINUX) || defined(linux)
1769 struct mutex ndev_op_sync;
1770 #endif /* defined (LINUX) || defined(linux) */
1771 bool debug_buf_dest_support;
1772 uint32 debug_buf_dest_stat[DEBUG_BUF_DEST_MAX];
1773 #ifdef WL_CFGVENDOR_SEND_HANG_EVENT
1774 char *hang_info;
1775 int hang_info_cnt;
1776 char debug_dump_time_hang_str[DEBUG_DUMP_TIME_BUF_LEN];
1777 #endif /* WL_CFGVENDOR_SEND_HANG_EVENT */
1778 char debug_dump_time_str[DEBUG_DUMP_TIME_BUF_LEN];
1779 void *event_log_filter;
1780 uint tput_test_done;
1781 #if defined(LINUX) || defined(linux)
1782 wait_queue_head_t tx_tput_test_wait;
1783 wait_queue_head_t tx_completion_wait;
1784 #ifdef WL_NANHO
1785 void *nanhoi; /* NANHO instance */
1786 #endif /* WL_NANHO */
1787 #endif /* defined(LINUX) || defined(linux) */
1788 #ifdef DHD_ERPOM
1789 bool enable_erpom;
1790 pom_func_handler_t pom_wlan_handler;
1791 int (*pom_func_register)(pom_func_handler_t *func);
1792 int (*pom_func_deregister)(pom_func_handler_t *func);
1793 int (*pom_toggle_reg_on)(uchar func_id, uchar reason);
1794 #endif /* DHD_ERPOM */
1795 #if defined(DHD_H2D_LOG_TIME_SYNC)
1796 #define DHD_H2D_LOG_TIME_STAMP_MATCH (10000) /* 10 Seconds */
1797 /*
1798 * Interval for updating the dongle console message time stamp with the Host (DHD)
1799 * time stamp
1800 */
1801 uint32 dhd_rte_time_sync_ms;
1802 #endif /* DHD_H2D_LOG_TIME_SYNC */
1803 uint32 batch_tx_pkts_cmpl;
1804 uint32 batch_tx_num_pkts;
1805 #ifdef DHD_EFI
1806 bool insert_random_mac;
1807 /* threshold # of pkts Tx'd/Rx'd after which efi dhd
1808 * will switch intr poll period to 100us
1809 */
1810 uint64 npkts_thresh;
1811 /* the period of time in which if no pkt is Tx'd/Rx'd
1812 * efi dhd will restore intr poll period to default value
1813 */
1814 uint64 pkt_intvl_thresh_us;
1815 /* time stamp of last Tx'd pkt */
1816 uint64 tx_last_pkt_ts;
1817 /* time stamp of last Rx'd pkt */
1818 uint64 rx_last_pkt_ts;
1819 /* used to temporarily store the current intr poll period
1820 * during efi dhd iovar execution, so as to restore it back
1821 * once iovar completes
1822 */
1823 uint32 cur_intr_poll_period;
1824 /* the intr poll period set by user through dhd iovar */
1825 uint32 iovar_intr_poll_period;
1826 bool pcie_readshared_done;
1827 #endif /* DHD_EFI */
1828 #ifdef DHD_DUMP_MNGR
1829 struct _dhd_dump_file_manage *dump_file_manage;
1830 #endif /* DHD_DUMP_MNGR */
1831 #ifdef BCMINTERNAL
1832 #ifdef DHD_FWTRACE
1833 fwtrace_info_t *fwtrace_info; /* f/w trace information */
1834 #endif /* DHD_FWTRACE */
1835 #endif /* BCMINTERNAL */
1836 bool event_log_max_sets_queried;
1837 uint32 event_log_max_sets;
1838 #ifdef DHD_STATUS_LOGGING
1839 void *statlog;
1840 #endif /* DHD_STATUS_LOGGING */
1841 #ifdef DHD_HP2P
1842 /* whether enabled from host by user iovar */
1843 bool hp2p_enable;
1844 bool hp2p_infra_enable;
1845 /* whether fw supports it */
1846 bool hp2p_capable;
1847 bool hp2p_mf_enable;
1848 bool hp2p_ts_capable;
1849 uint16 pkt_thresh;
1850 uint16 time_thresh;
1851 uint16 pkt_expiry;
1852 hp2p_info_t hp2p_info[MAX_HP2P_FLOWS];
1853 /* Flag to allow more hp2p ring creation */
1854 bool hp2p_ring_more;
1855 #endif /* D2H_HP2P */
1856 #ifdef DHD_DB0TS
1857 bool db0ts_capable;
1858 #endif /* DHD_DB0TS */
1859 bool extdtxs_in_txcpl;
1860 bool hostrdy_after_init;
1861 uint16 dhd_induce_error;
1862 uint16 dhd_induce_bh_error;
1863 int wlc_ver_major;
1864 int wlc_ver_minor;
1865 #ifdef DHD_PKTTS
1866 /* stores the packet meta data buffer length queried via iovar */
1867 uint16 pkt_metadata_version;
1868 uint16 pkt_metadata_buflen;
1869 #endif
1870 #ifdef SUPPORT_SET_TID
1871 uint8 tid_mode;
1872 uint32 target_uid;
1873 uint8 target_tid;
1874 #endif /* SUPPORT_SET_TID */
1875 #ifdef CONFIG_SILENT_ROAM
1876 bool sroam_turn_on; /* Silent roam monitor enable flags */
1877 bool sroamed; /* Silent roam monitor check flags */
1878 #endif /* CONFIG_SILENT_ROAM */
1879 #ifdef DHD_PKTDUMP_ROAM
1880 void *pktcnts;
1881 #endif /* DHD_PKTDUMP_ROAM */
1882 dhd_db7_info_t db7_trap;
1883 bool fw_preinit;
1884 bool ring_attached;
1885 #ifdef DHD_PCIE_RUNTIMEPM
1886 bool rx_pending_due_to_rpm;
1887 #endif /* DHD_PCIE_RUNTIMEPM */
1888 bool disable_dtim_in_suspend; /* Disable set bcn_li_dtim in suspend */
1889 union {
1890 wl_roam_stats_v1_t v1;
1891 } roam_evt;
1892 bool arpoe_enable;
1893 bool arpol_configured;
1894 #ifdef DHD_TX_PROFILE
1895 bool tx_profile_enab;
1896 uint8 num_profiles;
1897 dhd_tx_profile_protocol_t *protocol_filters;
1898 #endif /* defined(DHD_TX_PROFILE) */
1899 #ifdef DHD_MEM_STATS
1900 void *mem_stats_lock;
1901 uint64 txpath_mem;
1902 uint64 rxpath_mem;
1903 #endif /* DHD_MEM_STATS */
1904 #ifdef DHD_LB_RXP
1905 atomic_t lb_rxp_flow_ctrl;
1906 uint32 lb_rxp_stop_thr;
1907 uint32 lb_rxp_strt_thr;
1908 #endif /* DHD_LB_RXP */
1909 #ifdef DHD_LB_STATS
1910 uint64 lb_rxp_stop_thr_hitcnt;
1911 uint64 lb_rxp_strt_thr_hitcnt;
1912 uint64 lb_rxp_napi_sched_cnt;
1913 uint64 lb_rxp_napi_complete_cnt;
1914 #endif /* DHD_LB_STATS */
1915 bool check_trap_rot;
1916 /* if FW supports host insertion of SFH LLC */
1917 bool host_sfhllc_supported;
1918 #ifdef DHD_GRO_ENABLE_HOST_CTRL
1919 bool permitted_gro;
1920 #endif /* DHD_GRO_ENABLE_HOST_CTRL */
1921 #ifdef CSI_SUPPORT
1922 struct list_head csi_list;
1923 int csi_count;
1924 #endif /* CSI_SUPPORT */
1925 char *clm_path; /* module_param: path to clm vars file */
1926 char *conf_path; /* module_param: path to config vars file */
1927 struct dhd_conf *conf; /* Bus module handle */
1928 void *adapter; /* adapter information, interrupt, fw path etc. */
1929 void *event_params;
1930 #ifdef BCMDBUS
1931 bool dhd_remove;
1932 #endif /* BCMDBUS */
1933 #ifdef WL_ESCAN
1934 struct wl_escan_info *escan;
1935 #endif
1936 #if defined(WL_WIRELESS_EXT)
1937 void *wext_info;
1938 #endif
1939 #ifdef WL_EXT_IAPSTA
1940 void *iapsta_params;
1941 #endif
1942 int hostsleep;
1943 #ifdef SENDPROB
1944 bool recv_probereq;
1945 #endif
1946 #ifdef DHD_NOTIFY_MAC_CHANGED
1947 bool skip_dhd_stop;
1948 #endif /* DHD_NOTIFY_MAC_CHANGED */
1949 #ifdef WL_EXT_GENL
1950 void *zconf;
1951 #endif
1952 } dhd_pub_t;
1953
1954 #if defined(__linux__)
1955 int dhd_wifi_platform_set_power(dhd_pub_t *pub, bool on);
1956 #else
dhd_wifi_platform_set_power(dhd_pub_t * pub,bool on)1957 static INLINE int dhd_wifi_platform_set_power(dhd_pub_t *pub, bool on) { return 0; }
1958 #endif /* __linux__ */
1959
1960 typedef struct {
1961 uint rxwake;
1962 uint rcwake;
1963 #ifdef DHD_WAKE_RX_STATUS
1964 uint rx_bcast;
1965 uint rx_arp;
1966 uint rx_mcast;
1967 uint rx_multi_ipv6;
1968 uint rx_icmpv6;
1969 uint rx_icmpv6_ra;
1970 uint rx_icmpv6_na;
1971 uint rx_icmpv6_ns;
1972 uint rx_multi_ipv4;
1973 uint rx_multi_other;
1974 uint rx_ucast;
1975 #endif /* DHD_WAKE_RX_STATUS */
1976 #ifdef DHD_WAKE_EVENT_STATUS
1977 uint rc_event[WLC_E_LAST];
1978 #endif /* DHD_WAKE_EVENT_STATUS */
1979 } wake_counts_t;
1980
1981 #if defined(PCIE_FULL_DONGLE)
1982 /*
1983 * XXX: WARNING: dhd_wlfc.h also defines a dhd_pkttag_t
1984 * making wlfc incompatible with PCIE_FULL DONGLE
1985 */
1986
1987 /* Packet Tag for PCIE Full Dongle DHD */
1988 typedef struct dhd_pkttag_fd {
1989 uint16 flowid; /* Flowring Id */
1990 uint16 ifid;
1991 #ifdef DHD_SBN
1992 uint8 pkt_udr;
1993 uint8 pad;
1994 #endif /* DHD_SBN */
1995 #if defined(BCM_ROUTER_DHD) && defined(BCM_GMAC3)
1996 uint16 dataoff; /* start of packet */
1997 #endif /* BCM_ROUTER_DHD && BCM_GMAC3 */
1998 #ifndef DHD_PCIE_PKTID
1999 uint16 dma_len; /* pkt len for DMA_MAP/UNMAP */
2000 dmaaddr_t pa; /* physical address */
2001 void *dmah; /* dma mapper handle */
2002 void *secdma; /* secure dma sec_cma_info handle */
2003 #endif /* !DHD_PCIE_PKTID */
2004 #if defined(TX_STATUS_LATENCY_STATS) || defined(DHD_PKTTS)
2005 uint64 q_time_us; /* time when tx pkt queued to flowring */
2006 #endif /* TX_STATUS_LATENCY_STATS || DHD_PKTTS */
2007 } dhd_pkttag_fd_t;
2008
2009 /* Packet Tag for DHD PCIE Full Dongle */
2010 #define DHD_PKTTAG_FD(pkt) ((dhd_pkttag_fd_t *)(PKTTAG(pkt)))
2011
2012 #define DHD_PKT_GET_FLOWID(pkt) ((DHD_PKTTAG_FD(pkt))->flowid)
2013 #define DHD_PKT_SET_FLOWID(pkt, pkt_flowid) \
2014 DHD_PKTTAG_FD(pkt)->flowid = (uint16)(pkt_flowid)
2015
2016 #define DHD_PKT_GET_DATAOFF(pkt) ((DHD_PKTTAG_FD(pkt))->dataoff)
2017 #define DHD_PKT_SET_DATAOFF(pkt, pkt_dataoff) \
2018 DHD_PKTTAG_FD(pkt)->dataoff = (uint16)(pkt_dataoff)
2019
2020 #define DHD_PKT_GET_DMA_LEN(pkt) ((DHD_PKTTAG_FD(pkt))->dma_len)
2021 #define DHD_PKT_SET_DMA_LEN(pkt, pkt_dma_len) \
2022 DHD_PKTTAG_FD(pkt)->dma_len = (uint16)(pkt_dma_len)
2023
2024 #define DHD_PKT_GET_PA(pkt) ((DHD_PKTTAG_FD(pkt))->pa)
2025 #define DHD_PKT_SET_PA(pkt, pkt_pa) \
2026 DHD_PKTTAG_FD(pkt)->pa = (dmaaddr_t)(pkt_pa)
2027
2028 #define DHD_PKT_GET_DMAH(pkt) ((DHD_PKTTAG_FD(pkt))->dmah)
2029 #define DHD_PKT_SET_DMAH(pkt, pkt_dmah) \
2030 DHD_PKTTAG_FD(pkt)->dmah = (void *)(pkt_dmah)
2031
2032 #define DHD_PKT_GET_SECDMA(pkt) ((DHD_PKTTAG_FD(pkt))->secdma)
2033 #define DHD_PKT_SET_SECDMA(pkt, pkt_secdma) \
2034 DHD_PKTTAG_FD(pkt)->secdma = (void *)(pkt_secdma)
2035
2036 #if defined(TX_STATUS_LATENCY_STATS) || defined(DHD_PKTTS)
2037 #define DHD_PKT_GET_QTIME(pkt) ((DHD_PKTTAG_FD(pkt))->q_time_us)
2038 #define DHD_PKT_SET_QTIME(pkt, pkt_q_time_us) \
2039 DHD_PKTTAG_FD(pkt)->q_time_us = (uint64)(pkt_q_time_us)
2040 #endif /* TX_STATUS_LATENCY_STATS || DHD_PKTTS */
2041 #endif /* PCIE_FULL_DONGLE */
2042
2043 #if defined(BCMWDF)
2044 typedef struct {
2045 dhd_pub_t *dhd_pub;
2046 } dhd_workitem_context_t;
2047
2048 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(dhd_workitem_context_t, dhd_get_dhd_workitem_context)
2049 #endif /* (BCMWDF) */
2050
2051 #if defined(LINUX) || defined(linux)
2052 #if defined(CONFIG_PM_SLEEP)
2053
2054 #define DHD_PM_RESUME_WAIT_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
2055 #define _DHD_PM_RESUME_WAIT(a, b) do {\
2056 int retry = 0; \
2057 SMP_RD_BARRIER_DEPENDS(); \
2058 while (dhd_mmc_suspend && retry++ != b) { \
2059 SMP_RD_BARRIER_DEPENDS(); \
2060 wait_event_interruptible_timeout(a, !dhd_mmc_suspend, 1); \
2061 } \
2062 } while (0)
2063 #define DHD_PM_RESUME_WAIT(a) _DHD_PM_RESUME_WAIT(a, 200)
2064 #define DHD_PM_RESUME_WAIT_FOREVER(a) _DHD_PM_RESUME_WAIT(a, ~0)
2065 #define DHD_PM_RESUME_RETURN_ERROR(a) do { \
2066 if (dhd_mmc_suspend) { \
2067 printf("%s[%d]: mmc is still in suspend state!!!\n", \
2068 __FUNCTION__, __LINE__); \
2069 return a; \
2070 } \
2071 } while (0)
2072 #define DHD_PM_RESUME_RETURN do { if (dhd_mmc_suspend) return; } while (0)
2073
2074 #define DHD_SPINWAIT_SLEEP_INIT(a) DECLARE_WAIT_QUEUE_HEAD(a);
2075 #define SPINWAIT_SLEEP(a, exp, us) do { \
2076 uint countdown = (us) + 9999; \
2077 while ((exp) && (countdown >= 10000)) { \
2078 wait_event_interruptible_timeout(a, FALSE, 1); \
2079 countdown -= 10000; \
2080 } \
2081 } while (0)
2082
2083 #else
2084
2085 #define DHD_PM_RESUME_WAIT_INIT(a)
2086 #define DHD_PM_RESUME_WAIT(a)
2087 #define DHD_PM_RESUME_WAIT_FOREVER(a)
2088 #define DHD_PM_RESUME_RETURN_ERROR(a)
2089 #define DHD_PM_RESUME_RETURN
2090
2091 #define DHD_SPINWAIT_SLEEP_INIT(a)
2092 #define SPINWAIT_SLEEP(a, exp, us) do { \
2093 uint countdown = (us) + 9; \
2094 while ((exp) && (countdown >= 10)) { \
2095 OSL_DELAY(10); \
2096 countdown -= 10; \
2097 } \
2098 } while (0)
2099
2100 #endif /* CONFIG_PM_SLEEP */
2101 #else
2102 #define DHD_SPINWAIT_SLEEP_INIT(a)
2103 #define SPINWAIT_SLEEP(a, exp, us) do { \
2104 uint countdown = (us) + 9; \
2105 while ((exp) && (countdown >= 10)) { \
2106 OSL_DELAY(10); \
2107 countdown -= 10; \
2108 } \
2109 } while (0)
2110 #endif /* defined (LINUX) || defined(linux) */
2111
2112 #define DHD_IF_VIF 0x01 /* Virtual IF (Hidden from user) */
2113
2114 #ifdef PNO_SUPPORT
2115 int dhd_pno_clean(dhd_pub_t *dhd);
2116 #endif /* PNO_SUPPORT */
2117
2118 /*
2119 * Wake locks are an Android power management concept. They are used by applications and services
2120 * to request CPU resources.
2121 */
2122 #if defined(linux) && defined(OEM_ANDROID)
2123 extern int dhd_os_wake_lock(dhd_pub_t *pub);
2124 extern int dhd_os_wake_unlock(dhd_pub_t *pub);
2125 extern int dhd_os_wake_lock_waive(dhd_pub_t *pub);
2126 extern int dhd_os_wake_lock_restore(dhd_pub_t *pub);
2127 extern void dhd_event_wake_lock(dhd_pub_t *pub);
2128 extern void dhd_event_wake_unlock(dhd_pub_t *pub);
2129 extern void dhd_pm_wake_lock_timeout(dhd_pub_t *pub, int val);
2130 extern void dhd_pm_wake_unlock(dhd_pub_t *pub);
2131 extern void dhd_txfl_wake_lock_timeout(dhd_pub_t *pub, int val);
2132 extern void dhd_txfl_wake_unlock(dhd_pub_t *pub);
2133 extern void dhd_nan_wake_lock_timeout(dhd_pub_t *pub, int val);
2134 extern void dhd_nan_wake_unlock(dhd_pub_t *pub);
2135 extern int dhd_os_wake_lock_timeout(dhd_pub_t *pub);
2136 extern int dhd_os_wake_lock_rx_timeout_enable(dhd_pub_t *pub, int val);
2137 extern int dhd_os_wake_lock_ctrl_timeout_enable(dhd_pub_t *pub, int val);
2138 extern int dhd_os_wake_lock_ctrl_timeout_cancel(dhd_pub_t *pub);
2139 extern int dhd_os_wd_wake_lock(dhd_pub_t *pub);
2140 extern int dhd_os_wd_wake_unlock(dhd_pub_t *pub);
2141 extern void dhd_os_wake_lock_init(struct dhd_info *dhd);
2142 extern void dhd_os_wake_lock_destroy(struct dhd_info *dhd);
2143 #ifdef DHD_USE_SCAN_WAKELOCK
2144 extern void dhd_os_scan_wake_lock_timeout(dhd_pub_t *pub, int val);
2145 extern void dhd_os_scan_wake_unlock(dhd_pub_t *pub);
2146 #endif /* BCMPCIE_SCAN_WAKELOCK */
2147
2148 #ifdef WLEASYMESH
2149 extern int dhd_get_1905_almac(dhd_pub_t *dhdp, uint8 ifidx, uint8* ea, bool mcast);
2150 extern int dhd_set_1905_almac(dhd_pub_t *dhdp, uint8 ifidx, uint8* ea, bool mcast);
2151 #endif /* WLEASYMESH */
2152
MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)2153 inline static void MUTEX_LOCK_SOFTAP_SET_INIT(dhd_pub_t * dhdp)
2154 {
2155 #if defined(OEM_ANDROID)
2156 mutex_init(&dhdp->wl_softap_lock);
2157 #endif /* OEM_ANDROID */
2158 }
2159
MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)2160 inline static void MUTEX_LOCK_SOFTAP_SET(dhd_pub_t * dhdp)
2161 {
2162 #if defined(OEM_ANDROID)
2163 mutex_lock(&dhdp->wl_softap_lock);
2164 #endif /* OEM_ANDROID */
2165 }
2166
MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)2167 inline static void MUTEX_UNLOCK_SOFTAP_SET(dhd_pub_t * dhdp)
2168 {
2169 #if defined(OEM_ANDROID)
2170 mutex_unlock(&dhdp->wl_softap_lock);
2171 #endif /* OEM_ANDROID */
2172 }
2173
2174 #ifdef DHD_DEBUG_WAKE_LOCK
2175 #define DHD_OS_WAKE_LOCK(pub) \
2176 do { \
2177 printf("call wake_lock: %s %d\n", \
2178 __FUNCTION__, __LINE__); \
2179 dhd_os_wake_lock(pub); \
2180 } while (0)
2181 #define DHD_OS_WAKE_UNLOCK(pub) \
2182 do { \
2183 printf("call wake_unlock: %s %d\n", \
2184 __FUNCTION__, __LINE__); \
2185 dhd_os_wake_unlock(pub); \
2186 } while (0)
2187 #define DHD_EVENT_WAKE_LOCK(pub) \
2188 do { \
2189 printf("call event wake_lock: %s %d\n", \
2190 __FUNCTION__, __LINE__); \
2191 dhd_event_wake_lock(pub); \
2192 } while (0)
2193 #define DHD_EVENT_WAKE_UNLOCK(pub) \
2194 do { \
2195 printf("call event wake_unlock: %s %d\n", \
2196 __FUNCTION__, __LINE__); \
2197 dhd_event_wake_unlock(pub); \
2198 } while (0)
2199 #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) \
2200 do { \
2201 printf("call pm_wake_timeout enable\n"); \
2202 dhd_pm_wake_lock_timeout(pub, val); \
2203 } while (0)
2204 #define DHD_PM_WAKE_UNLOCK(pub) \
2205 do { \
2206 printf("call pm_wake unlock\n"); \
2207 dhd_pm_wake_unlock(pub); \
2208 } while (0)
2209 #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) \
2210 do { \
2211 printf("call pm_wake_timeout enable\n"); \
2212 dhd_txfl_wake_lock_timeout(pub, val); \
2213 } while (0)
2214 #define DHD_TXFL_WAKE_UNLOCK(pub) \
2215 do { \
2216 printf("call pm_wake unlock\n"); \
2217 dhd_txfl_wake_unlock(pub); \
2218 } while (0)
2219 #define DHD_NAN_WAKE_LOCK_TIMEOUT(pub, val) \
2220 do { \
2221 printf("call pm_wake_timeout enable\n"); \
2222 dhd_nan_wake_lock_timeout(pub, val); \
2223 } while (0)
2224 #define DHD_NAN_WAKE_UNLOCK(pub) \
2225 do { \
2226 printf("call pm_wake unlock\n"); \
2227 dhd_nan_wake_unlock(pub); \
2228 } while (0)
2229 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) \
2230 do { \
2231 printf("call wake_lock_timeout: %s %d\n", \
2232 __FUNCTION__, __LINE__); \
2233 dhd_os_wake_lock_timeout(pub); \
2234 } while (0)
2235 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
2236 do { \
2237 printf("call dhd_wake_lock_rx_timeout_enable[%d]: %s %d\n", \
2238 val, __FUNCTION__, __LINE__); \
2239 dhd_os_wake_lock_rx_timeout_enable(pub, val); \
2240 } while (0)
2241 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
2242 do { \
2243 printf("call dhd_wake_lock_ctrl_timeout_enable[%d]: %s %d\n", \
2244 val, __FUNCTION__, __LINE__); \
2245 dhd_os_wake_lock_ctrl_timeout_enable(pub, val); \
2246 } while (0)
2247 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
2248 do { \
2249 printf("call dhd_wake_lock_ctrl_timeout_cancel: %s %d\n", \
2250 __FUNCTION__, __LINE__); \
2251 dhd_os_wake_lock_ctrl_timeout_cancel(pub); \
2252 } while (0)
2253 #define DHD_OS_WAKE_LOCK_WAIVE(pub) \
2254 do { \
2255 printf("call dhd_wake_lock_waive: %s %d\n", \
2256 __FUNCTION__, __LINE__); \
2257 dhd_os_wake_lock_waive(pub); \
2258 } while (0)
2259 #define DHD_OS_WAKE_LOCK_RESTORE(pub) \
2260 do { \
2261 printf("call dhd_wake_lock_restore: %s %d\n", \
2262 __FUNCTION__, __LINE__); \
2263 dhd_os_wake_lock_restore(pub); \
2264 } while (0)
2265 #define DHD_OS_WAKE_LOCK_INIT(dhd) \
2266 do { \
2267 printf("call dhd_wake_lock_init: %s %d\n", \
2268 __FUNCTION__, __LINE__); \
2269 dhd_os_wake_lock_init(dhd); \
2270 } while (0)
2271 #define DHD_OS_WAKE_LOCK_DESTROY(dhd) \
2272 do { \
2273 printf("call dhd_wake_dhd_lock_destroy: %s %d\n", \
2274 __FUNCTION__, __LINE__); \
2275 dhd_os_wake_lock_destroy(dhd); \
2276 } while (0)
2277 #else
2278 #define DHD_OS_WAKE_LOCK(pub) dhd_os_wake_lock(pub)
2279 #define DHD_OS_WAKE_UNLOCK(pub) dhd_os_wake_unlock(pub)
2280 #define DHD_EVENT_WAKE_LOCK(pub) dhd_event_wake_lock(pub)
2281 #define DHD_EVENT_WAKE_UNLOCK(pub) dhd_event_wake_unlock(pub)
2282 #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val) dhd_pm_wake_lock_timeout(pub, val)
2283 #define DHD_PM_WAKE_UNLOCK(pub) dhd_pm_wake_unlock(pub)
2284 #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val) dhd_txfl_wake_lock_timeout(pub, val)
2285 #define DHD_TXFL_WAKE_UNLOCK(pub) dhd_txfl_wake_unlock(pub)
2286 #define DHD_NAN_WAKE_LOCK_TIMEOUT(pub, val) dhd_nan_wake_lock_timeout(pub, val)
2287 #define DHD_NAN_WAKE_UNLOCK(pub) dhd_nan_wake_unlock(pub)
2288 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub) dhd_os_wake_lock_timeout(pub)
2289 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) \
2290 dhd_os_wake_lock_rx_timeout_enable(pub, val)
2291 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) \
2292 dhd_os_wake_lock_ctrl_timeout_enable(pub, val)
2293 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub) \
2294 dhd_os_wake_lock_ctrl_timeout_cancel(pub)
2295 #define DHD_OS_WAKE_LOCK_WAIVE(pub) dhd_os_wake_lock_waive(pub)
2296 #define DHD_OS_WAKE_LOCK_RESTORE(pub) dhd_os_wake_lock_restore(pub)
2297 #define DHD_OS_WAKE_LOCK_INIT(dhd) dhd_os_wake_lock_init(dhd);
2298 #define DHD_OS_WAKE_LOCK_DESTROY(dhd) dhd_os_wake_lock_destroy(dhd);
2299 #endif /* DHD_DEBUG_WAKE_LOCK */
2300
2301 #define DHD_OS_WD_WAKE_LOCK(pub) dhd_os_wd_wake_lock(pub)
2302 #define DHD_OS_WD_WAKE_UNLOCK(pub) dhd_os_wd_wake_unlock(pub)
2303
2304 #ifdef DHD_USE_SCAN_WAKELOCK
2305 #ifdef DHD_DEBUG_SCAN_WAKELOCK
2306 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) \
2307 do { \
2308 printf("call wake_lock_scan: %s %d\n", \
2309 __FUNCTION__, __LINE__); \
2310 dhd_os_scan_wake_lock_timeout(pub, val); \
2311 } while (0)
2312 #define DHD_OS_SCAN_WAKE_UNLOCK(pub) \
2313 do { \
2314 printf("call wake_unlock_scan: %s %d\n", \
2315 __FUNCTION__, __LINE__); \
2316 dhd_os_scan_wake_unlock(pub); \
2317 } while (0)
2318 #else
2319 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_scan_wake_lock_timeout(pub, val)
2320 #define DHD_OS_SCAN_WAKE_UNLOCK(pub) dhd_os_scan_wake_unlock(pub)
2321 #endif /* DHD_DEBUG_SCAN_WAKELOCK */
2322 #else
2323 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val)
2324 #define DHD_OS_SCAN_WAKE_UNLOCK(pub)
2325 #endif /* DHD_USE_SCAN_WAKELOCK */
2326
2327 #else
2328
2329 /* Wake lock are used in Android only (until the Linux community accepts it) */
2330 #define DHD_OS_WAKE_LOCK(pub)
2331 #define DHD_OS_WAKE_UNLOCK(pub)
2332 #define DHD_EVENT_WAKE_LOCK(pub)
2333 #define DHD_EVENT_WAKE_UNLOCK(pub)
2334 #define DHD_PM_WAKE_LOCK_TIMEOUT(pub, val)
2335 #define DHD_PM_WAKE_UNLOCK(pub)
2336 #define DHD_TXFL_WAKE_LOCK_TIMEOUT(pub, val)
2337 #define DHD_TXFL_WAKE_UNLOCK(pub)
2338 #define DHD_NAN_WAKE_LOCK_TIMEOUT(pub, val)
2339 #define DHD_NAN_WAKE_UNLOCK(pub)
2340 #define DHD_OS_WD_WAKE_LOCK(pub)
2341 #define DHD_OS_WD_WAKE_UNLOCK(pub)
2342 #define DHD_OS_WAKE_LOCK_TIMEOUT(pub)
2343 #define DHD_OS_WAKE_LOCK_RX_TIMEOUT_ENABLE(pub, val) UNUSED_PARAMETER(val)
2344 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_ENABLE(pub, val) UNUSED_PARAMETER(val)
2345 #define DHD_OS_WAKE_LOCK_CTRL_TIMEOUT_CANCEL(pub, val)
2346 #define DHD_OS_WAKE_LOCK_WAIVE(pub)
2347 #define DHD_OS_WAKE_LOCK_RESTORE(pub)
2348 #define DHD_OS_SCAN_WAKE_LOCK_TIMEOUT(pub, val)
2349 #define DHD_OS_SCAN_WAKE_UNLOCK(pub)
2350 #define DHD_OS_WAKE_LOCK_INIT(dhd)
2351 #define DHD_OS_WAKE_LOCK_DESTROY(dhd)
2352
2353 #endif /* #defined(linux) && defined(OEM_ANDROID) */
2354
2355 #ifdef BCMPCIE_OOB_HOST_WAKE
2356 #define OOB_WAKE_LOCK_TIMEOUT 500
2357 extern void dhd_os_oob_irq_wake_lock_timeout(dhd_pub_t *pub, int val);
2358 extern void dhd_os_oob_irq_wake_unlock(dhd_pub_t *pub);
2359
2360 #define DHD_OS_OOB_IRQ_WAKE_LOCK_TIMEOUT(pub, val) dhd_os_oob_irq_wake_lock_timeout(pub, val)
2361 #define DHD_OS_OOB_IRQ_WAKE_UNLOCK(pub) dhd_os_oob_irq_wake_unlock(pub)
2362 #endif /* BCMPCIE_OOB_HOST_WAKE */
2363
2364 #define DHD_PACKET_TIMEOUT_MS 500
2365 #define DHD_EVENT_TIMEOUT_MS 1500
2366 #define SCAN_WAKE_LOCK_TIMEOUT 10000
2367 #define MAX_TX_TIMEOUT 500
2368
2369 /* Enum for IOCTL recieved status */
2370 typedef enum dhd_ioctl_recieved_status
2371 {
2372 IOCTL_WAIT = 0,
2373 IOCTL_RETURN_ON_SUCCESS,
2374 IOCTL_RETURN_ON_TRAP,
2375 IOCTL_RETURN_ON_BUS_STOP,
2376 IOCTL_RETURN_ON_ERROR
2377 } dhd_ioctl_recieved_status_t;
2378
2379 /* interface operations (register, remove) should be atomic, use this lock to prevent race
2380 * condition among wifi on/off and interface operation functions
2381 */
2382 #if defined(LINUX)
2383 void dhd_net_if_lock(struct net_device *dev);
2384 void dhd_net_if_unlock(struct net_device *dev);
2385 #endif /* LINUX */
2386
2387 #if defined(LINUX) || defined(linux)
2388 #if defined(MULTIPLE_SUPPLICANT)
2389 extern void wl_android_post_init(void); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe
2390 #endif /* MULTIPLE_SUPPLICANT */
2391
2392 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && defined(MULTIPLE_SUPPLICANT)
2393 extern struct mutex _dhd_mutex_lock_;
2394 #define DHD_MUTEX_IS_LOCK_RETURN() \
2395 if (mutex_is_locked(&_dhd_mutex_lock_) != 0) { \
2396 printf("%s : probe is already running! return.\n", __FUNCTION__); \
2397 return -EBUSY;; \
2398 }
2399 #define DHD_MUTEX_LOCK() \
2400 do { \
2401 if (mutex_is_locked(&_dhd_mutex_lock_) == 0) { \
2402 printf("%s : no mutex held\n", __FUNCTION__); \
2403 } else { \
2404 printf("%s : mutex is locked!. wait for unlocking\n", __FUNCTION__); \
2405 } \
2406 mutex_lock(&_dhd_mutex_lock_); \
2407 printf("%s : set mutex lock\n", __FUNCTION__); \
2408 } while (0)
2409 #define DHD_MUTEX_UNLOCK() \
2410 do { \
2411 printf("%s : mutex is released.\n", __FUNCTION__); \
2412 mutex_unlock(&_dhd_mutex_lock_); \
2413 } while (0)
2414 #else
2415 #define DHD_MUTEX_IS_LOCK_RETURN(a) do {} while (0)
2416 #define DHD_MUTEX_LOCK(a) do {} while (0)
2417 #define DHD_MUTEX_UNLOCK(a) do {} while (0)
2418 #endif
2419 #endif /* defined (LINUX) || defined(linux) */
2420
2421 typedef enum dhd_attach_states
2422 {
2423 DHD_ATTACH_STATE_INIT = 0x0,
2424 DHD_ATTACH_STATE_NET_ALLOC = 0x1,
2425 DHD_ATTACH_STATE_DHD_ALLOC = 0x2,
2426 DHD_ATTACH_STATE_ADD_IF = 0x4,
2427 DHD_ATTACH_STATE_PROT_ATTACH = 0x8,
2428 DHD_ATTACH_STATE_WL_ATTACH = 0x10,
2429 DHD_ATTACH_STATE_THREADS_CREATED = 0x20,
2430 DHD_ATTACH_STATE_WAKELOCKS_INIT = 0x40,
2431 DHD_ATTACH_STATE_CFG80211 = 0x80,
2432 DHD_ATTACH_STATE_EARLYSUSPEND_DONE = 0x100,
2433 DHD_ATTACH_TIMESYNC_ATTACH_DONE = 0x200,
2434 DHD_ATTACH_LOGTRACE_INIT = 0x400,
2435 DHD_ATTACH_STATE_LB_ATTACH_DONE = 0x800,
2436 DHD_ATTACH_STATE_DONE = 0x1000
2437 } dhd_attach_states_t;
2438
2439 /* Value -1 means we are unsuccessful in creating the kthread. */
2440 #define DHD_PID_KT_INVALID -1
2441 /* Value -2 means we are unsuccessful in both creating the kthread and tasklet */
2442 #define DHD_PID_KT_TL_INVALID -2
2443
2444 /* default reporting period */
2445 #define ECOUNTERS_DEFAULT_PERIOD 0
2446
2447 /* default number of reports. '0' indicates forever */
2448 #define ECOUNTERS_NUM_REPORTS 0
2449
2450 typedef struct ecounters_cfg {
2451 uint16 type;
2452 uint16 if_slice_idx;
2453 uint16 stats_rep;
2454 } ecounters_cfg_t;
2455
2456 typedef struct event_ecounters_cfg {
2457 uint16 event_id;
2458 uint16 type;
2459 uint16 if_slice_idx;
2460 uint16 stats_rep;
2461 } event_ecounters_cfg_t;
2462
2463 typedef struct ecountersv2_xtlv_list_elt {
2464 /* Not quite the exact bcm_xtlv_t type as data could be pointing to other pieces in
2465 * memory at the time of parsing arguments.
2466 */
2467 uint16 id;
2468 uint16 len;
2469 uint8 *data;
2470 struct ecountersv2_xtlv_list_elt *next;
2471 } ecountersv2_xtlv_list_elt_t;
2472
2473 typedef struct ecountersv2_processed_xtlv_list_elt {
2474 uint8 *data;
2475 struct ecountersv2_processed_xtlv_list_elt *next;
2476 } ecountersv2_processed_xtlv_list_elt;
2477
2478 /*
2479 * Exported from dhd OS modules (dhd_linux/dhd_ndis)
2480 */
2481
2482 /* Indication from bus module regarding presence/insertion of dongle.
2483 * Return dhd_pub_t pointer, used as handle to OS module in later calls.
2484 * Returned structure should have bus and prot pointers filled in.
2485 * bus_hdrlen specifies required headroom for bus module header.
2486 */
2487 extern dhd_pub_t *dhd_attach(osl_t *osh, struct dhd_bus *bus, uint bus_hdrlen
2488 #ifdef BCMDBUS
2489 , void *adapter
2490 #endif
2491 );
2492 extern int dhd_attach_net(dhd_pub_t *dhdp, bool need_rtnl_lock);
2493 #if defined(WLP2P) && defined(WL_CFG80211)
2494 /* To allow attach/detach calls corresponding to p2p0 interface */
2495 extern int dhd_attach_p2p(dhd_pub_t *);
2496 extern int dhd_detach_p2p(dhd_pub_t *);
2497 #endif /* WLP2P && WL_CFG80211 */
2498 extern int dhd_register_if(dhd_pub_t *dhdp, int idx, bool need_rtnl_lock);
2499
2500 /* Indication from bus module regarding removal/absence of dongle */
2501 extern void dhd_detach(dhd_pub_t *dhdp);
2502 extern void dhd_free(dhd_pub_t *dhdp);
2503 extern void dhd_clear(dhd_pub_t *dhdp);
2504
2505 /* Indication from bus module to change flow-control state */
2506 extern void dhd_txflowcontrol(dhd_pub_t *dhdp, int ifidx, bool on);
2507
2508 #ifdef BCMDONGLEHOST
2509 /* Store the status of a connection attempt for later retrieval by an iovar */
2510 extern void dhd_store_conn_status(uint32 event, uint32 status, uint32 reason);
2511 #endif /* BCMDONGLEHOST */
2512
2513 extern bool dhd_prec_enq(dhd_pub_t *dhdp, struct pktq *q, void *pkt, int prec);
2514
2515 extern void dhd_rx_frame(dhd_pub_t *dhdp, int ifidx, void *rxp, int numpkt, uint8 chan);
2516
2517 /* Return pointer to interface name */
2518 extern char *dhd_ifname(dhd_pub_t *dhdp, int idx);
2519
2520 #ifdef DHD_UCODE_DOWNLOAD
2521 /* Returns the ucode path */
2522 extern char *dhd_get_ucode_path(dhd_pub_t *dhdp);
2523 #endif /* DHD_UCODE_DOWNLOAD */
2524
2525 /* Request scheduling of the bus dpc */
2526 extern void dhd_sched_dpc(dhd_pub_t *dhdp);
2527
2528 /* Notify tx completion */
2529 extern void dhd_txcomplete(dhd_pub_t *dhdp, void *txp, bool success);
2530 #ifdef DHD_4WAYM4_FAIL_DISCONNECT
2531 extern void dhd_eap_txcomplete(dhd_pub_t *dhdp, void *txp, bool success, int ifidx);
2532 extern void dhd_cleanup_m4_state_work(dhd_pub_t *dhdp, int ifidx);
2533 #endif /* DHD_4WAYM4_FAIL_DISCONNECT */
2534
2535 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
2536 extern void dhd_bus_wakeup_work(dhd_pub_t *dhdp);
2537 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
2538
2539 #define WIFI_FEATURE_INFRA 0x0001 /* Basic infrastructure mode */
2540 #define WIFI_FEATURE_INFRA_5G 0x0002 /* Support for 5 GHz Band */
2541 #define WIFI_FEATURE_HOTSPOT 0x0004 /* Support for GAS/ANQP */
2542 #define WIFI_FEATURE_P2P 0x0008 /* Wifi-Direct */
2543 #define WIFI_FEATURE_SOFT_AP 0x0010 /* Soft AP */
2544 #define WIFI_FEATURE_GSCAN 0x0020 /* Google-Scan APIs */
2545 #define WIFI_FEATURE_NAN 0x0040 /* Neighbor Awareness Networking */
2546 #define WIFI_FEATURE_D2D_RTT 0x0080 /* Device-to-device RTT */
2547 #define WIFI_FEATURE_D2AP_RTT 0x0100 /* Device-to-AP RTT */
2548 #define WIFI_FEATURE_BATCH_SCAN 0x0200 /* Batched Scan (legacy) */
2549 #define WIFI_FEATURE_PNO 0x0400 /* Preferred network offload */
2550 #define WIFI_FEATURE_ADDITIONAL_STA 0x0800 /* Support for two STAs */
2551 #define WIFI_FEATURE_TDLS 0x1000 /* Tunnel directed link setup */
2552 #define WIFI_FEATURE_TDLS_OFFCHANNEL 0x2000 /* Support for TDLS off channel */
2553 #define WIFI_FEATURE_EPR 0x4000 /* Enhanced power reporting */
2554 #define WIFI_FEATURE_AP_STA 0x8000 /* Support for AP STA Concurrency */
2555 #define WIFI_FEATURE_LINKSTAT 0x10000 /* Support for Linkstats */
2556 #define WIFI_FEATURE_LOGGER 0x20000 /* WiFi Logger */
2557 #define WIFI_FEATURE_HAL_EPNO 0x40000 /* WiFi PNO enhanced */
2558 #define WIFI_FEATURE_RSSI_MONITOR 0x80000 /* RSSI Monitor */
2559 #define WIFI_FEATURE_MKEEP_ALIVE 0x100000 /* WiFi mkeep_alive */
2560 #define WIFI_FEATURE_CONFIG_NDO 0x200000 /* ND offload configure */
2561 #define WIFI_FEATURE_TX_TRANSMIT_POWER 0x400000 /* Capture Tx transmit power levels */
2562 #define WIFI_FEATURE_CONTROL_ROAMING 0x800000 /* Enable/Disable firmware roaming */
2563 #define WIFI_FEATURE_FILTER_IE 0x1000000 /* Probe req ie filter */
2564 #define WIFI_FEATURE_SCAN_RAND 0x2000000 /* MAC & Prb SN randomization */
2565 #define WIFI_FEATURE_SET_TX_POWER_LIMIT 0x4000000 /* Support Tx Power Limit setting */
2566 #define WIFI_FEATURE_USE_BODY_HEAD_SAR 0x8000000 /* Support Body/Head Proximity SAR */
2567 #define WIFI_FEATURE_SET_LATENCY_MODE 0x40000000 /* Support Latency mode setting */
2568 #define WIFI_FEATURE_P2P_RAND_MAC 0x80000000 /* Support P2P MAC randomization */
2569 #define WIFI_FEATURE_INVALID 0xFFFFFFFF /* Invalid Feature */
2570
2571 #define MAX_FEATURE_SET_CONCURRRENT_GROUPS 3
2572
2573 #if defined(linux) || defined(LINUX) || defined(OEM_ANDROID)
2574 extern int dhd_dev_get_feature_set(struct net_device *dev);
2575 extern int dhd_dev_get_feature_set_matrix(struct net_device *dev, int num);
2576 extern int dhd_dev_cfg_rand_mac_oui(struct net_device *dev, uint8 *oui);
2577 extern int dhd_update_rand_mac_addr(dhd_pub_t *dhd);
2578 #ifdef CUSTOM_FORCE_NODFS_FLAG
2579 extern int dhd_dev_set_nodfs(struct net_device *dev, uint nodfs);
2580 #endif /* CUSTOM_FORCE_NODFS_FLAG */
2581 #ifdef NDO_CONFIG_SUPPORT
2582 #ifndef NDO_MAX_HOST_IP_ENTRIES
2583 #define NDO_MAX_HOST_IP_ENTRIES 10
2584 #endif /* NDO_MAX_HOST_IP_ENTRIES */
2585
2586 extern int dhd_dev_ndo_cfg(struct net_device *dev, u8 enable);
2587 extern int dhd_dev_ndo_update_inet6addr(struct net_device * dev);
2588 #endif /* NDO_CONFIG_SUPPORT */
2589 #endif /* (linux) || (LINUX) || (OEM_ANDROID) */
2590 extern int dhd_set_rand_mac_oui(dhd_pub_t *dhd);
2591 #ifdef GSCAN_SUPPORT
2592 extern int dhd_dev_set_lazy_roam_cfg(struct net_device *dev,
2593 wlc_roam_exp_params_t *roam_param);
2594 extern int dhd_dev_lazy_roam_enable(struct net_device *dev, uint32 enable);
2595 extern int dhd_dev_set_lazy_roam_bssid_pref(struct net_device *dev,
2596 wl_bssid_pref_cfg_t *bssid_pref, uint32 flush);
2597 #endif /* GSCAN_SUPPORT */
2598 #if defined(GSCAN_SUPPORT) || defined(ROAMEXP_SUPPORT)
2599 extern int dhd_dev_set_blacklist_bssid(struct net_device *dev, maclist_t *blacklist,
2600 uint32 len, uint32 flush);
2601 extern int dhd_dev_set_whitelist_ssid(struct net_device *dev, wl_ssid_whitelist_t *whitelist,
2602 uint32 len, uint32 flush);
2603 #endif /* GSCAN_SUPPORT || ROAMEXP_SUPPORT */
2604
2605 /* OS independent layer functions */
2606 extern void dhd_os_dhdiovar_lock(dhd_pub_t *pub);
2607 extern void dhd_os_dhdiovar_unlock(dhd_pub_t *pub);
2608 void dhd_os_logdump_lock(dhd_pub_t *pub);
2609 void dhd_os_logdump_unlock(dhd_pub_t *pub);
2610 extern int dhd_os_proto_block(dhd_pub_t * pub);
2611 extern int dhd_os_proto_unblock(dhd_pub_t * pub);
2612 extern int dhd_os_ioctl_resp_wait(dhd_pub_t * pub, uint * condition);
2613 extern int dhd_os_ioctl_resp_wake(dhd_pub_t * pub);
2614 extern unsigned int dhd_os_get_ioctl_resp_timeout(void);
2615 extern void dhd_os_set_ioctl_resp_timeout(unsigned int timeout_msec);
2616 extern void dhd_os_ioctl_resp_lock(dhd_pub_t * pub);
2617 extern void dhd_os_ioctl_resp_unlock(dhd_pub_t * pub);
2618 #ifdef PCIE_FULL_DONGLE
2619 extern void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason);
2620 #else
dhd_wakeup_ioctl_event(dhd_pub_t * pub,dhd_ioctl_recieved_status_t reason)2621 static INLINE void dhd_wakeup_ioctl_event(dhd_pub_t *pub, dhd_ioctl_recieved_status_t reason)
2622 { printf("%s is NOT implemented for SDIO", __FUNCTION__); return; }
2623 #endif
2624 #ifdef SHOW_LOGTRACE
2625 /* Bound and delay are fine tuned after several experiments and these
2626 * are the best case values to handle bombarding of console logs.
2627 */
2628 #define DHD_EVENT_LOGTRACE_BOUND 10u
2629 #define DHD_EVENT_LOGTRACE_RESCHEDULE_DELAY_MS 10u
2630 extern int dhd_os_read_file(void *file, char *buf, uint32 size);
2631 extern int dhd_os_seek_file(void *file, int64 offset);
2632 #endif /* SHOW_LOGTRACE */
2633 int dhd_os_write_file_posn(void *fp, unsigned long *posn,
2634 void *buf, unsigned long buflen);
2635 int dhd_msix_message_set(dhd_pub_t *dhdp, uint table_entry,
2636 uint message_number, bool unmask);
2637
2638 #if defined(DHD_EFI)
2639 void dhd_os_set_intr_poll_period(struct dhd_bus *bus, unsigned int period_us);
2640 unsigned int dhd_os_get_intr_poll_period(void);
2641 int dhd_intr_poll(struct dhd_bus *bus, char *arg, int len, int set);
2642 #define INTR_POLL_PERIOD_CRITICAL 100 /* 100us -- in us */
2643 #define INTR_POLL_NPKTS_THRESH 1
2644 #define INTR_POLL_PKT_INTERVAL_THRESH 2000000 /* 2000ms -- in us */
2645 #if defined(DHD_INTR_POLL_PERIOD_DYNAMIC)
2646 void dhd_intr_poll_pkt_thresholds(dhd_pub_t *dhd);
2647 #endif /* DHD_INTR_POLL_PERIOD_DYNAMIC */
2648 #endif /* DHD_EFI && DHD_INTR_POLL_PERIOD_DYNAMIC */
2649
2650 extern void
2651 dhd_pcie_dump_core_regs(dhd_pub_t * pub, uint32 index, uint32 first_addr, uint32 last_addr);
2652 extern void wl_dhdpcie_dump_regs(void * context);
2653
2654 #define DHD_OS_IOCTL_RESP_LOCK(x)
2655 #define DHD_OS_IOCTL_RESP_UNLOCK(x)
2656
2657 #if defined(NDIS)
2658 #define dhd_os_open_image(a) wl_os_open_image(a)
2659 #define dhd_os_close_image(a) wl_os_close_image(a)
2660 #define dhd_os_get_image_block(a, b, c) wl_os_get_image_block(a, b, c)
2661 #define dhd_os_get_image_size(a) wl_os_get_image_size(a)
2662 extern void dhd_os_wakeind(dhd_pub_t * pub, uint32 *val);
2663 extern void dhd_bus_check_died(void *bus);
2664 extern void pci_save_state(osl_t *osh, uint32 *buffer);
2665 extern void pci_restore_state(osl_t *osh, uint32 *buffer);
2666 #endif /* #if defined(NDIS) */
2667
2668 extern int dhd_os_get_image_block(char * buf, int len, void * image);
2669 extern int dhd_os_get_image_size(void * image);
2670 #if defined(BT_OVER_SDIO)
2671 extern int dhd_os_gets_image(dhd_pub_t *pub, char *str, int len, void *image);
2672 extern void dhdsdio_bus_usr_cnt_inc(dhd_pub_t *pub);
2673 extern void dhdsdio_bus_usr_cnt_dec(dhd_pub_t *pub);
2674 #endif /* (BT_OVER_SDIO) */
2675 extern void *dhd_os_open_image1(dhd_pub_t *pub, char *filename); /* rev1 function signature */
2676 extern void dhd_os_close_image1(dhd_pub_t *pub, void *image);
2677 extern void dhd_os_wd_timer(void *bus, uint wdtick);
2678 #ifdef DHD_PCIE_RUNTIMEPM
2679 extern void dhd_os_runtimepm_timer(void *bus, uint tick);
2680 #endif /* DHD_PCIE_RUNTIMEPM */
2681 extern void dhd_os_sdlock(dhd_pub_t * pub);
2682 extern void dhd_os_sdunlock(dhd_pub_t * pub);
2683 extern void dhd_os_sdlock_txq(dhd_pub_t * pub);
2684 extern void dhd_os_sdunlock_txq(dhd_pub_t * pub);
2685 extern unsigned long dhd_os_sdlock_txoff(dhd_pub_t * pub);
2686 extern void dhd_os_sdunlock_txoff(dhd_pub_t * pub, unsigned long flags);
2687 extern void dhd_os_sdlock_rxq(dhd_pub_t * pub);
2688 extern void dhd_os_sdunlock_rxq(dhd_pub_t * pub);
2689 extern void dhd_os_sdlock_sndup_rxq(dhd_pub_t * pub);
2690 extern void dhd_os_tracelog(const char *format, ...);
2691 #ifdef DHDTCPACK_SUPPRESS
2692 extern unsigned long dhd_os_tcpacklock(dhd_pub_t *pub);
2693 extern void dhd_os_tcpackunlock(dhd_pub_t *pub, unsigned long flags);
2694 #endif /* DHDTCPACK_SUPPRESS */
2695
2696 extern int dhd_customer_oob_irq_map(void *adapter, unsigned long *irq_flags_ptr);
2697 extern int dhd_customer_gpio_wlan_ctrl(void *adapter, int onoff);
2698 extern int dhd_custom_get_mac_address(void *adapter, unsigned char *buf);
2699 #if defined(CUSTOM_COUNTRY_CODE)
2700 extern void get_customized_country_code(void *adapter, char *country_iso_code,
2701 wl_country_t *cspec, u32 flags);
2702 #else
2703 extern void get_customized_country_code(void *adapter, char *country_iso_code, wl_country_t *cspec);
2704 #endif /* CUSTOM_COUNTRY_CODE */
2705 extern void dhd_os_sdunlock_sndup_rxq(dhd_pub_t * pub);
2706 extern void dhd_os_sdlock_eventq(dhd_pub_t * pub);
2707 extern void dhd_os_sdunlock_eventq(dhd_pub_t * pub);
2708 extern bool dhd_os_check_hang(dhd_pub_t *dhdp, int ifidx, int ret);
2709 extern int dhd_os_send_hang_message(dhd_pub_t *dhdp);
2710 extern void dhd_set_version_info(dhd_pub_t *pub, char *fw);
2711 extern bool dhd_os_check_if_up(dhd_pub_t *pub);
2712 extern int dhd_os_check_wakelock(dhd_pub_t *pub);
2713 extern int dhd_os_check_wakelock_all(dhd_pub_t *pub);
2714 extern int dhd_get_instance(dhd_pub_t *pub);
2715 #ifdef CUSTOM_SET_CPUCORE
2716 extern void dhd_set_cpucore(dhd_pub_t *dhd, int set);
2717 #endif /* CUSTOM_SET_CPUCORE */
2718
2719 #if defined(KEEP_ALIVE)
2720 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
2721 #endif /* KEEP_ALIVE */
2722
2723 #if defined(DHD_FW_COREDUMP)
2724 void dhd_schedule_memdump(dhd_pub_t *dhdp, uint8 *buf, uint32 size);
2725 #endif /* DHD_FW_COREDUMP */
2726
2727 #if defined(linux) || defined(LINUX)
2728 int dhd_os_get_img_fwreq(const struct firmware **fw, char *file_path);
2729 void dhd_os_close_img_fwreq(const struct firmware *fw);
2730 #if defined(DHD_SSSR_DUMP)
2731 void dhd_write_sssr_dump(dhd_pub_t *dhdp, uint32 dump_mode);
2732 #endif /* DHD_SSSR_DUMP */
2733 #ifdef DNGL_AXI_ERROR_LOGGING
2734 void dhd_schedule_axi_error_dump(dhd_pub_t *dhdp, void *type);
2735 #endif /* DNGL_AXI_ERROR_LOGGING */
2736 #ifdef BCMPCIE
2737 void dhd_schedule_cto_recovery(dhd_pub_t *dhdp);
2738 #endif /* BCMPCIE */
2739 #else
2740 #if defined(DHD_SSSR_DUMP)
dhd_write_sssr_dump(dhd_pub_t * dhd,uint32 dump_mode)2741 static INLINE void dhd_write_sssr_dump(dhd_pub_t *dhd, uint32 dump_mode) { return; }
2742 #endif /* DHD_SSSR_DUMP */
2743 #ifdef DNGL_AXI_ERROR_LOGGING
dhd_schedule_axi_error_dump(dhd_pub_t * dhdp,void * type)2744 static INLINE void dhd_schedule_axi_error_dump(dhd_pub_t *dhdp, void *type) { return; }
2745 #endif /* DNGL_AXI_ERROR_LOGGING */
2746 /* For non-linux map dhd_schedule_cto_recovery to dhdpcie_cto_recovery_handler */
2747 #ifdef BCMPCIE
2748 #define dhd_schedule_cto_recovery(dhdp) dhdpcie_cto_recovery_handler(dhdp)
2749 #endif /* BCMPCIE */
2750 #endif /* linux || LINUX */
2751
2752 #ifdef EWP_EDL
2753 #define EDL_SCHEDULE_DELAY 500 /* 500ms */
2754 #if defined(linux) || defined(LINUX)
2755 void dhd_schedule_edl_work(dhd_pub_t *dhdp, uint delay_ms);
2756 #else
dhd_schedule_edl_work(dhd_pub_t * dhd,uint delay_ms)2757 static INLINE void dhd_schedule_edl_work(dhd_pub_t *dhd, uint delay_ms) { return; }
2758 #endif /* linux || LINUX */
2759 #endif /* EWP_EDL */
2760
2761 #ifdef SUPPORT_AP_POWERSAVE
2762 extern int dhd_set_ap_powersave(dhd_pub_t *dhdp, int ifidx, int enable);
2763 #endif /* SUPPORT_AP_POWERSAVE */
2764
2765 #ifdef PKT_FILTER_SUPPORT
2766 #define DHD_UNICAST_FILTER_NUM 0
2767 #define DHD_BROADCAST_FILTER_NUM 1
2768 #define DHD_MULTICAST4_FILTER_NUM 2
2769 #define DHD_MULTICAST6_FILTER_NUM 3
2770 #define DHD_MDNS_FILTER_NUM 4
2771 #define DHD_ARP_FILTER_NUM 5
2772 #define DHD_BROADCAST_ARP_FILTER_NUM 6
2773 #define DHD_IP4BCAST_DROP_FILTER_NUM 7
2774 #define DHD_LLC_STP_DROP_FILTER_NUM 8
2775 #define DHD_LLC_XID_DROP_FILTER_NUM 9
2776 #define DHD_UDPNETBIOS_DROP_FILTER_NUM 10
2777 #define DISCARD_IPV4_MCAST "102 1 6 IP4_H:16 0xf0 0xe0"
2778 #define DISCARD_IPV6_MCAST "103 1 6 IP6_H:24 0xff 0xff"
2779 #define DISCARD_IPV4_BCAST "107 1 6 IP4_H:16 0xffffffff 0xffffffff"
2780 #define DISCARD_LLC_STP "108 1 6 ETH_H:14 0xFFFFFFFFFFFF 0xAAAA0300000C"
2781 #define DISCARD_LLC_XID "109 1 6 ETH_H:14 0xFFFFFF 0x0001AF"
2782 #define DISCARD_UDPNETBIOS "110 1 6 UDP_H:2 0xffff 0x0089"
2783 extern int dhd_os_enable_packet_filter(dhd_pub_t *dhdp, int val);
2784 extern void dhd_enable_packet_filter(int value, dhd_pub_t *dhd);
2785 extern int dhd_packet_filter_add_remove(dhd_pub_t *dhdp, int add_remove, int num);
2786 extern int net_os_enable_packet_filter(struct net_device *dev, int val);
2787 extern int net_os_rxfilter_add_remove(struct net_device *dev, int val, int num);
2788 extern int net_os_set_suspend_bcn_li_dtim(struct net_device *dev, int val);
2789
2790 #define MAX_PKTFLT_BUF_SIZE 2048
2791 #define MAX_PKTFLT_FIXED_PATTERN_SIZE 32
2792 #define MAX_PKTFLT_FIXED_BUF_SIZE \
2793 (WL_PKT_FILTER_FIXED_LEN + MAX_PKTFLT_FIXED_PATTERN_SIZE * 2)
2794 #define MAXPKT_ARG 16
2795 #endif /* PKT_FILTER_SUPPORT */
2796
2797 #if defined(OEM_ANDROID) && defined(BCMPCIE)
2798 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd, int *dtim_period, int *bcn_interval);
2799 #else
2800 extern int dhd_get_suspend_bcn_li_dtim(dhd_pub_t *dhd);
2801 #endif /* OEM_ANDROID && BCMPCIE */
2802
2803 extern bool dhd_support_sta_mode(dhd_pub_t *dhd);
2804 extern int write_to_file(dhd_pub_t *dhd, uint8 *buf, int size);
2805
2806 #ifdef RSSI_MONITOR_SUPPORT
2807 extern int dhd_dev_set_rssi_monitor_cfg(struct net_device *dev, int start,
2808 int8 max_rssi, int8 min_rssi);
2809 #endif /* RSSI_MONITOR_SUPPORT */
2810
2811 #ifdef DHDTCPACK_SUPPRESS
2812 int dhd_dev_set_tcpack_sup_mode_cfg(struct net_device *dev, uint8 enable);
2813 #endif /* DHDTCPACK_SUPPRESS */
2814
2815 #define DHD_RSSI_MONITOR_EVT_VERSION 1
2816 typedef struct {
2817 uint8 version;
2818 int8 cur_rssi;
2819 struct ether_addr BSSID;
2820 } dhd_rssi_monitor_evt_t;
2821
2822 typedef struct {
2823 uint32 limit; /* Expiration time (usec) */
2824 uint32 increment; /* Current expiration increment (usec) */
2825 uint32 elapsed; /* Current elapsed time (usec) */
2826 uint32 tick; /* O/S tick time (usec) */
2827 } dhd_timeout_t;
2828
2829 #ifdef SHOW_LOGTRACE
2830 typedef struct {
2831 uint num_fmts;
2832 char **fmts;
2833 char *raw_fmts;
2834 char *raw_sstr;
2835 uint32 fmts_size;
2836 uint32 raw_fmts_size;
2837 uint32 raw_sstr_size;
2838 uint32 ramstart;
2839 uint32 rodata_start;
2840 uint32 rodata_end;
2841 char *rom_raw_sstr;
2842 uint32 rom_raw_sstr_size;
2843 uint32 rom_ramstart;
2844 uint32 rom_rodata_start;
2845 uint32 rom_rodata_end;
2846 } dhd_event_log_t;
2847 #endif /* SHOW_LOGTRACE */
2848
2849 #if defined(PKT_FILTER_SUPPORT) && defined(APF)
2850 /*
2851 * As per Google's current implementation, there will be only one APF filter.
2852 * Therefore, userspace doesn't bother about filter id and because of that
2853 * DHD has to manage the filter id.
2854 */
2855 #define PKT_FILTER_APF_ID 200
2856 #define DHD_APF_LOCK(ndev) dhd_apf_lock(ndev)
2857 #define DHD_APF_UNLOCK(ndev) dhd_apf_unlock(ndev)
2858
2859 extern void dhd_apf_lock(struct net_device *dev);
2860 extern void dhd_apf_unlock(struct net_device *dev);
2861 extern int dhd_dev_apf_get_version(struct net_device *ndev, uint32 *version);
2862 extern int dhd_dev_apf_get_max_len(struct net_device *ndev, uint32 *max_len);
2863 extern int dhd_dev_apf_add_filter(struct net_device *ndev, u8* program,
2864 uint32 program_len);
2865 extern int dhd_dev_apf_enable_filter(struct net_device *ndev);
2866 extern int dhd_dev_apf_disable_filter(struct net_device *ndev);
2867 extern int dhd_dev_apf_delete_filter(struct net_device *ndev);
2868 #endif /* PKT_FILTER_SUPPORT && APF */
2869
2870 extern void dhd_timeout_start(dhd_timeout_t *tmo, uint usec);
2871 extern int dhd_timeout_expired(dhd_timeout_t *tmo);
2872
2873 extern int dhd_ifname2idx(struct dhd_info *dhd, char *name);
2874 #ifdef LINUX
2875 extern int dhd_net2idx(struct dhd_info *dhd, struct net_device *net);
2876 extern struct net_device * dhd_idx2net(void *pub, int ifidx);
2877 extern int net_os_send_hang_message(struct net_device *dev);
2878 extern int net_os_send_hang_message_reason(struct net_device *dev, const char *string_num);
2879 #endif
2880 extern bool dhd_wowl_cap(void *bus);
2881 extern int wl_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
2882 wl_event_msg_t *, void **data_ptr, void *);
2883 extern int wl_process_host_event(dhd_pub_t *dhd_pub, int *idx, void *pktdata, uint pktlen,
2884 wl_event_msg_t *, void **data_ptr, void *);
2885 extern void wl_event_to_host_order(wl_event_msg_t * evt);
2886 extern int wl_host_event_get_data(void *pktdata, uint pktlen, bcm_event_msg_u_t *evu);
2887 extern int dhd_wl_ioctl(dhd_pub_t *dhd_pub, int ifindex, wl_ioctl_t *ioc, void *buf, int len);
2888 extern int dhd_wl_ioctl_cmd(dhd_pub_t *dhd_pub, int cmd, void *arg, int len, uint8 set,
2889 int ifindex);
2890 extern int dhd_wl_ioctl_get_intiovar(dhd_pub_t *dhd_pub, char *name, uint *pval,
2891 int cmd, uint8 set, int ifidx);
2892 extern int dhd_wl_ioctl_set_intiovar(dhd_pub_t *dhd_pub, char *name, uint val,
2893 int cmd, uint8 set, int ifidx);
2894 extern void dhd_common_init(osl_t *osh);
2895
2896 #if defined(linux) || defined(LINUX) || defined(OEM_ANDROID)
2897 extern int dhd_do_driver_init(struct net_device *net);
2898 #endif
2899 extern int dhd_event_ifadd(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
2900 char *name, uint8 *mac);
2901 extern int dhd_event_ifdel(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
2902 char *name, uint8 *mac);
2903 extern int dhd_event_ifchange(struct dhd_info *dhd, struct wl_event_data_if *ifevent,
2904 char *name, uint8 *mac);
2905 #ifdef DHD_UPDATE_INTF_MAC
2906 extern int dhd_op_if_update(dhd_pub_t *dhdpub, int ifidx);
2907 #endif /* DHD_UPDATE_INTF_MAC */
2908 extern struct net_device* dhd_allocate_if(dhd_pub_t *dhdpub, int ifidx, const char *name,
2909 uint8 *mac, uint8 bssidx, bool need_rtnl_lock, const char *dngl_name);
2910 extern int dhd_remove_if(dhd_pub_t *dhdpub, int ifidx, bool need_rtnl_lock);
2911 #ifdef WL_STATIC_IF
2912 extern s32 dhd_update_iflist_info(dhd_pub_t *dhdp, struct net_device *ndev, int ifidx,
2913 uint8 *mac, uint8 bssidx, const char *dngl_name, int if_state);
2914 #endif /* WL_STATIC_IF */
2915 extern void dhd_vif_add(struct dhd_info *dhd, int ifidx, char * name);
2916 extern void dhd_vif_del(struct dhd_info *dhd, int ifidx);
2917 extern void dhd_event(struct dhd_info *dhd, char *evpkt, int evlen, int ifidx);
2918 extern void dhd_vif_sendup(struct dhd_info *dhd, int ifidx, uchar *cp, int len);
2919
2920 #ifdef WL_NATOE
2921 extern int dhd_natoe_ct_event(dhd_pub_t *dhd, char *data);
2922 #endif /* WL_NATOE */
2923
2924 /* Send packet to dongle via data channel */
2925 extern int dhd_sendpkt(dhd_pub_t *dhdp, int ifidx, void *pkt);
2926
2927 /* send up locally generated event */
2928 extern void dhd_sendup_event_common(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
2929 /* Send event to host */
2930 extern void dhd_sendup_event(dhd_pub_t *dhdp, wl_event_msg_t *event, void *data);
2931 #ifdef LOG_INTO_TCPDUMP
2932 extern void dhd_sendup_log(dhd_pub_t *dhdp, void *data, int len);
2933 #endif /* LOG_INTO_TCPDUMP */
2934 #if defined(SHOW_LOGTRACE) && defined(EWP_EDL)
2935 void dhd_sendup_info_buf(dhd_pub_t *dhdp, uint8 *msg);
2936 #endif
2937 #if defined(WIFI_TURNON_USE_HALINIT)
2938 extern int dhd_open(struct net_device *net);
2939 #endif /* WIFI_TURNON_USE_HALINIT */
2940 extern int dhd_bus_devreset(dhd_pub_t *dhdp, uint8 flag);
2941 extern uint dhd_bus_status(dhd_pub_t *dhdp);
2942 extern int dhd_bus_start(dhd_pub_t *dhdp);
2943 extern int dhd_bus_suspend(dhd_pub_t *dhdpub);
2944 extern int dhd_bus_resume(dhd_pub_t *dhdpub, int stage);
2945 extern int dhd_bus_membytes(dhd_pub_t *dhdp, bool set, uint32 address, uint8 *data, uint size);
2946 extern void dhd_print_buf(void *pbuf, int len, int bytes_per_line);
2947 extern bool dhd_is_associated(dhd_pub_t *dhd, uint8 ifidx, int *retval);
2948 #if defined(BCMSDIO) || defined(BCMPCIE)
2949 extern uint dhd_bus_chip_id(dhd_pub_t *dhdp);
2950 extern uint dhd_bus_chiprev_id(dhd_pub_t *dhdp);
2951 extern uint dhd_bus_chippkg_id(dhd_pub_t *dhdp);
2952 #endif /* defined(BCMSDIO) || defined(BCMPCIE) */
2953 #if defined(LINUX) || defined(linux)
2954 int dhd_bus_get_fw_mode(dhd_pub_t *dhdp);
2955 #else
dhd_bus_get_fw_mode(dhd_pub_t * dhdp)2956 static INLINE int dhd_bus_get_fw_mode(dhd_pub_t *dhdp) { return 0; }
2957 #endif /* LINUX || linux */
2958
2959 #if defined(KEEP_ALIVE)
2960 extern int dhd_keep_alive_onoff(dhd_pub_t *dhd);
2961 #endif /* KEEP_ALIVE */
2962
2963 /* linux is defined for DHD EFI builds also,
2964 * since its cross-compiled for EFI from linux.
2965 * dbgring_lock apis are meant only for linux
2966 * to use mutexes, other OSes will continue to
2967 * use osl_spin_lock
2968 */
2969 #if (defined(LINUX) || defined(linux)) && !defined(DHD_EFI)
2970 void *dhd_os_dbgring_lock_init(osl_t *osh);
2971 void dhd_os_dbgring_lock_deinit(osl_t *osh, void *mtx);
2972 unsigned long dhd_os_dbgring_lock(void *lock);
2973 void dhd_os_dbgring_unlock(void *lock, unsigned long flags);
2974 #endif /* (LINUX || linux) && !DHD_EFI */
2975
2976 #ifdef PCIE_INB_DW
2977 #ifdef DHD_EFI
2978 extern int dhd_os_ds_enter_wait(dhd_pub_t * pub, uint * condition);
2979 extern int dhd_os_ds_enter_wake(dhd_pub_t * pub);
2980 #else
dhd_os_ds_enter_wait(dhd_pub_t * pub,uint * condition)2981 static INLINE int dhd_os_ds_enter_wait(dhd_pub_t * pub, uint * condition)
2982 { return 1; }
dhd_os_ds_enter_wake(dhd_pub_t * pub)2983 static INLINE int dhd_os_ds_enter_wake(dhd_pub_t * pub)
2984 { return 0; }
2985 #endif /* DHD_EFI */
2986 #endif /* PCIE_INB_DW */
2987
2988 #if defined(LINUX) || defined(linux) || defined(DHD_EFI)
2989 extern int dhd_os_busbusy_wait_negation(dhd_pub_t * pub, uint * condition);
2990 extern int dhd_os_busbusy_wake(dhd_pub_t * pub);
2991 extern void dhd_os_tx_completion_wake(dhd_pub_t *dhd);
2992 extern int dhd_os_busbusy_wait_condition(dhd_pub_t *pub, uint *var, uint condition);
2993 extern int dhd_os_d3ack_wait(dhd_pub_t * pub, uint * condition);
2994 extern int dhd_os_d3ack_wake(dhd_pub_t * pub);
2995 extern int dhd_os_dmaxfer_wait(dhd_pub_t *pub, uint *condition);
2996 extern int dhd_os_dmaxfer_wake(dhd_pub_t *pub);
2997 int dhd_os_busbusy_wait_bitmask(dhd_pub_t *pub, uint *var,
2998 uint bitmask, uint condition);
2999 #ifdef PCIE_INB_DW
3000 extern int dhd_os_ds_exit_wait(dhd_pub_t * pub, uint * condition);
3001 extern int dhd_os_ds_exit_wake(dhd_pub_t * pub);
3002 #endif /* PCIE_INB_DW */
3003 int dhd_os_tput_test_wait(dhd_pub_t *pub, uint *condition, uint timeout_ms);
3004 int dhd_os_tput_test_wake(dhd_pub_t * pub);
3005 #else
dhd_os_tput_test_wait(dhd_pub_t * pub,uint * condition,uint timeout_ms)3006 static INLINE int dhd_os_tput_test_wait(dhd_pub_t *pub, uint *condition,
3007 uint timeout_ms)
3008 { return 0; }
dhd_os_tput_test_wake(dhd_pub_t * pub)3009 static INLINE int dhd_os_tput_test_wake(dhd_pub_t * pub)
3010 { return 0; }
dhd_os_d3ack_wait(dhd_pub_t * pub,uint * condition)3011 static INLINE int dhd_os_d3ack_wait(dhd_pub_t * pub, uint * condition)
3012 { return dhd_os_ioctl_resp_wait(pub, condition); }
dhd_os_d3ack_wake(dhd_pub_t * pub)3013 static INLINE int dhd_os_d3ack_wake(dhd_pub_t * pub)
3014 { return dhd_os_ioctl_resp_wake(pub); }
3015 #ifdef PCIE_INB_DW
dhd_os_ds_exit_wait(dhd_pub_t * pub,uint * condition)3016 static INLINE int dhd_os_ds_exit_wait(dhd_pub_t * pub, uint * condition)
3017 { DHD_ERROR(("%s is Not supported for this platform", __FUNCTION__)); return 0; }
dhd_os_ds_exit_wake(dhd_pub_t * pub)3018 static INLINE int dhd_os_ds_exit_wake(dhd_pub_t * pub)
3019 { DHD_ERROR(("%s is Not supported for this platform", __FUNCTION__)); return 0; }
3020 #endif /* PCIE_INB_DW */
dhd_os_busbusy_wait_negation(dhd_pub_t * pub,uint * condition)3021 static INLINE int dhd_os_busbusy_wait_negation(dhd_pub_t * pub, uint * condition)
3022 { return 1; }
dhd_os_busbusy_wake(dhd_pub_t * pub)3023 static INLINE int dhd_os_busbusy_wake(dhd_pub_t * pub)
3024 { return 0; }
dhd_os_busbusy_wait_condition(dhd_pub_t * pub,uint * var,uint condition)3025 static INLINE int dhd_os_busbusy_wait_condition(dhd_pub_t *pub, uint *var, uint condition)
3026 { return 0; }
dhd_os_dmaxfer_wait(dhd_pub_t * pub,uint * condition)3027 static INLINE int dhd_os_dmaxfer_wait(dhd_pub_t *pub, uint *condition)
3028 { return 0; }
dhd_os_dmaxfer_wake(dhd_pub_t * pub)3029 static INLINE int dhd_os_dmaxfer_wake(dhd_pub_t *pub)
3030 { return 0; }
dhd_os_busbusy_wait_bitmask(dhd_pub_t * pub,uint * var,uint bitmask,uint condition)3031 static INLINE int dhd_os_busbusy_wait_bitmask(dhd_pub_t *pub, uint *var,
3032 uint bitmask, uint condition)
3033 { return 0; }
3034 #endif /* LINUX || DHD_EFI */
3035
3036 #if defined(LINUX) || defined(linux)
3037 /*
3038 * Manage sta objects in an interface. Interface is identified by an ifindex and
3039 * sta(s) within an interfaces are managed using a MacAddress of the sta.
3040 */
3041 struct dhd_sta;
3042 extern bool dhd_sta_associated(dhd_pub_t *dhdp, uint32 bssidx, uint8 *mac);
3043 extern struct dhd_sta *dhd_find_sta(void *pub, int ifidx, void *ea);
3044 extern struct dhd_sta *dhd_findadd_sta(void *pub, int ifidx, void *ea);
3045 extern void dhd_del_all_sta(void *pub, int ifidx);
3046 extern void dhd_del_sta(void *pub, int ifidx, void *ea);
3047 extern int dhd_get_ap_isolate(dhd_pub_t *dhdp, uint32 idx);
3048 extern int dhd_set_ap_isolate(dhd_pub_t *dhdp, uint32 idx, int val);
3049 extern int dhd_bssidx2idx(dhd_pub_t *dhdp, uint32 bssidx);
3050 extern struct net_device *dhd_linux_get_primary_netdev(dhd_pub_t *dhdp);
3051 #else /* LINUX */
dhd_sta_associated(dhd_pub_t * dhdp,uint32 bssidx,uint8 * mac)3052 static INLINE bool dhd_sta_associated(dhd_pub_t *dhdp, uint32 bssidx, uint8 *mac)
3053 { return FALSE;}
dhd_find_sta(void * pub,int ifidx,void * ea)3054 static INLINE void* dhd_find_sta(void *pub, int ifidx, void *ea) { return NULL;}
dhd_findadd_sta(void * pub,int ifidx,void * ea)3055 static INLINE void *dhd_findadd_sta(void *pub, int ifidx, void *ea) { return NULL; }
dhd_del_all_sta(void * pub,int ifidx)3056 static INLINE void dhd_del_all_sta(void *pub, int ifidx) { }
dhd_del_sta(void * pub,int ifidx,void * ea)3057 static INLINE void dhd_del_sta(void *pub, int ifidx, void *ea) { }
dhd_get_ap_isolate(dhd_pub_t * dhdp,uint32 idx)3058 static INLINE int dhd_get_ap_isolate(dhd_pub_t *dhdp, uint32 idx) { return 0; }
dhd_set_ap_isolate(dhd_pub_t * dhdp,uint32 idx,int val)3059 static INLINE int dhd_set_ap_isolate(dhd_pub_t *dhdp, uint32 idx, int val) { return 0; }
dhd_bssidx2idx(dhd_pub_t * dhdp,uint32 bssidx)3060 static INLINE int dhd_bssidx2idx(dhd_pub_t *dhdp, uint32 bssidx) { return 0; }
3061 #endif /* LINUX */
3062
3063 extern bool dhd_is_concurrent_mode(dhd_pub_t *dhd);
3064 int dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *param_buf, uint param_len,
3065 char *res_buf, uint res_len, bool set);
3066 extern int dhd_getiovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf,
3067 uint cmd_len, char **resptr, uint resp_len);
3068
3069 #ifdef DHD_MCAST_REGEN
3070 extern int dhd_get_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx);
3071 extern int dhd_set_mcast_regen_bss_enable(dhd_pub_t *dhdp, uint32 idx, int val);
3072 #endif
3073 typedef enum cust_gpio_modes {
3074 WLAN_RESET_ON,
3075 WLAN_RESET_OFF,
3076 WLAN_POWER_ON,
3077 WLAN_POWER_OFF
3078 } cust_gpio_modes_t;
3079
3080 typedef struct dmaxref_mem_map {
3081 dhd_dma_buf_t *srcmem;
3082 dhd_dma_buf_t *dstmem;
3083 } dmaxref_mem_map_t;
3084
3085 #if defined(OEM_ANDROID)
3086 extern int wl_iw_iscan_set_scan_broadcast_prep(struct net_device *dev, uint flag);
3087 extern int wl_iw_send_priv_event(struct net_device *dev, char *flag);
3088 #endif /* defined(OEM_ANDROID) */
3089
3090 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
3091 extern void dhd_flush_rx_tx_wq(dhd_pub_t *dhdp);
3092 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
3093
3094 /*
3095 * Insmod parameters for debug/test
3096 */
3097
3098 /* Watchdog timer interval */
3099 extern uint dhd_watchdog_ms;
3100 extern bool dhd_os_wd_timer_enabled(void *bus);
3101 #ifdef DHD_PCIE_RUNTIMEPM
3102 extern uint dhd_runtimepm_ms;
3103 #endif /* DHD_PCIE_RUNTIMEPM */
3104
3105 /** Default console output poll interval */
3106 extern uint dhd_console_ms;
3107
3108 extern uint android_msg_level;
3109 extern uint config_msg_level;
3110 extern uint sd_msglevel;
3111 extern uint dump_msg_level;
3112 #ifdef BCMDBUS
3113 extern uint dbus_msglevel;
3114 #endif /* BCMDBUS */
3115 #ifdef WL_WIRELESS_EXT
3116 extern uint iw_msg_level;
3117 #endif
3118 #ifdef WL_CFG80211
3119 extern uint wl_dbg_level;
3120 #endif
3121
3122 extern uint dhd_slpauto;
3123
3124 /* Use interrupts */
3125 extern uint dhd_intr;
3126
3127 /* Use polling */
3128 extern uint dhd_poll;
3129
3130 /* ARP offload agent mode */
3131 extern uint dhd_arp_mode;
3132
3133 /* Pkt filte enable control */
3134 extern uint dhd_pkt_filter_enable;
3135
3136 /* Pkt filter init setup */
3137 extern uint dhd_pkt_filter_init;
3138
3139 /* Pkt filter mode control */
3140 extern uint dhd_master_mode;
3141
3142 /* Roaming mode control */
3143 extern uint dhd_roam_disable;
3144
3145 /* Roaming mode control */
3146 extern uint dhd_radio_up;
3147
3148 /* TCM verification control */
3149 extern uint dhd_tcm_test_enable;
3150
3151 /* Initial idletime ticks (may be -1 for immediate idle, 0 for no idle) */
3152 extern int dhd_idletime;
3153 #ifdef DHD_USE_IDLECOUNT
3154 #define DHD_IDLETIME_TICKS 5
3155 #else
3156 #define DHD_IDLETIME_TICKS 1
3157 #endif /* DHD_USE_IDLECOUNT */
3158
3159 /* SDIO Drive Strength */
3160 extern uint dhd_sdiod_drive_strength;
3161
3162 /* triggers bcm_bprintf to print to kernel log */
3163 extern bool bcm_bprintf_bypass;
3164
3165 /* Override to force tx queueing all the time */
3166 extern uint dhd_force_tx_queueing;
3167
3168 /* Default bcn_timeout value is 4 */
3169 #define DEFAULT_BCN_TIMEOUT_VALUE 4
3170 #ifndef CUSTOM_BCN_TIMEOUT_SETTING
3171 #define CUSTOM_BCN_TIMEOUT_SETTING DEFAULT_BCN_TIMEOUT_VALUE
3172 #endif
3173
3174 /* Default KEEP_ALIVE Period is 55 sec to prevent AP from sending Keep Alive probe frame */
3175 #define DEFAULT_KEEP_ALIVE_VALUE 55000 /* msec */
3176 #ifndef CUSTOM_KEEP_ALIVE_SETTING
3177 #define CUSTOM_KEEP_ALIVE_SETTING DEFAULT_KEEP_ALIVE_VALUE
3178 #endif /* DEFAULT_KEEP_ALIVE_VALUE */
3179
3180 #define NULL_PKT_STR "null_pkt"
3181
3182 /* hooks for custom glom setting option via Makefile */
3183 #define DEFAULT_GLOM_VALUE -1
3184 #ifndef CUSTOM_GLOM_SETTING
3185 #define CUSTOM_GLOM_SETTING DEFAULT_GLOM_VALUE
3186 #endif
3187 #define WL_AUTO_ROAM_TRIGGER -75
3188 /* hooks for custom Roaming Trigger setting via Makefile */
3189 #define DEFAULT_ROAM_TRIGGER_VALUE -75 /* dBm default roam trigger all band */
3190 #define DEFAULT_ROAM_TRIGGER_SETTING -1
3191 #ifndef CUSTOM_ROAM_TRIGGER_SETTING
3192 #define CUSTOM_ROAM_TRIGGER_SETTING DEFAULT_ROAM_TRIGGER_VALUE
3193 #endif
3194
3195 /* hooks for custom Roaming Romaing setting via Makefile */
3196 #define DEFAULT_ROAM_DELTA_VALUE 10 /* dBm default roam delta all band */
3197 #define DEFAULT_ROAM_DELTA_SETTING -1
3198 #ifndef CUSTOM_ROAM_DELTA_SETTING
3199 #define CUSTOM_ROAM_DELTA_SETTING DEFAULT_ROAM_DELTA_VALUE
3200 #endif
3201
3202 /* hooks for custom PNO Event wake lock to guarantee enough time
3203 for the Platform to detect Event before system suspended
3204 */
3205 #define DEFAULT_PNO_EVENT_LOCK_xTIME 2 /* multiplay of DHD_PACKET_TIMEOUT_MS */
3206 #ifndef CUSTOM_PNO_EVENT_LOCK_xTIME
3207 #define CUSTOM_PNO_EVENT_LOCK_xTIME DEFAULT_PNO_EVENT_LOCK_xTIME
3208 #endif
3209 /* hooks for custom dhd_dpc_prio setting option via Makefile */
3210 #define DEFAULT_DHP_DPC_PRIO 1
3211 #ifndef CUSTOM_DPC_PRIO_SETTING
3212 #define CUSTOM_DPC_PRIO_SETTING DEFAULT_DHP_DPC_PRIO
3213 #endif
3214
3215 #ifndef CUSTOM_LISTEN_INTERVAL
3216 #define CUSTOM_LISTEN_INTERVAL LISTEN_INTERVAL
3217 #endif /* CUSTOM_LISTEN_INTERVAL */
3218
3219 #define DEFAULT_SUSPEND_BCN_LI_DTIM 3
3220 #ifndef CUSTOM_SUSPEND_BCN_LI_DTIM
3221 #define CUSTOM_SUSPEND_BCN_LI_DTIM DEFAULT_SUSPEND_BCN_LI_DTIM
3222 #endif
3223
3224 #ifdef OEM_ANDROID
3225 #ifndef BCN_TIMEOUT_IN_SUSPEND
3226 #define BCN_TIMEOUT_IN_SUSPEND 6 /* bcn timeout value in suspend mode */
3227 #endif
3228 #endif /* OEM_ANDROID */
3229
3230 #ifndef CUSTOM_RXF_PRIO_SETTING
3231 #define CUSTOM_RXF_PRIO_SETTING MAX((CUSTOM_DPC_PRIO_SETTING - 1), 1)
3232 #endif
3233
3234 #define DEFAULT_WIFI_TURNOFF_DELAY 0
3235 #ifndef WIFI_TURNOFF_DELAY
3236 #define WIFI_TURNOFF_DELAY DEFAULT_WIFI_TURNOFF_DELAY
3237 #endif /* WIFI_TURNOFF_DELAY */
3238
3239 #define DEFAULT_WIFI_TURNON_DELAY 200
3240 #ifndef WIFI_TURNON_DELAY
3241 #define WIFI_TURNON_DELAY DEFAULT_WIFI_TURNON_DELAY
3242 #endif /* WIFI_TURNON_DELAY */
3243
3244 #ifdef BCMSDIO
3245 #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 10 /* msec */
3246 #else
3247 #define DEFAULT_DHD_WATCHDOG_INTERVAL_MS 0 /* msec */
3248 #endif
3249 #ifndef CUSTOM_DHD_WATCHDOG_MS
3250 #define CUSTOM_DHD_WATCHDOG_MS DEFAULT_DHD_WATCHDOG_INTERVAL_MS
3251 #endif /* DEFAULT_DHD_WATCHDOG_INTERVAL_MS */
3252
3253 #define DHD_INB_DW_DEASSERT_MS 250
3254
3255 #define DEFAULT_ASSOC_RETRY_MAX 3
3256 #ifndef CUSTOM_ASSOC_RETRY_MAX
3257 #define CUSTOM_ASSOC_RETRY_MAX DEFAULT_ASSOC_RETRY_MAX
3258 #endif /* DEFAULT_ASSOC_RETRY_MAX */
3259
3260 #if defined(BCMSDIO) || defined(DISABLE_FRAMEBURST)
3261 #define DEFAULT_FRAMEBURST_SET 0
3262 #else
3263 #define DEFAULT_FRAMEBURST_SET 1
3264 #endif /* BCMSDIO */
3265
3266 #ifndef CUSTOM_FRAMEBURST_SET
3267 #define CUSTOM_FRAMEBURST_SET DEFAULT_FRAMEBURST_SET
3268 #endif /* CUSTOM_FRAMEBURST_SET */
3269
3270 #ifdef WLTDLS
3271 #ifndef CUSTOM_TDLS_IDLE_MODE_SETTING
3272 #define CUSTOM_TDLS_IDLE_MODE_SETTING 60000 /* 60sec to tear down TDLS of not active */
3273 #endif
3274 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_HIGH
3275 #define CUSTOM_TDLS_RSSI_THRESHOLD_HIGH -70 /* rssi threshold for establishing TDLS link */
3276 #endif
3277 #ifndef CUSTOM_TDLS_RSSI_THRESHOLD_LOW
3278 #define CUSTOM_TDLS_RSSI_THRESHOLD_LOW -80 /* rssi threshold for tearing down TDLS link */
3279 #endif
3280 #ifndef CUSTOM_TDLS_PCKTCNT_THRESHOLD_HIGH
3281 #define CUSTOM_TDLS_PCKTCNT_THRESHOLD_HIGH 100 /* pkt/sec threshold for establishing TDLS link */
3282 #endif
3283 #ifndef CUSTOM_TDLS_PCKTCNT_THRESHOLD_LOW
3284 #define CUSTOM_TDLS_PCKTCNT_THRESHOLD_LOW 10 /* pkt/sec threshold for tearing down TDLS link */
3285 #endif
3286 #endif /* WLTDLS */
3287
3288 #if defined(VSDB) || defined(ROAM_ENABLE)
3289 #define DEFAULT_BCN_TIMEOUT 6
3290 #else
3291 #define DEFAULT_BCN_TIMEOUT 4
3292 #endif /* CUSTOMER_HW4 && (VSDB || ROAM_ENABLE) */
3293
3294 #ifndef CUSTOM_BCN_TIMEOUT
3295 #define CUSTOM_BCN_TIMEOUT DEFAULT_BCN_TIMEOUT
3296 #endif
3297
3298 #define DEFAULT_BCN_TIMEOUT_IN_SUSPEND 10
3299 #ifndef CUSTOM_BCN_TIMEOUT_IN_SUSPEND
3300 #define CUSTOM_BCN_TIMEOUT_IN_SUSPEND DEFAULT_BCN_TIMEOUT_IN_SUSPEND
3301 #endif /* CUSTOM_BCN_TIMEOUT_IN_SUSPEND */
3302
3303 #define MAX_DTIM_SKIP_BEACON_INTERVAL 100 /* max allowed associated AP beacon for DTIM skip */
3304 #ifndef MAX_DTIM_ALLOWED_INTERVAL
3305 #define MAX_DTIM_ALLOWED_INTERVAL 600 /* max allowed total beacon interval for DTIM skip */
3306 #endif
3307
3308 #ifdef OEM_ANDROID
3309 #ifndef MIN_DTIM_FOR_ROAM_THRES_EXTEND
3310 #define MIN_DTIM_FOR_ROAM_THRES_EXTEND 600 /* minimum dtim interval to extend roam threshold */
3311 #endif
3312 #endif /* OEM_ANDROID */
3313
3314 #ifdef CONFIG_ROAM_RSSI_LIMIT
3315 extern int dhd_roam_rssi_limit_get(dhd_pub_t *dhd, int *lmt2g, int *lmt5g);
3316 extern int dhd_roam_rssi_limit_set(dhd_pub_t *dhd, int lmt2g, int lmt5g);
3317 #ifndef CUSTOM_ROAMRSSI_2G
3318 #define CUSTOM_ROAMRSSI_2G ROAMRSSI_2G_DEFAULT
3319 #endif /* CUSTOM_ROAMRSSI_2G */
3320 #ifndef CUSTOM_ROAMRSSI_5G
3321 #define CUSTOM_ROAMRSSI_5G ROAMRSSI_5G_DEFAULT
3322 #endif /* CUSTOM_ROAMRSSI_5G */
3323 #endif /* CONFIG_ROAM_RSSI_LIMIT */
3324 #ifdef CONFIG_ROAM_MIN_DELTA
3325 extern int dhd_roam_min_delta_get(dhd_pub_t *dhd, uint32 *dt2g, uint32 *dt5g);
3326 extern int dhd_roam_min_delta_set(dhd_pub_t *dhd, uint32 dt2g, uint32 dt5g);
3327 #ifndef CUSTOM_ROAM_MIN_DELTA
3328 #define CUSTOM_ROAM_MIN_DELTA ROAM_MIN_DELTA_DEFAULT
3329 #endif /* CUSTOM_ROAM_MIN_DELTA */
3330 #endif /* CONFIG_ROAM_MIN_DELTA */
3331
3332 #define NO_DTIM_SKIP 1
3333 #ifdef SDTEST
3334 /* Echo packet generator (SDIO), pkts/s */
3335 extern uint dhd_pktgen;
3336
3337 /* Echo packet len (0 => sawtooth, max 1800) */
3338 extern uint dhd_pktgen_len;
3339 #define MAX_PKTGEN_LEN 1800
3340 #endif
3341
3342 #ifdef BCMSLTGT
3343 /* Account for slow hardware (QT) */
3344 extern uint htclkratio;
3345 extern int dngl_xtalfreq;
3346 #endif
3347
3348 /* optionally set by a module_param_string() */
3349 #define MOD_PARAM_PATHLEN 2048
3350 #define MOD_PARAM_INFOLEN 512
3351 #define MOD_PARAM_SRLEN 64
3352
3353 #ifdef SOFTAP
3354 extern char fw_path2[MOD_PARAM_PATHLEN];
3355 #endif
3356
3357 #if defined(CUSTOMER_HW4)
3358 #define VENDOR_PATH "/vendor"
3359 #else
3360 #define VENDOR_PATH ""
3361 #endif /* CUSTOMER_HW4 */
3362
3363 /* Platform path Name -
3364 * Used to find out where to find the FW debug support files.
3365 * 1) If the Platform Makefile mentions from where it should be
3366 * picked from use it.
3367 * 2) If Platform Makefile does not mention anything,use the
3368 * scheme as mapped below
3369 */
3370 #if !defined(PLATFORM_PATH)
3371 /* First Overrides */
3372 #if defined(DHD_LEGACY_FILE_PATH)
3373 /* If Legacy file path is to be used */
3374 #define PLATFORM_PATH "/data/"
3375 #elif defined(PLATFORM_SLP)
3376 /* Path Name for SLP */
3377 #define PLATFORM_PATH "/opt/etc/"
3378 #else
3379 /* End of Overrides, rely on what is dictated by Android */
3380 #if defined(CUSTOMER_HW4)
3381 #define PLATFORM_PATH "/data/vendor/conn/"
3382 #else
3383 #define PLATFORM_PATH "/data/misc/conn/"
3384 #endif /* CUSTOMER_HW4 */
3385 #define DHD_MAC_ADDR_EXPORT
3386 #define DHD_ADPS_BAM_EXPORT
3387 #define DHD_EXPORT_CNTL_FILE
3388 #define DHD_SOFTAP_DUAL_IF_INFO
3389 #define DHD_SEND_HANG_PRIVCMD_ERRORS
3390 #endif /* DHD_LEGACY_FILE_PATH */
3391 #endif /* !PLATFORM_PATH */
3392
3393 #ifdef DHD_MAC_ADDR_EXPORT
3394 extern struct ether_addr sysfs_mac_addr;
3395 #endif /* DHD_MAC_ADDR_EXPORT */
3396
3397 #if defined(LINUX) || defined(linux)
3398 /* Flag to indicate if we should download firmware on driver load */
3399 extern uint dhd_download_fw_on_driverload;
3400 #ifndef BCMDBUS
3401 extern int allow_delay_fwdl;
3402 #endif /* !BCMDBUS */
3403
3404 extern int dhd_process_cid_mac(dhd_pub_t *dhdp, bool prepost);
3405 extern int dhd_write_file(const char *filepath, char *buf, int buf_len);
3406 extern int dhd_read_file(const char *filepath, char *buf, int buf_len);
3407 extern int dhd_write_file_and_check(const char *filepath, char *buf, int buf_len);
3408 extern int dhd_file_delete(char *path);
3409
3410 #ifdef READ_MACADDR
3411 extern int dhd_set_macaddr_from_file(dhd_pub_t *dhdp);
3412 #else
dhd_set_macaddr_from_file(dhd_pub_t * dhdp)3413 static INLINE int dhd_set_macaddr_from_file(dhd_pub_t *dhdp) { return 0; }
3414 #endif /* READ_MACADDR */
3415 #ifdef WRITE_MACADDR
3416 extern int dhd_write_macaddr(struct ether_addr *mac);
3417 #else
dhd_write_macaddr(struct ether_addr * mac)3418 static INLINE int dhd_write_macaddr(struct ether_addr *mac) { return 0; }
3419 #endif /* WRITE_MACADDR */
3420
3421 #if defined(USE_CID_CHECK) || defined(USE_DIRECT_VID_TAG)
3422 #if defined(BCM4361_CHIP) || defined(BCM4375_CHIP) || defined(BCM4389_CHIP_DEF)
3423 #define DHD_USE_CISINFO_FROM_OTP
3424 /* For COB, can't check CID/MAC in OTP, so, define it here */
3425 #define DHD_READ_CIS_FROM_BP
3426 #endif /* CONFIG_BCM4361 || CONFIG_BCM4375 || CONFIG_BCM4389_DEF */
3427 #define MAX_VNAME_LEN 64
3428 #define MAX_VID_LEN 8
3429 #define MODULE_NAME_INDEX_MAX 3
3430 #define MAX_EXTENSION 20
3431 typedef struct {
3432 char cid_ext[MAX_EXTENSION];
3433 char nvram_ext[MAX_EXTENSION];
3434 char fw_ext[MAX_EXTENSION];
3435 } naming_info_t;
3436 #ifdef DHD_EXPORT_CNTL_FILE
3437 extern char cidinfostr[MAX_VNAME_LEN];
3438 #endif /* DHD_EXPORT_CNTL_FILE */
3439 extern int dhd_check_module_cid(dhd_pub_t *dhdp);
3440 #else
dhd_check_module_cid(dhd_pub_t * dhdp)3441 static INLINE int dhd_check_module_cid(dhd_pub_t *dhdp) { return 0; }
3442 #endif /* USE_CID_CHECK || USE_DIRECT_VID_TAG */
3443 #ifdef USE_CID_CHECK
3444 extern char *dhd_get_cid_info(unsigned char *vid, int vid_length);
3445 #endif /* USE_CID_CHECK */
3446 #ifdef GET_MAC_FROM_OTP
3447 extern int dhd_check_module_mac(dhd_pub_t *dhdp);
3448 #else
dhd_check_module_mac(dhd_pub_t * dhdp)3449 static INLINE int dhd_check_module_mac(dhd_pub_t *dhdp) { return 0; }
3450 #endif /* GET_MAC_FROM_OTP */
3451
3452 #if defined(READ_MACADDR) || defined(WRITE_MACADDR) || defined(USE_CID_CHECK) || \
3453 defined(GET_MAC_FROM_OTP)
3454 #define DHD_USE_CISINFO
3455 #endif /* READ_MACADDR || WRITE_MACADDR || USE_CID_CHECK || GET_MAC_FROM_OTP */
3456
3457 #ifdef DHD_USE_CISINFO
3458 int dhd_read_cis(dhd_pub_t *dhdp);
3459 int dhd_read_otp_sw_rgn(dhd_pub_t *dhdp);
3460 void dhd_clear_cis(dhd_pub_t *dhdp);
3461 int dhd_alloc_cis(dhd_pub_t *dhdp);
3462 #if defined(SUPPORT_MULTIPLE_MODULE_CIS) && defined(USE_CID_CHECK)
3463 extern int dhd_check_module_b85a(void);
3464 extern int dhd_check_module_b90(void);
3465 #define BCM4359_MODULE_TYPE_B90B 1
3466 #define BCM4359_MODULE_TYPE_B90S 2
3467 #endif /* defined(SUPPORT_MULTIPLE_MODULE_CIS) && defined(USE_CID_CHECK) */
3468 #if defined(USE_CID_CHECK)
3469 extern int dhd_check_module_bcm(char *module_type, int index, bool *is_murata_fem);
3470 extern naming_info_t *
3471 dhd_find_naming_info(dhd_pub_t *dhdp, char *module_type);
3472 extern naming_info_t * dhd_find_naming_info_by_chip_rev(dhd_pub_t *dhdp, bool *is_murata_fem);
3473 #endif /* defined(USE_CID_CHECK) */
3474 #ifdef USE_DIRECT_VID_TAG
3475 #define VENDOR_OFF 1
3476 #define MD_REV_OFF 0
3477 #define A0_REV "_a0"
3478 #define B0_REV "_b0"
3479 extern int dhd_check_stored_module_info(char *vid);
3480 extern int concate_nvram_by_vid(dhd_pub_t *dhdp, char *nv_path, char *chipstr);
3481 #endif /* USE_DIRECT_VID_TAG */
3482 #if defined(USE_CID_CHECK) && defined(USE_DIRECT_VID_TAG)
3483 #error Please use USE_CID_CHECK/USE_DIRECT_VID_TAG exclusively
3484 #endif /* USE_CID_CHECK && USE_DIRECT_VID_TAG */
3485 #else
dhd_read_cis(dhd_pub_t * dhdp)3486 static INLINE int dhd_read_cis(dhd_pub_t *dhdp) { return 0; }
dhd_read_otp_sw_rgn(dhd_pub_t * dhdp)3487 static INLINE int dhd_read_otp_sw_rgn(dhd_pub_t *dhdp) { return 0; }
dhd_clear_cis(dhd_pub_t * dhdp)3488 static INLINE void dhd_clear_cis(dhd_pub_t *dhdp) { }
dhd_alloc_cis(dhd_pub_t * dhdp)3489 static INLINE int dhd_alloc_cis(dhd_pub_t *dhdp) { return 0; }
3490 #endif /* DHD_USE_CISINFO */
3491
3492 #else /* LINUX || linux */
dhd_process_cid_mac(dhd_pub_t * dhdp,bool prepost)3493 static INLINE int dhd_process_cid_mac(dhd_pub_t *dhdp, bool prepost) { return 0; }
3494 #endif /* LINUX || linux */
3495
3496 #if defined(WL_CFG80211) && defined(SUPPORT_DEEP_SLEEP)
3497 /* Flags to indicate if we distingish power off policy when
3498 * user set the memu "Keep Wi-Fi on during sleep" to "Never"
3499 */
3500 extern int trigger_deep_sleep;
3501 int dhd_deepsleep(struct net_device *dev, int flag);
3502 #endif /* WL_CFG80211 && SUPPORT_DEEP_SLEEP */
3503
3504 extern void dhd_wait_for_event(dhd_pub_t *dhd, bool *lockvar);
3505 extern void dhd_wait_event_wakeup(dhd_pub_t*dhd);
3506
3507 #define IFLOCK_INIT(lock) *lock = 0
3508 #define IFLOCK(lock) while (InterlockedCompareExchange((lock), 1, 0)) \
3509 NdisStallExecution(1);
3510 #define IFUNLOCK(lock) InterlockedExchange((lock), 0)
3511 #define IFLOCK_FREE(lock)
3512 #define FW_SUPPORTED(dhd, capa) ((strstr(dhd->fw_capabilities, " " #capa " ") != NULL))
3513 #ifdef ARP_OFFLOAD_SUPPORT
3514 #define MAX_IPV4_ENTRIES 8
3515 void dhd_arp_offload_set(dhd_pub_t * dhd, int arp_mode);
3516 void dhd_arp_offload_enable(dhd_pub_t * dhd, int arp_enable);
3517
3518 /* dhd_commn arp offload wrapers */
3519 void dhd_aoe_hostip_clr(dhd_pub_t *dhd, int idx);
3520 void dhd_aoe_arp_clr(dhd_pub_t *dhd, int idx);
3521 int dhd_arp_get_arp_hostip_table(dhd_pub_t *dhd, void *buf, int buflen, int idx);
3522 void dhd_arp_offload_add_ip(dhd_pub_t *dhd, uint32 ipaddr, int idx);
3523 #endif /* ARP_OFFLOAD_SUPPORT */
3524 #ifdef WLTDLS
3525 int dhd_tdls_enable(struct net_device *dev, bool tdls_on, bool auto_on, struct ether_addr *mac);
3526 int dhd_tdls_set_mode(dhd_pub_t *dhd, bool wfd_mode);
3527 #ifdef PCIE_FULL_DONGLE
3528 int dhd_tdls_update_peer_info(dhd_pub_t *dhdp, wl_event_msg_t *event);
3529 int dhd_tdls_event_handler(dhd_pub_t *dhd_pub, wl_event_msg_t *event);
3530 int dhd_free_tdls_peer_list(dhd_pub_t *dhd_pub);
3531 #endif /* PCIE_FULL_DONGLE */
3532 #endif /* WLTDLS */
3533
3534 /* Neighbor Discovery Offload Support */
3535 extern int dhd_ndo_enable(dhd_pub_t * dhd, int ndo_enable);
3536 int dhd_ndo_add_ip(dhd_pub_t *dhd, char* ipaddr, int idx);
3537 int dhd_ndo_remove_ip(dhd_pub_t *dhd, int idx);
3538
3539 /* Enhanced ND offload support */
3540 uint16 dhd_ndo_get_version(dhd_pub_t *dhdp);
3541 int dhd_ndo_add_ip_with_type(dhd_pub_t *dhdp, char *ipv6addr, uint8 type, int idx);
3542 int dhd_ndo_remove_ip_by_addr(dhd_pub_t *dhdp, char *ipv6addr, int idx);
3543 int dhd_ndo_remove_ip_by_type(dhd_pub_t *dhdp, uint8 type, int idx);
3544 int dhd_ndo_unsolicited_na_filter_enable(dhd_pub_t *dhdp, int enable);
3545
3546 /* ioctl processing for nl80211 */
3547 int dhd_ioctl_process(dhd_pub_t *pub, int ifidx, struct dhd_ioctl *ioc, void *data_buf);
3548
3549 #if defined(SUPPORT_MULTIPLE_REVISION)
3550 extern int
3551 concate_revision(struct dhd_bus *bus, char *fwpath, char *nvpath);
3552 #endif /* SUPPORT_MULTIPLE_REVISION */
3553 void dhd_bus_update_fw_nv_path(struct dhd_bus *bus, char *pfw_path, char *pnv_path,
3554 char *pclm_path, char *pconf_path);
3555 void dhd_set_bus_state(void *bus, uint32 state);
3556
3557 /* Remove proper pkts(either one no-frag pkt or whole fragmented pkts) */
3558 typedef int (*f_droppkt_t)(dhd_pub_t *dhdp, int prec, void* p, bool bPktInQ);
3559 extern bool dhd_prec_drop_pkts(dhd_pub_t *dhdp, struct pktq *pq, int prec, f_droppkt_t fn);
3560
3561 #ifdef PROP_TXSTATUS
3562 int dhd_os_wlfc_block(dhd_pub_t *pub);
3563 int dhd_os_wlfc_unblock(dhd_pub_t *pub);
3564 extern const uint8 prio2fifo[];
3565 #endif /* PROP_TXSTATUS */
3566
3567 int dhd_os_socram_dump(struct net_device *dev, uint32 *dump_size);
3568 int dhd_os_get_socram_dump(struct net_device *dev, char **buf, uint32 *size);
3569 int dhd_common_socram_dump(dhd_pub_t *dhdp);
3570
3571 int dhd_dump(dhd_pub_t *dhdp, char *buf, int buflen);
3572
3573 int dhd_os_get_version(struct net_device *dev, bool dhd_ver, char **buf, uint32 size);
3574 void dhd_get_memdump_filename(struct net_device *ndev, char *memdump_path, int len, char *fname);
3575 uint8* dhd_os_prealloc(dhd_pub_t *dhdpub, int section, uint size, bool kmalloc_if_fail);
3576 void dhd_os_prefree(dhd_pub_t *dhdpub, void *addr, uint size);
3577
3578 #if defined(CONFIG_DHD_USE_STATIC_BUF)
3579 #define DHD_OS_PREALLOC(dhdpub, section, size) dhd_os_prealloc(dhdpub, section, size, FALSE)
3580 #define DHD_OS_PREFREE(dhdpub, addr, size) dhd_os_prefree(dhdpub, addr, size)
3581 #else
3582 #define DHD_OS_PREALLOC(dhdpub, section, size) MALLOC(dhdpub->osh, size)
3583 #define DHD_OS_PREFREE(dhdpub, addr, size) MFREE(dhdpub->osh, addr, size)
3584 #endif /* defined(CONFIG_DHD_USE_STATIC_BUF) */
3585
3586 #ifdef USE_WFA_CERT_CONF
3587 enum {
3588 SET_PARAM_BUS_TXGLOM_MODE,
3589 SET_PARAM_ROAMOFF,
3590 #ifdef USE_WL_FRAMEBURST
3591 SET_PARAM_FRAMEBURST,
3592 #endif /* USE_WL_FRAMEBURST */
3593 #ifdef USE_WL_TXBF
3594 SET_PARAM_TXBF,
3595 #endif /* USE_WL_TXBF */
3596 #ifdef PROP_TXSTATUS
3597 SET_PARAM_PROPTX,
3598 SET_PARAM_PROPTXMODE,
3599 #endif /* PROP_TXSTATUS */
3600 PARAM_LAST_VALUE
3601 };
3602 extern int sec_get_param_wfa_cert(dhd_pub_t *dhd, int mode, uint* read_val);
3603 #ifdef DHD_EXPORT_CNTL_FILE
3604 #define VALUENOTSET 0xFFFFFFFFu
3605 extern uint32 bus_txglom;
3606 extern uint32 roam_off;
3607 #ifdef USE_WL_FRAMEBURST
3608 extern uint32 frameburst;
3609 #endif /* USE_WL_FRAMEBURST */
3610 #ifdef USE_WL_TXBF
3611 extern uint32 txbf;
3612 #endif /* USE_WL_TXBF */
3613 #ifdef PROP_TXSTATUS
3614 extern uint32 proptx;
3615 #endif /* PROP_TXSTATUS */
3616 #endif /* DHD_EXPORT_CNTL_FILE */
3617 #endif /* USE_WFA_CERT_CONF */
3618
3619 #if defined(BCM_ROUTER_DHD)
3620 #if defined(HNDCTF)
3621 bool dhd_ctf_hotbrc_check(dhd_pub_t *dhdp, uint8 *eh, int ifidx);
3622 void dhd_ctf_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
3623 bool dhd_l2_filter_chainable(dhd_pub_t *dhdp, uint8 *eh, int ifidx);
3624 bool dhd_wet_chainable(dhd_pub_t *dhdap);
3625 bool dhd_rx_pkt_chainable(dhd_pub_t *dhdp, int ifidx);
3626 #endif /* HNDCTF */
3627 extern void dhd_schedule_trap_log_dump(dhd_pub_t *dhdp,
3628 uint8 *buf, uint32 size);
3629 /* When a new flowid is allocated/deallocated, inform dhd. */
3630 extern void dhd_add_flowid(dhd_pub_t * dhdp, int ifidx,
3631 uint8 ac_prio, void * ea, uint16 flowid);
3632 extern void dhd_del_flowid(dhd_pub_t * dhdp, int ifidx, uint16 flowid);
3633 #else /* ! BCM_ROUTER_DHD */
3634 #define dhd_add_flowid(pub, ifidx, ac_prio, ea, flowid) do {} while (0)
3635 #define dhd_del_flowid(pub, ifidx, flowid) do {} while (0)
3636 bool dhd_wet_chainable(dhd_pub_t *dhdp);
3637 #endif /* ! BCM_ROUTER_DHD */
3638
3639 extern unsigned long dhd_os_general_spin_lock(dhd_pub_t *pub);
3640 extern void dhd_os_general_spin_unlock(dhd_pub_t *pub, unsigned long flags);
3641
3642 /** Miscellaenous DHD Spin Locks */
3643
3644 /* Enable DHD general spin lock/unlock */
3645 #define DHD_GENERAL_LOCK(dhdp, flags) \
3646 (flags) = dhd_os_general_spin_lock(dhdp)
3647 #define DHD_GENERAL_UNLOCK(dhdp, flags) \
3648 dhd_os_general_spin_unlock((dhdp), (flags))
3649
3650 /* Enable DHD timer spin lock/unlock */
3651 #define DHD_TIMER_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3652 #define DHD_TIMER_UNLOCK(lock, flags) osl_spin_unlock(lock, (flags))
3653
3654 /* Enable DHD flowring spin lock/unlock */
3655 #define DHD_FLOWRING_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3656 #define DHD_FLOWRING_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3657
3658 /* Enable DHD common flowring info spin lock/unlock */
3659 #define DHD_FLOWID_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3660 #define DHD_FLOWID_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3661
3662 /* Enable DHD common flowring list spin lock/unlock */
3663 #define DHD_FLOWRING_LIST_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3664 #define DHD_FLOWRING_LIST_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3665
3666 #define DHD_RING_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3667 #define DHD_RING_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3668
3669 #define DHD_BUS_LP_STATE_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3670 #define DHD_BUS_LP_STATE_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3671
3672 #define DHD_BAR1_SWITCH_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3673 #define DHD_BAR1_SWITCH_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3674
3675 #define DHD_BUS_PWR_REQ_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3676 #define DHD_BUS_PWR_REQ_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3677
3678 #ifdef PCIE_INB_DW
3679 #define DHD_BUS_DONGLE_DS_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3680 #define DHD_BUS_DONGLE_DS_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3681 #endif /* PCIE_INB_DW */
3682
3683 /* Enable DHD backplane spin lock/unlock */
3684 #define DHD_BACKPLANE_ACCESS_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3685 #define DHD_BACKPLANE_ACCESS_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3686
3687 #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3688 #define DHD_BUS_INB_DW_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3689
3690 /* Enable DHD TDLS peer list spin lock/unlock */
3691 #ifdef WLTDLS
3692 #define DHD_TDLS_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3693 #define DHD_TDLS_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3694 #endif /* WLTDLS */
3695
3696 #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3697 #define DHD_BUS_INB_DW_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3698
3699 #ifdef DBG_PKT_MON
3700 /* Enable DHD PKT MON spin lock/unlock */
3701 #define DHD_PKT_MON_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3702 #define DHD_PKT_MON_UNLOCK(lock, flags) osl_spin_unlock(lock, (flags))
3703 #endif /* DBG_PKT_MON */
3704
3705 #ifdef DHD_PKT_LOGGING
3706 /* Enable DHD PKT LOG spin lock/unlock */
3707 #define DHD_PKT_LOG_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3708 #define DHD_PKT_LOG_UNLOCK(lock, flags) osl_spin_unlock(lock, (flags))
3709 #endif /* DHD_PKT_LOGGING */
3710
3711 #if defined(DHD_AWDL) && defined(AWDL_SLOT_STATS)
3712 #define DHD_AWDL_STATS_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3713 #define DHD_AWDL_STATS_UNLOCK(lock, flags) osl_spin_unlock(lock, (flags))
3714 #endif /* DHD_AWDL && AWDL_SLOT_STATS */
3715
3716 #if defined(linux) || defined(LINUX)
3717 #define DHD_LINUX_GENERAL_LOCK(dhdp, flags) DHD_GENERAL_LOCK(dhdp, flags)
3718 #define DHD_LINUX_GENERAL_UNLOCK(dhdp, flags) DHD_GENERAL_UNLOCK(dhdp, flags)
3719 #else
3720 #define DHD_LINUX_GENERAL_LOCK(dhdp, flags) do {BCM_REFERENCE(flags);} while (0)
3721 #define DHD_LINUX_GENERAL_UNLOCK(dhdp, flags) do {BCM_REFERENCE(flags);} while (0)
3722 #endif
3723
3724 #define DHD_BUS_INB_DW_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3725 #define DHD_BUS_INB_DW_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3726
3727 #define DHD_RX_NAPI_QUEUE_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3728 #define DHD_RX_NAPI_QUEUE_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3729
3730 #define DHD_UP_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3731 #define DHD_UP_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3732
3733 #define DHD_WAKE_SPIN_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3734 #define DHD_WAKE_SPIN_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3735
3736 /*
3737 * Temporarily change log dump lock to spin_lock_irqsave as DHD_ERROR/DHD_LOG_MEM
3738 * are being called from dhdpcie_bus_isr.
3739 * This will be reverted after proper solution is implemented to handle isr prints
3740 */
3741 #define DHD_LOG_DUMP_BUF_LOCK(lock, flags) (flags) = osl_spin_lock_irq(lock)
3742 #define DHD_LOG_DUMP_BUF_UNLOCK(lock, flags) osl_spin_unlock_irq((lock), (flags))
3743
3744 #define DHD_PKT_WAKE_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3745 #define DHD_PKT_WAKE_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3746
3747 #define DHD_OOB_IRQ_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3748 #define DHD_OOB_IRQ_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3749
3750 #define DHD_IF_STA_LIST_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3751 #define DHD_IF_STA_LIST_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3752
3753 #define DHD_DBG_RING_LOCK_INIT(osh) osl_spin_lock_init(osh)
3754 #define DHD_DBG_RING_LOCK_DEINIT(osh, lock) osl_spin_lock_deinit(osh, (lock))
3755 #define DHD_DBG_RING_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3756 #define DHD_DBG_RING_UNLOCK(lock, flags) osl_spin_unlock((lock), flags)
3757
3758 #ifdef DHD_MEM_STATS
3759 /* memory stats lock/unlock */
3760 #define DHD_MEM_STATS_LOCK(lock, flags) (flags) = osl_spin_lock(lock)
3761 #define DHD_MEM_STATS_UNLOCK(lock, flags) osl_spin_unlock((lock), (flags))
3762 #endif /* DHD_MEM_STATS */
3763
3764 extern void dhd_dump_to_kernelog(dhd_pub_t *dhdp);
3765
3766 #if defined(LINUX) || defined(linux)
3767 extern void dhd_print_tasklet_status(dhd_pub_t *dhd);
3768 #ifdef PCIE_INB_DW
3769 extern bool dhd_check_cfg_in_progress(dhd_pub_t *dhdp);
3770 #endif
3771 #else
dhd_print_tasklet_status(dhd_pub_t * dhd)3772 static INLINE void dhd_print_tasklet_status(dhd_pub_t *dhd) { }
dhd_check_cfg_in_progress(dhd_pub_t * dhdp)3773 static INLINE bool dhd_check_cfg_in_progress(dhd_pub_t *dhdp)
3774 { return FALSE; }
3775 #endif /* LINUX | linux */
3776
3777 #ifdef BCMDBUS
3778 extern uint dhd_get_rxsz(dhd_pub_t *pub);
3779 extern void dhd_set_path(dhd_pub_t *pub);
3780 extern void dhd_bus_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
3781 extern void dhd_bus_clearcounts(dhd_pub_t *dhdp);
3782 #endif /* BCMDBUS */
3783
3784 #ifdef DHD_L2_FILTER
3785 extern int dhd_get_parp_status(dhd_pub_t *dhdp, uint32 idx);
3786 extern int dhd_set_parp_status(dhd_pub_t *dhdp, uint32 idx, int val);
3787 extern int dhd_get_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx);
3788 extern int dhd_set_dhcp_unicast_status(dhd_pub_t *dhdp, uint32 idx, int val);
3789 extern int dhd_get_block_ping_status(dhd_pub_t *dhdp, uint32 idx);
3790 extern int dhd_set_block_ping_status(dhd_pub_t *dhdp, uint32 idx, int val);
3791 extern int dhd_get_grat_arp_status(dhd_pub_t *dhdp, uint32 idx);
3792 extern int dhd_set_grat_arp_status(dhd_pub_t *dhdp, uint32 idx, int val);
3793 extern int dhd_get_block_tdls_status(dhd_pub_t *dhdp, uint32 idx);
3794 extern int dhd_set_block_tdls_status(dhd_pub_t *dhdp, uint32 idx, int val);
3795 #endif /* DHD_L2_FILTER */
3796
3797 #if (defined(BCM_ROUTER_DHD) && defined(QOS_MAP_SET))
3798 extern int dhd_set_qosmap_up_table(dhd_pub_t *dhdp, uint32 idx, bcm_tlv_t *qos_map_ie);
3799 #endif /* BCM_ROUTER_DHD && QOS_MAP_SET */
3800
3801 typedef struct wl_io_pport {
3802 dhd_pub_t *dhd_pub;
3803 uint ifidx;
3804 } wl_io_pport_t;
3805
3806 typedef struct wl_evt_pport {
3807 dhd_pub_t *dhd_pub;
3808 int *ifidx;
3809 void *pktdata;
3810 uint data_len;
3811 void **data_ptr;
3812 void *raw_event;
3813 } wl_evt_pport_t;
3814
3815 extern void *dhd_pub_shim(dhd_pub_t *dhd_pub);
3816 #ifdef DHD_FW_COREDUMP
3817 void* dhd_get_fwdump_buf(dhd_pub_t *dhd_pub, uint32 length);
3818 #endif /* DHD_FW_COREDUMP */
3819
3820 #if defined(SET_XPS_CPUS)
3821 int dhd_xps_cpus_enable(struct net_device *net, int enable);
3822 int custom_xps_map_set(struct net_device *net, char *buf, size_t len);
3823 void custom_xps_map_clear(struct net_device *net);
3824 #endif
3825
3826 #if defined(SET_RPS_CPUS)
3827 int dhd_rps_cpus_enable(struct net_device *net, int enable);
3828 int custom_rps_map_set(struct netdev_rx_queue *queue, char *buf, size_t len);
3829 void custom_rps_map_clear(struct netdev_rx_queue *queue);
3830 #define PRIMARY_INF 0
3831 #define VIRTUAL_INF 1
3832 #if defined(CONFIG_MACH_UNIVERSAL7420) || defined(CONFIG_SOC_EXYNOS8890)
3833 #define RPS_CPUS_MASK "10"
3834 #define RPS_CPUS_MASK_P2P "10"
3835 #define RPS_CPUS_MASK_IBSS "10"
3836 #define RPS_CPUS_WLAN_CORE_ID 4
3837 #else
3838 #if defined(DHD_TPUT_PATCH)
3839 #define RPS_CPUS_MASK "f"
3840 #define RPS_CPUS_MASK_P2P "f"
3841 #define RPS_CPUS_MASK_IBSS "f"
3842 #else
3843 #define RPS_CPUS_MASK "6"
3844 #define RPS_CPUS_MASK_P2P "6"
3845 #define RPS_CPUS_MASK_IBSS "6"
3846 #endif
3847 #endif /* CONFIG_MACH_UNIVERSAL7420 || CONFIG_SOC_EXYNOS8890 */
3848 #endif // endif
3849
3850 int dhd_get_download_buffer(dhd_pub_t *dhd, char *file_path, download_type_t component,
3851 char ** buffer, int *length);
3852
3853 void dhd_free_download_buffer(dhd_pub_t *dhd, void *buffer, int length);
3854
3855 int dhd_download_blob(dhd_pub_t *dhd, unsigned char *buf,
3856 uint32 len, char *iovar);
3857
3858 int dhd_download_blob_cached(dhd_pub_t *dhd, char *file_path,
3859 uint32 len, char *iovar);
3860
3861 int dhd_apply_default_txcap(dhd_pub_t *dhd, char *txcap_path);
3862 int dhd_apply_default_clm(dhd_pub_t *dhd, char *clm_path);
3863
3864 #ifdef SHOW_LOGTRACE
3865 int dhd_parse_logstrs_file(osl_t *osh, char *raw_fmts, int logstrs_size,
3866 dhd_event_log_t *event_log);
3867 int dhd_parse_map_file(osl_t *osh, void *file, uint32 *ramstart,
3868 uint32 *rodata_start, uint32 *rodata_end);
3869 #ifdef PCIE_FULL_DONGLE
3870 int dhd_event_logtrace_infobuf_pkt_process(dhd_pub_t *dhdp, void *pktbuf,
3871 dhd_event_log_t *event_data);
3872 #endif /* PCIE_FULL_DONGLE */
3873 #endif /* SHOW_LOGTRACE */
3874
3875 /*
3876 * control_logtrace:
3877 * "0" -> do not print event log messages in any form
3878 * "1" -> print event log messages as EL
3879 * "2" -> print event log messages as formatted CONSOLE_E if logstrs.bin etc. files are available
3880 */
3881 typedef enum logtrace_ctrl {
3882 LOGTRACE_DISABLE = 0,
3883 LOGTRACE_RAW_FMT = 1,
3884 LOGTRACE_PARSED_FMT = 2
3885 } logtrace_ctrl_t;
3886
3887 #define DEFAULT_CONTROL_LOGTRACE LOGTRACE_PARSED_FMT
3888 #ifndef CUSTOM_CONTROL_LOGTRACE
3889 #define CUSTOM_CONTROL_LOGTRACE DEFAULT_CONTROL_LOGTRACE
3890 #endif
3891
3892 extern uint8 control_logtrace;
3893
3894 #ifdef BTLOG
3895 int dhd_bt_log_pkt_process(dhd_pub_t *dhdp, void *pktbuf);
3896 #endif /* BTLOG */
3897
3898 #if defined(NDIS)
3899 bool dhd_is_device_removed(dhd_pub_t *dhd);
3900 #else
3901 #define dhd_is_device_removed(x) FALSE
3902 #define dhd_os_ind_firmware_stall(x)
3903 #endif /* defined(NDIS) */
3904
3905 #if defined(DHD_FW_COREDUMP)
3906 #if defined(linux) || defined(LINUX)
3907 extern void dhd_get_memdump_info(dhd_pub_t *dhd);
3908 #else
dhd_get_memdump_info(dhd_pub_t * dhd)3909 static INLINE void dhd_get_memdump_info(dhd_pub_t *dhd)
3910 { return; }
3911 #endif /* linux || LINUX */
3912 #endif /* defined(DHD_FW_COREDUMP) */
3913 #ifdef BCMASSERT_LOG
3914 extern void dhd_get_assert_info(dhd_pub_t *dhd);
3915 #else
dhd_get_assert_info(dhd_pub_t * dhd)3916 static INLINE void dhd_get_assert_info(dhd_pub_t *dhd) { }
3917 #endif /* BCMASSERT_LOG */
3918
3919 #if defined(LINUX) || defined(linux)
3920 #define DMAXFER_FREE(dhdp, dmap) dhd_schedule_dmaxfer_free(dhdp, dmap);
3921 #else /* !(LINUX || linux) */
3922 #define DMAXFER_FREE(dhdp, dmmap) dmaxfer_free_prev_dmaaddr(dhdp, dmmap);
3923 #endif /* linux || LINUX */
3924
3925 #if defined(PCIE_FULL_DONGLE)
3926 extern void dmaxfer_free_prev_dmaaddr(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
3927 void dhd_schedule_dmaxfer_free(dhd_pub_t *dhdp, dmaxref_mem_map_t *dmmap);
3928 #endif /* PCIE_FULL_DONGLE */
3929
3930 #define DHD_LB_STATS_NOOP do { /* noop */ } while (0)
3931 #if defined(DHD_LB_STATS)
3932 #include <bcmutils.h>
3933 extern void dhd_lb_stats_init(dhd_pub_t *dhd);
3934 extern void dhd_lb_stats_deinit(dhd_pub_t *dhd);
3935 extern void dhd_lb_stats_reset(dhd_pub_t *dhd);
3936 #ifdef DHD_MEM_STATS
3937 extern uint64 dhd_lb_mem_usage(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
3938 #endif /* DHD_MEM_STATS */
3939 extern void dhd_lb_stats_dump(dhd_pub_t *dhdp, struct bcmstrbuf *strbuf);
3940 extern void dhd_lb_stats_update_napi_histo(dhd_pub_t *dhdp, uint32 count);
3941 extern void dhd_lb_stats_update_txc_histo(dhd_pub_t *dhdp, uint32 count);
3942 extern void dhd_lb_stats_update_rxc_histo(dhd_pub_t *dhdp, uint32 count);
3943 extern void dhd_lb_stats_txc_percpu_cnt_incr(dhd_pub_t *dhdp);
3944 extern void dhd_lb_stats_rxc_percpu_cnt_incr(dhd_pub_t *dhdp);
3945 #define DHD_LB_STATS_INIT(dhdp) dhd_lb_stats_init(dhdp)
3946 #define DHD_LB_STATS_DEINIT(dhdp) dhd_lb_stats_deinit(dhdp)
3947 /* Reset is called from common layer so it takes dhd_pub_t as argument */
3948 #define DHD_LB_STATS_RESET(dhdp) dhd_lb_stats_reset(dhdp)
3949 #define DHD_LB_STATS_CLR(x) (x) = 0U
3950 #define DHD_LB_STATS_INCR(x) (x) = (x) + 1
3951 #define DHD_LB_STATS_ADD(x, c) (x) = (x) + (c)
3952 #define DHD_LB_STATS_PERCPU_ARR_INCR(x) \
3953 { \
3954 int cpu = get_cpu(); put_cpu(); \
3955 DHD_LB_STATS_INCR(x[cpu]); \
3956 }
3957 #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhdp, x) dhd_lb_stats_update_napi_histo(dhdp, x)
3958 #else /* !DHD_LB_STATS */
3959 #define DHD_LB_STATS_INIT(dhdp) DHD_LB_STATS_NOOP
3960 #define DHD_LB_STATS_DEINIT(dhdp) DHD_LB_STATS_NOOP
3961 #define DHD_LB_STATS_RESET(dhdp) DHD_LB_STATS_NOOP
3962 #define DHD_LB_STATS_CLR(x) DHD_LB_STATS_NOOP
3963 #define DHD_LB_STATS_INCR(x) DHD_LB_STATS_NOOP
3964 #define DHD_LB_STATS_ADD(x, c) DHD_LB_STATS_NOOP
3965 #define DHD_LB_STATS_PERCPU_ARR_INCR(x) DHD_LB_STATS_NOOP
3966 #define DHD_LB_STATS_UPDATE_NAPI_HISTO(dhd, x) DHD_LB_STATS_NOOP
3967 #endif /* !DHD_LB_STATS */
3968
3969 #ifdef BCMDBG
3970 extern void dhd_schedule_macdbg_dump(dhd_pub_t *dhdp);
3971 #endif /* BCMDBG */
3972
3973 #ifdef DHD_SSSR_DUMP
3974 #ifdef DHD_SSSR_DUMP_BEFORE_SR
3975 #define DHD_SSSR_MEMPOOL_SIZE (2 * 1024 * 1024) /* 2MB size */
3976 #else
3977 #define DHD_SSSR_MEMPOOL_SIZE (1 * 1024 * 1024) /* 1MB size */
3978 #endif /* DHD_SSSR_DUMP_BEFORE_SR */
3979
3980 /* used in sssr_dump_mode */
3981 #define SSSR_DUMP_MODE_SSSR 0 /* dump both *before* and *after* files */
3982 #define SSSR_DUMP_MODE_FIS 1 /* dump *after* files only */
3983
3984 extern int dhd_sssr_mempool_init(dhd_pub_t *dhd);
3985 extern void dhd_sssr_mempool_deinit(dhd_pub_t *dhd);
3986 extern int dhd_sssr_dump_init(dhd_pub_t *dhd);
3987 extern void dhd_sssr_dump_deinit(dhd_pub_t *dhd);
3988 extern int dhdpcie_sssr_dump(dhd_pub_t *dhd);
3989 extern void dhd_sssr_print_filepath(dhd_pub_t *dhd, char *path);
3990 extern int dhd_sssr_reg_info_init(dhd_pub_t *dhd);
3991 extern void dhd_sssr_reg_info_deinit(dhd_pub_t *dhd);
3992 extern uint dhd_sssr_dig_buf_size(dhd_pub_t *dhdp);
3993 extern uint dhd_sssr_dig_buf_addr(dhd_pub_t *dhdp);
3994 extern uint dhd_sssr_mac_buf_size(dhd_pub_t *dhdp, uint8 core_idx);
3995 extern uint dhd_sssr_mac_xmtaddress(dhd_pub_t *dhdp, uint8 core_idx);
3996 extern uint dhd_sssr_mac_xmtdata(dhd_pub_t *dhdp, uint8 core_idx);
3997
3998 #define DHD_SSSR_MEMPOOL_INIT(dhdp) dhd_sssr_mempool_init(dhdp)
3999 #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) dhd_sssr_mempool_deinit(dhdp)
4000 #define DHD_SSSR_DUMP_INIT(dhdp) dhd_sssr_dump_init(dhdp)
4001 #define DHD_SSSR_DUMP_DEINIT(dhdp) dhd_sssr_dump_deinit(dhdp)
4002 #define DHD_SSSR_PRINT_FILEPATH(dhdp, path) dhd_sssr_print_filepath(dhdp, path)
4003 #define DHD_SSSR_REG_INFO_INIT(dhdp) dhd_sssr_reg_info_init(dhdp)
4004 #define DHD_SSSR_REG_INFO_DEINIT(dhdp) dhd_sssr_reg_info_deinit(dhdp)
4005 #else
4006 #define DHD_SSSR_MEMPOOL_INIT(dhdp) do { /* noop */ } while (0)
4007 #define DHD_SSSR_MEMPOOL_DEINIT(dhdp) do { /* noop */ } while (0)
4008 #define DHD_SSSR_DUMP_INIT(dhdp) do { /* noop */ } while (0)
4009 #define DHD_SSSR_DUMP_DEINIT(dhdp) do { /* noop */ } while (0)
4010 #define DHD_SSSR_PRINT_FILEPATH(dhdp, path) do { /* noop */ } while (0)
4011 #define DHD_SSSR_REG_INFO_INIT(dhdp) do { /* noop */ } while (0)
4012 #define DHD_SSSR_REG_INFO_DEINIT(dhdp) do { /* noop */ } while (0)
4013 #endif /* DHD_SSSR_DUMP */
4014
4015 #ifdef BCMPCIE
4016 extern int dhd_prot_debug_info_print(dhd_pub_t *dhd);
4017 extern bool dhd_bus_skip_clm(dhd_pub_t *dhdp);
4018 extern void dhd_pcie_dump_rc_conf_space_cap(dhd_pub_t *dhd);
4019 extern bool dhd_pcie_dump_int_regs(dhd_pub_t *dhd);
4020 #else
4021 #define dhd_prot_debug_info_print(x)
dhd_bus_skip_clm(dhd_pub_t * dhd_pub)4022 static INLINE bool dhd_bus_skip_clm(dhd_pub_t *dhd_pub)
4023 { return 0; }
4024 #endif /* BCMPCIE */
4025
4026 #if defined(LINUX) || defined(linux)
4027 void dhd_show_kirqstats(dhd_pub_t *dhd);
4028 #else
dhd_show_kirqstats(dhd_pub_t * dhd)4029 static INLINE void dhd_show_kirqstats(dhd_pub_t *dhd)
4030 { return; }
4031 #endif /* defined(LINUX) || defined(linux) */
4032
4033 /* Bitmask used for Join Timeout */
4034 #define WLC_SSID_MASK 0x01
4035 #define WLC_WPA_MASK 0x02
4036
4037 #if defined(LINUX) || defined(linux) || defined(DHD_EFI)
4038 fw_download_status_t dhd_fw_download_status(dhd_pub_t *dhd_pub);
4039 extern int dhd_start_join_timer(dhd_pub_t *pub);
4040 extern int dhd_stop_join_timer(dhd_pub_t *pub);
4041 extern int dhd_start_scan_timer(dhd_pub_t *pub, bool is_escan);
4042 extern int dhd_stop_scan_timer(dhd_pub_t *pub, bool is_escan, uint16 sync_id);
4043 extern int dhd_start_cmd_timer(dhd_pub_t *pub);
4044 extern int dhd_stop_cmd_timer(dhd_pub_t *pub);
4045 extern int dhd_start_bus_timer(dhd_pub_t *pub);
4046 extern int dhd_stop_bus_timer(dhd_pub_t *pub);
4047 extern uint16 dhd_get_request_id(dhd_pub_t *pub);
4048 extern int dhd_set_request_id(dhd_pub_t *pub, uint16 id, uint32 cmd);
4049 extern void dhd_clear_join_error(dhd_pub_t *pub, uint32 mask);
4050 extern void dhd_get_scan_to_val(dhd_pub_t *pub, uint32 *to_val);
4051 extern void dhd_set_scan_to_val(dhd_pub_t *pub, uint32 to_val);
4052 extern void dhd_get_join_to_val(dhd_pub_t *pub, uint32 *to_val);
4053 extern void dhd_set_join_to_val(dhd_pub_t *pub, uint32 to_val);
4054 extern void dhd_get_cmd_to_val(dhd_pub_t *pub, uint32 *to_val);
4055 extern void dhd_set_cmd_to_val(dhd_pub_t *pub, uint32 to_val);
4056 extern void dhd_get_bus_to_val(dhd_pub_t *pub, uint32 *to_val);
4057 extern void dhd_set_bus_to_val(dhd_pub_t *pub, uint32 to_val);
4058 extern int dhd_start_timesync_timer(dhd_pub_t *pub);
4059 extern int dhd_stop_timesync_timer(dhd_pub_t *pub);
4060 #else
dhd_fw_download_status(dhd_pub_t * dhd_pub)4061 static INLINE fw_download_status_t dhd_fw_download_status(dhd_pub_t *dhd_pub)
4062 { return FW_UNLOADED; }
dhd_start_join_timer(dhd_pub_t * pub)4063 static INLINE int dhd_start_join_timer(dhd_pub_t *pub) { return 0; }
dhd_stop_join_timer(dhd_pub_t * pub)4064 static INLINE int dhd_stop_join_timer(dhd_pub_t *pub) { return 0; }
dhd_start_scan_timer(dhd_pub_t * pub,bool is_escan)4065 static INLINE int dhd_start_scan_timer(dhd_pub_t *pub, bool is_escan) { return 0; }
dhd_stop_scan_timer(dhd_pub_t * pub,bool is_escan,uint16 sync_id)4066 static INLINE int dhd_stop_scan_timer(dhd_pub_t *pub, bool is_escan, uint16 sync_id) { return 0; }
dhd_start_cmd_timer(dhd_pub_t * pub)4067 static INLINE int dhd_start_cmd_timer(dhd_pub_t *pub) { return 0; }
dhd_stop_cmd_timer(dhd_pub_t * pub)4068 static INLINE int dhd_stop_cmd_timer(dhd_pub_t *pub) { return 0; }
dhd_start_bus_timer(dhd_pub_t * pub)4069 static INLINE int dhd_start_bus_timer(dhd_pub_t *pub) { return 0; }
dhd_stop_bus_timer(dhd_pub_t * pub)4070 static INLINE int dhd_stop_bus_timer(dhd_pub_t *pub) { return 0; }
dhd_get_request_id(dhd_pub_t * pub)4071 static INLINE uint16 dhd_get_request_id(dhd_pub_t *pub) { return 0; }
dhd_set_request_id(dhd_pub_t * pub,uint16 id)4072 static INLINE int dhd_set_request_id(dhd_pub_t *pub, uint16 id) { return 0; }
dhd_clear_join_error(dhd_pub_t * pub,uint32 mask)4073 static INLINE void dhd_clear_join_error(dhd_pub_t *pub, uint32 mask) { return; }
dhd_get_scan_to_val(dhd_pub_t * pub,uint32 * to_val)4074 static INLINE void dhd_get_scan_to_val(dhd_pub_t *pub, uint32 *to_val) { return; }
dhd_set_scan_to_val(dhd_pub_t * pub,uint32 to_val)4075 static INLINE void dhd_set_scan_to_val(dhd_pub_t *pub, uint32 to_val) { return; }
dhd_get_join_to_val(dhd_pub_t * pub,uint32 * to_val)4076 static INLINE void dhd_get_join_to_val(dhd_pub_t *pub, uint32 *to_val) { return; }
dhd_set_join_to_val(dhd_pub_t * pub,uint32 to_val)4077 static INLINE void dhd_set_join_to_val(dhd_pub_t *pub, uint32 to_val) { return; }
dhd_get_cmd_to_val(dhd_pub_t * pub,uint32 * to_val)4078 static INLINE void dhd_get_cmd_to_val(dhd_pub_t *pub, uint32 *to_val) { return; }
dhd_set_cmd_to_val(dhd_pub_t * pub,uint32 to_val)4079 static INLINE void dhd_set_cmd_to_val(dhd_pub_t *pub, uint32 to_val) { return; }
dhd_get_bus_to_val(dhd_pub_t * pub,uint32 * to_val)4080 static INLINE void dhd_get_bus_to_val(dhd_pub_t *pub, uint32 *to_val) { return; }
dhd_set_bus_to_val(dhd_pub_t * pub,uint32 to_val)4081 static INLINE void dhd_set_bus_to_val(dhd_pub_t *pub, uint32 to_val) { return; }
dhd_start_timesync_timer(dhd_pub_t * pub)4082 static INLINE int dhd_start_timesync_timer(dhd_pub_t *pub) { return 0; }
dhd_stop_timesync_timer(dhd_pub_t * pub)4083 static INLINE int dhd_stop_timesync_timer(dhd_pub_t *pub) { return 0; }
4084 #endif /* defined(LINUX) || defined(linux) */
4085
4086 #ifdef DHD_PKTID_AUDIT_ENABLED
4087 #if defined(LINUX) || defined(linux)
4088 void dhd_pktid_error_handler(dhd_pub_t *dhdp);
4089 #else /* !(LINUX || linux) */
dhd_pktid_error_handler(dhd_pub_t * dhdp)4090 static INLINE void dhd_pktid_error_handler(dhd_pub_t *dhdp) { ASSERT(0); }
4091 #endif /* LINUX || linux */
4092 #endif /* DHD_PKTID_AUDIT_ENABLED */
4093
4094 #ifdef DHD_MAP_PKTID_LOGGING
4095 #if defined(LINUX) || defined(linux)
4096 extern void dhd_pktid_logging_dump(dhd_pub_t *dhdp);
4097 #else /* !(LINUX || linux) */
dhd_pktid_logging_dump(dhd_pub_t * dhdp)4098 static INLINE void dhd_pktid_logging_dump(dhd_pub_t *dhdp) { }
4099 #endif /* LINUX || linux */
4100 #endif /* DHD_MAP_PKTID_LOGGING */
4101
4102 #ifdef DHD_PCIE_RUNTIMEPM
4103 #define DEFAULT_DHD_RUNTIME_MS 100
4104 #ifndef CUSTOM_DHD_RUNTIME_MS
4105 #define CUSTOM_DHD_RUNTIME_MS DEFAULT_DHD_RUNTIME_MS
4106 #endif /* CUSTOM_DHD_RUNTIME_MS */
4107
4108 #ifndef MAX_IDLE_COUNT
4109 #define MAX_IDLE_COUNT 11
4110 #endif /* MAX_IDLE_COUNT */
4111
4112 extern bool dhd_runtimepm_state(dhd_pub_t *dhd);
4113 extern bool dhd_runtime_bus_wake(struct dhd_bus *bus, bool wait, void *func_addr);
4114 extern bool dhdpcie_runtime_bus_wake(dhd_pub_t *dhdp, bool wait, void *func_addr);
4115 extern void dhdpcie_block_runtime_pm(dhd_pub_t *dhdp);
4116 extern bool dhdpcie_is_resume_done(dhd_pub_t *dhdp);
4117 extern void dhd_runtime_pm_disable(dhd_pub_t *dhdp);
4118 extern void dhd_runtime_pm_enable(dhd_pub_t *dhdp);
4119 /* Disable the Runtime PM thread and wake up if the bus is already in suspend */
4120 #define DHD_DISABLE_RUNTIME_PM(dhdp) \
4121 do { \
4122 dhd_runtime_pm_disable(dhdp); \
4123 } while (0);
4124
4125 /* Enable the Runtime PM thread */
4126 #define DHD_ENABLE_RUNTIME_PM(dhdp) \
4127 do { \
4128 dhd_runtime_pm_enable(dhdp); \
4129 } while (0);
4130
4131 /* Stop the timer and disable RPM thread */
4132 #define DHD_STOP_RPM_TIMER(dhdp) \
4133 do { \
4134 dhd_os_runtimepm_timer(dhdp, 0); \
4135 DHD_DISABLE_RUNTIME_PM(dhdp) \
4136 } while (0);
4137
4138 /* Start the timer and enable RPM thread */
4139 #define DHD_START_RPM_TIMER(dhdp) \
4140 do { \
4141 dhd_os_runtimepm_timer(dhdp, dhd_runtimepm_ms); \
4142 DHD_ENABLE_RUNTIME_PM(dhdp) \
4143 } while (0);
4144 #else
4145 #define DHD_DISABLE_RUNTIME_PM(dhdp)
4146 #define DHD_ENABLE_RUNTIME_PM(dhdp)
4147 #define DHD_STOP_RPM_TIMER(dhdp)
4148 #define DHD_START_RPM_TIMER(dhdp)
4149 #endif /* DHD_PCIE_RUNTIMEPM */
4150
4151 extern bool dhd_prot_is_cmpl_ring_empty(dhd_pub_t *dhd, void *prot_info);
4152 extern void dhd_prot_dump_ring_ptrs(void *prot_info);
4153
4154 #if defined(LINUX) || defined(linux)
4155 #if defined(DHD_TRACE_WAKE_LOCK)
4156 void dhd_wk_lock_stats_dump(dhd_pub_t *dhdp);
4157 #endif
4158 #endif /* LINUX || linux */
4159
4160 extern bool dhd_query_bus_erros(dhd_pub_t *dhdp);
4161 void dhd_clear_bus_errors(dhd_pub_t *dhdp);
4162
4163 #if (defined(linux) || defined(LINUX)) && defined(CONFIG_64BIT)
4164 #define DHD_SUPPORT_64BIT
4165 #elif defined(DHD_EFI)
4166 #define DHD_SUPPORT_64BIT
4167 /* by default disabled for other platforms, can enable appropriate macro to enable 64 bit support */
4168 #endif /* (linux || LINUX) && CONFIG_64BIT */
4169
4170 #if defined(DHD_EFI) || defined(DHD_ERPOM)
4171 extern void dhd_schedule_reset(dhd_pub_t *dhdp);
4172 #else
dhd_schedule_reset(dhd_pub_t * dhdp)4173 static INLINE void dhd_schedule_reset(dhd_pub_t *dhdp) {;}
4174 #endif /* DHD_EFI || DHD_ERPOM */
4175
4176 extern void init_dhd_timeouts(dhd_pub_t *pub);
4177 extern void deinit_dhd_timeouts(dhd_pub_t *pub);
4178
4179 typedef enum timeout_resons {
4180 DHD_REASON_COMMAND_TO,
4181 DHD_REASON_JOIN_TO,
4182 DHD_REASON_SCAN_TO,
4183 DHD_REASON_OQS_TO
4184 } timeout_reasons_t;
4185
4186 #ifdef REPORT_FATAL_TIMEOUTS
4187 void dhd_send_trap_to_fw_for_timeout(dhd_pub_t * pub, timeout_reasons_t reason);
4188 #endif
4189 #if defined(PCIE_OOB) || defined(PCIE_INB_DW)
4190 extern int dhd_bus_set_device_wake(struct dhd_bus *bus, bool val);
4191 extern void dhd_bus_dw_deassert(dhd_pub_t *dhd);
4192 #endif /* defined(PCIE_OOB) || defined(PCIE_INB_DW) */
4193 extern void dhd_prhex(const char *msg, volatile uchar *buf, uint nbytes, uint8 dbg_level);
4194 int dhd_tput_test(dhd_pub_t *dhd, tput_test_t *tput_data);
4195 void dhd_tput_test_rx(dhd_pub_t *dhd, void *pkt);
4196 #ifdef DHD_EFI
4197 int dhd_get_max_txbufs(dhd_pub_t *dhdp);
4198 #else
dhd_get_max_txbufs(dhd_pub_t * dhdp)4199 static INLINE int dhd_get_max_txbufs(dhd_pub_t *dhdp)
4200 { return -1; }
4201 #endif
4202
4203 #ifdef FILTER_IE
4204 int dhd_read_from_file(dhd_pub_t *dhd);
4205 int dhd_parse_filter_ie(dhd_pub_t *dhd, uint8 *buf);
4206 int dhd_get_filter_ie_count(dhd_pub_t *dhd, uint8 *buf);
4207 int dhd_parse_oui(dhd_pub_t *dhd, uint8 *inbuf, uint8 *oui, int len);
4208 int dhd_check_valid_ie(dhd_pub_t *dhdp, uint8 *buf, int len);
4209 #endif /* FILTER_IE */
4210
4211 uint16 dhd_prot_get_ioctl_trans_id(dhd_pub_t *dhdp);
4212
4213 #ifdef SET_PCIE_IRQ_CPU_CORE
4214 enum {
4215 DHD_AFFINITY_OFF = 0,
4216 DHD_AFFINITY_TPUT_150MBPS,
4217 DHD_AFFINITY_TPUT_300MBPS,
4218 DHD_AFFINITY_LAST
4219 };
4220
4221 extern void dhd_set_irq_cpucore(dhd_pub_t *dhdp, int affinity_cmd);
4222 #endif /* SET_PCIE_IRQ_CPU_CORE */
4223 #if defined(DHD_HANG_SEND_UP_TEST)
4224 extern void dhd_make_hang_with_reason(struct net_device *dev, const char *string_num);
4225 #endif /* DHD_HANG_SEND_UP_TEST */
4226 #ifdef BTLOG
4227 extern void dhd_rx_bt_log(dhd_pub_t *dhdp, void *pkt);
4228 #endif /* BTLOG */
4229
4230 #ifdef DHD_RND_DEBUG
4231 int dhd_dump_rnd_info(dhd_pub_t *dhd, uint8 *rnd_buf, uint32 rnd_len);
4232 int dhd_get_rnd_info(dhd_pub_t *dhd);
4233 #endif /* DHD_RND_DEBUG */
4234
4235 #ifdef DHD_WAKE_STATUS
4236 wake_counts_t* dhd_get_wakecount(dhd_pub_t *dhdp);
4237 #endif /* DHD_WAKE_STATUS */
4238 extern int dhd_get_random_bytes(uint8 *buf, uint len);
4239
4240 #if defined(DHD_BLOB_EXISTENCE_CHECK)
4241 extern void dhd_set_blob_support(dhd_pub_t *dhdp, char *fw_path);
4242 #endif /* DHD_BLOB_EXISTENCE_CHECK */
4243
4244 int dhd_get_preserve_log_numbers(dhd_pub_t *dhd, uint32 *logset_mask);
4245 #ifdef DHD_LOG_DUMP
4246 void dhd_schedule_log_dump(dhd_pub_t *dhdp, void *type);
4247 void dhd_log_dump_trigger(dhd_pub_t *dhdp, int subcmd);
4248 #endif
4249
4250 #ifdef DHD_LOG_DUMP
4251 int dhd_log_dump_ring_to_file(dhd_pub_t *dhdp, void *ring_ptr, void *file,
4252 unsigned long *file_posn, log_dump_section_hdr_t *sec_hdr, char *text_hdr,
4253 uint32 sec_type);
4254 int dhd_dump_debug_ring(dhd_pub_t *dhdp, void *ring_ptr, const void *user_buf,
4255 log_dump_section_hdr_t *sec_hdr, char *text_hdr, int buflen, uint32 sec_type);
4256 int dhd_log_dump_cookie_to_file(dhd_pub_t *dhdp, void *fp,
4257 const void *user_buf, unsigned long *f_pos);
4258 int dhd_log_dump_cookie(dhd_pub_t *dhdp, const void *user_buf);
4259 uint32 dhd_log_dump_cookie_len(dhd_pub_t *dhdp);
4260 int dhd_logdump_cookie_init(dhd_pub_t *dhdp, uint8 *buf, uint32 buf_size);
4261 void dhd_logdump_cookie_deinit(dhd_pub_t *dhdp);
4262 void dhd_logdump_cookie_save(dhd_pub_t *dhdp, char *cookie, char *type);
4263 int dhd_logdump_cookie_get(dhd_pub_t *dhdp, char *ret_cookie, uint32 buf_size);
4264 int dhd_logdump_cookie_count(dhd_pub_t *dhdp);
4265 int dhd_get_dld_log_dump(void *dev, dhd_pub_t *dhdp, const void *user_buf, void *fp,
4266 uint32 len, int type, void *pos);
4267 #if defined(BCMPCIE)
4268 int dhd_print_ext_trap_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4269 void *fp, uint32 len, void *pos);
4270 uint32 dhd_get_ext_trap_len(void *ndev, dhd_pub_t *dhdp);
4271 #endif /* BCMPCIE */
4272 int dhd_print_dump_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4273 void *fp, uint32 len, void *pos);
4274 int dhd_print_cookie_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4275 void *fp, uint32 len, void *pos);
4276 int dhd_print_health_chk_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4277 void *fp, uint32 len, void *pos);
4278 int dhd_print_time_str(const void *user_buf, void *fp, uint32 len, void *pos);
4279 #ifdef DHD_DUMP_PCIE_RINGS
4280 int dhd_print_flowring_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4281 void *fp, uint32 len, void *pos);
4282 uint32 dhd_get_flowring_len(void *ndev, dhd_pub_t *dhdp);
4283 #endif /* DHD_DUMP_PCIE_RINGS */
4284 #ifdef DHD_STATUS_LOGGING
4285 extern int dhd_print_status_log_data(void *dev, dhd_pub_t *dhdp,
4286 const void *user_buf, void *fp, uint32 len, void *pos);
4287 extern uint32 dhd_get_status_log_len(void *ndev, dhd_pub_t *dhdp);
4288 #endif /* DHD_STATUS_LOGGING */
4289 int dhd_print_ecntrs_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4290 void *fp, uint32 len, void *pos);
4291 int dhd_print_rtt_data(void *dev, dhd_pub_t *dhdp, const void *user_buf,
4292 void *fp, uint32 len, void *pos);
4293 int dhd_get_debug_dump_file_name(void *dev, dhd_pub_t *dhdp,
4294 char *dump_path, int size);
4295 uint32 dhd_get_time_str_len(void);
4296 uint32 dhd_get_health_chk_len(void *ndev, dhd_pub_t *dhdp);
4297 uint32 dhd_get_dhd_dump_len(void *ndev, dhd_pub_t *dhdp);
4298 uint32 dhd_get_cookie_log_len(void *ndev, dhd_pub_t *dhdp);
4299 uint32 dhd_get_ecntrs_len(void *ndev, dhd_pub_t *dhdp);
4300 uint32 dhd_get_rtt_len(void *ndev, dhd_pub_t *dhdp);
4301 uint32 dhd_get_dld_len(int log_type);
4302 void dhd_init_sec_hdr(log_dump_section_hdr_t *sec_hdr);
4303 extern char *dhd_log_dump_get_timestamp(void);
4304 bool dhd_log_dump_ecntr_enabled(void);
4305 bool dhd_log_dump_rtt_enabled(void);
4306 void dhd_nla_put_sssr_dump_len(void *ndev, uint32 *arr_len);
4307 int dhd_get_debug_dump(void *dev, const void *user_buf, uint32 len, int type);
4308 #ifdef DHD_SSSR_DUMP_BEFORE_SR
4309 int
4310 dhd_sssr_dump_d11_buf_before(void *dev, const void *user_buf, uint32 len, int core);
4311 int
4312 dhd_sssr_dump_dig_buf_before(void *dev, const void *user_buf, uint32 len);
4313 #endif /* DHD_SSSR_DUMP_BEFORE_SR */
4314 int
4315 dhd_sssr_dump_d11_buf_after(void *dev, const void *user_buf, uint32 len, int core);
4316 int
4317 dhd_sssr_dump_dig_buf_after(void *dev, const void *user_buf, uint32 len);
4318 #ifdef DHD_PKT_LOGGING
4319 extern int dhd_os_get_pktlog_dump(void *dev, const void *user_buf, uint32 len);
4320 extern uint32 dhd_os_get_pktlog_dump_size(struct net_device *dev);
4321 extern void dhd_os_get_pktlogdump_filename(struct net_device *dev, char *dump_path, int len);
4322 #endif /* DHD_PKT_LOGGING */
4323
4324 #ifdef DNGL_AXI_ERROR_LOGGING
4325 extern int dhd_os_get_axi_error_dump(void *dev, const void *user_buf, uint32 len);
4326 extern int dhd_os_get_axi_error_dump_size(struct net_device *dev);
4327 extern void dhd_os_get_axi_error_filename(struct net_device *dev, char *dump_path, int len);
4328 #endif /* DNGL_AXI_ERROR_LOGGING */
4329
4330 #endif /* DHD_LOG_DUMP */
4331
4332 #define DHD_WORD_TO_LEN_SHIFT (2u) /* WORD to BYTES SHIFT */
4333
4334 #if defined(linux) || defined(LINUX) || defined(DHD_EFI)
4335 int dhd_export_debug_data(void *mem_buf, void *fp, const void *user_buf, uint32 buf_len, void *pos);
4336 #else
dhd_export_debug_data(void * mem_buf,void * fp,const void * user_buf,uint32 buf_len,void * pos)4337 static int dhd_export_debug_data(void *mem_buf, void *fp, const void *user_buf,
4338 uint32 buf_len, void *pos)
4339 { return 0; }
4340 #endif /* linux || LINUX */
4341 #if defined(linux) || defined(LINUX)
4342 #define DHD_PCIE_CONFIG_SAVE(bus) pci_save_state(bus->dev)
4343 #define DHD_PCIE_CONFIG_RESTORE(bus) pci_restore_state(bus->dev)
4344 #elif defined(DHD_EFI) || defined(NDIS)
4345 /* For EFI the pcie config space which is saved during init
4346 * is the one that should always be restored, so NOP for save
4347 */
4348 #define DHD_PCIE_CONFIG_SAVE(bus)
4349 #define DHD_PCIE_CONFIG_RESTORE(bus) dhdpcie_config_restore(bus, TRUE)
4350 #else
4351 #define DHD_PCIE_CONFIG_SAVE(bus) do { /* noop */ } while (0)
4352 #define DHD_PCIE_CONFIG_RESTORE(bus) do { /* noop */ } while (0)
4353 #endif /* linux || LINUX */
4354
4355 typedef struct dhd_pkt_parse {
4356 uint32 proto; /* Network layer protocol */
4357 uint32 t1; /* n-tuple */
4358 uint32 t2;
4359 } dhd_pkt_parse_t;
4360
4361 /* ========= RING API functions : exposed to others ============= */
4362 #define DHD_RING_TYPE_FIXED 1
4363 #define DHD_RING_TYPE_SINGLE_IDX 2
4364 uint32 dhd_ring_get_hdr_size(void);
4365 void *dhd_ring_init(dhd_pub_t *dhdp, uint8 *buf, uint32 buf_size, uint32 elem_size,
4366 uint32 elem_cnt, uint32 type);
4367 void dhd_ring_deinit(dhd_pub_t *dhdp, void *_ring);
4368 void *dhd_ring_get_first(void *_ring);
4369 void dhd_ring_free_first(void *_ring);
4370 void dhd_ring_set_read_idx(void *_ring, uint32 read_idx);
4371 void dhd_ring_set_write_idx(void *_ring, uint32 write_idx);
4372 uint32 dhd_ring_get_read_idx(void *_ring);
4373 uint32 dhd_ring_get_write_idx(void *_ring);
4374 void *dhd_ring_get_last(void *_ring);
4375 void *dhd_ring_get_next(void *_ring, void *cur);
4376 void *dhd_ring_get_prev(void *_ring, void *cur);
4377 void *dhd_ring_get_empty(void *_ring);
4378 int dhd_ring_get_cur_size(void *_ring);
4379 void dhd_ring_lock(void *ring, void *fist_ptr, void *last_ptr);
4380 void dhd_ring_lock_free(void *ring);
4381 void *dhd_ring_lock_get_first(void *_ring);
4382 void *dhd_ring_lock_get_last(void *_ring);
4383 int dhd_ring_lock_get_count(void *_ring);
4384 void dhd_ring_lock_free_first(void *ring);
4385 void dhd_ring_whole_lock(void *ring);
4386 void dhd_ring_whole_unlock(void *ring);
4387
4388 #ifdef GDB_PROXY
4389 /** Firmware loaded and GDB proxy may access memory and registers */
4390 #define DHD_GDB_PROXY_PROBE_ACCESS_ENABLED 0x00000001
4391 /** Firmware loaded, access to it is enabled but it is not running yet */
4392 #define DHD_GDB_PROXY_PROBE_FIRMWARE_NOT_RUNNING 0x00000002
4393 /** Firmware is running */
4394 #define DHD_GDB_PROXY_PROBE_FIRMWARE_RUNNING 0x00000004
4395 /** Firmware was started in bootloader mode */
4396 #define DHD_GDB_PROXY_PROBE_BOOTLOADER_MODE 0x00000008
4397 /** Host memory code offload present */
4398 #define DHD_GDB_PROXY_PROBE_HOSTMEM_CODE 0x00000010
4399
4400 /* Data structure, returned by "gdb_proxy_probe" iovar */
4401 typedef struct dhd_gdb_proxy_probe_data {
4402 uint32 data_len; /* Length of data in structure */
4403 uint32 magic; /* Must contain DHD_IOCTL_MAGIC */
4404 uint32 flags; /* Set of DHD_GDB_PROXY_PROBE_... bits */
4405 uint32 last_id; /* 0 or proxy ID last set */
4406 uint32 hostmem_code_win_base; /* Hostmem code window start in ARM physical address space
4407 */
4408 uint32 hostmem_code_win_length; /* Hostmem code window length */
4409 } dhd_gdb_proxy_probe_data_t;
4410 #endif /* GDB_PROXY */
4411
4412 #if defined(DHD_AWDL) && defined(AWDL_SLOT_STATS)
4413 void dhd_clear_awdl_stats(dhd_pub_t *dhd);
4414 #endif /* DHD_AWDL && AWDL_SLOT_STATS */
4415 #ifdef DHD_EFI
4416 extern void dhd_insert_random_mac_addr(dhd_pub_t *dhd, char *nvram_mem, uint *len);
4417 #endif /* DHD_EFI */
4418
4419 #ifdef PKT_FILTER_SUPPORT
4420 extern void dhd_pktfilter_offload_set(dhd_pub_t * dhd, char *arg);
4421 extern void dhd_pktfilter_offload_enable(dhd_pub_t * dhd, char *arg, int enable, int master_mode);
4422 extern void dhd_pktfilter_offload_delete(dhd_pub_t *dhd, int id);
4423 #endif
4424
4425 #ifdef DHD_DUMP_PCIE_RINGS
4426 extern int dhd_d2h_h2d_ring_dump(dhd_pub_t *dhd, void *file, const void *user_buf,
4427 unsigned long *file_posn, bool file_write);
4428 #endif /* DHD_DUMP_PCIE_RINGS */
4429
4430 #ifdef EWP_EDL
4431 #define DHD_EDL_RING_SIZE (D2HRING_EDL_MAX_ITEM * D2HRING_EDL_ITEMSIZE)
4432 int dhd_event_logtrace_process_edl(dhd_pub_t *dhdp, uint8 *data,
4433 void *evt_decode_data);
4434 int dhd_edl_mem_init(dhd_pub_t *dhd);
4435 void dhd_edl_mem_deinit(dhd_pub_t *dhd);
4436 void dhd_prot_edl_ring_tcm_rd_update(dhd_pub_t *dhd);
4437 #define DHD_EDL_MEM_INIT(dhdp) dhd_edl_mem_init(dhdp)
4438 #define DHD_EDL_MEM_DEINIT(dhdp) dhd_edl_mem_deinit(dhdp)
4439 #define DHD_EDL_RING_TCM_RD_UPDATE(dhdp) \
4440 dhd_prot_edl_ring_tcm_rd_update(dhdp)
4441 #else
4442 #define DHD_EDL_MEM_INIT(dhdp) do { /* noop */ } while (0)
4443 #define DHD_EDL_MEM_DEINIT(dhdp) do { /* noop */ } while (0)
4444 #define DHD_EDL_RING_TCM_RD_UPDATE(dhdp) do { /* noop */ } while (0)
4445 #endif /* EWP_EDL */
4446
4447 #ifdef BIGDATA_SOFTAP
4448 void dhd_schedule_gather_ap_stadata(void *bcm_cfg, void *ndev, const wl_event_msg_t *e);
4449 #endif /* BIGDATA_SOFTAP */
4450
4451 #ifdef DHD_PKTTS
4452 int dhd_get_pktts_enab(dhd_pub_t *dhdp);
4453 int dhd_set_pktts_enab(dhd_pub_t *dhdp, bool val);
4454
4455 int dhd_get_pktts_flow(dhd_pub_t *dhdp, void *args, int len);
4456 int dhd_set_pktts_flow(dhd_pub_t *dhdp, void *params, int plen);
4457 pktts_flow_t *dhd_match_pktts_flow(dhd_pub_t *dhdp, uint32 checksum,
4458 uint32 *idx, uint32 *num_config);
4459 #endif /* DHD_PKTTS */
4460
4461 #if defined(DHD_H2D_LOG_TIME_SYNC)
4462 void dhd_h2d_log_time_sync_deferred_wq_schedule(dhd_pub_t *dhdp);
4463 void dhd_h2d_log_time_sync(dhd_pub_t *dhdp);
4464 #endif /* DHD_H2D_LOG_TIME_SYNC */
4465 extern void dhd_cleanup_if(struct net_device *net);
4466
4467 void dhd_schedule_logtrace(void *dhd_info);
4468 int dhd_print_fw_ver_from_file(dhd_pub_t *dhdp, char *fwpath);
4469
4470 #if defined(LINUX) || defined(linux)
4471 /* configuration of ecounters. API's tp start/stop. currently supported only for linux */
4472 extern int dhd_ecounter_configure(dhd_pub_t *dhd, bool enable);
4473 extern int dhd_start_ecounters(dhd_pub_t *dhd);
4474 extern int dhd_stop_ecounters(dhd_pub_t *dhd);
4475 extern int dhd_start_event_ecounters(dhd_pub_t *dhd);
4476 extern int dhd_stop_event_ecounters(dhd_pub_t *dhd);
4477 #endif /* LINUX || linux */
4478
4479 #define DHD_DUMP_TYPE_NAME_SIZE 32
4480 #define DHD_DUMP_FILE_PATH_SIZE 256
4481 #define DHD_DUMP_FILE_COUNT_MAX 5
4482 #define DHD_DUMP_TYPE_COUNT_MAX 10
4483
4484 #ifdef DHD_DUMP_MNGR
4485 typedef struct _DFM_elem {
4486 char type_name[DHD_DUMP_TYPE_NAME_SIZE];
4487 char file_path[DHD_DUMP_FILE_COUNT_MAX][DHD_DUMP_FILE_PATH_SIZE];
4488 int file_idx;
4489 } DFM_elem_t;
4490
4491 typedef struct _dhd_dump_file_manage {
4492 DFM_elem_t elems[DHD_DUMP_TYPE_COUNT_MAX];
4493 } dhd_dump_file_manage_t;
4494
4495 extern void dhd_dump_file_manage_enqueue(dhd_pub_t *dhd, char *dump_path, char *fname);
4496 #endif /* DHD_DUMP_MNGR */
4497
4498 #define HD_PREFIX_SIZE 2 /* hexadecimal prefix size */
4499 #define HD_BYTE_SIZE 2 /* hexadecimal byte size */
4500
4501 #ifdef DHD_HP2P
4502 extern unsigned long dhd_os_hp2plock(dhd_pub_t *pub);
4503 extern void dhd_os_hp2punlock(dhd_pub_t *pub, unsigned long flags);
4504 #endif /* DHD_HP2P */
4505
4506 #ifdef DNGL_AXI_ERROR_LOGGING
4507 extern void dhd_axi_error(dhd_pub_t *dhd);
4508 #ifdef DHD_USE_WQ_FOR_DNGL_AXI_ERROR
4509 extern void dhd_axi_error_dispatch(dhd_pub_t *dhdp);
4510 #endif /* DHD_USE_WQ_FOR_DNGL_AXI_ERROR */
4511 #endif /* DNGL_AXI_ERROR_LOGGING */
4512
4513 #ifdef DHD_STATUS_LOGGING
4514 #include <dhd_statlog.h>
4515 #else
4516 #define ST(x) 0
4517 #define STDIR(x) 0
4518 #define DHD_STATLOG_CTRL(dhdp, stat, ifidx, reason) \
4519 do { /* noop */ } while (0)
4520 #define DHD_STATLOG_DATA(dhdp, stat, ifidx, dir, cond) \
4521 do { BCM_REFERENCE(cond); } while (0)
4522 #define DHD_STATLOG_DATA_RSN(dhdp, stat, ifidx, dir, reason) \
4523 do { /* noop */ } while (0)
4524 #endif /* DHD_STATUS_LOGGING */
4525
4526 #ifdef SUPPORT_SET_TID
4527 enum dhd_set_tid_mode {
4528 /* Disalbe changing TID */
4529 SET_TID_OFF = 0,
4530 /* Change TID for all UDP frames */
4531 SET_TID_ALL_UDP,
4532 /* Change TID for UDP frames based on UID */
4533 SET_TID_BASED_ON_UID
4534 };
4535 #if defined(linux) || defined(LINUX)
4536 extern void dhd_set_tid_based_on_uid(dhd_pub_t *dhdp, void *pkt);
4537 #else
dhd_set_tid_based_on_uid(dhd_pub_t * dhdp,void * pkt)4538 static INLINE void dhd_set_tid_based_on_uid(dhd_pub_t *dhdp, void *pkt) { return; }
4539 #endif /* linux || LINUX */
4540 #endif /* SUPPORT_SET_TID */
4541
4542 #ifdef CONFIG_SILENT_ROAM
4543 extern int dhd_sroam_set_mon(dhd_pub_t *dhd, bool set);
4544 typedef wlc_sroam_info_v1_t wlc_sroam_info_t;
4545 #endif /* CONFIG_SILENT_ROAM */
4546
4547 #ifdef DHD_DUMP_FILE_WRITE_FROM_KERNEL
4548 #define FILE_NAME_HAL_TAG ""
4549 #else
4550 #define FILE_NAME_HAL_TAG "_hal" /* The tag name concatenated by HAL */
4551 #endif /* DHD_DUMP_FILE_WRITE_FROM_KERNEL */
4552
4553 /* Given a number 'n' returns 'm' that is next larger power of 2 after n */
next_larger_power2(uint32 num)4554 static inline uint32 next_larger_power2(uint32 num)
4555 {
4556 if (num) {
4557 num--;
4558 num |= (num >> 1);
4559 num |= (num >> 2);
4560 num |= (num >> 4);
4561 num |= (num >> 8);
4562 num |= (num >> 16);
4563 }
4564 return (num + 1);
4565 }
4566
4567 extern struct dhd_if * dhd_get_ifp(dhd_pub_t *dhdp, uint32 ifidx);
4568 uint8 dhd_d11_slices_num_get(dhd_pub_t *dhdp);
4569 #ifdef WL_AUTO_QOS
4570 extern void dhd_wl_sock_qos_set_status(dhd_pub_t *dhdp, unsigned long on_off);
4571 #endif /* WL_AUTO_QOS */
4572
4573 void *dhd_get_roam_evt(dhd_pub_t *dhdp);
4574 #if defined(DISABLE_HE_ENAB) || defined(CUSTOM_CONTROL_HE_ENAB)
4575 extern int dhd_control_he_enab(dhd_pub_t * dhd, uint8 he_enab);
4576 extern uint8 control_he_enab;
4577 #endif /* DISABLE_HE_ENAB || CUSTOM_CONTROL_HE_ENAB */
4578
4579 #ifdef DHD_SDTC_ETB_DUMP
4580
4581 #define DHD_SDTC_ETB_MEMPOOL_SIZE (33 * 1024)
4582 extern int dhd_sdtc_etb_mempool_init(dhd_pub_t *dhd);
4583 extern void dhd_sdtc_etb_mempool_deinit(dhd_pub_t *dhd);
4584 extern void dhd_sdtc_etb_init(dhd_pub_t *dhd);
4585 extern void dhd_sdtc_etb_deinit(dhd_pub_t *dhd);
4586 extern void dhd_sdtc_etb_dump(dhd_pub_t *dhd);
4587 #endif /* DHD_SDTC_ETB_DUMP */
4588
4589 #ifdef DHD_TX_PROFILE
4590 int dhd_tx_profile_attach(dhd_pub_t *dhdp);
4591 int dhd_tx_profile_detach(dhd_pub_t *dhdp);
4592 #endif /* defined (DHD_TX_PROFILE) */
4593 #if defined(DHD_LB_RXP)
4594 uint32 dhd_lb_rxp_process_qlen(dhd_pub_t *dhdp);
4595 /*
4596 * To avoid OOM, Flow control will be kicked in when packet size in process_queue
4597 * crosses LB_RXP_STOP_THR * rcpl ring size * 1500(pkt size) and will stop
4598 * when it goes below LB_RXP_STRT_THR * rcpl ring size * 1500(pkt size)
4599 */
4600 #define LB_RXP_STOP_THR 200 /* 200 * 1024 * 1500 = 300MB */
4601 #define LB_RXP_STRT_THR 199 /* 199 * 1024 * 1500 = 291MB */
4602 #endif /* DHD_LB_RXP */
4603 #ifdef DHD_SUPPORT_HDM
4604 extern bool hdm_trigger_init;
4605 extern int dhd_module_init_hdm(void);
4606 extern void dhd_hdm_wlan_sysfs_init(void);
4607 extern void dhd_hdm_wlan_sysfs_deinit(struct work_struct *);
4608 #define SYSFS_DEINIT_MS 10
4609 #endif /* DHD_SUPPORT_HDM */
4610
4611 #if defined(linux) || defined(LINUX)
4612 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0) && defined(DHD_TCP_LIMIT_OUTPUT)
4613 void dhd_ctrl_tcp_limit_output_bytes(int level);
4614 #endif /* LINUX_VERSION_CODE > 4.19.0 && DHD_TCP_LIMIT_OUTPUT */
4615 #endif /* linux || LINUX */
4616
4617 #if defined(__linux__)
4618 extern void dhd_schedule_delayed_dpc_on_dpc_cpu(dhd_pub_t *dhdp, ulong delay);
4619 extern void dhd_handle_pktdata(dhd_pub_t *dhdp, int ifidx, void *pkt, uint8 *pktdata,
4620 uint32 pktid, uint32 pktlen, uint16 *pktfate, uint8 *dhd_udr, bool tx, int pkt_wake,
4621 bool pkt_log);
4622 #else
dhd_schedule_delayed_dpc_on_dpc_cpu(dhd_pub_t * dhdp,ulong delay)4623 static INLINE void dhd_schedule_delayed_dpc_on_dpc_cpu(dhd_pub_t *dhdp, ulong delay)
4624 { return; }
dhd_handle_pktdata(dhd_pub_t * dhdp,int ifidx,void * pkt,uint8 * pktdata,uint32 pktid,uint32 pktlen,uint16 * pktfate,uint8 * dhd_udr,bool tx,int pkt_wake,bool pkt_log)4625 static INLINE void dhd_handle_pktdata(dhd_pub_t *dhdp, int ifidx, void *pkt, uint8 *pktdata,
4626 uint32 pktid, uint32 pktlen, uint16 *pktfate, uint8 *dhd_udr, bool tx, int pkt_wake,
4627 bool pkt_log) { return; }
4628 #endif /* __linux */
4629
4630 #if defined(BCMPCIE) && defined(__linux__)
4631 extern int dhd_check_shinfo_nrfrags(dhd_pub_t *dhdp, void *pktbuf, dmaaddr_t *pa, uint32 pktid);
4632 #else
dhd_check_shinfo_nrfrags(dhd_pub_t * dhdp,void * pktbuf,dmaaddr_t * pa,uint32 pktid)4633 static INLINE int dhd_check_shinfo_nrfrags(dhd_pub_t *dhdp, void *pktbuf, dmaaddr_t *pa,
4634 uint32 pktid) { return BCME_OK; }
4635 #endif /* BCMPCIE && __linux__ */
4636
4637 #ifdef HOST_SFH_LLC
4638 int dhd_ether_to_8023_hdr(osl_t *osh, struct ether_header *eh, void *p);
4639 int dhd_8023_llc_to_ether_hdr(osl_t *osh, struct ether_header *eh8023, void *p);
4640 #endif
4641 int dhd_schedule_socram_dump(dhd_pub_t *dhdp);
4642
4643 #ifdef DHD_AWDL
4644 int dhd_ether_to_awdl_llc_hdr(struct dhd_pub *dhd, struct ether_header *eh, void *p);
4645 int dhd_awdl_llc_to_eth_hdr(struct dhd_pub *dhd, struct ether_header *eh, void *p);
4646 #endif /* DHD_AWDL */
4647
4648 #ifdef DHD_DEBUGABILITY_LOG_DUMP_RING
4649 #ifndef DEBUGABILITY
4650 #error "DHD_DEBUGABILITY_LOG_DUMP_RING without DEBUGABILITY"
4651 #endif /* DEBUGABILITY */
4652 #endif /* DHD_DEBUGABILITY_LOG_DUMP_RING */
4653 #ifdef WL_MONITOR
4654 void dhd_set_monitor(dhd_pub_t *pub, int ifidx, int val);
4655 #endif /* WL_MONITOR */
4656 #endif /* _dhd_h_ */
4657