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 struct mwifiex_band_config {
521 	u8 chan_band:2;
522 	u8 chan_width:2;
523 	u8 chan2_offset:2;
524 	u8 scan_mode:2;
525 } __packed;
526 
527 struct mwifiex_channel_band {
528 	struct mwifiex_band_config band_config;
529 	u8 channel;
530 };
531 
532 struct mwifiex_private {
533 	struct mwifiex_adapter *adapter;
534 	u8 bss_type;
535 	u8 bss_role;
536 	u8 bss_priority;
537 	u8 bss_num;
538 	u8 bss_started;
539 	u8 frame_type;
540 	u8 curr_addr[ETH_ALEN];
541 	u8 media_connected;
542 	u8 port_open;
543 	u8 usb_port;
544 	u32 num_tx_timeout;
545 	/* track consecutive timeout */
546 	u8 tx_timeout_cnt;
547 	struct net_device *netdev;
548 	struct net_device_stats stats;
549 	u32 curr_pkt_filter;
550 	u32 bss_mode;
551 	u32 pkt_tx_ctrl;
552 	u16 tx_power_level;
553 	u8 max_tx_power_level;
554 	u8 min_tx_power_level;
555 	u32 tx_ant;
556 	u32 rx_ant;
557 	u8 tx_rate;
558 	u8 tx_htinfo;
559 	u8 rxpd_htinfo;
560 	u8 rxpd_rate;
561 	u16 rate_bitmap;
562 	u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
563 	u32 data_rate;
564 	u8 is_data_rate_auto;
565 	u16 bcn_avg_factor;
566 	u16 data_avg_factor;
567 	s16 data_rssi_last;
568 	s16 data_nf_last;
569 	s16 data_rssi_avg;
570 	s16 data_nf_avg;
571 	s16 bcn_rssi_last;
572 	s16 bcn_nf_last;
573 	s16 bcn_rssi_avg;
574 	s16 bcn_nf_avg;
575 	struct mwifiex_bssdescriptor *attempted_bss_desc;
576 	struct cfg80211_ssid prev_ssid;
577 	u8 prev_bssid[ETH_ALEN];
578 	struct mwifiex_current_bss_params curr_bss_params;
579 	u16 beacon_period;
580 	u8 dtim_period;
581 	u16 listen_interval;
582 	u16 atim_window;
583 	u8 adhoc_channel;
584 	u8 adhoc_is_link_sensed;
585 	u8 adhoc_state;
586 	struct mwifiex_802_11_security sec_info;
587 	struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
588 	u16 wep_key_curr_index;
589 	u8 wpa_ie[256];
590 	u16 wpa_ie_len;
591 	u8 wpa_is_gtk_set;
592 	struct host_cmd_ds_802_11_key_material aes_key;
593 	struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
594 	u8 wapi_ie[256];
595 	u16 wapi_ie_len;
596 	u8 *wps_ie;
597 	u16 wps_ie_len;
598 	u8 wmm_required;
599 	u8 wmm_enabled;
600 	u8 wmm_qosinfo;
601 	struct mwifiex_wmm_desc wmm;
602 	atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
603 	struct list_head sta_list;
604 	/* spin lock for associated station/TDLS peers list */
605 	spinlock_t sta_list_spinlock;
606 	struct list_head auto_tdls_list;
607 	/* spin lock for auto TDLS peer list */
608 	spinlock_t auto_tdls_lock;
609 	struct list_head tx_ba_stream_tbl_ptr;
610 	/* spin lock for tx_ba_stream_tbl_ptr queue */
611 	spinlock_t tx_ba_stream_tbl_lock;
612 	struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
613 	struct mwifiex_add_ba_param add_ba_param;
614 	u16 rx_seq[MAX_NUM_TID];
615 	u8 tos_to_tid_inv[MAX_NUM_TID];
616 	struct list_head rx_reorder_tbl_ptr;
617 	/* spin lock for rx_reorder_tbl_ptr queue */
618 	spinlock_t rx_reorder_tbl_lock;
619 	/* spin lock for Rx packets */
620 	spinlock_t rx_pkt_lock;
621 
622 #define MWIFIEX_ASSOC_RSP_BUF_SIZE  500
623 	u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
624 	u32 assoc_rsp_size;
625 
626 #define MWIFIEX_GENIE_BUF_SIZE      256
627 	u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
628 	u8 gen_ie_buf_len;
629 
630 	struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
631 
632 #define MWIFIEX_ASSOC_TLV_BUF_SIZE  256
633 	u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
634 	u8 assoc_tlv_buf_len;
635 
636 	u8 *curr_bcn_buf;
637 	u32 curr_bcn_size;
638 	/* spin lock for beacon buffer */
639 	spinlock_t curr_bcn_buf_lock;
640 	struct wireless_dev wdev;
641 	struct mwifiex_chan_freq_power cfp;
642 	u32 versionstrsel;
643 	char version_str[128];
644 #ifdef CONFIG_DEBUG_FS
645 	struct dentry *dfs_dev_dir;
646 #endif
647 	u16 current_key_index;
648 	struct mutex async_mutex;
649 	struct cfg80211_scan_request *scan_request;
650 	u8 cfg_bssid[6];
651 	struct wps wps;
652 	u8 scan_block;
653 	s32 cqm_rssi_thold;
654 	u32 cqm_rssi_hyst;
655 	u8 subsc_evt_rssi_state;
656 	struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
657 	struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
658 	u16 beacon_idx;
659 	u16 proberesp_idx;
660 	u16 assocresp_idx;
661 	u16 gen_idx;
662 	u8 ap_11n_enabled;
663 	u8 ap_11ac_enabled;
664 	u32 mgmt_frame_mask;
665 	struct mwifiex_roc_cfg roc_cfg;
666 	bool scan_aborting;
667 	u8 sched_scanning;
668 	u8 csa_chan;
669 	unsigned long csa_expire_time;
670 	u8 del_list_idx;
671 	bool hs2_enabled;
672 	struct mwifiex_uap_bss_param bss_cfg;
673 	struct cfg80211_chan_def bss_chandef;
674 	struct station_parameters *sta_params;
675 	struct sk_buff_head tdls_txq;
676 	u8 check_tdls_tx;
677 	struct timer_list auto_tdls_timer;
678 	bool auto_tdls_timer_active;
679 	struct idr ack_status_frames;
680 	/* spin lock for ack status */
681 	spinlock_t ack_status_lock;
682 	/** rx histogram data */
683 	struct mwifiex_histogram_data *hist_data;
684 	struct cfg80211_chan_def dfs_chandef;
685 	struct workqueue_struct *dfs_cac_workqueue;
686 	struct delayed_work dfs_cac_work;
687 	struct timer_list dfs_chan_switch_timer;
688 	struct workqueue_struct *dfs_chan_sw_workqueue;
689 	struct delayed_work dfs_chan_sw_work;
690 	struct cfg80211_beacon_data beacon_after;
691 	struct mwifiex_11h_intf_state state_11h;
692 	struct mwifiex_ds_mem_rw mem_rw;
693 	struct sk_buff_head bypass_txq;
694 	struct mwifiex_user_scan_chan hidden_chan[MWIFIEX_USER_SCAN_CHAN_MAX];
695 	u8 assoc_resp_ht_param;
696 	bool ht_param_present;
697 };
698 
699 
700 struct mwifiex_tx_ba_stream_tbl {
701 	struct list_head list;
702 	int tid;
703 	u8 ra[ETH_ALEN];
704 	enum mwifiex_ba_status ba_status;
705 	u8 amsdu;
706 };
707 
708 struct mwifiex_rx_reorder_tbl;
709 
710 struct reorder_tmr_cnxt {
711 	struct timer_list timer;
712 	struct mwifiex_rx_reorder_tbl *ptr;
713 	struct mwifiex_private *priv;
714 	u8 timer_is_set;
715 };
716 
717 struct mwifiex_rx_reorder_tbl {
718 	struct list_head list;
719 	int tid;
720 	u8 ta[ETH_ALEN];
721 	int init_win;
722 	int start_win;
723 	int win_size;
724 	void **rx_reorder_ptr;
725 	struct reorder_tmr_cnxt timer_context;
726 	u8 amsdu;
727 	u8 flags;
728 };
729 
730 struct mwifiex_bss_prio_node {
731 	struct list_head list;
732 	struct mwifiex_private *priv;
733 };
734 
735 struct mwifiex_bss_prio_tbl {
736 	struct list_head bss_prio_head;
737 	/* spin lock for bss priority  */
738 	spinlock_t bss_prio_lock;
739 	struct mwifiex_bss_prio_node *bss_prio_cur;
740 };
741 
742 struct cmd_ctrl_node {
743 	struct list_head list;
744 	struct mwifiex_private *priv;
745 	u32 cmd_oid;
746 	u32 cmd_flag;
747 	struct sk_buff *cmd_skb;
748 	struct sk_buff *resp_skb;
749 	void *data_buf;
750 	u32 wait_q_enabled;
751 	struct sk_buff *skb;
752 	u8 *condition;
753 	u8 cmd_wait_q_woken;
754 };
755 
756 struct mwifiex_bss_priv {
757 	u8 band;
758 	u64 fw_tsf;
759 };
760 
761 struct mwifiex_tdls_capab {
762 	__le16 capab;
763 	u8 rates[32];
764 	u8 rates_len;
765 	u8 qos_info;
766 	u8 coex_2040;
767 	u16 aid;
768 	struct ieee80211_ht_cap ht_capb;
769 	struct ieee80211_ht_operation ht_oper;
770 	struct ieee_types_extcap extcap;
771 	struct ieee_types_generic rsn_ie;
772 	struct ieee80211_vht_cap vhtcap;
773 	struct ieee80211_vht_operation vhtoper;
774 };
775 
776 struct mwifiex_station_stats {
777 	u64 last_rx;
778 	s8 rssi;
779 	u64 rx_bytes;
780 	u64 tx_bytes;
781 	u32 rx_packets;
782 	u32 tx_packets;
783 	u32 tx_failed;
784 	u8 last_tx_rate;
785 	u8 last_tx_htinfo;
786 };
787 
788 /* This is AP/TDLS specific structure which stores information
789  * about associated/peer STA
790  */
791 struct mwifiex_sta_node {
792 	struct list_head list;
793 	u8 mac_addr[ETH_ALEN];
794 	u8 is_wmm_enabled;
795 	u8 is_11n_enabled;
796 	u8 is_11ac_enabled;
797 	u8 ampdu_sta[MAX_NUM_TID];
798 	u16 rx_seq[MAX_NUM_TID];
799 	u16 max_amsdu;
800 	u8 tdls_status;
801 	struct mwifiex_tdls_capab tdls_cap;
802 	struct mwifiex_station_stats stats;
803 	u8 tx_pause;
804 };
805 
806 struct mwifiex_auto_tdls_peer {
807 	struct list_head list;
808 	u8 mac_addr[ETH_ALEN];
809 	u8 tdls_status;
810 	int rssi;
811 	long rssi_jiffies;
812 	u8 failure_count;
813 	u8 do_discover;
814 	u8 do_setup;
815 };
816 
817 #define MWIFIEX_TYPE_AGGR_DATA_V2 11
818 #define MWIFIEX_BUS_AGGR_MODE_LEN_V2 (2)
819 #define MWIFIEX_BUS_AGGR_MAX_LEN 16000
820 #define MWIFIEX_BUS_AGGR_MAX_NUM 10
821 struct bus_aggr_params {
822 	u16 enable;
823 	u16 mode;
824 	u16 tx_aggr_max_size;
825 	u16 tx_aggr_max_num;
826 	u16 tx_aggr_align;
827 };
828 
829 struct mwifiex_if_ops {
830 	int (*init_if) (struct mwifiex_adapter *);
831 	void (*cleanup_if) (struct mwifiex_adapter *);
832 	int (*check_fw_status) (struct mwifiex_adapter *, u32);
833 	int (*check_winner_status)(struct mwifiex_adapter *);
834 	int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
835 	int (*register_dev) (struct mwifiex_adapter *);
836 	void (*unregister_dev) (struct mwifiex_adapter *);
837 	int (*enable_int) (struct mwifiex_adapter *);
838 	void (*disable_int) (struct mwifiex_adapter *);
839 	int (*process_int_status) (struct mwifiex_adapter *);
840 	int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
841 			     struct mwifiex_tx_param *);
842 	int (*wakeup) (struct mwifiex_adapter *);
843 	int (*wakeup_complete) (struct mwifiex_adapter *);
844 
845 	/* Interface specific functions */
846 	void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
847 	void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
848 	int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
849 	int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
850 	int (*init_fw_port) (struct mwifiex_adapter *);
851 	int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
852 	void (*card_reset) (struct mwifiex_adapter *);
853 	int (*reg_dump)(struct mwifiex_adapter *, char *);
854 	void (*device_dump)(struct mwifiex_adapter *);
855 	int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
856 	void (*iface_work)(struct work_struct *work);
857 	void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
858 	void (*deaggr_pkt)(struct mwifiex_adapter *, struct sk_buff *);
859 	void (*multi_port_resync)(struct mwifiex_adapter *);
860 	bool (*is_port_ready)(struct mwifiex_private *);
861 	void (*down_dev)(struct mwifiex_adapter *);
862 	void (*up_dev)(struct mwifiex_adapter *);
863 };
864 
865 struct mwifiex_adapter {
866 	u8 iface_type;
867 	unsigned int debug_mask;
868 	struct mwifiex_iface_comb iface_limit;
869 	struct mwifiex_iface_comb curr_iface_comb;
870 	struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
871 	u8 priv_num;
872 	const struct firmware *firmware;
873 	char fw_name[32];
874 	int winner;
875 	struct device *dev;
876 	struct wiphy *wiphy;
877 	u8 perm_addr[ETH_ALEN];
878 	bool surprise_removed;
879 	u32 fw_release_number;
880 	u8 intf_hdr_len;
881 	u16 init_wait_q_woken;
882 	wait_queue_head_t init_wait_q;
883 	void *card;
884 	struct mwifiex_if_ops if_ops;
885 	atomic_t bypass_tx_pending;
886 	atomic_t rx_pending;
887 	atomic_t tx_pending;
888 	atomic_t cmd_pending;
889 	atomic_t tx_hw_pending;
890 	struct workqueue_struct *workqueue;
891 	struct work_struct main_work;
892 	struct workqueue_struct *rx_workqueue;
893 	struct work_struct rx_work;
894 	struct workqueue_struct *dfs_workqueue;
895 	struct work_struct dfs_work;
896 	bool rx_work_enabled;
897 	bool rx_processing;
898 	bool delay_main_work;
899 	bool rx_locked;
900 	bool main_locked;
901 	struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
902 	/* spin lock for main process */
903 	spinlock_t main_proc_lock;
904 	u32 mwifiex_processing;
905 	u8 more_task_flag;
906 	u16 tx_buf_size;
907 	u16 curr_tx_buf_size;
908 	/* sdio single port rx aggregation capability */
909 	bool host_disable_sdio_rx_aggr;
910 	bool sdio_rx_aggr_enable;
911 	u16 sdio_rx_block_size;
912 	u32 ioport;
913 	enum MWIFIEX_HARDWARE_STATUS hw_status;
914 	u16 number_of_antenna;
915 	u32 fw_cap_info;
916 	/* spin lock for interrupt handling */
917 	spinlock_t int_lock;
918 	u8 int_status;
919 	u32 event_cause;
920 	struct sk_buff *event_skb;
921 	u8 upld_buf[MWIFIEX_UPLD_SIZE];
922 	u8 data_sent;
923 	u8 cmd_sent;
924 	u8 cmd_resp_received;
925 	u8 event_received;
926 	u8 data_received;
927 	u16 seq_num;
928 	struct cmd_ctrl_node *cmd_pool;
929 	struct cmd_ctrl_node *curr_cmd;
930 	/* spin lock for command */
931 	spinlock_t mwifiex_cmd_lock;
932 	u8 is_cmd_timedout;
933 	u16 last_init_cmd;
934 	struct timer_list cmd_timer;
935 	struct list_head cmd_free_q;
936 	/* spin lock for cmd_free_q */
937 	spinlock_t cmd_free_q_lock;
938 	struct list_head cmd_pending_q;
939 	/* spin lock for cmd_pending_q */
940 	spinlock_t cmd_pending_q_lock;
941 	struct list_head scan_pending_q;
942 	/* spin lock for scan_pending_q */
943 	spinlock_t scan_pending_q_lock;
944 	/* spin lock for RX processing routine */
945 	spinlock_t rx_proc_lock;
946 	struct sk_buff_head tx_data_q;
947 	atomic_t tx_queued;
948 	u32 scan_processing;
949 	u16 region_code;
950 	struct mwifiex_802_11d_domain_reg domain_reg;
951 	u16 scan_probes;
952 	u32 scan_mode;
953 	u16 specific_scan_time;
954 	u16 active_scan_time;
955 	u16 passive_scan_time;
956 	u16 scan_chan_gap_time;
957 	u8 fw_bands;
958 	u8 adhoc_start_band;
959 	u8 config_bands;
960 	struct mwifiex_chan_scan_param_set *scan_channels;
961 	u8 tx_lock_flag;
962 	struct mwifiex_sleep_params sleep_params;
963 	struct mwifiex_sleep_period sleep_period;
964 	u16 ps_mode;
965 	u32 ps_state;
966 	u8 need_to_wakeup;
967 	u16 multiple_dtim;
968 	u16 local_listen_interval;
969 	u16 null_pkt_interval;
970 	struct sk_buff *sleep_cfm;
971 	u16 bcn_miss_time_out;
972 	u16 adhoc_awake_period;
973 	u8 is_deep_sleep;
974 	u8 delay_null_pkt;
975 	u16 delay_to_ps;
976 	u16 enhanced_ps_mode;
977 	u8 pm_wakeup_card_req;
978 	u16 gen_null_pkt;
979 	u16 pps_uapsd_mode;
980 	u32 pm_wakeup_fw_try;
981 	struct timer_list wakeup_timer;
982 	u8 is_hs_configured;
983 	struct mwifiex_hs_config_param hs_cfg;
984 	u8 hs_activated;
985 	u16 hs_activate_wait_q_woken;
986 	wait_queue_head_t hs_activate_wait_q;
987 	bool is_suspended;
988 	bool hs_enabling;
989 	u8 event_body[MAX_EVENT_SIZE];
990 	u32 hw_dot_11n_dev_cap;
991 	u8 hw_dev_mcs_support;
992 	u8 user_dev_mcs_support;
993 	u8 adhoc_11n_enabled;
994 	u8 sec_chan_offset;
995 	struct mwifiex_dbg dbg;
996 	u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
997 	u32 arp_filter_size;
998 	struct mwifiex_wait_queue cmd_wait_q;
999 	u8 scan_wait_q_woken;
1000 	spinlock_t queue_lock;		/* lock for tx queues */
1001 	u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
1002 	u16 max_mgmt_ie_index;
1003 	const struct firmware *cal_data;
1004 	struct device_node *dt_node;
1005 
1006 	/* 11AC */
1007 	u32 is_hw_11ac_capable;
1008 	u32 hw_dot_11ac_dev_cap;
1009 	u32 hw_dot_11ac_mcs_support;
1010 	u32 usr_dot_11ac_dev_cap_bg;
1011 	u32 usr_dot_11ac_dev_cap_a;
1012 	u32 usr_dot_11ac_mcs_support;
1013 
1014 	atomic_t pending_bridged_pkts;
1015 
1016 	/* For synchronizing FW initialization with device lifecycle. */
1017 	struct completion *fw_done;
1018 
1019 	bool ext_scan;
1020 	u8 fw_api_ver;
1021 	u8 key_api_major_ver, key_api_minor_ver;
1022 	struct memory_type_mapping *mem_type_mapping_tbl;
1023 	u8 num_mem_types;
1024 	bool scan_chan_gap_enabled;
1025 	struct sk_buff_head rx_data_q;
1026 	bool mfg_mode;
1027 	struct mwifiex_chan_stats *chan_stats;
1028 	u32 num_in_chan_stats;
1029 	int survey_idx;
1030 	bool auto_tdls;
1031 	u8 coex_scan;
1032 	u8 coex_min_scan_time;
1033 	u8 coex_max_scan_time;
1034 	u8 coex_win_size;
1035 	u8 coex_tx_win_size;
1036 	u8 coex_rx_win_size;
1037 	bool drcs_enabled;
1038 	u8 active_scan_triggered;
1039 	bool usb_mc_status;
1040 	bool usb_mc_setup;
1041 	struct cfg80211_wowlan_nd_info *nd_info;
1042 	struct ieee80211_regdomain *regd;
1043 
1044 	/* Wake-on-WLAN (WoWLAN) */
1045 	int irq_wakeup;
1046 	bool wake_by_wifi;
1047 	/* Aggregation parameters*/
1048 	struct bus_aggr_params bus_aggr;
1049 	/* Device dump data/length */
1050 	void *devdump_data;
1051 	int devdump_len;
1052 	struct timer_list devdump_timer;
1053 };
1054 
1055 void mwifiex_process_tx_queue(struct mwifiex_adapter *adapter);
1056 
1057 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
1058 
1059 void mwifiex_set_trans_start(struct net_device *dev);
1060 
1061 void mwifiex_stop_net_dev_queue(struct net_device *netdev,
1062 		struct mwifiex_adapter *adapter);
1063 
1064 void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
1065 		struct mwifiex_adapter *adapter);
1066 
1067 int mwifiex_init_priv(struct mwifiex_private *priv);
1068 void mwifiex_free_priv(struct mwifiex_private *priv);
1069 
1070 int mwifiex_init_fw(struct mwifiex_adapter *adapter);
1071 
1072 int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
1073 
1074 void mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
1075 
1076 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
1077 
1078 int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
1079 int mwifiex_uap_recv_packet(struct mwifiex_private *priv,
1080 			    struct sk_buff *skb);
1081 
1082 int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
1083 				struct sk_buff *skb);
1084 
1085 int mwifiex_process_event(struct mwifiex_adapter *adapter);
1086 
1087 int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
1088 			 struct cmd_ctrl_node *cmd_node);
1089 
1090 int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
1091 		     u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
1092 
1093 void mwifiex_cmd_timeout_func(struct timer_list *t);
1094 
1095 int mwifiex_get_debug_info(struct mwifiex_private *,
1096 			   struct mwifiex_debug_info *);
1097 
1098 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
1099 void mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
1100 void mwifiex_free_cmd_buffers(struct mwifiex_adapter *adapter);
1101 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
1102 void mwifiex_cancel_pending_scan_cmd(struct mwifiex_adapter *adapter);
1103 void mwifiex_cancel_scan(struct mwifiex_adapter *adapter);
1104 
1105 void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
1106 			      struct cmd_ctrl_node *cmd_node);
1107 
1108 void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
1109 				     struct cmd_ctrl_node *cmd_node);
1110 
1111 int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
1112 int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
1113 int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
1114 			     struct sk_buff *skb);
1115 int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
1116 		       struct mwifiex_tx_param *tx_param);
1117 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
1118 int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
1119 				struct sk_buff *skb, int aggr, int status);
1120 void mwifiex_clean_txrx(struct mwifiex_private *priv);
1121 u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
1122 void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
1123 void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
1124 					u32);
1125 int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
1126 			       struct host_cmd_ds_command *cmd,
1127 			       u16 cmd_action, uint16_t ps_bitmap,
1128 			       struct mwifiex_ds_auto_ds *auto_ds);
1129 int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
1130 			       struct host_cmd_ds_command *resp,
1131 			       struct mwifiex_ds_pm_cfg *pm_cfg);
1132 void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
1133 void mwifiex_hs_activated_event(struct mwifiex_private *priv,
1134 					u8 activated);
1135 int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
1136 			  int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg);
1137 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
1138 			      struct host_cmd_ds_command *resp);
1139 int mwifiex_process_rx_packet(struct mwifiex_private *priv,
1140 			      struct sk_buff *skb);
1141 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
1142 			    u16 cmd_action, u32 cmd_oid,
1143 			    void *data_buf, void *cmd_buf);
1144 int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
1145 			    u16 cmd_action, u32 cmd_oid,
1146 			    void *data_buf, void *cmd_buf);
1147 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
1148 				struct host_cmd_ds_command *resp);
1149 int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
1150 				  struct sk_buff *skb);
1151 int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
1152 				  struct sk_buff *skb);
1153 int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
1154 				  struct sk_buff *skb);
1155 int mwifiex_process_sta_event(struct mwifiex_private *);
1156 int mwifiex_process_uap_event(struct mwifiex_private *);
1157 void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
1158 void mwifiex_wmm_del_peer_ra_list(struct mwifiex_private *priv,
1159 				  const u8 *ra_addr);
1160 void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
1161 void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
1162 int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta, bool init);
1163 int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
1164 			    struct mwifiex_scan_cmd_config *scan_cfg);
1165 void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
1166 			    struct cmd_ctrl_node *cmd_node);
1167 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
1168 			    struct host_cmd_ds_command *resp);
1169 s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
1170 int mwifiex_associate(struct mwifiex_private *priv,
1171 		      struct mwifiex_bssdescriptor *bss_desc);
1172 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
1173 				 struct host_cmd_ds_command *cmd,
1174 				 struct mwifiex_bssdescriptor *bss_desc);
1175 int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
1176 				 struct host_cmd_ds_command *resp);
1177 void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason,
1178 				 bool from_ap);
1179 u8 mwifiex_band_to_radio_type(u8 band);
1180 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
1181 void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
1182 int mwifiex_adhoc_start(struct mwifiex_private *priv,
1183 			struct cfg80211_ssid *adhoc_ssid);
1184 int mwifiex_adhoc_join(struct mwifiex_private *priv,
1185 		       struct mwifiex_bssdescriptor *bss_desc);
1186 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
1187 				    struct host_cmd_ds_command *cmd,
1188 				    struct cfg80211_ssid *req_ssid);
1189 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1190 				   struct host_cmd_ds_command *cmd,
1191 				   struct mwifiex_bssdescriptor *bss_desc);
1192 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
1193 			      struct host_cmd_ds_command *resp);
1194 int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
1195 struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
1196 						u8 band, u16 channel, u32 freq);
1197 u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
1198 			       u8 index, u8 ht_info);
1199 u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
1200 				   u8 index, u8 ht_info);
1201 u32 mwifiex_find_freq_from_band_chan(u8, u8);
1202 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
1203 				u8 **buffer);
1204 u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
1205 				    u8 *rates);
1206 u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
1207 u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
1208 				    u8 *rates, u8 radio_type);
1209 u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
1210 extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
1211 void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
1212 void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
1213 int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
1214 			    struct host_cmd_ds_command *cmd);
1215 int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
1216 			    struct host_cmd_ds_command *resp);
1217 int is_command_pending(struct mwifiex_adapter *adapter);
1218 void mwifiex_init_priv_params(struct mwifiex_private *priv,
1219 						struct net_device *dev);
1220 int mwifiex_set_secure_params(struct mwifiex_private *priv,
1221 			      struct mwifiex_uap_bss_param *bss_config,
1222 			      struct cfg80211_ap_settings *params);
1223 void mwifiex_set_ht_params(struct mwifiex_private *priv,
1224 			   struct mwifiex_uap_bss_param *bss_cfg,
1225 			   struct cfg80211_ap_settings *params);
1226 void mwifiex_set_vht_params(struct mwifiex_private *priv,
1227 			    struct mwifiex_uap_bss_param *bss_cfg,
1228 			    struct cfg80211_ap_settings *params);
1229 void mwifiex_set_tpc_params(struct mwifiex_private *priv,
1230 			    struct mwifiex_uap_bss_param *bss_cfg,
1231 			    struct cfg80211_ap_settings *params);
1232 void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
1233 			   struct cfg80211_ap_settings *params);
1234 void mwifiex_set_vht_width(struct mwifiex_private *priv,
1235 			   enum nl80211_chan_width width,
1236 			   bool ap_11ac_disable);
1237 void
1238 mwifiex_set_wmm_params(struct mwifiex_private *priv,
1239 		       struct mwifiex_uap_bss_param *bss_cfg,
1240 		       struct cfg80211_ap_settings *params);
1241 void mwifiex_set_ba_params(struct mwifiex_private *priv);
1242 
1243 void mwifiex_update_ampdu_txwinsize(struct mwifiex_adapter *pmadapter);
1244 void mwifiex_bt_coex_wlan_param_update_event(struct mwifiex_private *priv,
1245 					     struct sk_buff *event_skb);
1246 
1247 void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
1248 int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
1249 				struct host_cmd_ds_command *cmd,
1250 				void *data_buf);
1251 int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
1252 				struct host_cmd_ds_command *resp);
1253 int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
1254 					 void *buf);
1255 int mwifiex_cmd_802_11_bg_scan_config(struct mwifiex_private *priv,
1256 				      struct host_cmd_ds_command *cmd,
1257 				      void *data_buf);
1258 int mwifiex_stop_bg_scan(struct mwifiex_private *priv);
1259 
1260 /*
1261  * This function checks if the queuing is RA based or not.
1262  */
1263 static inline u8
1264 mwifiex_queuing_ra_based(struct mwifiex_private *priv)
1265 {
1266 	/*
1267 	 * Currently we assume if we are in Infra, then DA=RA. This might not be
1268 	 * true in the future
1269 	 */
1270 	if ((priv->bss_mode == NL80211_IFTYPE_STATION ||
1271 	     priv->bss_mode == NL80211_IFTYPE_P2P_CLIENT) &&
1272 	    (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
1273 		return false;
1274 
1275 	return true;
1276 }
1277 
1278 /*
1279  * This function copies rates.
1280  */
1281 static inline u32
1282 mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
1283 {
1284 	int i;
1285 
1286 	for (i = 0; i < len && src[i]; i++, pos++) {
1287 		if (pos >= MWIFIEX_SUPPORTED_RATES)
1288 			break;
1289 		dest[pos] = src[i];
1290 	}
1291 
1292 	return pos;
1293 }
1294 
1295 /* This function return interface number with the same bss_type.
1296  */
1297 static inline u8
1298 mwifiex_get_intf_num(struct mwifiex_adapter *adapter, u8 bss_type)
1299 {
1300 	u8 i, num = 0;
1301 
1302 	for (i = 0; i < adapter->priv_num; i++)
1303 		if (adapter->priv[i] && adapter->priv[i]->bss_type == bss_type)
1304 			num++;
1305 	return num;
1306 }
1307 
1308 /*
1309  * This function returns the correct private structure pointer based
1310  * upon the BSS type and BSS number.
1311  */
1312 static inline struct mwifiex_private *
1313 mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
1314 		       u8 bss_num, u8 bss_type)
1315 {
1316 	int i;
1317 
1318 	for (i = 0; i < adapter->priv_num; i++) {
1319 		if (adapter->priv[i]) {
1320 			if ((adapter->priv[i]->bss_num == bss_num) &&
1321 			    (adapter->priv[i]->bss_type == bss_type))
1322 				break;
1323 		}
1324 	}
1325 	return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1326 }
1327 
1328 /*
1329  * This function returns the first available private structure pointer
1330  * based upon the BSS role.
1331  */
1332 static inline struct mwifiex_private *
1333 mwifiex_get_priv(struct mwifiex_adapter *adapter,
1334 		 enum mwifiex_bss_role bss_role)
1335 {
1336 	int i;
1337 
1338 	for (i = 0; i < adapter->priv_num; i++) {
1339 		if (adapter->priv[i]) {
1340 			if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
1341 			    GET_BSS_ROLE(adapter->priv[i]) == bss_role)
1342 				break;
1343 		}
1344 	}
1345 
1346 	return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1347 }
1348 
1349 /*
1350  * This function checks available bss_num when adding new interface or
1351  * changing interface type.
1352  */
1353 static inline u8
1354 mwifiex_get_unused_bss_num(struct mwifiex_adapter *adapter, u8 bss_type)
1355 {
1356 	u8 i, j;
1357 	int index[MWIFIEX_MAX_BSS_NUM];
1358 
1359 	memset(index, 0, sizeof(index));
1360 	for (i = 0; i < adapter->priv_num; i++)
1361 		if (adapter->priv[i]) {
1362 			if (adapter->priv[i]->bss_type == bss_type &&
1363 			    !(adapter->priv[i]->bss_mode ==
1364 			      NL80211_IFTYPE_UNSPECIFIED)) {
1365 				index[adapter->priv[i]->bss_num] = 1;
1366 			}
1367 		}
1368 	for (j = 0; j < MWIFIEX_MAX_BSS_NUM; j++)
1369 		if (!index[j])
1370 			return j;
1371 	return -1;
1372 }
1373 
1374 /*
1375  * This function returns the first available unused private structure pointer.
1376  */
1377 static inline struct mwifiex_private *
1378 mwifiex_get_unused_priv_by_bss_type(struct mwifiex_adapter *adapter,
1379 				    u8 bss_type)
1380 {
1381 	u8 i;
1382 
1383 	for (i = 0; i < adapter->priv_num; i++)
1384 		if (adapter->priv[i]->bss_mode ==
1385 		   NL80211_IFTYPE_UNSPECIFIED) {
1386 			adapter->priv[i]->bss_num =
1387 			mwifiex_get_unused_bss_num(adapter, bss_type);
1388 			break;
1389 		}
1390 
1391 	return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1392 }
1393 
1394 /*
1395  * This function returns the driver private structure of a network device.
1396  */
1397 static inline struct mwifiex_private *
1398 mwifiex_netdev_get_priv(struct net_device *dev)
1399 {
1400 	return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
1401 }
1402 
1403 /*
1404  * This function checks if a skb holds a management frame.
1405  */
1406 static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
1407 {
1408 	return (get_unaligned_le32(skb->data) == PKT_TYPE_MGMT);
1409 }
1410 
1411 /* This function retrieves channel closed for operation by Channel
1412  * Switch Announcement.
1413  */
1414 static inline u8
1415 mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
1416 {
1417 	if (!priv->csa_chan)
1418 		return 0;
1419 
1420 	/* Clear csa channel, if DFS channel move time has passed */
1421 	if (time_after(jiffies, priv->csa_expire_time)) {
1422 		priv->csa_chan = 0;
1423 		priv->csa_expire_time = 0;
1424 	}
1425 
1426 	return priv->csa_chan;
1427 }
1428 
1429 static inline u8 mwifiex_is_any_intf_active(struct mwifiex_private *priv)
1430 {
1431 	struct mwifiex_private *priv_num;
1432 	int i;
1433 
1434 	for (i = 0; i < priv->adapter->priv_num; i++) {
1435 		priv_num = priv->adapter->priv[i];
1436 		if (priv_num) {
1437 			if ((GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_UAP &&
1438 			     priv_num->bss_started) ||
1439 			    (GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_STA &&
1440 			     priv_num->media_connected))
1441 				return 1;
1442 		}
1443 	}
1444 
1445 	return 0;
1446 }
1447 
1448 static inline u8 mwifiex_is_tdls_link_setup(u8 status)
1449 {
1450 	switch (status) {
1451 	case TDLS_SETUP_COMPLETE:
1452 	case TDLS_CHAN_SWITCHING:
1453 	case TDLS_IN_BASE_CHAN:
1454 	case TDLS_IN_OFF_CHAN:
1455 		return true;
1456 	default:
1457 		break;
1458 	}
1459 
1460 	return false;
1461 }
1462 
1463 /* Disable platform specific wakeup interrupt */
1464 static inline void mwifiex_disable_wake(struct mwifiex_adapter *adapter)
1465 {
1466 	if (adapter->irq_wakeup >= 0) {
1467 		disable_irq_wake(adapter->irq_wakeup);
1468 		disable_irq(adapter->irq_wakeup);
1469 		if (adapter->wake_by_wifi)
1470 			/* Undo our disable, since interrupt handler already
1471 			 * did this.
1472 			 */
1473 			enable_irq(adapter->irq_wakeup);
1474 
1475 	}
1476 }
1477 
1478 /* Enable platform specific wakeup interrupt */
1479 static inline void mwifiex_enable_wake(struct mwifiex_adapter *adapter)
1480 {
1481 	/* Enable platform specific wakeup interrupt */
1482 	if (adapter->irq_wakeup >= 0) {
1483 		adapter->wake_by_wifi = false;
1484 		enable_irq(adapter->irq_wakeup);
1485 		enable_irq_wake(adapter->irq_wakeup);
1486 	}
1487 }
1488 
1489 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
1490 			     u32 func_init_shutdown);
1491 
1492 int mwifiex_add_card(void *card, struct completion *fw_done,
1493 		     struct mwifiex_if_ops *if_ops, u8 iface_type,
1494 		     struct device *dev);
1495 int mwifiex_remove_card(struct mwifiex_adapter *adapter);
1496 
1497 void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
1498 			 int maxlen);
1499 int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
1500 			struct mwifiex_multicast_list *mcast_list);
1501 int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
1502 			    struct net_device *dev);
1503 int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
1504 				struct cmd_ctrl_node *cmd_queued);
1505 int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
1506 		      struct cfg80211_ssid *req_ssid);
1507 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
1508 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
1509 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
1510 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
1511 int mwifiex_request_scan(struct mwifiex_private *priv,
1512 			 struct cfg80211_ssid *req_ssid);
1513 int mwifiex_scan_networks(struct mwifiex_private *priv,
1514 			  const struct mwifiex_user_scan_cfg *user_scan_in);
1515 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
1516 
1517 int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1518 		       const u8 *key, int key_len, u8 key_index,
1519 		       const u8 *mac_addr, int disable);
1520 
1521 int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
1522 
1523 int mwifiex_get_ver_ext(struct mwifiex_private *priv, u32 version_str_sel);
1524 
1525 int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1526 			       struct ieee80211_channel *chan,
1527 			       unsigned int duration);
1528 
1529 int mwifiex_get_stats_info(struct mwifiex_private *priv,
1530 			   struct mwifiex_ds_get_stats *log);
1531 
1532 int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1533 		      u32 reg_offset, u32 reg_value);
1534 
1535 int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1536 		     u32 reg_offset, u32 *value);
1537 
1538 int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1539 			u8 *value);
1540 
1541 int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1542 
1543 int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1544 
1545 int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1546 
1547 int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1548 
1549 int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
1550 
1551 int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1552 				   char *version, int max_len);
1553 
1554 int mwifiex_set_tx_power(struct mwifiex_private *priv,
1555 			 struct mwifiex_power_cfg *power_cfg);
1556 
1557 int mwifiex_main_process(struct mwifiex_adapter *);
1558 
1559 int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
1560 
1561 int mwifiex_get_bss_info(struct mwifiex_private *,
1562 			 struct mwifiex_bss_info *);
1563 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
1564 			      struct cfg80211_bss *bss,
1565 			      struct mwifiex_bssdescriptor *bss_desc);
1566 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
1567 				    struct mwifiex_bssdescriptor *bss_entry);
1568 int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
1569 					struct mwifiex_bssdescriptor *bss_desc);
1570 
1571 u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
1572 u8 mwifiex_get_chan_type(struct mwifiex_private *priv);
1573 
1574 struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
1575 					      const char *name,
1576 					      unsigned char name_assign_type,
1577 					      enum nl80211_iftype type,
1578 					      struct vif_params *params);
1579 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
1580 
1581 void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
1582 
1583 int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
1584 
1585 int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
1586 			 struct cfg80211_beacon_data *data);
1587 int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
1588 u8 *mwifiex_11d_code_2_region(u8 code);
1589 void mwifiex_uap_set_channel(struct mwifiex_private *priv,
1590 			     struct mwifiex_uap_bss_param *bss_cfg,
1591 			     struct cfg80211_chan_def chandef);
1592 int mwifiex_config_start_uap(struct mwifiex_private *priv,
1593 			     struct mwifiex_uap_bss_param *bss_cfg);
1594 void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
1595 			      struct mwifiex_sta_node *node);
1596 
1597 void mwifiex_config_uap_11d(struct mwifiex_private *priv,
1598 			    struct cfg80211_beacon_data *beacon_data);
1599 
1600 void mwifiex_init_11h_params(struct mwifiex_private *priv);
1601 int mwifiex_is_11h_active(struct mwifiex_private *priv);
1602 int mwifiex_11h_activate(struct mwifiex_private *priv, bool flag);
1603 
1604 void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
1605 			      struct mwifiex_bssdescriptor *bss_desc);
1606 int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
1607 int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1608 			    struct device_node *node, const char *prefix);
1609 void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
1610 
1611 extern const struct ethtool_ops mwifiex_ethtool_ops;
1612 
1613 void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
1614 void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1615 void
1616 mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
1617 		       int ies_len, struct mwifiex_sta_node *node);
1618 struct mwifiex_sta_node *
1619 mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1620 struct mwifiex_sta_node *
1621 mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1622 u8 mwifiex_is_tdls_chan_switching(struct mwifiex_private *priv);
1623 u8 mwifiex_is_tdls_off_chan(struct mwifiex_private *priv);
1624 u8 mwifiex_is_send_cmd_allowed(struct mwifiex_private *priv);
1625 int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
1626 				 u8 action_code, u8 dialog_token,
1627 				 u16 status_code, const u8 *extra_ies,
1628 				 size_t extra_ies_len);
1629 int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
1630 				   u8 action_code, u8 dialog_token,
1631 				   u16 status_code, const u8 *extra_ies,
1632 				   size_t extra_ies_len);
1633 void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
1634 				       u8 *buf, int len);
1635 int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
1636 int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
1637 int mwifiex_get_tdls_list(struct mwifiex_private *priv,
1638 			  struct tdls_peer_info *buf);
1639 void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
1640 bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
1641 u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
1642 				 u32 pri_chan, u8 chan_bw);
1643 int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
1644 
1645 int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb);
1646 void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv);
1647 void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1648 					  const u8 *mac, u8 link_status);
1649 void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1650 					  u8 *mac, s8 snr, s8 nflr);
1651 void mwifiex_check_auto_tdls(struct timer_list *t);
1652 void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac);
1653 void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv);
1654 void mwifiex_clean_auto_tdls(struct mwifiex_private *priv);
1655 int mwifiex_config_tdls_enable(struct mwifiex_private *priv);
1656 int mwifiex_config_tdls_disable(struct mwifiex_private *priv);
1657 int mwifiex_config_tdls_cs_params(struct mwifiex_private *priv);
1658 int mwifiex_stop_tdls_cs(struct mwifiex_private *priv, const u8 *peer_mac);
1659 int mwifiex_start_tdls_cs(struct mwifiex_private *priv, const u8 *peer_mac,
1660 			  u8 primary_chan, u8 second_chan_offset, u8 band);
1661 
1662 int mwifiex_cmd_issue_chan_report_request(struct mwifiex_private *priv,
1663 					  struct host_cmd_ds_command *cmd,
1664 					  void *data_buf);
1665 int mwifiex_11h_handle_chanrpt_ready(struct mwifiex_private *priv,
1666 				     struct sk_buff *skb);
1667 
1668 void mwifiex_parse_tx_status_event(struct mwifiex_private *priv,
1669 				   void *event_body);
1670 
1671 struct sk_buff *
1672 mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
1673 				struct sk_buff *skb, u8 flag, u64 *cookie);
1674 void mwifiex_dfs_cac_work_queue(struct work_struct *work);
1675 void mwifiex_dfs_chan_sw_work_queue(struct work_struct *work);
1676 void mwifiex_abort_cac(struct mwifiex_private *priv);
1677 int mwifiex_stop_radar_detection(struct mwifiex_private *priv,
1678 				 struct cfg80211_chan_def *chandef);
1679 int mwifiex_11h_handle_radar_detected(struct mwifiex_private *priv,
1680 				      struct sk_buff *skb);
1681 
1682 void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
1683 			   s8 nflr);
1684 void mwifiex_hist_data_reset(struct mwifiex_private *priv);
1685 void mwifiex_hist_data_add(struct mwifiex_private *priv,
1686 			   u8 rx_rate, s8 snr, s8 nflr);
1687 u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
1688 			    u8 rx_rate, u8 ht_info);
1689 
1690 void mwifiex_drv_info_dump(struct mwifiex_adapter *adapter);
1691 void mwifiex_prepare_fw_dump_info(struct mwifiex_adapter *adapter);
1692 void mwifiex_upload_device_dump(struct mwifiex_adapter *adapter);
1693 void *mwifiex_alloc_dma_align_buf(int rx_len, gfp_t flags);
1694 void mwifiex_fw_dump_event(struct mwifiex_private *priv);
1695 void mwifiex_queue_main_work(struct mwifiex_adapter *adapter);
1696 int mwifiex_get_wakeup_reason(struct mwifiex_private *priv, u16 action,
1697 			      int cmd_type,
1698 			      struct mwifiex_ds_wakeup_reason *wakeup_reason);
1699 int mwifiex_get_chan_info(struct mwifiex_private *priv,
1700 			  struct mwifiex_channel_band *channel_band);
1701 int mwifiex_ret_wakeup_reason(struct mwifiex_private *priv,
1702 			      struct host_cmd_ds_command *resp,
1703 			      struct host_cmd_ds_wakeup_reason *wakeup_reason);
1704 void mwifiex_coex_ampdu_rxwinsize(struct mwifiex_adapter *adapter);
1705 void mwifiex_11n_delba(struct mwifiex_private *priv, int tid);
1706 int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy);
1707 void mwifiex_process_tx_pause_event(struct mwifiex_private *priv,
1708 				    struct sk_buff *event);
1709 void mwifiex_process_multi_chan_event(struct mwifiex_private *priv,
1710 				      struct sk_buff *event_skb);
1711 void mwifiex_multi_chan_resync(struct mwifiex_adapter *adapter);
1712 int mwifiex_set_mac_address(struct mwifiex_private *priv,
1713 			    struct net_device *dev,
1714 			    bool external, u8 *new_mac);
1715 void mwifiex_devdump_tmo_func(unsigned long function_context);
1716 
1717 #ifdef CONFIG_DEBUG_FS
1718 void mwifiex_debugfs_init(void);
1719 void mwifiex_debugfs_remove(void);
1720 
1721 void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1722 void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1723 #endif
1724 int mwifiex_reinit_sw(struct mwifiex_adapter *adapter);
1725 int mwifiex_shutdown_sw(struct mwifiex_adapter *adapter);
1726 #endif /* !_MWIFIEX_MAIN_H_ */
1727