forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/net/wireless/rockchip_wlan/cywdhd/bcmdhd/dhd_linux.h
....@@ -1,15 +1,16 @@
1
-/* SPDX-License-Identifier: GPL-2.0 */
21 /*
32 * DHD Linux header file (dhd_linux exports for cfg80211 and other components)
43 *
5
- * Copyright (C) 1999-2019, Broadcom Corporation
6
- *
4
+ * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation
5
+ *
6
+ * Copyright (C) 1999-2017, Broadcom Corporation
7
+ *
78 * Unless you and Broadcom execute a separate written software license
89 * agreement governing use of this software, this software is licensed to you
910 * under the terms of the GNU General Public License version 2 (the "GPL"),
1011 * available at http://www.broadcom.com/licenses/GPLv2.php, with the
1112 * following added to such license:
12
- *
13
+ *
1314 * As a special exception, the copyright holders of this software give you
1415 * permission to link this software with independent modules, and to copy and
1516 * distribute the resulting executable under terms of your choice, provided that
....@@ -17,7 +18,7 @@
1718 * the license of that module. An independent module is a module which is not
1819 * derived from this software. The special exception does not apply to any
1920 * modifications of the software.
20
- *
21
+ *
2122 * Notwithstanding the above, under no circumstances may you combine this
2223 * software in any way with any other Broadcom software provided under a license
2324 * other than the GPL, without Broadcom's express prior written consent.
....@@ -25,7 +26,7 @@
2526 *
2627 * <<Broadcom-WL-IPTag/Open:>>
2728 *
28
- * $Id: dhd_linux.h 399301 2013-04-29 21:41:52Z $
29
+ * $Id: dhd_linux.h 701006 2017-05-23 08:25:04Z $
2930 */
3031
3132 /* wifi platform functions for power, interrupt and pre-alloc, either
....@@ -39,11 +40,13 @@
3940 #include <linux/kernel.h>
4041 #include <linux/init.h>
4142 #include <linux/fs.h>
43
+
4244 #include <dngl_stats.h>
4345 #include <dhd.h>
44
-#ifdef DHD_WMF
45
-#include <dhd_wmf_linux.h>
46
-#endif
46
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 1))
47
+#include <linux/time64.h>
48
+#define get_monotonic_boottime ktime_get_boottime_ts64
49
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 1)) */
4750 /* Linux wireless extension support */
4851 #if defined(WL_WIRELESS_EXT)
4952 #include <wl_iw.h>
....@@ -51,26 +54,211 @@
5154 #if defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND)
5255 #include <linux/earlysuspend.h>
5356 #endif /* defined(CONFIG_HAS_EARLYSUSPEND) && defined(DHD_USE_EARLYSUSPEND) */
54
-
5557 #if defined(CONFIG_WIFI_CONTROL_FUNC)
5658 #include <linux/wlan_plat.h>
57
-#endif
59
+#endif // endif
60
+#ifdef PCIE_FULL_DONGLE
61
+#include <etd.h>
62
+#endif /* PCIE_FULL_DONGLE */
63
+#ifdef WL_MONITOR
64
+#include <bcmmsgbuf.h>
65
+#define MAX_RADIOTAP_SIZE 256 /* Maximum size to hold HE Radiotap header format */
66
+#define MAX_MON_PKT_SIZE (4096 + MAX_RADIOTAP_SIZE)
67
+#endif /* WL_MONITOR */
68
+
69
+#define FILE_DUMP_MAX_WAIT_TIME 4000
70
+
71
+#define htod32(i) (i)
72
+#define htod16(i) (i)
73
+#define dtoh32(i) (i)
74
+#define dtoh16(i) (i)
75
+#define htodchanspec(i) (i)
76
+#define dtohchanspec(i) (i)
77
+
78
+#ifdef BLOCK_IPV6_PACKET
79
+#define HEX_PREF_STR "0x"
80
+#define UNI_FILTER_STR "010000000000"
81
+#define ZERO_ADDR_STR "000000000000"
82
+#define ETHER_TYPE_STR "0000"
83
+#define IPV6_FILTER_STR "20"
84
+#define ZERO_TYPE_STR "00"
85
+#endif /* BLOCK_IPV6_PACKET */
86
+
87
+typedef struct dhd_if_event {
88
+ struct list_head list;
89
+ wl_event_data_if_t event;
90
+ char name[IFNAMSIZ+1];
91
+ uint8 mac[ETHER_ADDR_LEN];
92
+} dhd_if_event_t;
93
+
94
+/* Interface control information */
95
+typedef struct dhd_if {
96
+ struct dhd_info *info; /* back pointer to dhd_info */
97
+ /* OS/stack specifics */
98
+ struct net_device *net;
99
+ int idx; /* iface idx in dongle */
100
+ uint subunit; /* subunit */
101
+ uint8 mac_addr[ETHER_ADDR_LEN]; /* assigned MAC address */
102
+ bool set_macaddress;
103
+ bool set_multicast;
104
+ uint8 bssidx; /* bsscfg index for the interface */
105
+ bool attached; /* Delayed attachment when unset */
106
+ bool txflowcontrol; /* Per interface flow control indicator */
107
+ char name[IFNAMSIZ+1]; /* linux interface name */
108
+ char dngl_name[IFNAMSIZ+1]; /* corresponding dongle interface name */
109
+ struct net_device_stats stats;
110
+ struct list_head sta_list; /* sll of associated stations */
111
+ spinlock_t sta_list_lock; /* lock for manipulating sll */
112
+ uint32 ap_isolate; /* ap-isolation settings */
113
+#ifdef DHD_L2_FILTER
114
+ bool parp_enable;
115
+ bool parp_discard;
116
+ bool parp_allnode;
117
+ arp_table_t *phnd_arp_table;
118
+ /* for Per BSS modification */
119
+ bool dhcp_unicast;
120
+ bool block_ping;
121
+ bool grat_arp;
122
+ bool block_tdls;
123
+#endif /* DHD_L2_FILTER */
124
+#ifdef DHD_MCAST_REGEN
125
+ bool mcast_regen_bss_enable;
126
+#endif // endif
127
+ bool rx_pkt_chainable; /* set all rx packet to chainable config by default */
128
+ cumm_ctr_t cumm_ctr; /* cummulative queue length of child flowrings */
129
+ uint8 tx_paths_active;
130
+ bool del_in_progress;
131
+ bool static_if; /* used to avoid some operations on static_if */
132
+#ifdef DHD_4WAYM4_FAIL_DISCONNECT
133
+ struct delayed_work m4state_work;
134
+ atomic_t m4state;
135
+#endif /* DHD_4WAYM4_FAIL_DISCONNECT */
136
+#ifdef DHD_POST_EAPOL_M1_AFTER_ROAM_EVT
137
+ bool recv_reassoc_evt;
138
+ bool post_roam_evt;
139
+#endif /* DHD_POST_EAPOL_M1_AFTER_ROAM_EVT */
140
+#ifdef DHDTCPSYNC_FLOOD_BLK
141
+ uint32 tsync_rcvd;
142
+ uint32 tsyncack_txed;
143
+ u64 last_sync;
144
+ struct work_struct blk_tsfl_work;
145
+#endif /* DHDTCPSYNC_FLOOD_BLK */
146
+#if defined(BCMSDIO)
147
+ int role;
148
+#endif /* BCMSDIO */
149
+} dhd_if_t;
150
+
151
+struct ipv6_work_info_t {
152
+ uint8 if_idx;
153
+ char ipv6_addr[IPV6_ADDR_LEN];
154
+ unsigned long event;
155
+};
156
+
157
+typedef struct dhd_dump {
158
+ uint8 *buf;
159
+ int bufsize;
160
+ uint8 *hscb_buf;
161
+ int hscb_bufsize;
162
+} dhd_dump_t;
163
+#ifdef DNGL_AXI_ERROR_LOGGING
164
+typedef struct dhd_axi_error_dump {
165
+ ulong fault_address;
166
+ uint32 axid;
167
+ struct hnd_ext_trap_axi_error_v1 etd_axi_error_v1;
168
+} dhd_axi_error_dump_t;
169
+#endif /* DNGL_AXI_ERROR_LOGGING */
170
+
171
+#ifdef DHD_PCIE_NATIVE_RUNTIMEPM
172
+struct dhd_rx_tx_work {
173
+ struct work_struct work;
174
+ struct sk_buff *skb;
175
+ struct net_device *net;
176
+ struct dhd_pub *pub;
177
+};
178
+#endif /* DHD_PCIE_NATIVE_RUNTIMEPM */
179
+
180
+#if defined(DHD_LB)
181
+#if !defined(PCIE_FULL_DONGLE)
182
+#error "DHD Loadbalancing only supported on PCIE_FULL_DONGLE"
183
+#endif /* !PCIE_FULL_DONGLE */
184
+#endif /* DHD_LB */
185
+
186
+#if defined(DHD_LB_RXP) || defined(DHD_LB_RXC) || defined(DHD_LB_TXC) || \
187
+ defined(DHD_LB_STATS)
188
+#if !defined(DHD_LB)
189
+#error "DHD loadbalance derivatives are supported only if DHD_LB is defined"
190
+#endif /* !DHD_LB */
191
+#endif /* DHD_LB_RXP || DHD_LB_RXC || DHD_LB_TXC || DHD_LB_STATS */
192
+
193
+#if defined(DHD_LB)
194
+/* Dynamic CPU selection for load balancing */
195
+#include <linux/cpu.h>
196
+#include <linux/cpumask.h>
197
+#include <linux/notifier.h>
198
+#include <linux/workqueue.h>
199
+#include <asm/atomic.h>
200
+
201
+#if !defined(DHD_LB_PRIMARY_CPUS)
202
+#define DHD_LB_PRIMARY_CPUS 0x0 /* Big CPU coreids mask */
203
+#endif // endif
204
+#if !defined(DHD_LB_SECONDARY_CPUS)
205
+#define DHD_LB_SECONDARY_CPUS 0xFE /* Little CPU coreids mask */
206
+#endif // endif
207
+
208
+#define HIST_BIN_SIZE 9
209
+
210
+#if defined(DHD_LB_TXP)
211
+/* Pkttag not compatible with PROP_TXSTATUS or WLFC */
212
+typedef struct dhd_tx_lb_pkttag_fr {
213
+ struct net_device *net;
214
+ int ifidx;
215
+} dhd_tx_lb_pkttag_fr_t;
216
+
217
+#define DHD_LB_TX_PKTTAG_SET_NETDEV(tag, netdevp) ((tag)->net = netdevp)
218
+#define DHD_LB_TX_PKTTAG_NETDEV(tag) ((tag)->net)
219
+
220
+#define DHD_LB_TX_PKTTAG_SET_IFIDX(tag, ifidx) ((tag)->ifidx = ifidx)
221
+#define DHD_LB_TX_PKTTAG_IFIDX(tag) ((tag)->ifidx)
222
+#endif /* DHD_LB_TXP */
223
+
224
+#endif /* DHD_LB */
225
+
226
+#ifdef FILTER_IE
227
+#define FILTER_IE_PATH "/etc/wifi/filter_ie"
228
+#define FILTER_IE_BUFSZ 1024 /* ioc buffsize for FILTER_IE */
229
+#define FILE_BLOCK_READ_SIZE 256
230
+#define WL_FILTER_IE_IOV_HDR_SIZE OFFSETOF(wl_filter_ie_iov_v1_t, tlvs)
231
+#endif /* FILTER_IE */
232
+
233
+#define NULL_CHECK(p, s, err) \
234
+ do { \
235
+ if (!(p)) { \
236
+ printk("NULL POINTER (%s) : %s\n", __FUNCTION__, (s)); \
237
+ err = BCME_ERROR; \
238
+ return err; \
239
+ } \
240
+ } while (0)
58241
59242 #if !defined(CONFIG_WIFI_CONTROL_FUNC)
60
-#define WLAN_PLAT_NODFS_FLAG 0x01
243
+#define WLAN_PLAT_NODFS_FLAG 0x01
244
+#define WLAN_PLAT_AP_FLAG 0x02
61245 struct wifi_platform_data {
62246 int (*set_power)(int val);
63247 int (*set_reset)(int val);
64248 int (*set_carddetect)(int val);
65249 void *(*mem_prealloc)(int section, unsigned long size);
66250 int (*get_mac_addr)(unsigned char *buf);
251
+#ifdef BCMSDIO
252
+ int (*get_wake_irq)(void);
253
+#endif // endif
67254 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) || defined(CUSTOM_COUNTRY_CODE)
68255 void *(*get_country_code)(char *ccode, u32 flags);
69256 #else /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) || defined (CUSTOM_COUNTRY_CODE) */
70257 void *(*get_country_code)(char *ccode);
71258 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 58)) */
72
- };
259
+};
73260 #endif /* CONFIG_WIFI_CONTROL_FUNC */
261
+
74262 #define DHD_REGISTRATION_TIMEOUT 12000 /* msec : allowed time to finished dhd registration */
75263
76264 typedef struct wifi_adapter_info {
....@@ -83,6 +271,9 @@
83271 uint bus_type;
84272 uint bus_num;
85273 uint slot_num;
274
+#if defined(BT_OVER_SDIO)
275
+ const char *btfw_path;
276
+#endif /* defined (BT_OVER_SDIO) */
86277 } wifi_adapter_info_t;
87278
88279 typedef struct bcmdhd_wifi_platdata {
....@@ -99,11 +290,97 @@
99290 struct list_head list; /* link into dhd_if::sta_list */
100291 int idx; /* index of self in dhd_pub::sta_pool[] */
101292 int ifidx; /* index of interface in dhd */
102
-#ifdef DHD_WMF
103
- struct dhd_sta *psta_prim; /* primary index of psta interface */
104
-#endif /* DHD_WMF */
105293 } dhd_sta_t;
106294 typedef dhd_sta_t dhd_sta_pool_t;
295
+
296
+#ifdef DHD_4WAYM4_FAIL_DISCONNECT
297
+typedef enum {
298
+ M3_RXED,
299
+ M4_TXFAILED
300
+} msg_4way_state_t;
301
+#define MAX_4WAY_TIMEOUT_MS 2000
302
+#endif /* DHD_4WAYM4_FAIL_DISCONNECT */
303
+
304
+#ifdef DHD_SEND_HANG_PRIVCMD_ERRORS
305
+extern uint32 report_hang_privcmd_err;
306
+#endif /* DHD_SEND_HANG_PRIVCMD_ERRORS */
307
+
308
+#if defined(ARGOS_NOTIFY_CB)
309
+int argos_register_notifier_init(struct net_device *net);
310
+int argos_register_notifier_deinit(void);
311
+
312
+extern int sec_argos_register_notifier(struct notifier_block *n, char *label);
313
+extern int sec_argos_unregister_notifier(struct notifier_block *n, char *label);
314
+
315
+typedef struct {
316
+ struct net_device *wlan_primary_netdev;
317
+ int argos_rps_cpus_enabled;
318
+} argos_rps_ctrl;
319
+
320
+#define RPS_TPUT_THRESHOLD 300
321
+#define DELAY_TO_CLEAR_RPS_CPUS 300
322
+#endif // endif
323
+
324
+#if defined(BT_OVER_SDIO)
325
+extern void wl_android_set_wifi_on_flag(bool enable);
326
+#endif /* BT_OVER_SDIO */
327
+
328
+#ifdef DHD_LOG_DUMP
329
+/* 0: DLD_BUF_TYPE_GENERAL, 1: DLD_BUF_TYPE_PRESERVE
330
+* 2: DLD_BUF_TYPE_SPECIAL
331
+*/
332
+#define DLD_BUFFER_NUM 3
333
+
334
+#ifndef CUSTOM_LOG_DUMP_BUFSIZE_MB
335
+#define CUSTOM_LOG_DUMP_BUFSIZE_MB 4 /* DHD_LOG_DUMP_BUF_SIZE 4 MB static memory in kernel */
336
+#endif /* CUSTOM_LOG_DUMP_BUFSIZE_MB */
337
+
338
+#define LOG_DUMP_TOTAL_BUFSIZE (1024 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
339
+
340
+/*
341
+ * Below are different sections that use the prealloced buffer
342
+ * and sum of the sizes of these should not cross LOG_DUMP_TOTAL_BUFSIZE
343
+ */
344
+#define LOG_DUMP_GENERAL_MAX_BUFSIZE (256 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
345
+#define LOG_DUMP_PRESERVE_MAX_BUFSIZE (128 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
346
+#define LOG_DUMP_ECNTRS_MAX_BUFSIZE (256 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
347
+#define LOG_DUMP_RTT_MAX_BUFSIZE (256 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
348
+#define LOG_DUMP_FILTER_MAX_BUFSIZE (128 * 1024 * CUSTOM_LOG_DUMP_BUFSIZE_MB)
349
+
350
+#if LOG_DUMP_TOTAL_BUFSIZE < (LOG_DUMP_GENERAL_MAX_BUFSIZE + \
351
+ LOG_DUMP_PRESERVE_MAX_BUFSIZE + LOG_DUMP_ECNTRS_MAX_BUFSIZE + LOG_DUMP_RTT_MAX_BUFSIZE \
352
+ + LOG_DUMP_FILTER_MAX_BUFSIZE)
353
+#error "LOG_DUMP_TOTAL_BUFSIZE is lesser than sum of all rings"
354
+#endif // endif
355
+
356
+/* Special buffer is allocated as separately in prealloc */
357
+#define LOG_DUMP_SPECIAL_MAX_BUFSIZE (8 * 1024)
358
+
359
+#define LOG_DUMP_MAX_FILESIZE (8 *1024 * 1024) /* 8 MB default */
360
+#ifdef CONFIG_LOG_BUF_SHIFT
361
+/* 15% of kernel log buf size, if for example klog buf size is 512KB
362
+* 15% of 512KB ~= 80KB
363
+*/
364
+#define LOG_DUMP_KERNEL_TAIL_FLUSH_SIZE \
365
+ (15 * ((1 << CONFIG_LOG_BUF_SHIFT)/100))
366
+#endif /* CONFIG_LOG_BUF_SHIFT */
367
+
368
+#define LOG_DUMP_COOKIE_BUFSIZE 1024u
369
+
370
+typedef struct {
371
+ char *hdr_str;
372
+ log_dump_section_type_t sec_type;
373
+} dld_hdr_t;
374
+
375
+typedef struct {
376
+ int attr;
377
+ char *hdr_str;
378
+ log_dump_section_type_t sec_type;
379
+ int log_type;
380
+} dld_log_hdr_t;
381
+
382
+#define DHD_PRINT_BUF_NAME_LEN 30
383
+#endif /* DHD_LOG_DUMP */
107384
108385 int dhd_wifi_platform_register_drv(void);
109386 void dhd_wifi_platform_unregister_drv(void);
....@@ -115,7 +392,7 @@
115392 int wifi_platform_get_mac_addr(wifi_adapter_info_t *adapter, unsigned char *buf);
116393 #ifdef CUSTOM_COUNTRY_CODE
117394 void *wifi_platform_get_country_code(wifi_adapter_info_t *adapter, char *ccode,
118
- u32 flags);
395
+ u32 flags);
119396 #else
120397 void *wifi_platform_get_country_code(wifi_adapter_info_t *adapter, char *ccode);
121398 #endif /* CUSTOM_COUNTRY_CODE */
....@@ -125,13 +402,21 @@
125402 int dhd_get_fw_mode(struct dhd_info *dhdinfo);
126403 bool dhd_update_fw_nv_path(struct dhd_info *dhdinfo);
127404
128
-#ifdef DHD_WMF
129
-dhd_wmf_t* dhd_wmf_conf(dhd_pub_t *dhdp, uint32 idx);
130
-int dhd_get_wmf_psta_disable(dhd_pub_t *dhdp, uint32 idx);
131
-int dhd_set_wmf_psta_disable(dhd_pub_t *dhdp, uint32 idx, int val);
132
-void dhd_update_psta_interface_for_sta(dhd_pub_t *dhdp, char* ifname,
133
- void* mac_addr, void* event_data);
134
-#endif /* DHD_WMF */
405
+#if defined(BT_OVER_SDIO)
406
+int dhd_net_bus_get(struct net_device *dev);
407
+int dhd_net_bus_put(struct net_device *dev);
408
+#endif /* BT_OVER_SDIO */
409
+#if defined(WLADPS) || defined(WLADPS_PRIVATE_CMD)
410
+#define ADPS_ENABLE 1
411
+#define ADPS_DISABLE 0
135412
136
-void dhd_set_monitor(dhd_pub_t *dhd, int ifidx, int val);
413
+int dhd_enable_adps(dhd_pub_t *dhd, uint8 on);
414
+#endif /* WLADPS || WLADPS_PRIVATE_CMD */
415
+#ifdef DHDTCPSYNC_FLOOD_BLK
416
+extern void dhd_reset_tcpsync_info_by_ifp(dhd_if_t *ifp);
417
+extern void dhd_reset_tcpsync_info_by_dev(struct net_device *dev);
418
+#endif /* DHDTCPSYNC_FLOOD_BLK */
419
+
420
+int compat_kernel_read(struct file *file, loff_t offset, char *addr, unsigned long count);
421
+
137422 #endif /* __DHD_LINUX_H__ */