source: G950FXXS5DSI1
[GitHub/exynos8895/android_kernel_samsung_universal8895.git] / drivers / net / wireless / bcmdhd4361 / dhd_linux.h
1 /*
2 * DHD Linux header file (dhd_linux exports for cfg80211 and other components)
3 *
4 * Copyright (C) 1999-2019, Broadcom.
5 *
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:
11 *
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.
19 *
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.
23 *
24 *
25 * <<Broadcom-WL-IPTag/Open:>>
26 *
27 * $Id: dhd_linux.h 798798 2019-01-10 10:24:21Z $
28 */
29
30 /* wifi platform functions for power, interrupt and pre-alloc, either
31 * from Android-like platform device data, or Broadcom wifi platform
32 * device data.
33 *
34 */
35 #ifndef __DHD_LINUX_H__
36 #define __DHD_LINUX_H__
37
38 #include <linux/kernel.h>
39 #include <linux/init.h>
40 #include <linux/fs.h>
41 #include <dngl_stats.h>
42 #include <dhd.h>
43 /* Linux wireless extension support */
44 #if defined(WL_WIRELESS_EXT)
45 #include <wl_iw.h>
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>
52 #endif // endif
53
54 #ifdef WL_MONITOR
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 */
59
60 #define htod32(i) (i)
61 #define htod16(i) (i)
62 #define dtoh32(i) (i)
63 #define dtoh16(i) (i)
64 #define htodchanspec(i) (i)
65 #define dtohchanspec(i) (i)
66
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 */
75
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];
81 } dhd_if_event_t;
82
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 */
91 bool set_macaddress;
92 bool set_multicast;
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 */
104 #ifdef DHD_L2_FILTER
105 bool parp_enable;
106 bool parp_discard;
107 bool parp_allnode;
108 arp_table_t *phnd_arp_table;
109 /* for Per BSS modification */
110 bool dhcp_unicast;
111 bool block_ping;
112 bool grat_arp;
113 bool block_tdls;
114 #endif /* DHD_L2_FILTER */
115 #ifdef DHD_MCAST_REGEN
116 bool mcast_regen_bss_enable;
117 #endif // endif
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;
125 atomic_t m4state;
126 #endif /* DHD_4WAYM4_FAIL_DISCONNECT */
127 #ifdef DHDTCPSYNC_FLOOD_BLK
128 uint32 tsync_rcvd;
129 uint32 tsyncack_txed;
130 u64 last_sync;
131 struct work_struct blk_tsfl_work;
132 #endif /* DHDTCPSYNC_FLOOD_BLK */
133 } dhd_if_t;
134
135 struct ipv6_work_info_t {
136 uint8 if_idx;
137 char ipv6_addr[IPV6_ADDR_LEN];
138 unsigned long event;
139 };
140
141 typedef struct dhd_dump {
142 uint8 *buf;
143 int bufsize;
144 uint8 *hscb_buf;
145 int hscb_bufsize;
146 } dhd_dump_t;
147
148 #ifdef DHD_PCIE_NATIVE_RUNTIMEPM
149 struct dhd_rx_tx_work {
150 struct work_struct work;
151 struct sk_buff *skb;
152 struct net_device *net;
153 struct dhd_pub *pub;
154 };
155 #endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
156
157 #if defined(DHD_LB)
158 #if !defined(PCIE_FULL_DONGLE)
159 #error "DHD Loadbalancing only supported on PCIE_FULL_DONGLE"
160 #endif /* !PCIE_FULL_DONGLE */
161 #endif /* DHD_LB */
162
163 #if defined(DHD_LB_RXP) || defined(DHD_LB_RXC) || defined(DHD_LB_TXC) || \
164 defined(DHD_LB_STATS)
165 #if !defined(DHD_LB)
166 #error "DHD loadbalance derivatives are supported only if DHD_LB is defined"
167 #endif /* !DHD_LB */
168 #endif /* DHD_LB_RXP || DHD_LB_RXC || DHD_LB_TXC || DHD_LB_STATS */
169
170 #if defined(DHD_LB)
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>
177
178 #if !defined(DHD_LB_PRIMARY_CPUS)
179 #define DHD_LB_PRIMARY_CPUS 0x0 /* Big CPU coreids mask */
180 #endif // endif
181 #if !defined(DHD_LB_SECONDARY_CPUS)
182 #define DHD_LB_SECONDARY_CPUS 0xFE /* Little CPU coreids mask */
183 #endif // endif
184
185 #define HIST_BIN_SIZE 9
186
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;
191 int ifidx;
192 } dhd_tx_lb_pkttag_fr_t;
193
194 #define DHD_LB_TX_PKTTAG_SET_NETDEV(tag, netdevp) ((tag)->net = netdevp)
195 #define DHD_LB_TX_PKTTAG_NETDEV(tag) ((tag)->net)
196
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 */
200
201 #endif /* DHD_LB */
202
203 #ifdef FILTER_IE
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 */
209
210 #define NULL_CHECK(p, s, err) \
211 do { \
212 if (!(p)) { \
213 printk("NULL POINTER (%s) : %s\n", __FUNCTION__, (s)); \
214 err = BCME_ERROR; \
215 return err; \
216 } \
217 } while (0)
218
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);
228 #ifdef BCMSDIO
229 int (*get_wake_irq)(void);
230 #endif // endif
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)) */
236 };
237 #endif /* CONFIG_WIFI_CONTROL_FUNC */
238
239 #define DHD_REGISTRATION_TIMEOUT 12000 /* msec : allowed time to finished dhd registration */
240
241 typedef struct wifi_adapter_info {
242 const char *name;
243 uint irq_num;
244 uint intr_flags;
245 const char *fw_path;
246 const char *nv_path;
247 void *wifi_plat_data; /* wifi ctrl func, for backward compatibility */
248 uint bus_type;
249 uint bus_num;
250 uint slot_num;
251 #if defined(BT_OVER_SDIO)
252 const char *btfw_path;
253 #endif /* defined (BT_OVER_SDIO) */
254 } wifi_adapter_info_t;
255
256 typedef struct bcmdhd_wifi_platdata {
257 uint num_adapters;
258 wifi_adapter_info_t *adapters;
259 } bcmdhd_wifi_platdata_t;
260
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 */
270 } dhd_sta_t;
271 typedef dhd_sta_t dhd_sta_pool_t;
272
273 #ifdef CUSTOMER_HW4
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 */
304
305 #ifdef DHD_SEND_HANG_PRIVCMD_ERRORS
306 extern uint32 report_hang_privcmd_err;
307 #endif /* DHD_SEND_HANG_PRIVCMD_ERRORS */
308
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 */
318
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);
323
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);
326
327 typedef struct {
328 struct net_device *wlan_primary_netdev;
329 int argos_rps_cpus_enabled;
330 } argos_rps_ctrl;
331
332 #ifdef DYNAMIC_MUMIMO_CONTROL
333 typedef struct {
334 struct timer_list config_timer;
335 struct work_struct mumimo_ctrl_work;
336 struct net_device *dev;
337 int cur_murx_bfe_cap;
338 } argos_mumimo_ctrl;
339 #endif /* DYNAMIC_MUMIMO_CONTROL */
340
341 #ifdef BCMPCIE
342 #define RPS_TPUT_THRESHOLD 300
343 #else
344 #define RPS_TPUT_THRESHOLD 150
345 #endif /* BCMPCIE */
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 */
350
351 #if defined(BT_OVER_SDIO)
352 extern void wl_android_set_wifi_on_flag(bool enable);
353 #endif /* BT_OVER_SDIO */
354
355 #ifdef DHD_LOG_DUMP
356 /* 0: DLD_BUF_TYPE_GENERAL, 1: DLD_BUF_TYPE_PRESERVE
357 * 2: DLD_BUF_TYPE_SPECIAL
358 */
359 #define DLD_BUFFER_NUM 3
360
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 */
364
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
375 */
376 #define LOG_DUMP_KERNEL_TAIL_FLUSH_SIZE \
377 (15 * ((1 << CONFIG_LOG_BUF_SHIFT)/100))
378 #endif /* CONFIG_LOG_BUF_SHIFT */
379
380 #define LOG_DUMP_COOKIE_BUFSIZE 1024u
381
382 typedef struct {
383 char *hdr_str;
384 log_dump_section_type_t sec_type;
385 } dld_hdr_t;
386
387 #define DHD_PRINT_BUF_NAME_LEN 30
388 #endif /* DHD_LOG_DUMP */
389
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,
393 uint32 slot_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,
400 u32 flags);
401 #else
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);
406
407 int dhd_get_fw_mode(struct dhd_info *dhdinfo);
408 bool dhd_update_fw_nv_path(struct dhd_info *dhdinfo);
409
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
417
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__ */