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