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