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