2 * DHD Linux header file (dhd_linux exports for cfg80211 and other components)
4 * Copyright (C) 1999-2019, Broadcom.
6 * Unless you and Broadcom execute a separate written software license
7 * agreement governing use of this software, this software is licensed to you
8 * under the terms of the GNU General Public License version 2 (the "GPL"),
9 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
10 * following added to such license:
12 * As a special exception, the copyright holders of this software give you
13 * permission to link this software with independent modules, and to copy and
14 * distribute the resulting executable under terms of your choice, provided that
15 * you also meet, for each linked independent module, the terms and conditions of
16 * the license of that module. An independent module is a module which is not
17 * derived from this software. The special exception does not apply to any
18 * modifications of the software.
20 * Notwithstanding the above, under no circumstances may you combine this
21 * software in any way with any other Broadcom software provided under a license
22 * other than the GPL, without Broadcom's express prior written consent.
25 * <<Broadcom-WL-IPTag/Open:>>
27 * $Id: dhd_linux.h 798798 2019-01-10 10:24:21Z $
30 /* wifi platform functions for power, interrupt and pre-alloc, either
31 * from Android-like platform device data, or Broadcom wifi platform
35 #ifndef __DHD_LINUX_H__
36 #define __DHD_LINUX_H__
38 #include <linux/kernel.h>
39 #include <linux/init.h>
41 #include <dngl_stats.h>
43 /* Linux wireless extension support */
44 #if defined(WL_WIRELESS_EXT)
46 #endif /* defined(WL_WIRELESS_EXT) */
47 #if defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND)
48 #include <linux/earlysuspend.h>
49 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND) */
50 #if defined(CONFIG_WIFI_CONTROL_FUNC)
51 #include <linux/wlan_plat.h>
55 #include <bcmmsgbuf.h>
56 #define MAX_RADIOTAP_SIZE 256 /* Maximum size to hold HE Radiotap header format */
57 #define MAX_MON_PKT_SIZE (4096 + MAX_RADIOTAP_SIZE)
58 #endif /* WL_MONITOR */
64 #define htodchanspec(i) (i)
65 #define dtohchanspec(i) (i)
67 #ifdef BLOCK_IPV6_PACKET
68 #define HEX_PREF_STR "0x"
69 #define UNI_FILTER_STR "010000000000"
70 #define ZERO_ADDR_STR "000000000000"
71 #define ETHER_TYPE_STR "0000"
72 #define IPV6_FILTER_STR "20"
73 #define ZERO_TYPE_STR "00"
74 #endif /* BLOCK_IPV6_PACKET */
76 typedef struct dhd_if_event
{
77 struct list_head list
;
78 wl_event_data_if_t event
;
79 char name
[IFNAMSIZ
+1];
80 uint8 mac
[ETHER_ADDR_LEN
];
83 /* Interface control information */
84 typedef struct dhd_if
{
85 struct dhd_info
*info
; /* back pointer to dhd_info */
86 /* OS/stack specifics */
87 struct net_device
*net
;
88 int idx
; /* iface idx in dongle */
89 uint subunit
; /* subunit */
90 uint8 mac_addr
[ETHER_ADDR_LEN
]; /* assigned MAC address */
93 uint8 bssidx
; /* bsscfg index for the interface */
94 bool attached
; /* Delayed attachment when unset */
95 bool txflowcontrol
; /* Per interface flow control indicator */
96 char name
[IFNAMSIZ
+1]; /* linux interface name */
97 char dngl_name
[IFNAMSIZ
+1]; /* corresponding dongle interface name */
98 struct net_device_stats stats
;
99 #ifdef PCIE_FULL_DONGLE
100 struct list_head sta_list
; /* sll of associated stations */
101 spinlock_t sta_list_lock
; /* lock for manipulating sll */
102 #endif /* PCIE_FULL_DONGLE */
103 uint32 ap_isolate
; /* ap-isolation settings */
108 arp_table_t
*phnd_arp_table
;
109 /* for Per BSS modification */
114 #endif /* DHD_L2_FILTER */
115 #ifdef DHD_MCAST_REGEN
116 bool mcast_regen_bss_enable
;
118 bool rx_pkt_chainable
; /* set all rx packet to chainable config by default */
119 cumm_ctr_t cumm_ctr
; /* cummulative queue length of child flowrings */
120 uint8 tx_paths_active
;
121 bool del_in_progress
;
122 bool static_if
; /* used to avoid some operations on static_if */
123 #ifdef DHD_4WAYM4_FAIL_DISCONNECT
124 struct delayed_work m4state_work
;
126 #endif /* DHD_4WAYM4_FAIL_DISCONNECT */
127 #ifdef DHDTCPSYNC_FLOOD_BLK
129 uint32 tsyncack_txed
;
131 struct work_struct blk_tsfl_work
;
132 #endif /* DHDTCPSYNC_FLOOD_BLK */
135 struct ipv6_work_info_t
{
137 char ipv6_addr
[IPV6_ADDR_LEN
];
141 typedef struct dhd_dump
{
148 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
149 struct dhd_rx_tx_work
{
150 struct work_struct work
;
152 struct net_device
*net
;
155 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
158 #if !defined(PCIE_FULL_DONGLE)
159 #error "DHD Loadbalancing only supported on PCIE_FULL_DONGLE"
160 #endif /* !PCIE_FULL_DONGLE */
163 #if defined(DHD_LB_RXP) || defined(DHD_LB_RXC) || defined(DHD_LB_TXC) || \
164 defined(DHD_LB_STATS)
166 #error "DHD loadbalance derivatives are supported only if DHD_LB is defined"
168 #endif /* DHD_LB_RXP || DHD_LB_RXC || DHD_LB_TXC || DHD_LB_STATS */
171 /* Dynamic CPU selection for load balancing */
172 #include <linux/cpu.h>
173 #include <linux/cpumask.h>
174 #include <linux/notifier.h>
175 #include <linux/workqueue.h>
176 #include <asm/atomic.h>
178 #if !defined(DHD_LB_PRIMARY_CPUS)
179 #define DHD_LB_PRIMARY_CPUS 0x0 /* Big CPU coreids mask */
181 #if !defined(DHD_LB_SECONDARY_CPUS)
182 #define DHD_LB_SECONDARY_CPUS 0xFE /* Little CPU coreids mask */
185 #define HIST_BIN_SIZE 9
187 #if defined(DHD_LB_TXP)
188 /* Pkttag not compatible with PROP_TXSTATUS or WLFC */
189 typedef struct dhd_tx_lb_pkttag_fr
{
190 struct net_device
*net
;
192 } dhd_tx_lb_pkttag_fr_t
;
194 #define DHD_LB_TX_PKTTAG_SET_NETDEV(tag, netdevp) ((tag)->net = netdevp)
195 #define DHD_LB_TX_PKTTAG_NETDEV(tag) ((tag)->net)
197 #define DHD_LB_TX_PKTTAG_SET_IFIDX(tag, ifidx) ((tag)->ifidx = ifidx)
198 #define DHD_LB_TX_PKTTAG_IFIDX(tag) ((tag)->ifidx)
199 #endif /* DHD_LB_TXP */
204 #define FILTER_IE_PATH "/etc/wifi/filter_ie"
205 #define FILTER_IE_BUFSZ 1024 /* ioc buffsize for FILTER_IE */
206 #define FILE_BLOCK_READ_SIZE 256
207 #define WL_FILTER_IE_IOV_HDR_SIZE OFFSETOF(wl_filter_ie_iov_v1_t, tlvs)
208 #endif /* FILTER_IE */
210 #define NULL_CHECK(p, s, err) \
213 printk("NULL POINTER (%s) : %s\n", __FUNCTION__, (s)); \
219 #if !defined(CONFIG_WIFI_CONTROL_FUNC)
220 #define WLAN_PLAT_NODFS_FLAG 0x01
221 #define WLAN_PLAT_AP_FLAG 0x02
222 struct wifi_platform_data
{
223 int (*set_power
)(int val
);
224 int (*set_reset
)(int val
);
225 int (*set_carddetect
)(int val
);
226 void *(*mem_prealloc
)(int section
, unsigned long size
);
227 int (*get_mac_addr
)(unsigned char *buf
);
229 int (*get_wake_irq
)(void);
231 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) || defined(CUSTOM_COUNTRY_CODE)
232 void *(*get_country_code
)(char *ccode
, u32 flags
);
233 #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) || defined (CUSTOM_COUNTRY_CODE) */
234 void *(*get_country_code
)(char *ccode
);
235 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) */
237 #endif /* CONFIG_WIFI_CONTROL_FUNC */
239 #define DHD_REGISTRATION_TIMEOUT 12000 /* msec : allowed time to finished dhd registration */
241 typedef struct wifi_adapter_info
{
247 void *wifi_plat_data
; /* wifi ctrl func, for backward compatibility */
251 #if defined(BT_OVER_SDIO)
252 const char *btfw_path
;
253 #endif /* defined (BT_OVER_SDIO) */
254 } wifi_adapter_info_t
;
256 typedef struct bcmdhd_wifi_platdata
{
258 wifi_adapter_info_t
*adapters
;
259 } bcmdhd_wifi_platdata_t
;
261 /** Per STA params. A list of dhd_sta objects are managed in dhd_if */
262 typedef struct dhd_sta
{
263 cumm_ctr_t cumm_ctr
; /* cummulative queue length of child flowrings */
264 uint16 flowid
[NUMPRIO
]; /* allocated flow ring ids (by priority) */
265 void * ifp
; /* associated dhd_if */
266 struct ether_addr ea
; /* stations ethernet mac address */
267 struct list_head list
; /* link into dhd_if::sta_list */
268 int idx
; /* index of self in dhd_pub::sta_pool[] */
269 int ifidx
; /* index of interface in dhd */
271 typedef dhd_sta_t dhd_sta_pool_t
;
274 #ifdef MIMO_ANT_SETTING
275 #ifdef DHD_EXPORT_CNTL_FILE
276 extern unsigned long antsel
;
277 #endif /* DHD_EXPORT_CNTL_FILE */
278 extern int dhd_sel_ant_from_file(dhd_pub_t
*dhd
);
279 #endif /* MIMO_ANT_SETTING */
280 #ifdef WRITE_WLANINFO
281 #define MAX_VERSION_LEN 512
282 #ifdef DHD_EXPORT_CNTL_FILE
283 extern char version_info
[MAX_VERSION_LEN
];
284 #endif /* DHD_EXPORT_CNTL_FILE */
285 extern uint32
sec_save_wlinfo(char *firm_ver
, char *dhd_ver
, char *nvram_p
, char *clm_ver
);
286 #endif /* WRITE_WLANINFO */
287 #ifdef DHD_OF_SUPPORT
288 extern void interrupt_set_cpucore(int set
, unsigned int dpc_cpucore
, unsigned int primary_cpucore
);
289 #endif /* DHD_OF_SUPPORT */
290 #ifdef LOGTRACE_FROM_FILE
291 extern int dhd_logtrace_from_file(dhd_pub_t
*dhd
);
292 #ifdef DHD_EXPORT_CNTL_FILE
293 extern unsigned long logtrace_val
;
294 #endif /* DHD_EXPORT_CNTL_FILE */
295 #endif /* LOGTRACE_FROM_FILE */
296 #ifdef GEN_SOFTAP_INFO_FILE
297 #define SOFTAP_INFO_BUF_SZ 512
298 #ifdef DHD_EXPORT_CNTL_FILE
299 extern char softapinfostr
[SOFTAP_INFO_BUF_SZ
];
300 #endif /* DHD_EXPORT_CNTL_FILE */
301 extern uint32
sec_save_softap_info(void);
302 #endif /* GEN_SOFTAP_INFO_FILE */
303 #endif /* CUSTOMER_HW4 */
305 #ifdef DHD_SEND_HANG_PRIVCMD_ERRORS
306 extern uint32 report_hang_privcmd_err
;
307 #endif /* DHD_SEND_HANG_PRIVCMD_ERRORS */
309 #if defined(ARGOS_CPU_SCHEDULER) && !defined(DHD_LB_IRQSET) && \
310 !defined(CONFIG_SOC_EXYNOS7870)
311 extern int argos_task_affinity_setup_label(struct task_struct
*p
, const char *label
,
312 struct cpumask
* affinity_cpu_mask
, struct cpumask
* default_cpu_mask
);
313 extern struct cpumask hmp_slow_cpu_mask
;
314 extern struct cpumask hmp_fast_cpu_mask
;
315 extern void set_irq_cpucore(unsigned int irq
, cpumask_var_t default_cpu_mask
,
316 cpumask_var_t affinity_cpu_mask
);
317 #endif /* ARGOS_CPU_SCHEDULER && !DHD_LB_IRQSET && !CONFIG_SOC_EXYNOS7870 */
319 #if (defined(ARGOS_CPU_SCHEDULER) && defined(ARGOS_RPS_CPU_CTL)) || \
320 defined(ARGOS_NOTIFY_CB)
321 int argos_register_notifier_init(struct net_device
*net
);
322 int argos_register_notifier_deinit(void);
324 extern int sec_argos_register_notifier(struct notifier_block
*n
, char *label
);
325 extern int sec_argos_unregister_notifier(struct notifier_block
*n
, char *label
);
328 struct net_device
*wlan_primary_netdev
;
329 int argos_rps_cpus_enabled
;
332 #ifdef DYNAMIC_MUMIMO_CONTROL
334 struct timer_list config_timer
;
335 struct work_struct mumimo_ctrl_work
;
336 struct net_device
*dev
;
337 int cur_murx_bfe_cap
;
339 #endif /* DYNAMIC_MUMIMO_CONTROL */
342 #define RPS_TPUT_THRESHOLD 300
344 #define RPS_TPUT_THRESHOLD 150
346 #define DELAY_TO_CLEAR_RPS_CPUS 300
347 #define SUMIMO_TO_MUMIMO_TPUT_THRESHOLD 0
348 #define MUMIMO_TO_SUMIMO_TPUT_THRESHOLD 150
349 #endif /* (ARGOS_RPS_CPU_CTL && ARGOS_CPU_SCHEDULER) || ARGOS_NOTIFY_CB */
351 #if defined(BT_OVER_SDIO)
352 extern void wl_android_set_wifi_on_flag(bool enable
);
353 #endif /* BT_OVER_SDIO */
356 /* 0: DLD_BUF_TYPE_GENERAL, 1: DLD_BUF_TYPE_PRESERVE
357 * 2: DLD_BUF_TYPE_SPECIAL
359 #define DLD_BUFFER_NUM 3
361 #ifndef CUSTOM_LOG_DUMP_BUFSIZE_MB
362 #define CUSTOM_LOG_DUMP_BUFSIZE_MB 4 /* DHD_LOG_DUMP_BUF_SIZE 4 MB static memory in kernel */
363 #endif /* CUSTOM_LOG_DUMP_BUFSIZE_MB */
365 #define LOG_DUMP_TOTAL_BUFSIZE (1024 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
366 #define LOG_DUMP_GENERAL_MAX_BUFSIZE (384 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
367 #define LOG_DUMP_PRESERVE_MAX_BUFSIZE (128 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
368 #define LOG_DUMP_SPECIAL_MAX_BUFSIZE (8 * 1024)
369 #define LOG_DUMP_ECNTRS_MAX_BUFSIZE (384 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
370 #define LOG_DUMP_FILTER_MAX_BUFSIZE (128 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
371 #define LOG_DUMP_MAX_FILESIZE (8 *1024 * 1024) /* 8 MB default */
372 #ifdef CONFIG_LOG_BUF_SHIFT
373 /* 15% of kernel log buf size, if for example klog buf size is 512KB
374 * 15% of 512KB ~= 80KB
376 #define LOG_DUMP_KERNEL_TAIL_FLUSH_SIZE \
377 (15 * ((1 << CONFIG_LOG_BUF_SHIFT)/100))
378 #endif /* CONFIG_LOG_BUF_SHIFT */
380 #define LOG_DUMP_COOKIE_BUFSIZE 1024u
384 log_dump_section_type_t sec_type
;
387 #define DHD_PRINT_BUF_NAME_LEN 30
388 #endif /* DHD_LOG_DUMP */
390 int dhd_wifi_platform_register_drv(void);
391 void dhd_wifi_platform_unregister_drv(void);
392 wifi_adapter_info_t
* dhd_wifi_platform_get_adapter(uint32 bus_type
, uint32 bus_num
,
394 int wifi_platform_set_power(wifi_adapter_info_t
*adapter
, bool on
, unsigned long msec
);
395 int wifi_platform_bus_enumerate(wifi_adapter_info_t
*adapter
, bool device_present
);
396 int wifi_platform_get_irq_number(wifi_adapter_info_t
*adapter
, unsigned long *irq_flags_ptr
);
397 int wifi_platform_get_mac_addr(wifi_adapter_info_t
*adapter
, unsigned char *buf
);
398 #ifdef CUSTOM_COUNTRY_CODE
399 void *wifi_platform_get_country_code(wifi_adapter_info_t
*adapter
, char *ccode
,
402 void *wifi_platform_get_country_code(wifi_adapter_info_t
*adapter
, char *ccode
);
403 #endif /* CUSTOM_COUNTRY_CODE */
404 void* wifi_platform_prealloc(wifi_adapter_info_t
*adapter
, int section
, unsigned long size
);
405 void* wifi_platform_get_prealloc_func_ptr(wifi_adapter_info_t
*adapter
);
407 int dhd_get_fw_mode(struct dhd_info
*dhdinfo
);
408 bool dhd_update_fw_nv_path(struct dhd_info
*dhdinfo
);
410 #if defined(BT_OVER_SDIO)
411 int dhd_net_bus_get(struct net_device
*dev
);
412 int dhd_net_bus_put(struct net_device
*dev
);
413 #endif /* BT_OVER_SDIO */
414 #if defined(WLADPS) || defined(WLADPS_PRIVATE_CMD)
415 #define ADPS_ENABLE 1
416 #define ADPS_DISABLE 0
418 int dhd_enable_adps(dhd_pub_t
*dhd
, uint8 on
);
419 #endif /* WLADPS || WLADPS_PRIVATE_CMD */
420 #ifdef DHD_DISABLE_VHTMODE
421 extern void dhd_disable_vhtmode(dhd_pub_t
*dhd
);
422 #endif /* DHD_DISABLE_VHTMODE */
423 #ifdef DHDTCPSYNC_FLOOD_BLK
424 extern void dhd_reset_tcpsync_info_by_dev(struct net_device
*dev
);
425 #endif /* DHDTCPSYNC_FLOOD_BLK */
426 #endif /* __DHD_LINUX_H__ */