xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_config.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 
3 #ifndef _dhd_config_
4 #define _dhd_config_
5 
6 #include <bcmdevs.h>
7 #include <siutils.h>
8 #include <dngl_stats.h>
9 #include <dhd.h>
10 #include <wlioctl.h>
11 #include <802.11.h>
12 
13 #define FW_TYPE_STA     0
14 #define FW_TYPE_APSTA   1
15 #define FW_TYPE_P2P     2
16 #define FW_TYPE_MESH    3
17 #define FW_TYPE_EZMESH  4
18 #define FW_TYPE_ES      5
19 #define FW_TYPE_MFG     6
20 #define FW_TYPE_MINIME  7
21 #define FW_TYPE_G       0
22 #define FW_TYPE_AG      1
23 
24 #define FW_PATH_AUTO_SELECT 1
25 #ifdef BCMDHD_MDRIVER
26 #define CONFIG_PATH_AUTO_SELECT
27 #else
28 //#define CONFIG_PATH_AUTO_SELECT
29 #endif
30 extern char firmware_path[MOD_PARAM_PATHLEN];
31 #if defined(BCMSDIO) || defined(BCMPCIE)
32 extern uint dhd_rxbound;
33 extern uint dhd_txbound;
34 #endif
35 #ifdef BCMSDIO
36 #define TXGLOM_RECV_OFFSET 8
37 extern uint dhd_doflow;
38 extern uint dhd_slpauto;
39 #endif
40 
41 #ifdef SET_FWNV_BY_MAC
42 typedef struct wl_mac_range {
43 	uint32 oui;
44 	uint32 nic_start;
45 	uint32 nic_end;
46 } wl_mac_range_t;
47 
48 typedef struct wl_mac_list {
49 	int count;
50 	wl_mac_range_t *mac;
51 	char name[MOD_PARAM_PATHLEN];
52 } wl_mac_list_t;
53 
54 typedef struct wl_mac_list_ctrl {
55 	int count;
56 	struct wl_mac_list *m_mac_list_head;
57 } wl_mac_list_ctrl_t;
58 #endif
59 
60 typedef struct wl_chip_nv_path {
61 	uint chip;
62 	uint chiprev;
63 	char name[MOD_PARAM_PATHLEN];
64 } wl_chip_nv_path_t;
65 
66 typedef struct wl_chip_nv_path_list_ctrl {
67 	int count;
68 	struct wl_chip_nv_path *m_chip_nv_path_head;
69 } wl_chip_nv_path_list_ctrl_t;
70 
71 #define MAX_CTRL_CHANSPECS 256
72 typedef struct wl_channel_list {
73 	uint32 count;
74 	uint32 channel[MAX_CTRL_CHANSPECS];
75 } wl_channel_list_t;
76 
77 typedef struct wmes_param {
78 	int aifsn[AC_COUNT];
79 	int ecwmin[AC_COUNT];
80 	int ecwmax[AC_COUNT];
81 	int txop[AC_COUNT];
82 } wme_param_t;
83 
84 #ifdef PKT_FILTER_SUPPORT
85 #define DHD_CONF_FILTER_MAX	8
86 #define PKT_FILTER_LEN 300
87 #define MAGIC_PKT_FILTER_LEN 450
88 typedef struct conf_pkt_filter_add {
89 	uint32 count;
90 	char filter[DHD_CONF_FILTER_MAX][PKT_FILTER_LEN];
91 } conf_pkt_filter_add_t;
92 
93 typedef struct conf_pkt_filter_del {
94 	uint32 count;
95 	uint32 id[DHD_CONF_FILTER_MAX];
96 } conf_pkt_filter_del_t;
97 #endif
98 
99 #define CONFIG_COUNTRY_LIST_SIZE 500
100 typedef struct country_list {
101 	struct country_list *next;
102 	wl_country_t cspec;
103 } country_list_t;
104 
105 /* mchan_params */
106 #define MCHAN_MAX_NUM 4
107 #define MIRACAST_SOURCE	1
108 #define MIRACAST_SINK	2
109 typedef struct mchan_params {
110 	struct mchan_params *next;
111 	int bw;
112 	int p2p_mode;
113 	int miracast_mode;
114 } mchan_params_t;
115 
116 #ifdef SCAN_SUPPRESS
117 enum scan_intput_flags {
118 	NO_SCAN_INTPUT	= (1 << (0)),
119 	SCAN_CURCHAN_INTPUT	= (1 << (1)),
120 	SCAN_LIGHT_INTPUT	= (1 << (2)),
121 };
122 #endif
123 
124 enum war_flags {
125 	SET_CHAN_INCONN	= (1 << (0)),
126 	FW_REINIT_INCSA	= (1 << (1)),
127 	FW_REINIT_EMPTY_SCAN	= (1 << (2)),
128 	P2P_AP_MAC_CONFLICT	= (1 << (3)),
129 	RESEND_EAPOL_PKT	= (1 << (4))
130 };
131 
132 enum in4way_flags {
133 	STA_NO_SCAN_IN4WAY	= (1 << (0)),
134 	STA_NO_BTC_IN4WAY	= (1 << (1)),
135 	STA_WAIT_DISCONNECTED	= (1 << (2)),
136 	AP_WAIT_STA_RECONNECT	= (1 << (3)),
137 	STA_FAKE_SCAN_IN_CONNECT	= (1 << (4)),
138 	STA_REASSOC_RETRY	= (1 << (5)),
139 };
140 
141 enum in_suspend_flags {
142 	NO_EVENT_IN_SUSPEND		= (1 << (0)),
143 	NO_TXDATA_IN_SUSPEND	= (1 << (1)),
144 	NO_TXCTL_IN_SUSPEND		= (1 << (2)),
145 	AP_DOWN_IN_SUSPEND		= (1 << (3)),
146 	ROAM_OFFLOAD_IN_SUSPEND	= (1 << (4)),
147 	AP_FILTER_IN_SUSPEND	= (1 << (5)),
148 	WOWL_IN_SUSPEND			= (1 << (6)),
149 	ALL_IN_SUSPEND 			= 0xFFFFFFFF,
150 };
151 
152 enum in_suspend_mode {
153 	EARLY_SUSPEND = 0,
154 	PM_NOTIFIER = 1,
155 	SUSPEND_MODE_2 = 2
156 };
157 
158 #ifdef TPUT_MONITOR
159 enum data_drop_mode {
160 	NO_DATA_DROP = -1,
161 	FW_DROP = 0,
162 	TXPKT_DROP = 1,
163 	XMIT_DROP = 2
164 };
165 #endif
166 
167 enum conn_state {
168 	CONN_STATE_IDLE = 0,
169 	CONN_STATE_CONNECTING = 1,
170 	CONN_STATE_AUTH_SAE_M1 = 2,
171 	CONN_STATE_AUTH_SAE_M2 = 3,
172 	CONN_STATE_AUTH_SAE_M3 = 4,
173 	CONN_STATE_AUTH_SAE_M4 = 5,
174 	CONN_STATE_REQID = 6,
175 	CONN_STATE_RSPID = 7,
176 	CONN_STATE_WSC_START = 8,
177 	CONN_STATE_WPS_M1 = 9,
178 	CONN_STATE_WPS_M2 = 10,
179 	CONN_STATE_WPS_M3 = 11,
180 	CONN_STATE_WPS_M4 = 12,
181 	CONN_STATE_WPS_M5 = 13,
182 	CONN_STATE_WPS_M6 = 14,
183 	CONN_STATE_WPS_M7 = 15,
184 	CONN_STATE_WPS_M8 = 16,
185 	CONN_STATE_WSC_DONE = 17,
186 	CONN_STATE_4WAY_M1 = 18,
187 	CONN_STATE_4WAY_M2 = 19,
188 	CONN_STATE_4WAY_M3 = 20,
189 	CONN_STATE_4WAY_M4 = 21,
190 	CONN_STATE_CONNECTED = 22,
191 	CONN_STATE_GROUPKEY_M1 = 23,
192 	CONN_STATE_GROUPKEY_M2 = 24,
193 };
194 
195 enum enq_pkt_type {
196 	ENQ_PKT_TYPE_EAPOL	= (1 << (0)),
197 	ENQ_PKT_TYPE_ARP	= (1 << (1)),
198 	ENQ_PKT_TYPE_DHCP	= (1 << (2)),
199 	ENQ_PKT_TYPE_ICMP	= (1 << (3)),
200 };
201 
202 typedef struct dhd_conf {
203 	uint devid;
204 	uint chip;
205 	uint chiprev;
206 #if defined(BCMPCIE)
207 	uint svid;
208 	uint ssid;
209 #endif
210 #ifdef GET_OTP_MODULE_NAME
211 	char module_name[16];
212 #endif
213 	struct ether_addr otp_mac;
214 	int fw_type;
215 #ifdef SET_FWNV_BY_MAC
216 	wl_mac_list_ctrl_t fw_by_mac;
217 	wl_mac_list_ctrl_t nv_by_mac;
218 #endif
219 	wl_chip_nv_path_list_ctrl_t nv_by_chip;
220 	country_list_t *country_head;
221 	int band;
222 	int bw_cap[2];
223 	wl_country_t cspec;
224 	wl_channel_list_t channels;
225 	uint roam_off;
226 	uint roam_off_suspend;
227 	int roam_trigger[2];
228 	int roam_scan_period[2];
229 	int roam_delta[2];
230 	int fullroamperiod;
231 	uint keep_alive_period;
232 	bool rekey_offload;
233 #ifdef ARP_OFFLOAD_SUPPORT
234 	bool garp;
235 #endif
236 	int force_wme_ac;
237 	wme_param_t wme_sta;
238 	wme_param_t wme_ap;
239 #ifdef PKT_FILTER_SUPPORT
240 	conf_pkt_filter_add_t pkt_filter_add;
241 	conf_pkt_filter_del_t pkt_filter_del;
242 	char *magic_pkt_filter_add;
243 #endif
244 	int srl;
245 	int lrl;
246 	uint bcn_timeout;
247 	int disable_proptx;
248 	int dhd_poll;
249 #ifdef BCMSDIO
250 	int use_rxchain;
251 	bool bus_rxglom;
252 	bool txglom_ext; /* Only for 43362/4330/43340/43341/43241 */
253 	/* terence 20161011:
254 	    1) conf->tx_max_offset = 1 to fix credict issue in adaptivity testing
255 	    2) conf->tx_max_offset = 1 will cause to UDP Tx not work in rxglom supported,
256 	        but not happened in sw txglom
257 	*/
258 	int tx_max_offset;
259 	uint txglomsize;
260 	int txctl_tmo_fix;
261 	bool txglom_mode;
262 	uint deferred_tx_len;
263 	/*txglom_bucket_size:
264 	 * 43362/4330: 1680
265 	 * 43340/43341/43241: 1684
266 	 */
267 	int txglom_bucket_size;
268 	int txinrx_thres;
269 	int dhd_txminmax; // -1=DATABUFCNT(bus)
270 #ifdef DYNAMIC_MAX_HDR_READ
271 	int max_hdr_read;
272 #endif
273 	bool oob_enabled_later;
274 #ifdef MINIME
275 	uint32 ramsize;
276 #endif
277 #if defined(SDIO_ISR_THREAD)
278 	bool intr_extn;
279 #endif
280 #ifdef BCMSDIO_RXLIM_POST
281 	bool rxlim_en;
282 #endif
283 #ifdef BCMSDIO_TXSEQ_SYNC
284 	bool txseq_sync;
285 #endif
286 #ifdef BCMSDIO_INTSTATUS_WAR
287 	uint read_intr_mode;
288 #endif
289 	int kso_try_max;
290 #ifdef KSO_DEBUG
291 	uint kso_try_array[10];
292 #endif
293 #endif
294 #ifdef BCMPCIE
295 	int bus_deepsleep_disable;
296 	int flow_ring_queue_threshold;
297 	int d2h_intr_method;
298 	int d2h_intr_control;
299 	int enq_hdr_pkt;
300 #endif
301 	int dpc_cpucore;
302 	int rxf_cpucore;
303 	int dhd_dpc_prio;
304 	int frameburst;
305 	bool deepsleep;
306 	int pm;
307 	int pm_in_suspend;
308 	int suspend_mode;
309 	int suspend_bcn_li_dtim;
310 #ifdef DHDTCPACK_SUPPRESS
311 	uint8 tcpack_sup_mode;
312 	uint32 tcpack_sup_ratio;
313 	uint32 tcpack_sup_delay;
314 #endif
315 	int pktprio8021x;
316 	uint insuspend;
317 	bool suspended;
318 	struct ether_addr bssid_insuspend;
319 #ifdef SUSPEND_EVENT
320 	char resume_eventmask[WL_EVENTING_MASK_LEN];
321 	bool wlfc;
322 #endif
323 #ifdef IDHCP
324 	int dhcpc_enable;
325 	int dhcpd_enable;
326 	struct ipv4_addr dhcpd_ip_addr;
327 	struct ipv4_addr dhcpd_ip_mask;
328 	struct ipv4_addr dhcpd_ip_start;
329 	struct ipv4_addr dhcpd_ip_end;
330 #endif
331 #ifdef ISAM_PREINIT
332 	char isam_init[50];
333 	char isam_config[300];
334 	char isam_enable[50];
335 #endif
336 	int ctrl_resched;
337 	uint rxcnt_timeout;
338 	mchan_params_t *mchan;
339 	char *wl_preinit;
340 	char *wl_suspend;
341 	char *wl_resume;
342 	int tsq;
343 	int orphan_move;
344 	uint in4way;
345 	uint war;
346 #ifdef WL_EXT_WOWL
347 	uint wowl;
348 #endif
349 #ifdef GET_CUSTOM_MAC_FROM_CONFIG
350 	char hw_ether[62];
351 #endif
352 	wait_queue_head_t event_complete;
353 #ifdef PROPTX_MAXCOUNT
354 	int proptx_maxcnt_2g;
355 	int proptx_maxcnt_5g;
356 #endif /* DYNAMIC_PROPTX_MAXCOUNT */
357 #ifdef TPUT_MONITOR
358 	int data_drop_mode;
359 	unsigned long net_len;
360 	uint tput_monitor_ms;
361 	struct osl_timespec tput_ts;
362 	unsigned long last_tx;
363 	unsigned long last_rx;
364 	unsigned long last_net_tx;
365 #ifdef BCMSDIO
366 	int32 doflow_tput_thresh;
367 #endif
368 #endif
369 #ifdef SCAN_SUPPRESS
370 	uint scan_intput;
371 	int scan_busy_thresh;
372 	int scan_busy_tmo;
373 	int32 scan_tput_thresh;
374 #endif
375 #ifdef DHD_TPUT_PATCH
376 	bool tput_patch;
377 	int mtu;
378 	bool pktsetsum;
379 #endif
380 #ifdef SET_XPS_CPUS
381 	bool xps_cpus;
382 #endif
383 #ifdef SET_RPS_CPUS
384 	bool rps_cpus;
385 #endif
386 #ifdef CHECK_DOWNLOAD_FW
387 	bool fwchk;
388 #endif
389 	char *vndr_ie_assocreq;
390 } dhd_conf_t;
391 
392 #ifdef BCMSDIO
393 void dhd_conf_get_otp(dhd_pub_t *dhd, bcmsdh_info_t *sdh, si_t *sih);
394 #if defined(HW_OOB) || defined(FORCE_WOWLAN)
395 void dhd_conf_set_hw_oob_intr(bcmsdh_info_t *sdh, struct si_pub *sih);
396 #endif
397 void dhd_conf_set_txglom_params(dhd_pub_t *dhd, bool enable);
398 #endif
399 #ifdef BCMPCIE
400 int dhd_conf_get_otp(dhd_pub_t *dhd, si_t *sih);
401 bool dhd_conf_legacy_msi_chip(dhd_pub_t *dhd);
402 #endif
403 void dhd_conf_set_path_params(dhd_pub_t *dhd, char *fw_path, char *nv_path);
404 int dhd_conf_set_intiovar(dhd_pub_t *dhd, int ifidx, uint cmd, char *name,
405 	int val, int def, bool down);
406 int dhd_conf_get_band(dhd_pub_t *dhd);
407 int dhd_conf_set_country(dhd_pub_t *dhd, wl_country_t *cspec);
408 int dhd_conf_get_country(dhd_pub_t *dhd, wl_country_t *cspec);
409 int dhd_conf_map_country_list(dhd_pub_t *dhd, wl_country_t *cspec);
410 #ifdef CCODE_LIST
411 int dhd_ccode_map_country_list(dhd_pub_t *dhd, wl_country_t *cspec);
412 #endif
413 int dhd_conf_fix_country(dhd_pub_t *dhd);
414 bool dhd_conf_match_channel(dhd_pub_t *dhd, uint32 channel);
415 void dhd_conf_set_wme(dhd_pub_t *dhd, int ifidx, int mode);
416 void dhd_conf_set_mchan_bw(dhd_pub_t *dhd, int go, int source);
417 void dhd_conf_add_pkt_filter(dhd_pub_t *dhd);
418 bool dhd_conf_del_pkt_filter(dhd_pub_t *dhd, uint32 id);
419 void dhd_conf_discard_pkt_filter(dhd_pub_t *dhd);
420 int dhd_conf_read_config(dhd_pub_t *dhd, char *conf_path);
421 int dhd_conf_set_chiprev(dhd_pub_t *dhd, uint chip, uint chiprev);
422 uint dhd_conf_get_chip(void *context);
423 uint dhd_conf_get_chiprev(void *context);
424 int dhd_conf_get_pm(dhd_pub_t *dhd);
425 int dhd_conf_check_hostsleep(dhd_pub_t *dhd, int cmd, void *buf, int len,
426 	int *hostsleep_set, int *hostsleep_val, int *ret);
427 void dhd_conf_get_hostsleep(dhd_pub_t *dhd,
428 	int hostsleep_set, int hostsleep_val, int ret);
429 int dhd_conf_mkeep_alive(dhd_pub_t *dhd, int ifidx, int id, int period,
430 	char *packet, bool bcast);
431 #ifdef ARP_OFFLOAD_SUPPORT
432 void dhd_conf_set_garp(dhd_pub_t *dhd, int ifidx, uint32 ipa, bool enable);
433 #endif
434 #ifdef PROP_TXSTATUS
435 int dhd_conf_get_disable_proptx(dhd_pub_t *dhd);
436 #endif
437 #ifdef TPUT_MONITOR
438 void dhd_conf_tput_monitor(dhd_pub_t *dhd);
439 #endif
440 uint dhd_conf_get_insuspend(dhd_pub_t *dhd, uint mask);
441 int dhd_conf_set_suspend_resume(dhd_pub_t *dhd, int suspend);
442 void dhd_conf_postinit_ioctls(dhd_pub_t *dhd);
443 int dhd_conf_preinit(dhd_pub_t *dhd);
444 int dhd_conf_reset(dhd_pub_t *dhd);
445 int dhd_conf_attach(dhd_pub_t *dhd);
446 void dhd_conf_detach(dhd_pub_t *dhd);
447 void *dhd_get_pub(struct net_device *dev);
448 int wl_pattern_atoh(char *src, char *dst);
449 int dhd_conf_suspend_resume_sta(dhd_pub_t *dhd, int ifidx, int suspend);
450 /* Add to adjust 802.1x priority */
451 extern void pktset8021xprio(void *pkt, int prio);
452 #ifdef BCMSDIO
453 extern int dhd_bus_sleep(dhd_pub_t *dhdp, bool sleep, uint32 *intstatus);
454 #endif
455 #endif /* _dhd_config_ */
456