1 /*
2  * Marvell Wireless LAN device driver: major data structures and prototypes
3  *
4  * Copyright (C) 2011-2014, Marvell International Ltd.
5  *
6  * This software file (the "File") is distributed by Marvell International
7  * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8  * (the "License").  You may use, redistribute and/or modify this File in
9  * accordance with the terms and conditions of the License, a copy of which
10  * is available by writing to the Free Software Foundation, Inc.,
11  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12  * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13  *
14  * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
16  * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
17  * this warranty disclaimer.
18  */
19 
20 #ifndef _MWIFIEX_MAIN_H_
21 #define _MWIFIEX_MAIN_H_
22 
23 #include <linux/completion.h>
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/sched.h>
27 #include <linux/semaphore.h>
28 #include <linux/ip.h>
29 #include <linux/skbuff.h>
30 #include <linux/if_arp.h>
31 #include <linux/etherdevice.h>
32 #include <net/sock.h>
33 #include <net/lib80211.h>
34 #include <linux/vmalloc.h>
35 #include <linux/firmware.h>
36 #include <linux/ctype.h>
37 #include <linux/of.h>
38 #include <linux/idr.h>
39 #include <linux/inetdevice.h>
40 #include <linux/devcoredump.h>
41 #include <linux/err.h>
42 #include <linux/gpio.h>
43 #include <linux/gfp.h>
44 #include <linux/interrupt.h>
45 #include <linux/io.h>
46 #include <linux/of_gpio.h>
47 #include <linux/of_platform.h>
48 #include <linux/platform_device.h>
49 #include <linux/pm_runtime.h>
50 #include <linux/slab.h>
51 #include <linux/of_irq.h>
52 
53 #include "decl.h"
54 #include "ioctl.h"
55 #include "util.h"
56 #include "fw.h"
57 #include "pcie.h"
58 #include "usb.h"
59 #include "sdio.h"
60 
61 extern const char driver_version[];
62 extern bool mfg_mode;
63 extern bool aggr_ctrl;
64 
65 struct mwifiex_adapter;
66 struct mwifiex_private;
67 
68 enum {
69 	MWIFIEX_ASYNC_CMD,
70 	MWIFIEX_SYNC_CMD
71 };
72 
73 #define MWIFIEX_DRIVER_MODE_STA			BIT(0)
74 #define MWIFIEX_DRIVER_MODE_UAP			BIT(1)
75 #define MWIFIEX_DRIVER_MODE_P2P			BIT(2)
76 #define MWIFIEX_DRIVER_MODE_BITMASK		(BIT(0) | BIT(1) | BIT(2))
77 
78 #define MWIFIEX_MAX_AP				64
79 
80 #define MWIFIEX_MAX_PKTS_TXQ			16
81 
82 #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT	(5 * HZ)
83 
84 #define MWIFIEX_TIMER_10S			10000
85 #define MWIFIEX_TIMER_1S			1000
86 
87 #define MAX_TX_PENDING      400
88 #define LOW_TX_PENDING      380
89 
90 #define HIGH_RX_PENDING     50
91 #define LOW_RX_PENDING      20
92 
93 #define MWIFIEX_UPLD_SIZE               (2312)
94 
95 #define MAX_EVENT_SIZE                  2048
96 
97 #define MWIFIEX_FW_DUMP_SIZE       (2 * 1024 * 1024)
98 
99 #define ARP_FILTER_MAX_BUF_SIZE         68
100 
101 #define MWIFIEX_KEY_BUFFER_SIZE			16
102 #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
103 #define MWIFIEX_MAX_REGION_CODE         9
104 
105 #define DEFAULT_BCN_AVG_FACTOR          8
106 #define DEFAULT_DATA_AVG_FACTOR         8
107 
108 #define FIRST_VALID_CHANNEL				0xff
109 #define DEFAULT_AD_HOC_CHANNEL			6
110 #define DEFAULT_AD_HOC_CHANNEL_A		36
111 
112 #define DEFAULT_BCN_MISS_TIMEOUT		5
113 
114 #define MAX_SCAN_BEACON_BUFFER			8000
115 
116 #define SCAN_BEACON_ENTRY_PAD			6
117 
118 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME	110
119 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME	40
120 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME	40
121 #define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME  50
122 
123 #define SCAN_RSSI(RSSI)					(0x100 - ((u8)(RSSI)))
124 
125 #define MWIFIEX_MAX_TOTAL_SCAN_TIME	(MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
126 
127 #define RSN_GTK_OUI_OFFSET				2
128 
129 #define MWIFIEX_OUI_NOT_PRESENT			0
130 #define MWIFIEX_OUI_PRESENT				1
131 
132 #define PKT_TYPE_MGMT	0xE5
133 
134 /*
135  * Do not check for data_received for USB, as data_received
136  * is handled in mwifiex_usb_recv for USB
137  */
138 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
139 				adapter->event_received || \
140 				adapter->data_received)
141 
142 #define MWIFIEX_TYPE_CMD				1
143 #define MWIFIEX_TYPE_DATA				0
144 #define MWIFIEX_TYPE_AGGR_DATA				10
145 #define MWIFIEX_TYPE_EVENT				3
146 
147 #define MAX_BITMAP_RATES_SIZE			18
148 
149 #define MAX_CHANNEL_BAND_BG     14
150 #define MAX_CHANNEL_BAND_A      165
151 
152 #define MAX_FREQUENCY_BAND_BG   2484
153 
154 #define MWIFIEX_EVENT_HEADER_LEN           4
155 #define MWIFIEX_UAP_EVENT_EXTRA_HEADER	   2
156 
157 #define MWIFIEX_TYPE_LEN			4
158 #define MWIFIEX_USB_TYPE_CMD			0xF00DFACE
159 #define MWIFIEX_USB_TYPE_DATA			0xBEADC0DE
160 #define MWIFIEX_USB_TYPE_EVENT			0xBEEFFACE
161 
162 /* Threshold for tx_timeout_cnt before we trigger a card reset */
163 #define TX_TIMEOUT_THRESHOLD	6
164 
165 #define MWIFIEX_DRV_INFO_SIZE_MAX 0x40000
166 
167 /* Address alignment */
168 #define MWIFIEX_ALIGN_ADDR(p, a) (((long)(p) + (a) - 1) & ~((a) - 1))
169 
170 #define MWIFIEX_MAC_LOCAL_ADMIN_BIT		41
171 
172 /**
173  *enum mwifiex_debug_level  -  marvell wifi debug level
174  */
175 enum MWIFIEX_DEBUG_LEVEL {
176 	MWIFIEX_DBG_MSG		= 0x00000001,
177 	MWIFIEX_DBG_FATAL	= 0x00000002,
178 	MWIFIEX_DBG_ERROR	= 0x00000004,
179 	MWIFIEX_DBG_DATA	= 0x00000008,
180 	MWIFIEX_DBG_CMD		= 0x00000010,
181 	MWIFIEX_DBG_EVENT	= 0x00000020,
182 	MWIFIEX_DBG_INTR	= 0x00000040,
183 	MWIFIEX_DBG_IOCTL	= 0x00000080,
184 
185 	MWIFIEX_DBG_MPA_D	= 0x00008000,
186 	MWIFIEX_DBG_DAT_D	= 0x00010000,
187 	MWIFIEX_DBG_CMD_D	= 0x00020000,
188 	MWIFIEX_DBG_EVT_D	= 0x00040000,
189 	MWIFIEX_DBG_FW_D	= 0x00080000,
190 	MWIFIEX_DBG_IF_D	= 0x00100000,
191 
192 	MWIFIEX_DBG_ENTRY	= 0x10000000,
193 	MWIFIEX_DBG_WARN	= 0x20000000,
194 	MWIFIEX_DBG_INFO	= 0x40000000,
195 	MWIFIEX_DBG_DUMP	= 0x80000000,
196 
197 	MWIFIEX_DBG_ANY		= 0xffffffff
198 };
199 
200 #define MWIFIEX_DEFAULT_DEBUG_MASK	(MWIFIEX_DBG_MSG | \
201 					MWIFIEX_DBG_FATAL | \
202 					MWIFIEX_DBG_ERROR)
203 
204 __printf(3, 4)
205 void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
206 		  const char *fmt, ...);
207 #define mwifiex_dbg(adapter, mask, fmt, ...)				\
208 	_mwifiex_dbg(adapter, MWIFIEX_DBG_##mask, fmt, ##__VA_ARGS__)
209 
210 #define DEBUG_DUMP_DATA_MAX_LEN		128
211 #define mwifiex_dbg_dump(adapter, dbg_mask, str, buf, len)	\
212 do {								\
213 	if ((adapter)->debug_mask & MWIFIEX_DBG_##dbg_mask)	\
214 		print_hex_dump(KERN_DEBUG, str,			\
215 			       DUMP_PREFIX_OFFSET, 16, 1,	\
216 			       buf, len, false);		\
217 } while (0)
218 
219 /** Min BGSCAN interval 15 second */
220 #define MWIFIEX_BGSCAN_INTERVAL 15000
221 /** default repeat count */
222 #define MWIFIEX_BGSCAN_REPEAT_COUNT 6
223 
224 struct mwifiex_dbg {
225 	u32 num_cmd_host_to_card_failure;
226 	u32 num_cmd_sleep_cfm_host_to_card_failure;
227 	u32 num_tx_host_to_card_failure;
228 	u32 num_event_deauth;
229 	u32 num_event_disassoc;
230 	u32 num_event_link_lost;
231 	u32 num_cmd_deauth;
232 	u32 num_cmd_assoc_success;
233 	u32 num_cmd_assoc_failure;
234 	u32 num_tx_timeout;
235 	u16 timeout_cmd_id;
236 	u16 timeout_cmd_act;
237 	u16 last_cmd_id[DBG_CMD_NUM];
238 	u16 last_cmd_act[DBG_CMD_NUM];
239 	u16 last_cmd_index;
240 	u16 last_cmd_resp_id[DBG_CMD_NUM];
241 	u16 last_cmd_resp_index;
242 	u16 last_event[DBG_CMD_NUM];
243 	u16 last_event_index;
244 	u32 last_mp_wr_bitmap[MWIFIEX_DBG_SDIO_MP_NUM];
245 	u32 last_mp_wr_ports[MWIFIEX_DBG_SDIO_MP_NUM];
246 	u32 last_mp_wr_len[MWIFIEX_DBG_SDIO_MP_NUM];
247 	u32 last_mp_curr_wr_port[MWIFIEX_DBG_SDIO_MP_NUM];
248 	u8 last_sdio_mp_index;
249 };
250 
251 enum MWIFIEX_HARDWARE_STATUS {
252 	MWIFIEX_HW_STATUS_READY,
253 	MWIFIEX_HW_STATUS_INITIALIZING,
254 	MWIFIEX_HW_STATUS_INIT_DONE,
255 	MWIFIEX_HW_STATUS_RESET,
256 	MWIFIEX_HW_STATUS_NOT_READY
257 };
258 
259 enum MWIFIEX_802_11_POWER_MODE {
260 	MWIFIEX_802_11_POWER_MODE_CAM,
261 	MWIFIEX_802_11_POWER_MODE_PSP
262 };
263 
264 struct mwifiex_tx_param {
265 	u32 next_pkt_len;
266 };
267 
268 enum MWIFIEX_PS_STATE {
269 	PS_STATE_AWAKE,
270 	PS_STATE_PRE_SLEEP,
271 	PS_STATE_SLEEP_CFM,
272 	PS_STATE_SLEEP
273 };
274 
275 enum mwifiex_iface_type {
276 	MWIFIEX_SDIO,
277 	MWIFIEX_PCIE,
278 	MWIFIEX_USB
279 };
280 
281 struct mwifiex_add_ba_param {
282 	u32 tx_win_size;
283 	u32 rx_win_size;
284 	u32 timeout;
285 	u8 tx_amsdu;
286 	u8 rx_amsdu;
287 };
288 
289 struct mwifiex_tx_aggr {
290 	u8 ampdu_user;
291 	u8 ampdu_ap;
292 	u8 amsdu;
293 };
294 
295 enum mwifiex_ba_status {
296 	BA_SETUP_NONE = 0,
297 	BA_SETUP_INPROGRESS,
298 	BA_SETUP_COMPLETE
299 };
300 
301 struct mwifiex_ra_list_tbl {
302 	struct list_head list;
303 	struct sk_buff_head skb_head;
304 	u8 ra[ETH_ALEN];
305 	u32 is_11n_enabled;
306 	u16 max_amsdu;
307 	u16 ba_pkt_count;
308 	u8 ba_packet_thr;
309 	enum mwifiex_ba_status ba_status;
310 	u8 amsdu_in_ampdu;
311 	u16 total_pkt_count;
312 	bool tdls_link;
313 	bool tx_paused;
314 };
315 
316 struct mwifiex_tid_tbl {
317 	struct list_head ra_list;
318 };
319 
320 #define WMM_HIGHEST_PRIORITY		7
321 #define HIGH_PRIO_TID				7
322 #define LOW_PRIO_TID				0
323 #define NO_PKT_PRIO_TID				-1
324 #define MWIFIEX_WMM_DRV_DELAY_MAX 510
325 
326 struct mwifiex_wmm_desc {
327 	struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
328 	u32 packets_out[MAX_NUM_TID];
329 	u32 pkts_paused[MAX_NUM_TID];
330 	/* spin lock to protect ra_list */
331 	spinlock_t ra_list_spinlock;
332 	struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
333 	enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
334 	u32 drv_pkt_delay_max;
335 	u8 queue_priority[IEEE80211_NUM_ACS];
336 	u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1];	/* UP: 0 to 7 */
337 	/* Number of transmit packets queued */
338 	atomic_t tx_pkts_queued;
339 	/* Tracks highest priority with a packet queued */
340 	atomic_t highest_queued_prio;
341 };
342 
343 struct mwifiex_802_11_security {
344 	u8 wpa_enabled;
345 	u8 wpa2_enabled;
346 	u8 wapi_enabled;
347 	u8 wapi_key_on;
348 	u8 wep_enabled;
349 	u32 authentication_mode;
350 	u8 is_authtype_auto;
351 	u32 encryption_mode;
352 };
353 
354 struct ieee_types_header {
355 	u8 element_id;
356 	u8 len;
357 } __packed;
358 
359 struct ieee_types_vendor_specific {
360 	struct ieee_types_vendor_header vend_hdr;
361 	u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
362 } __packed;
363 
364 struct ieee_types_generic {
365 	struct ieee_types_header ieee_hdr;
366 	u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
367 } __packed;
368 
369 struct ieee_types_bss_co_2040 {
370 	struct ieee_types_header ieee_hdr;
371 	u8 bss_2040co;
372 } __packed;
373 
374 struct ieee_types_extcap {
375 	struct ieee_types_header ieee_hdr;
376 	u8 ext_capab[8];
377 } __packed;
378 
379 struct ieee_types_vht_cap {
380 	struct ieee_types_header ieee_hdr;
381 	struct ieee80211_vht_cap vhtcap;
382 } __packed;
383 
384 struct ieee_types_vht_oper {
385 	struct ieee_types_header ieee_hdr;
386 	struct ieee80211_vht_operation vhtoper;
387 } __packed;
388 
389 struct ieee_types_aid {
390 	struct ieee_types_header ieee_hdr;
391 	u16 aid;
392 } __packed;
393 
394 struct mwifiex_bssdescriptor {
395 	u8 mac_address[ETH_ALEN];
396 	struct cfg80211_ssid ssid;
397 	u32 privacy;
398 	s32 rssi;
399 	u32 channel;
400 	u32 freq;
401 	u16 beacon_period;
402 	u8 erp_flags;
403 	u32 bss_mode;
404 	u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
405 	u8 data_rates[MWIFIEX_SUPPORTED_RATES];
406 	/* Network band.
407 	 * BAND_B(0x01): 'b' band
408 	 * BAND_G(0x02): 'g' band
409 	 * BAND_A(0X04): 'a' band
410 	 */
411 	u16 bss_band;
412 	u64 fw_tsf;
413 	u64 timestamp;
414 	union ieee_types_phy_param_set phy_param_set;
415 	union ieee_types_ss_param_set ss_param_set;
416 	u16 cap_info_bitmap;
417 	struct ieee_types_wmm_parameter wmm_ie;
418 	u8  disable_11n;
419 	struct ieee80211_ht_cap *bcn_ht_cap;
420 	u16 ht_cap_offset;
421 	struct ieee80211_ht_operation *bcn_ht_oper;
422 	u16 ht_info_offset;
423 	u8 *bcn_bss_co_2040;
424 	u16 bss_co_2040_offset;
425 	u8 *bcn_ext_cap;
426 	u16 ext_cap_offset;
427 	struct ieee80211_vht_cap *bcn_vht_cap;
428 	u16 vht_cap_offset;
429 	struct ieee80211_vht_operation *bcn_vht_oper;
430 	u16 vht_info_offset;
431 	struct ieee_types_oper_mode_ntf *oper_mode;
432 	u16 oper_mode_offset;
433 	u8 disable_11ac;
434 	struct ieee_types_vendor_specific *bcn_wpa_ie;
435 	u16 wpa_offset;
436 	struct ieee_types_generic *bcn_rsn_ie;
437 	u16 rsn_offset;
438 	struct ieee_types_generic *bcn_wapi_ie;
439 	u16 wapi_offset;
440 	u8 *beacon_buf;
441 	u32 beacon_buf_size;
442 	u8 sensed_11h;
443 	u8 local_constraint;
444 	u8 chan_sw_ie_present;
445 };
446 
447 struct mwifiex_current_bss_params {
448 	struct mwifiex_bssdescriptor bss_descriptor;
449 	u8 wmm_enabled;
450 	u8 wmm_uapsd_enabled;
451 	u8 band;
452 	u32 num_of_rates;
453 	u8 data_rates[MWIFIEX_SUPPORTED_RATES];
454 };
455 
456 struct mwifiex_sleep_params {
457 	u16 sp_error;
458 	u16 sp_offset;
459 	u16 sp_stable_time;
460 	u8 sp_cal_control;
461 	u8 sp_ext_sleep_clk;
462 	u16 sp_reserved;
463 };
464 
465 struct mwifiex_sleep_period {
466 	u16 period;
467 	u16 reserved;
468 };
469 
470 struct mwifiex_wep_key {
471 	u32 length;
472 	u32 key_index;
473 	u32 key_length;
474 	u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
475 };
476 
477 #define MAX_REGION_CHANNEL_NUM  2
478 
479 struct mwifiex_chan_freq_power {
480 	u16 channel;
481 	u32 freq;
482 	u16 max_tx_power;
483 	u8 unsupported;
484 };
485 
486 enum state_11d_t {
487 	DISABLE_11D = 0,
488 	ENABLE_11D = 1,
489 };
490 
491 #define MWIFIEX_MAX_TRIPLET_802_11D		83
492 
493 struct mwifiex_802_11d_domain_reg {
494 	u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
495 	u8 no_of_triplet;
496 	struct ieee80211_country_ie_triplet
497 		triplet[MWIFIEX_MAX_TRIPLET_802_11D];
498 };
499 
500 struct mwifiex_vendor_spec_cfg_ie {
501 	u16 mask;
502 	u16 flag;
503 	u8 ie[MWIFIEX_MAX_VSIE_LEN];
504 };
505 
506 struct wps {
507 	u8 session_enable;
508 };
509 
510 struct mwifiex_roc_cfg {
511 	u64 cookie;
512 	struct ieee80211_channel chan;
513 };
514 
515 enum mwifiex_iface_work_flags {
516 	MWIFIEX_IFACE_WORK_DEVICE_DUMP,
517 	MWIFIEX_IFACE_WORK_CARD_RESET,
518 };
519 
520 enum mwifiex_adapter_work_flags {
521 	MWIFIEX_SURPRISE_REMOVED,
522 	MWIFIEX_IS_CMD_TIMEDOUT,
523 	MWIFIEX_IS_SUSPENDED,
524 	MWIFIEX_IS_HS_CONFIGURED,
525 	MWIFIEX_IS_HS_ENABLING,
526 };
527 
528 struct mwifiex_band_config {
529 	u8 chan_band:2;
530 	u8 chan_width:2;
531 	u8 chan2_offset:2;
532 	u8 scan_mode:2;
533 } __packed;
534 
535 struct mwifiex_channel_band {
536 	struct mwifiex_band_config band_config;
537 	u8 channel;
538 };
539 
540 struct mwifiex_private {
541 	struct mwifiex_adapter *adapter;
542 	u8 bss_type;
543 	u8 bss_role;
544 	u8 bss_priority;
545 	u8 bss_num;
546 	u8 bss_started;
547 	u8 frame_type;
548 	u8 curr_addr[ETH_ALEN];
549 	u8 media_connected;
550 	u8 port_open;
551 	u8 usb_port;
552 	u32 num_tx_timeout;
553 	/* track consecutive timeout */
554 	u8 tx_timeout_cnt;
555 	struct net_device *netdev;
556 	struct net_device_stats stats;
557 	u32 curr_pkt_filter;
558 	u32 bss_mode;
559 	u32 pkt_tx_ctrl;
560 	u16 tx_power_level;
561 	u8 max_tx_power_level;
562 	u8 min_tx_power_level;
563 	u32 tx_ant;
564 	u32 rx_ant;
565 	u8 tx_rate;
566 	u8 tx_htinfo;
567 	u8 rxpd_htinfo;
568 	u8 rxpd_rate;
569 	u16 rate_bitmap;
570 	u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
571 	u32 data_rate;
572 	u8 is_data_rate_auto;
573 	u16 bcn_avg_factor;
574 	u16 data_avg_factor;
575 	s16 data_rssi_last;
576 	s16 data_nf_last;
577 	s16 data_rssi_avg;
578 	s16 data_nf_avg;
579 	s16 bcn_rssi_last;
580 	s16 bcn_nf_last;
581 	s16 bcn_rssi_avg;
582 	s16 bcn_nf_avg;
583 	struct mwifiex_bssdescriptor *attempted_bss_desc;
584 	struct cfg80211_ssid prev_ssid;
585 	u8 prev_bssid[ETH_ALEN];
586 	struct mwifiex_current_bss_params curr_bss_params;
587 	u16 beacon_period;
588 	u8 dtim_period;
589 	u16 listen_interval;
590 	u16 atim_window;
591 	u8 adhoc_channel;
592 	u8 adhoc_is_link_sensed;
593 	u8 adhoc_state;
594 	struct mwifiex_802_11_security sec_info;
595 	struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
596 	u16 wep_key_curr_index;
597 	u8 wpa_ie[256];
598 	u16 wpa_ie_len;
599 	u8 wpa_is_gtk_set;
600 	struct host_cmd_ds_802_11_key_material aes_key;
601 	struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
602 	u8 wapi_ie[256];
603 	u16 wapi_ie_len;
604 	u8 *wps_ie;
605 	u16 wps_ie_len;
606 	u8 wmm_required;
607 	u8 wmm_enabled;
608 	u8 wmm_qosinfo;
609 	struct mwifiex_wmm_desc wmm;
610 	atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
611 	struct list_head sta_list;
612 	/* spin lock for associated station/TDLS peers list */
613 	spinlock_t sta_list_spinlock;
614 	struct list_head auto_tdls_list;
615 	/* spin lock for auto TDLS peer list */
616 	spinlock_t auto_tdls_lock;
617 	struct list_head tx_ba_stream_tbl_ptr;
618 	/* spin lock for tx_ba_stream_tbl_ptr queue */
619 	spinlock_t tx_ba_stream_tbl_lock;
620 	struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
621 	struct mwifiex_add_ba_param add_ba_param;
622 	u16 rx_seq[MAX_NUM_TID];
623 	u8 tos_to_tid_inv[MAX_NUM_TID];
624 	struct list_head rx_reorder_tbl_ptr;
625 	/* spin lock for rx_reorder_tbl_ptr queue */
626 	spinlock_t rx_reorder_tbl_lock;
627 #define MWIFIEX_ASSOC_RSP_BUF_SIZE  500
628 	u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
629 	u32 assoc_rsp_size;
630 
631 #define MWIFIEX_GENIE_BUF_SIZE      256
632 	u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
633 	u8 gen_ie_buf_len;
634 
635 	struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
636 
637 #define MWIFIEX_ASSOC_TLV_BUF_SIZE  256
638 	u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
639 	u8 assoc_tlv_buf_len;
640 
641 	u8 *curr_bcn_buf;
642 	u32 curr_bcn_size;
643 	/* spin lock for beacon buffer */
644 	spinlock_t curr_bcn_buf_lock;
645 	struct wireless_dev wdev;
646 	struct mwifiex_chan_freq_power cfp;
647 	u32 versionstrsel;
648 	char version_str[128];
649 #ifdef CONFIG_DEBUG_FS
650 	struct dentry *dfs_dev_dir;
651 #endif
652 	u16 current_key_index;
653 	struct mutex async_mutex;
654 	struct cfg80211_scan_request *scan_request;
655 	u8 cfg_bssid[6];
656 	struct wps wps;
657 	u8 scan_block;
658 	s32 cqm_rssi_thold;
659 	u32 cqm_rssi_hyst;
660 	u8 subsc_evt_rssi_state;
661 	struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
662 	struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
663 	u16 beacon_idx;
664 	u16 proberesp_idx;
665 	u16 assocresp_idx;
666 	u16 gen_idx;
667 	u8 ap_11n_enabled;
668 	u8 ap_11ac_enabled;
669 	u32 mgmt_frame_mask;
670 	struct mwifiex_roc_cfg roc_cfg;
671 	bool scan_aborting;
672 	u8 sched_scanning;
673 	u8 csa_chan;
674 	unsigned long csa_expire_time;
675 	u8 del_list_idx;
676 	bool hs2_enabled;
677 	struct mwifiex_uap_bss_param bss_cfg;
678 	struct cfg80211_chan_def bss_chandef;
679 	struct station_parameters *sta_params;
680 	struct sk_buff_head tdls_txq;
681 	u8 check_tdls_tx;
682 	struct timer_list auto_tdls_timer;
683 	bool auto_tdls_timer_active;
684 	struct idr ack_status_frames;
685 	/* spin lock for ack status */
686 	spinlock_t ack_status_lock;
687 	/** rx histogram data */
688 	struct mwifiex_histogram_data *hist_data;
689 	struct cfg80211_chan_def dfs_chandef;
690 	struct workqueue_struct *dfs_cac_workqueue;
691 	struct delayed_work dfs_cac_work;
692 	struct timer_list dfs_chan_switch_timer;
693 	struct workqueue_struct *dfs_chan_sw_workqueue;
694 	struct delayed_work dfs_chan_sw_work;
695 	struct cfg80211_beacon_data beacon_after;
696 	struct mwifiex_11h_intf_state state_11h;
697 	struct mwifiex_ds_mem_rw mem_rw;
698 	struct sk_buff_head bypass_txq;
699 	struct mwifiex_user_scan_chan hidden_chan[MWIFIEX_USER_SCAN_CHAN_MAX];
700 	u8 assoc_resp_ht_param;
701 	bool ht_param_present;
702 };
703 
704 
705 struct mwifiex_tx_ba_stream_tbl {
706 	struct list_head list;
707 	int tid;
708 	u8 ra[ETH_ALEN];
709 	enum mwifiex_ba_status ba_status;
710 	u8 amsdu;
711 };
712 
713 struct mwifiex_rx_reorder_tbl;
714 
715 struct reorder_tmr_cnxt {
716 	struct timer_list timer;
717 	struct mwifiex_rx_reorder_tbl *ptr;
718 	struct mwifiex_private *priv;
719 	u8 timer_is_set;
720 };
721 
722 struct mwifiex_rx_reorder_tbl {
723 	struct list_head list;
724 	int tid;
725 	u8 ta[ETH_ALEN];
726 	int init_win;
727 	int start_win;
728 	int win_size;
729 	void **rx_reorder_ptr;
730 	struct reorder_tmr_cnxt timer_context;
731 	u8 amsdu;
732 	u8 flags;
733 };
734 
735 struct mwifiex_bss_prio_node {
736 	struct list_head list;
737 	struct mwifiex_private *priv;
738 };
739 
740 struct mwifiex_bss_prio_tbl {
741 	struct list_head bss_prio_head;
742 	/* spin lock for bss priority  */
743 	spinlock_t bss_prio_lock;
744 	struct mwifiex_bss_prio_node *bss_prio_cur;
745 };
746 
747 struct cmd_ctrl_node {
748 	struct list_head list;
749 	struct mwifiex_private *priv;
750 	u32 cmd_oid;
751 	u32 cmd_flag;
752 	struct sk_buff *cmd_skb;
753 	struct sk_buff *resp_skb;
754 	void *data_buf;
755 	u32 wait_q_enabled;
756 	struct sk_buff *skb;
757 	u8 *condition;
758 	u8 cmd_wait_q_woken;
759 };
760 
761 struct mwifiex_bss_priv {
762 	u8 band;
763 	u64 fw_tsf;
764 };
765 
766 struct mwifiex_tdls_capab {
767 	__le16 capab;
768 	u8 rates[32];
769 	u8 rates_len;
770 	u8 qos_info;
771 	u8 coex_2040;
772 	u16 aid;
773 	struct ieee80211_ht_cap ht_capb;
774 	struct ieee80211_ht_operation ht_oper;
775 	struct ieee_types_extcap extcap;
776 	struct ieee_types_generic rsn_ie;
777 	struct ieee80211_vht_cap vhtcap;
778 	struct ieee80211_vht_operation vhtoper;
779 };
780 
781 struct mwifiex_station_stats {
782 	u64 last_rx;
783 	s8 rssi;
784 	u64 rx_bytes;
785 	u64 tx_bytes;
786 	u32 rx_packets;
787 	u32 tx_packets;
788 	u32 tx_failed;
789 	u8 last_tx_rate;
790 	u8 last_tx_htinfo;
791 };
792 
793 /* This is AP/TDLS specific structure which stores information
794  * about associated/peer STA
795  */
796 struct mwifiex_sta_node {
797 	struct list_head list;
798 	u8 mac_addr[ETH_ALEN];
799 	u8 is_wmm_enabled;
800 	u8 is_11n_enabled;
801 	u8 is_11ac_enabled;
802 	u8 ampdu_sta[MAX_NUM_TID];
803 	u16 rx_seq[MAX_NUM_TID];
804 	u16 max_amsdu;
805 	u8 tdls_status;
806 	struct mwifiex_tdls_capab tdls_cap;
807 	struct mwifiex_station_stats stats;
808 	u8 tx_pause;
809 };
810 
811 struct mwifiex_auto_tdls_peer {
812 	struct list_head list;
813 	u8 mac_addr[ETH_ALEN];
814 	u8 tdls_status;
815 	int rssi;
816 	long rssi_jiffies;
817 	u8 failure_count;
818 	u8 do_discover;
819 	u8 do_setup;
820 };
821 
822 #define MWIFIEX_TYPE_AGGR_DATA_V2 11
823 #define MWIFIEX_BUS_AGGR_MODE_LEN_V2 (2)
824 #define MWIFIEX_BUS_AGGR_MAX_LEN 16000
825 #define MWIFIEX_BUS_AGGR_MAX_NUM 10
826 struct bus_aggr_params {
827 	u16 enable;
828 	u16 mode;
829 	u16 tx_aggr_max_size;
830 	u16 tx_aggr_max_num;
831 	u16 tx_aggr_align;
832 };
833 
834 struct mwifiex_if_ops {
835 	int (*init_if) (struct mwifiex_adapter *);
836 	void (*cleanup_if) (struct mwifiex_adapter *);
837 	int (*check_fw_status) (struct mwifiex_adapter *, u32);
838 	int (*check_winner_status)(struct mwifiex_adapter *);
839 	int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
840 	int (*register_dev) (struct mwifiex_adapter *);
841 	void (*unregister_dev) (struct mwifiex_adapter *);
842 	int (*enable_int) (struct mwifiex_adapter *);
843 	void (*disable_int) (struct mwifiex_adapter *);
844 	int (*process_int_status) (struct mwifiex_adapter *);
845 	int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
846 			     struct mwifiex_tx_param *);
847 	int (*wakeup) (struct mwifiex_adapter *);
848 	int (*wakeup_complete) (struct mwifiex_adapter *);
849 
850 	/* Interface specific functions */
851 	void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
852 	void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
853 	int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
854 	int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
855 	int (*init_fw_port) (struct mwifiex_adapter *);
856 	int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
857 	void (*card_reset) (struct mwifiex_adapter *);
858 	int (*reg_dump)(struct mwifiex_adapter *, char *);
859 	void (*device_dump)(struct mwifiex_adapter *);
860 	int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
861 	void (*iface_work)(struct work_struct *work);
862 	void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
863 	void (*deaggr_pkt)(struct mwifiex_adapter *, struct sk_buff *);
864 	void (*multi_port_resync)(struct mwifiex_adapter *);
865 	bool (*is_port_ready)(struct mwifiex_private *);
866 	void (*down_dev)(struct mwifiex_adapter *);
867 	void (*up_dev)(struct mwifiex_adapter *);
868 };
869 
870 struct mwifiex_adapter {
871 	u8 iface_type;
872 	unsigned int debug_mask;
873 	struct mwifiex_iface_comb iface_limit;
874 	struct mwifiex_iface_comb curr_iface_comb;
875 	struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
876 	u8 priv_num;
877 	const struct firmware *firmware;
878 	char fw_name[32];
879 	int winner;
880 	struct device *dev;
881 	struct wiphy *wiphy;
882 	u8 perm_addr[ETH_ALEN];
883 	unsigned long work_flags;
884 	u32 fw_release_number;
885 	u8 intf_hdr_len;
886 	u16 init_wait_q_woken;
887 	wait_queue_head_t init_wait_q;
888 	void *card;
889 	struct mwifiex_if_ops if_ops;
890 	atomic_t bypass_tx_pending;
891 	atomic_t rx_pending;
892 	atomic_t tx_pending;
893 	atomic_t cmd_pending;
894 	atomic_t tx_hw_pending;
895 	struct workqueue_struct *workqueue;
896 	struct work_struct main_work;
897 	struct workqueue_struct *rx_workqueue;
898 	struct work_struct rx_work;
899 	struct workqueue_struct *dfs_workqueue;
900 	struct work_struct dfs_work;
901 	bool rx_work_enabled;
902 	bool rx_processing;
903 	bool delay_main_work;
904 	bool rx_locked;
905 	bool main_locked;
906 	struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
907 	/* spin lock for main process */
908 	spinlock_t main_proc_lock;
909 	u32 mwifiex_processing;
910 	u8 more_task_flag;
911 	u16 tx_buf_size;
912 	u16 curr_tx_buf_size;
913 	/* sdio single port rx aggregation capability */
914 	bool host_disable_sdio_rx_aggr;
915 	bool sdio_rx_aggr_enable;
916 	u16 sdio_rx_block_size;
917 	u32 ioport;
918 	enum MWIFIEX_HARDWARE_STATUS hw_status;
919 	u16 number_of_antenna;
920 	u32 fw_cap_info;
921 	/* spin lock for interrupt handling */
922 	spinlock_t int_lock;
923 	u8 int_status;
924 	u32 event_cause;
925 	struct sk_buff *event_skb;
926 	u8 upld_buf[MWIFIEX_UPLD_SIZE];
927 	u8 data_sent;
928 	u8 cmd_sent;
929 	u8 cmd_resp_received;
930 	u8 event_received;
931 	u8 data_received;
932 	u16 seq_num;
933 	struct cmd_ctrl_node *cmd_pool;
934 	struct cmd_ctrl_node *curr_cmd;
935 	/* spin lock for command */
936 	spinlock_t mwifiex_cmd_lock;
937 	u16 last_init_cmd;
938 	struct timer_list cmd_timer;
939 	struct list_head cmd_free_q;
940 	/* spin lock for cmd_free_q */
941 	spinlock_t cmd_free_q_lock;
942 	struct list_head cmd_pending_q;
943 	/* spin lock for cmd_pending_q */
944 	spinlock_t cmd_pending_q_lock;
945 	struct list_head scan_pending_q;
946 	/* spin lock for scan_pending_q */
947 	spinlock_t scan_pending_q_lock;
948 	/* spin lock for RX processing routine */
949 	spinlock_t rx_proc_lock;
950 	struct sk_buff_head tx_data_q;
951 	atomic_t tx_queued;
952 	u32 scan_processing;
953 	u16 region_code;
954 	struct mwifiex_802_11d_domain_reg domain_reg;
955 	u16 scan_probes;
956 	u32 scan_mode;
957 	u16 specific_scan_time;
958 	u16 active_scan_time;
959 	u16 passive_scan_time;
960 	u16 scan_chan_gap_time;
961 	u8 fw_bands;
962 	u8 adhoc_start_band;
963 	u8 config_bands;
964 	struct mwifiex_chan_scan_param_set *scan_channels;
965 	u8 tx_lock_flag;
966 	struct mwifiex_sleep_params sleep_params;
967 	struct mwifiex_sleep_period sleep_period;
968 	u16 ps_mode;
969 	u32 ps_state;
970 	u8 need_to_wakeup;
971 	u16 multiple_dtim;
972 	u16 local_listen_interval;
973 	u16 null_pkt_interval;
974 	struct sk_buff *sleep_cfm;
975 	u16 bcn_miss_time_out;
976 	u16 adhoc_awake_period;
977 	u8 is_deep_sleep;
978 	u8 delay_null_pkt;
979 	u16 delay_to_ps;
980 	u16 enhanced_ps_mode;
981 	u8 pm_wakeup_card_req;
982 	u16 gen_null_pkt;
983 	u16 pps_uapsd_mode;
984 	u32 pm_wakeup_fw_try;
985 	struct timer_list wakeup_timer;
986 	struct mwifiex_hs_config_param hs_cfg;
987 	u8 hs_activated;
988 	u16 hs_activate_wait_q_woken;
989 	wait_queue_head_t hs_activate_wait_q;
990 	u8 event_body[MAX_EVENT_SIZE];
991 	u32 hw_dot_11n_dev_cap;
992 	u8 hw_dev_mcs_support;
993 	u8 user_dev_mcs_support;
994 	u8 adhoc_11n_enabled;
995 	u8 sec_chan_offset;
996 	struct mwifiex_dbg dbg;
997 	u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
998 	u32 arp_filter_size;
999 	struct mwifiex_wait_queue cmd_wait_q;
1000 	u8 scan_wait_q_woken;
1001 	spinlock_t queue_lock;		/* lock for tx queues */
1002 	u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
1003 	u16 max_mgmt_ie_index;
1004 	const struct firmware *cal_data;
1005 	struct device_node *dt_node;
1006 
1007 	/* 11AC */
1008 	u32 is_hw_11ac_capable;
1009 	u32 hw_dot_11ac_dev_cap;
1010 	u32 hw_dot_11ac_mcs_support;
1011 	u32 usr_dot_11ac_dev_cap_bg;
1012 	u32 usr_dot_11ac_dev_cap_a;
1013 	u32 usr_dot_11ac_mcs_support;
1014 
1015 	atomic_t pending_bridged_pkts;
1016 
1017 	/* For synchronizing FW initialization with device lifecycle. */
1018 	struct completion *fw_done;
1019 
1020 	bool ext_scan;
1021 	u8 fw_api_ver;
1022 	u8 key_api_major_ver, key_api_minor_ver;
1023 	struct memory_type_mapping *mem_type_mapping_tbl;
1024 	u8 num_mem_types;
1025 	bool scan_chan_gap_enabled;
1026 	struct sk_buff_head rx_data_q;
1027 	bool mfg_mode;
1028 	struct mwifiex_chan_stats *chan_stats;
1029 	u32 num_in_chan_stats;
1030 	int survey_idx;
1031 	bool auto_tdls;
1032 	u8 coex_scan;
1033 	u8 coex_min_scan_time;
1034 	u8 coex_max_scan_time;
1035 	u8 coex_win_size;
1036 	u8 coex_tx_win_size;
1037 	u8 coex_rx_win_size;
1038 	bool drcs_enabled;
1039 	u8 active_scan_triggered;
1040 	bool usb_mc_status;
1041 	bool usb_mc_setup;
1042 	struct cfg80211_wowlan_nd_info *nd_info;
1043 	struct ieee80211_regdomain *regd;
1044 
1045 	/* Wake-on-WLAN (WoWLAN) */
1046 	int irq_wakeup;
1047 	bool wake_by_wifi;
1048 	/* Aggregation parameters*/
1049 	struct bus_aggr_params bus_aggr;
1050 	/* Device dump data/length */
1051 	void *devdump_data;
1052 	int devdump_len;
1053 	struct timer_list devdump_timer;
1054 };
1055 
1056 void mwifiex_process_tx_queue(struct mwifiex_adapter *adapter);
1057 
1058 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
1059 
1060 void mwifiex_set_trans_start(struct net_device *dev);
1061 
1062 void mwifiex_stop_net_dev_queue(struct net_device *netdev,
1063 		struct mwifiex_adapter *adapter);
1064 
1065 void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
1066 		struct mwifiex_adapter *adapter);
1067 
1068 int mwifiex_init_priv(struct mwifiex_private *priv);
1069 void mwifiex_free_priv(struct mwifiex_private *priv);
1070 
1071 int mwifiex_init_fw(struct mwifiex_adapter *adapter);
1072 
1073 int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
1074 
1075 void mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
1076 
1077 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
1078 
1079 int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
1080 int mwifiex_uap_recv_packet(struct mwifiex_private *priv,
1081 			    struct sk_buff *skb);
1082 
1083 int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
1084 				struct sk_buff *skb);
1085 
1086 int mwifiex_process_event(struct mwifiex_adapter *adapter);
1087 
1088 int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
1089 			 struct cmd_ctrl_node *cmd_node);
1090 
1091 int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
1092 		     u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
1093 
1094 void mwifiex_cmd_timeout_func(struct timer_list *t);
1095 
1096 int mwifiex_get_debug_info(struct mwifiex_private *,
1097 			   struct mwifiex_debug_info *);
1098 
1099 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
1100 void mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
1101 void mwifiex_free_cmd_buffers(struct mwifiex_adapter *adapter);
1102 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
1103 void mwifiex_cancel_pending_scan_cmd(struct mwifiex_adapter *adapter);
1104 void mwifiex_cancel_scan(struct mwifiex_adapter *adapter);
1105 
1106 void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
1107 			      struct cmd_ctrl_node *cmd_node);
1108 
1109 void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
1110 				     struct cmd_ctrl_node *cmd_node);
1111 
1112 int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
1113 int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
1114 int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
1115 			     struct sk_buff *skb);
1116 int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
1117 		       struct mwifiex_tx_param *tx_param);
1118 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
1119 int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
1120 				struct sk_buff *skb, int aggr, int status);
1121 void mwifiex_clean_txrx(struct mwifiex_private *priv);
1122 u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
1123 void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
1124 void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
1125 					u32);
1126 int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
1127 			       struct host_cmd_ds_command *cmd,
1128 			       u16 cmd_action, uint16_t ps_bitmap,
1129 			       struct mwifiex_ds_auto_ds *auto_ds);
1130 int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
1131 			       struct host_cmd_ds_command *resp,
1132 			       struct mwifiex_ds_pm_cfg *pm_cfg);
1133 void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
1134 void mwifiex_hs_activated_event(struct mwifiex_private *priv,
1135 					u8 activated);
1136 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
1137 			  int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg);
1138 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
1139 			      struct host_cmd_ds_command *resp);
1140 int mwifiex_process_rx_packet(struct mwifiex_private *priv,
1141 			      struct sk_buff *skb);
1142 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
1143 			    u16 cmd_action, u32 cmd_oid,
1144 			    void *data_buf, void *cmd_buf);
1145 int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1146 			    u16 cmd_action, u32 cmd_oid,
1147 			    void *data_buf, void *cmd_buf);
1148 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
1149 				struct host_cmd_ds_command *resp);
1150 int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
1151 				  struct sk_buff *skb);
1152 int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
1153 				  struct sk_buff *skb);
1154 int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
1155 				  struct sk_buff *skb);
1156 int mwifiex_process_sta_event(struct mwifiex_private *);
1157 int mwifiex_process_uap_event(struct mwifiex_private *);
1158 void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
1159 void mwifiex_wmm_del_peer_ra_list(struct mwifiex_private *priv,
1160 				  const u8 *ra_addr);
1161 void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
1162 void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
1163 int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta, bool init);
1164 int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
1165 			    struct mwifiex_scan_cmd_config *scan_cfg);
1166 void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
1167 			    struct cmd_ctrl_node *cmd_node);
1168 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
1169 			    struct host_cmd_ds_command *resp);
1170 s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
1171 int mwifiex_associate(struct mwifiex_private *priv,
1172 		      struct mwifiex_bssdescriptor *bss_desc);
1173 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
1174 				 struct host_cmd_ds_command *cmd,
1175 				 struct mwifiex_bssdescriptor *bss_desc);
1176 int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
1177 				 struct host_cmd_ds_command *resp);
1178 void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason,
1179 				 bool from_ap);
1180 u8 mwifiex_band_to_radio_type(u8 band);
1181 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
1182 void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
1183 int mwifiex_adhoc_start(struct mwifiex_private *priv,
1184 			struct cfg80211_ssid *adhoc_ssid);
1185 int mwifiex_adhoc_join(struct mwifiex_private *priv,
1186 		       struct mwifiex_bssdescriptor *bss_desc);
1187 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
1188 				    struct host_cmd_ds_command *cmd,
1189 				    struct cfg80211_ssid *req_ssid);
1190 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1191 				   struct host_cmd_ds_command *cmd,
1192 				   struct mwifiex_bssdescriptor *bss_desc);
1193 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
1194 			      struct host_cmd_ds_command *resp);
1195 int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
1196 struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
1197 						u8 band, u16 channel, u32 freq);
1198 u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
1199 			       u8 index, u8 ht_info);
1200 u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
1201 				   u8 index, u8 ht_info);
1202 u32 mwifiex_find_freq_from_band_chan(u8, u8);
1203 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
1204 				u8 **buffer);
1205 u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
1206 				    u8 *rates);
1207 u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
1208 u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
1209 				    u8 *rates, u8 radio_type);
1210 u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
1211 extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
1212 void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
1213 void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
1214 int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
1215 			    struct host_cmd_ds_command *cmd);
1216 int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
1217 			    struct host_cmd_ds_command *resp);
1218 int is_command_pending(struct mwifiex_adapter *adapter);
1219 void mwifiex_init_priv_params(struct mwifiex_private *priv,
1220 						struct net_device *dev);
1221 int mwifiex_set_secure_params(struct mwifiex_private *priv,
1222 			      struct mwifiex_uap_bss_param *bss_config,
1223 			      struct cfg80211_ap_settings *params);
1224 void mwifiex_set_ht_params(struct mwifiex_private *priv,
1225 			   struct mwifiex_uap_bss_param *bss_cfg,
1226 			   struct cfg80211_ap_settings *params);
1227 void mwifiex_set_vht_params(struct mwifiex_private *priv,
1228 			    struct mwifiex_uap_bss_param *bss_cfg,
1229 			    struct cfg80211_ap_settings *params);
1230 void mwifiex_set_tpc_params(struct mwifiex_private *priv,
1231 			    struct mwifiex_uap_bss_param *bss_cfg,
1232 			    struct cfg80211_ap_settings *params);
1233 void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
1234 			   struct cfg80211_ap_settings *params);
1235 void mwifiex_set_vht_width(struct mwifiex_private *priv,
1236 			   enum nl80211_chan_width width,
1237 			   bool ap_11ac_disable);
1238 void
1239 mwifiex_set_wmm_params(struct mwifiex_private *priv,
1240 		       struct mwifiex_uap_bss_param *bss_cfg,
1241 		       struct cfg80211_ap_settings *params);
1242 void mwifiex_set_ba_params(struct mwifiex_private *priv);
1243 
1244 void mwifiex_update_ampdu_txwinsize(struct mwifiex_adapter *pmadapter);
1245 void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
1246 					     struct sk_buff *event_skb);
1247 
1248 void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
1249 int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
1250 				struct host_cmd_ds_command *cmd,
1251 				void *data_buf);
1252 int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
1253 				struct host_cmd_ds_command *resp);
1254 int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
1255 					 void *buf);
1256 int mwifiex_cmd_802_11_bg_scan_config(struct mwifiex_private *priv,
1257 				      struct host_cmd_ds_command *cmd,
1258 				      void *data_buf);
1259 int mwifiex_stop_bg_scan(struct mwifiex_private *priv);
1260 
1261 /*
1262  * This function checks if the queuing is RA based or not.
1263  */
1264 static inline u8
mwifiex_queuing_ra_based(struct mwifiex_private * priv)1265 mwifiex_queuing_ra_based(struct mwifiex_private *priv)
1266 {
1267 	/*
1268 	 * Currently we assume if we are in Infra, then DA=RA. This might not be
1269 	 * true in the future
1270 	 */
1271 	if ((priv->bss_mode == NL80211_IFTYPE_STATION ||
1272 	     priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) &&
1273 	    (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
1274 		return false;
1275 
1276 	return true;
1277 }
1278 
1279 /*
1280  * This function copies rates.
1281  */
1282 static inline u32
mwifiex_copy_rates(u8 * dest,u32 pos,u8 * src,int len)1283 mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
1284 {
1285 	int i;
1286 
1287 	for (i = 0; i < len && src[i]; i++, pos++) {
1288 		if (pos >= MWIFIEX_SUPPORTED_RATES)
1289 			break;
1290 		dest[pos] = src[i];
1291 	}
1292 
1293 	return pos;
1294 }
1295 
1296 /* This function return interface number with the same bss_type.
1297  */
1298 static inline u8
mwifiex_get_intf_num(struct mwifiex_adapter * adapter,u8 bss_type)1299 mwifiex_get_intf_num(struct mwifiex_adapter *adapter, u8 bss_type)
1300 {
1301 	u8 i, num = 0;
1302 
1303 	for (i = 0; i < adapter->priv_num; i++)
1304 		if (adapter->priv[i] && adapter->priv[i]->bss_type == bss_type)
1305 			num++;
1306 	return num;
1307 }
1308 
1309 /*
1310  * This function returns the correct private structure pointer based
1311  * upon the BSS type and BSS number.
1312  */
1313 static inline struct mwifiex_private *
mwifiex_get_priv_by_id(struct mwifiex_adapter * adapter,u8 bss_num,u8 bss_type)1314 mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
1315 		       u8 bss_num, u8 bss_type)
1316 {
1317 	int i;
1318 
1319 	for (i = 0; i < adapter->priv_num; i++) {
1320 		if (adapter->priv[i]) {
1321 			if ((adapter->priv[i]->bss_num == bss_num) &&
1322 			    (adapter->priv[i]->bss_type == bss_type))
1323 				break;
1324 		}
1325 	}
1326 	return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1327 }
1328 
1329 /*
1330  * This function returns the first available private structure pointer
1331  * based upon the BSS role.
1332  */
1333 static inline struct mwifiex_private *
mwifiex_get_priv(struct mwifiex_adapter * adapter,enum mwifiex_bss_role bss_role)1334 mwifiex_get_priv(struct mwifiex_adapter *adapter,
1335 		 enum mwifiex_bss_role bss_role)
1336 {
1337 	int i;
1338 
1339 	for (i = 0; i < adapter->priv_num; i++) {
1340 		if (adapter->priv[i]) {
1341 			if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
1342 			    GET_BSS_ROLE(adapter->priv[i]) == bss_role)
1343 				break;
1344 		}
1345 	}
1346 
1347 	return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1348 }
1349 
1350 /*
1351  * This function checks available bss_num when adding new interface or
1352  * changing interface type.
1353  */
1354 static inline u8
mwifiex_get_unused_bss_num(struct mwifiex_adapter * adapter,u8 bss_type)1355 mwifiex_get_unused_bss_num(struct mwifiex_adapter *adapter, u8 bss_type)
1356 {
1357 	u8 i, j;
1358 	int index[MWIFIEX_MAX_BSS_NUM];
1359 
1360 	memset(index, 0, sizeof(index));
1361 	for (i = 0; i < adapter->priv_num; i++)
1362 		if (adapter->priv[i]) {
1363 			if (adapter->priv[i]->bss_type == bss_type &&
1364 			    !(adapter->priv[i]->bss_mode ==
1365 			      NL80211_IFTYPE_UNSPECIFIED)) {
1366 				index[adapter->priv[i]->bss_num] = 1;
1367 			}
1368 		}
1369 	for (j = 0; j < MWIFIEX_MAX_BSS_NUM; j++)
1370 		if (!index[j])
1371 			return j;
1372 	return -1;
1373 }
1374 
1375 /*
1376  * This function returns the first available unused private structure pointer.
1377  */
1378 static inline struct mwifiex_private *
mwifiex_get_unused_priv_by_bss_type(struct mwifiex_adapter * adapter,u8 bss_type)1379 mwifiex_get_unused_priv_by_bss_type(struct mwifiex_adapter *adapter,
1380 				    u8 bss_type)
1381 {
1382 	u8 i;
1383 
1384 	for (i = 0; i < adapter->priv_num; i++)
1385 		if (adapter->priv[i]->bss_mode ==
1386 		   NL80211_IFTYPE_UNSPECIFIED) {
1387 			adapter->priv[i]->bss_num =
1388 			mwifiex_get_unused_bss_num(adapter, bss_type);
1389 			break;
1390 		}
1391 
1392 	return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1393 }
1394 
1395 /*
1396  * This function returns the driver private structure of a network device.
1397  */
1398 static inline struct mwifiex_private *
mwifiex_netdev_get_priv(struct net_device * dev)1399 mwifiex_netdev_get_priv(struct net_device *dev)
1400 {
1401 	return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
1402 }
1403 
1404 /*
1405  * This function checks if a skb holds a management frame.
1406  */
mwifiex_is_skb_mgmt_frame(struct sk_buff * skb)1407 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
1408 {
1409 	return (get_unaligned_le32(skb->data) == PKT_TYPE_MGMT);
1410 }
1411 
1412 /* This function retrieves channel closed for operation by Channel
1413  * Switch Announcement.
1414  */
1415 static inline u8
mwifiex_11h_get_csa_closed_channel(struct mwifiex_private * priv)1416 mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
1417 {
1418 	if (!priv->csa_chan)
1419 		return 0;
1420 
1421 	/* Clear csa channel, if DFS channel move time has passed */
1422 	if (time_after(jiffies, priv->csa_expire_time)) {
1423 		priv->csa_chan = 0;
1424 		priv->csa_expire_time = 0;
1425 	}
1426 
1427 	return priv->csa_chan;
1428 }
1429 
mwifiex_is_any_intf_active(struct mwifiex_private * priv)1430 static inline u8 mwifiex_is_any_intf_active(struct mwifiex_private *priv)
1431 {
1432 	struct mwifiex_private *priv_num;
1433 	int i;
1434 
1435 	for (i = 0; i < priv->adapter->priv_num; i++) {
1436 		priv_num = priv->adapter->priv[i];
1437 		if (priv_num) {
1438 			if ((GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_UAP &&
1439 			     priv_num->bss_started) ||
1440 			    (GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_STA &&
1441 			     priv_num->media_connected))
1442 				return 1;
1443 		}
1444 	}
1445 
1446 	return 0;
1447 }
1448 
mwifiex_is_tdls_link_setup(u8 status)1449 static inline u8 mwifiex_is_tdls_link_setup(u8 status)
1450 {
1451 	switch (status) {
1452 	case TDLS_SETUP_COMPLETE:
1453 	case TDLS_CHAN_SWITCHING:
1454 	case TDLS_IN_BASE_CHAN:
1455 	case TDLS_IN_OFF_CHAN:
1456 		return true;
1457 	default:
1458 		break;
1459 	}
1460 
1461 	return false;
1462 }
1463 
1464 /* Disable platform specific wakeup interrupt */
mwifiex_disable_wake(struct mwifiex_adapter * adapter)1465 static inline void mwifiex_disable_wake(struct mwifiex_adapter *adapter)
1466 {
1467 	if (adapter->irq_wakeup >= 0) {
1468 		disable_irq_wake(adapter->irq_wakeup);
1469 		disable_irq(adapter->irq_wakeup);
1470 		if (adapter->wake_by_wifi)
1471 			/* Undo our disable, since interrupt handler already
1472 			 * did this.
1473 			 */
1474 			enable_irq(adapter->irq_wakeup);
1475 
1476 	}
1477 }
1478 
1479 /* Enable platform specific wakeup interrupt */
mwifiex_enable_wake(struct mwifiex_adapter * adapter)1480 static inline void mwifiex_enable_wake(struct mwifiex_adapter *adapter)
1481 {
1482 	/* Enable platform specific wakeup interrupt */
1483 	if (adapter->irq_wakeup >= 0) {
1484 		adapter->wake_by_wifi = false;
1485 		enable_irq(adapter->irq_wakeup);
1486 		enable_irq_wake(adapter->irq_wakeup);
1487 	}
1488 }
1489 
1490 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
1491 			     u32 func_init_shutdown);
1492 
1493 int mwifiex_add_card(void *card, struct completion *fw_done,
1494 		     struct mwifiex_if_ops *if_ops, u8 iface_type,
1495 		     struct device *dev);
1496 int mwifiex_remove_card(struct mwifiex_adapter *adapter);
1497 
1498 void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
1499 			 int maxlen);
1500 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
1501 			struct mwifiex_multicast_list *mcast_list);
1502 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
1503 			    struct net_device *dev);
1504 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
1505 				struct cmd_ctrl_node *cmd_queued);
1506 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1507 		      struct cfg80211_ssid *req_ssid);
1508 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
1509 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
1510 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
1511 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
1512 int mwifiex_request_scan(struct mwifiex_private *priv,
1513 			 struct cfg80211_ssid *req_ssid);
1514 int mwifiex_scan_networks(struct mwifiex_private *priv,
1515 			  const struct mwifiex_user_scan_cfg *user_scan_in);
1516 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
1517 
1518 int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1519 		       const u8 *key, int key_len, u8 key_index,
1520 		       const u8 *mac_addr, int disable);
1521 
1522 int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
1523 
1524 int mwifiex_get_ver_ext(struct mwifiex_private *priv, u32 version_str_sel);
1525 
1526 int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1527 			       struct ieee80211_channel *chan,
1528 			       unsigned int duration);
1529 
1530 int mwifiex_get_stats_info(struct mwifiex_private *priv,
1531 			   struct mwifiex_ds_get_stats *log);
1532 
1533 int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1534 		      u32 reg_offset, u32 reg_value);
1535 
1536 int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1537 		     u32 reg_offset, u32 *value);
1538 
1539 int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1540 			u8 *value);
1541 
1542 int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1543 
1544 int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1545 
1546 int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1547 
1548 int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1549 
1550 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
1551 
1552 int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1553 				   char *version, int max_len);
1554 
1555 int mwifiex_set_tx_power(struct mwifiex_private *priv,
1556 			 struct mwifiex_power_cfg *power_cfg);
1557 
1558 int mwifiex_main_process(struct mwifiex_adapter *);
1559 
1560 int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
1561 
1562 int mwifiex_get_bss_info(struct mwifiex_private *,
1563 			 struct mwifiex_bss_info *);
1564 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
1565 			      struct cfg80211_bss *bss,
1566 			      struct mwifiex_bssdescriptor *bss_desc);
1567 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1568 				    struct mwifiex_bssdescriptor *bss_entry);
1569 int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
1570 					struct mwifiex_bssdescriptor *bss_desc);
1571 
1572 u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
1573 u8 mwifiex_get_chan_type(struct mwifiex_private *priv);
1574 
1575 struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1576 					      const char *name,
1577 					      unsigned char name_assign_type,
1578 					      enum nl80211_iftype type,
1579 					      struct vif_params *params);
1580 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
1581 
1582 void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
1583 
1584 int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
1585 
1586 int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1587 			 struct cfg80211_beacon_data *data);
1588 int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
1589 u8 *mwifiex_11d_code_2_region(u8 code);
1590 void mwifiex_uap_set_channel(struct mwifiex_private *priv,
1591 			     struct mwifiex_uap_bss_param *bss_cfg,
1592 			     struct cfg80211_chan_def chandef);
1593 int mwifiex_config_start_uap(struct mwifiex_private *priv,
1594 			     struct mwifiex_uap_bss_param *bss_cfg);
1595 void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
1596 			      struct mwifiex_sta_node *node);
1597 
1598 void mwifiex_config_uap_11d(struct mwifiex_private *priv,
1599 			    struct cfg80211_beacon_data *beacon_data);
1600 
1601 void mwifiex_init_11h_params(struct mwifiex_private *priv);
1602 int mwifiex_is_11h_active(struct mwifiex_private *priv);
1603 int mwifiex_11h_activate(struct mwifiex_private *priv, bool flag);
1604 
1605 void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
1606 			      struct mwifiex_bssdescriptor *bss_desc);
1607 int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
1608 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1609 			    struct device_node *node, const char *prefix);
1610 void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
1611 
1612 extern const struct ethtool_ops mwifiex_ethtool_ops;
1613 
1614 void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
1615 void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1616 void
1617 mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
1618 		       int ies_len, struct mwifiex_sta_node *node);
1619 struct mwifiex_sta_node *
1620 mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1621 struct mwifiex_sta_node *
1622 mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1623 u8 mwifiex_is_tdls_chan_switching(struct mwifiex_private *priv);
1624 u8 mwifiex_is_tdls_off_chan(struct mwifiex_private *priv);
1625 u8 mwifiex_is_send_cmd_allowed(struct mwifiex_private *priv);
1626 int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
1627 				 u8 action_code, u8 dialog_token,
1628 				 u16 status_code, const u8 *extra_ies,
1629 				 size_t extra_ies_len);
1630 int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
1631 				   u8 action_code, u8 dialog_token,
1632 				   u16 status_code, const u8 *extra_ies,
1633 				   size_t extra_ies_len);
1634 void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
1635 				       u8 *buf, int len);
1636 int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
1637 int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
1638 int mwifiex_get_tdls_list(struct mwifiex_private *priv,
1639 			  struct tdls_peer_info *buf);
1640 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
1641 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
1642 u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
1643 				 u32 pri_chan, u8 chan_bw);
1644 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
1645 
1646 int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb);
1647 void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv);
1648 void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1649 					  const u8 *mac, u8 link_status);
1650 void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1651 					  u8 *mac, s8 snr, s8 nflr);
1652 void mwifiex_check_auto_tdls(struct timer_list *t);
1653 void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac);
1654 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv);
1655 void mwifiex_clean_auto_tdls(struct mwifiex_private *priv);
1656 int mwifiex_config_tdls_enable(struct mwifiex_private *priv);
1657 int mwifiex_config_tdls_disable(struct mwifiex_private *priv);
1658 int mwifiex_config_tdls_cs_params(struct mwifiex_private *priv);
1659 int mwifiex_stop_tdls_cs(struct mwifiex_private *priv, const u8 *peer_mac);
1660 int mwifiex_start_tdls_cs(struct mwifiex_private *priv, const u8 *peer_mac,
1661 			  u8 primary_chan, u8 second_chan_offset, u8 band);
1662 
1663 int mwifiex_cmd_issue_chan_report_request(struct mwifiex_private *priv,
1664 					  struct host_cmd_ds_command *cmd,
1665 					  void *data_buf);
1666 int mwifiex_11h_handle_chanrpt_ready(struct mwifiex_private *priv,
1667 				     struct sk_buff *skb);
1668 
1669 void mwifiex_parse_tx_status_event(struct mwifiex_private *priv,
1670 				   void *event_body);
1671 
1672 struct sk_buff *
1673 mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
1674 				struct sk_buff *skb, u8 flag, u64 *cookie);
1675 void mwifiex_dfs_cac_work_queue(struct work_struct *work);
1676 void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work);
1677 void mwifiex_abort_cac(struct mwifiex_private *priv);
1678 int mwifiex_stop_radar_detection(struct mwifiex_private *priv,
1679 				 struct cfg80211_chan_def *chandef);
1680 int mwifiex_11h_handle_radar_detected(struct mwifiex_private *priv,
1681 				      struct sk_buff *skb);
1682 
1683 void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
1684 			   s8 nflr);
1685 void mwifiex_hist_data_reset(struct mwifiex_private *priv);
1686 void mwifiex_hist_data_add(struct mwifiex_private *priv,
1687 			   u8 rx_rate, s8 snr, s8 nflr);
1688 u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
1689 			    u8 rx_rate, u8 ht_info);
1690 
1691 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter);
1692 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter);
1693 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter);
1694 void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags);
1695 void mwifiex_fw_dump_event(struct mwifiex_private *priv);
1696 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter);
1697 int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action,
1698 			      int cmd_type,
1699 			      struct mwifiex_ds_wakeup_reason *wakeup_reason);
1700 int mwifiex_get_chan_info(struct mwifiex_private *priv,
1701 			  struct mwifiex_channel_band *channel_band);
1702 int mwifiex_ret_wakeup_reason(struct mwifiex_private *priv,
1703 			      struct host_cmd_ds_command *resp,
1704 			      struct host_cmd_ds_wakeup_reason *wakeup_reason);
1705 void mwifiex_coex_ampdu_rxwinsize(struct mwifiex_adapter *adapter);
1706 void mwifiex_11n_delba(struct mwifiex_private *priv, int tid);
1707 int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy);
1708 void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
1709 				    struct sk_buff *event);
1710 void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
1711 				      struct sk_buff *event_skb);
1712 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter);
1713 int mwifiex_set_mac_address(struct mwifiex_private *priv,
1714 			    struct net_device *dev,
1715 			    bool external, u8 *new_mac);
1716 void mwifiex_devdump_tmo_func(unsigned long function_context);
1717 
1718 #ifdef CONFIG_DEBUG_FS
1719 void mwifiex_debugfs_init(void);
1720 void mwifiex_debugfs_remove(void);
1721 
1722 void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1723 void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1724 #endif
1725 int mwifiex_reinit_sw(struct mwifiex_adapter *adapter);
1726 int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter);
1727 #endif /* !_MWIFIEX_MAIN_H_ */
1728