]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/net/wireless/mwifiex/main.h
mwifiex: do not declare wdev as pointer
[mirror_ubuntu-artful-kernel.git] / drivers / net / wireless / mwifiex / main.h
CommitLineData
5e6e3a92
BZ
1/*
2 * Marvell Wireless LAN device driver: major data structures and prototypes
3 *
65da33f5 4 * Copyright (C) 2011-2014, Marvell International Ltd.
5e6e3a92
BZ
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/kernel.h>
24#include <linux/module.h>
25#include <linux/sched.h>
26#include <linux/semaphore.h>
27#include <linux/ip.h>
28#include <linux/skbuff.h>
29#include <linux/if_arp.h>
30#include <linux/etherdevice.h>
31#include <net/sock.h>
32#include <net/lib80211.h>
92c2538f 33#include <linux/vmalloc.h>
5e6e3a92
BZ
34#include <linux/firmware.h>
35#include <linux/ctype.h>
699b027b 36#include <linux/of.h>
808bbebc 37#include <linux/idr.h>
5e6e3a92
BZ
38
39#include "decl.h"
40#include "ioctl.h"
41#include "util.h"
42#include "fw.h"
d930faee 43#include "pcie.h"
11cd07a9
XH
44#include "usb.h"
45#include "sdio.h"
5e6e3a92
BZ
46
47extern const char driver_version[];
5e6e3a92
BZ
48
49enum {
600f5d90
AK
50 MWIFIEX_ASYNC_CMD,
51 MWIFIEX_SYNC_CMD
5e6e3a92
BZ
52};
53
0013c7ce
AP
54#define MWIFIEX_DRIVER_MODE_STA BIT(0)
55#define MWIFIEX_DRIVER_MODE_UAP BIT(1)
56#define MWIFIEX_DRIVER_MODE_P2P BIT(2)
57#define MWIFIEX_DRIVER_MODE_BITMASK (BIT(0) | BIT(1) | BIT(2))
58
67a50035
BZ
59#define MWIFIEX_MAX_AP 64
60
5e6e3a92
BZ
61#define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT (5 * HZ)
62
63#define MWIFIEX_TIMER_10S 10000
64#define MWIFIEX_TIMER_1S 1000
65
62a5b7dc
MY
66#define MAX_TX_PENDING 100
67#define LOW_TX_PENDING 80
5e6e3a92 68
6e251174
AP
69#define HIGH_RX_PENDING 50
70#define LOW_RX_PENDING 20
71
5e6e3a92
BZ
72#define MWIFIEX_UPLD_SIZE (2312)
73
21f58d20 74#define MAX_EVENT_SIZE 2048
5e6e3a92
BZ
75
76#define ARP_FILTER_MAX_BUF_SIZE 68
77
78#define MWIFIEX_KEY_BUFFER_SIZE 16
79#define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
80#define MWIFIEX_MAX_REGION_CODE 7
81
82#define DEFAULT_BCN_AVG_FACTOR 8
83#define DEFAULT_DATA_AVG_FACTOR 8
84
85#define FIRST_VALID_CHANNEL 0xff
86#define DEFAULT_AD_HOC_CHANNEL 6
87#define DEFAULT_AD_HOC_CHANNEL_A 36
88
89#define DEFAULT_BCN_MISS_TIMEOUT 5
90
91#define MAX_SCAN_BEACON_BUFFER 8000
92
93#define SCAN_BEACON_ENTRY_PAD 6
94
38e8b7d9
BZ
95#define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
96#define MWIFIEX_ACTIVE_SCAN_CHAN_TIME 30
97#define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 30
cb91be87 98#define MWIFIEX_DEF_SCAN_CHAN_GAP_TIME 50
5e6e3a92
BZ
99
100#define SCAN_RSSI(RSSI) (0x100 - ((u8)(RSSI)))
101
102#define MWIFIEX_MAX_TOTAL_SCAN_TIME (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
103
104#define RSN_GTK_OUI_OFFSET 2
105
106#define MWIFIEX_OUI_NOT_PRESENT 0
107#define MWIFIEX_OUI_PRESENT 1
108
e39faa73
SP
109#define PKT_TYPE_MGMT 0xE5
110
4daffe35
AK
111/*
112 * Do not check for data_received for USB, as data_received
113 * is handled in mwifiex_usb_recv for USB
114 */
5e6e3a92 115#define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
4daffe35 116 adapter->event_received || \
ec4a16b4 117 adapter->data_received)
5e6e3a92
BZ
118
119#define MWIFIEX_TYPE_CMD 1
120#define MWIFIEX_TYPE_DATA 0
121#define MWIFIEX_TYPE_EVENT 3
122
a0b7315a 123#define MAX_BITMAP_RATES_SIZE 18
5e6e3a92
BZ
124
125#define MAX_CHANNEL_BAND_BG 14
a3c2c4f6 126#define MAX_CHANNEL_BAND_A 165
5e6e3a92
BZ
127
128#define MAX_FREQUENCY_BAND_BG 2484
129
d930faee 130#define MWIFIEX_EVENT_HEADER_LEN 4
e568634a 131#define MWIFIEX_UAP_EVENT_EXTRA_HEADER 2
d930faee 132
4daffe35
AK
133#define MWIFIEX_TYPE_LEN 4
134#define MWIFIEX_USB_TYPE_CMD 0xF00DFACE
135#define MWIFIEX_USB_TYPE_DATA 0xBEADC0DE
136#define MWIFIEX_USB_TYPE_EVENT 0xBEEFFACE
137
8908c7d5
AN
138/* Threshold for tx_timeout_cnt before we trigger a card reset */
139#define TX_TIMEOUT_THRESHOLD 6
140
11cd07a9
XH
141#define MWIFIEX_DRV_INFO_SIZE_MAX 0x40000
142
5e6e3a92
BZ
143struct mwifiex_dbg {
144 u32 num_cmd_host_to_card_failure;
145 u32 num_cmd_sleep_cfm_host_to_card_failure;
146 u32 num_tx_host_to_card_failure;
147 u32 num_event_deauth;
148 u32 num_event_disassoc;
149 u32 num_event_link_lost;
150 u32 num_cmd_deauth;
151 u32 num_cmd_assoc_success;
152 u32 num_cmd_assoc_failure;
153 u32 num_tx_timeout;
5e6e3a92
BZ
154 u16 timeout_cmd_id;
155 u16 timeout_cmd_act;
156 u16 last_cmd_id[DBG_CMD_NUM];
157 u16 last_cmd_act[DBG_CMD_NUM];
158 u16 last_cmd_index;
159 u16 last_cmd_resp_id[DBG_CMD_NUM];
160 u16 last_cmd_resp_index;
161 u16 last_event[DBG_CMD_NUM];
162 u16 last_event_index;
163};
164
165enum MWIFIEX_HARDWARE_STATUS {
166 MWIFIEX_HW_STATUS_READY,
167 MWIFIEX_HW_STATUS_INITIALIZING,
5e6e3a92
BZ
168 MWIFIEX_HW_STATUS_INIT_DONE,
169 MWIFIEX_HW_STATUS_RESET,
170 MWIFIEX_HW_STATUS_CLOSING,
171 MWIFIEX_HW_STATUS_NOT_READY
172};
173
174enum MWIFIEX_802_11_POWER_MODE {
175 MWIFIEX_802_11_POWER_MODE_CAM,
176 MWIFIEX_802_11_POWER_MODE_PSP
177};
178
179struct mwifiex_tx_param {
180 u32 next_pkt_len;
181};
182
183enum MWIFIEX_PS_STATE {
184 PS_STATE_AWAKE,
185 PS_STATE_PRE_SLEEP,
186 PS_STATE_SLEEP_CFM,
187 PS_STATE_SLEEP
188};
189
d930faee
AK
190enum mwifiex_iface_type {
191 MWIFIEX_SDIO,
192 MWIFIEX_PCIE,
4daffe35 193 MWIFIEX_USB
d930faee
AK
194};
195
5e6e3a92
BZ
196struct mwifiex_add_ba_param {
197 u32 tx_win_size;
198 u32 rx_win_size;
199 u32 timeout;
4c9f9fb2
AK
200 u8 tx_amsdu;
201 u8 rx_amsdu;
5e6e3a92
BZ
202};
203
204struct mwifiex_tx_aggr {
205 u8 ampdu_user;
206 u8 ampdu_ap;
207 u8 amsdu;
208};
209
210struct mwifiex_ra_list_tbl {
211 struct list_head list;
212 struct sk_buff_head skb_head;
213 u8 ra[ETH_ALEN];
5e6e3a92 214 u32 is_11n_enabled;
5a009adf 215 u16 max_amsdu;
f0cb84f8 216 u16 ba_pkt_count;
5a009adf 217 u8 ba_packet_thr;
c7d9ed9e 218 u16 total_pkt_count;
daeb5bb4 219 bool tdls_link;
5e6e3a92
BZ
220};
221
222struct mwifiex_tid_tbl {
223 struct list_head ra_list;
5e6e3a92
BZ
224};
225
226#define WMM_HIGHEST_PRIORITY 7
227#define HIGH_PRIO_TID 7
228#define LOW_PRIO_TID 0
229
230struct mwifiex_wmm_desc {
231 struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
232 u32 packets_out[MAX_NUM_TID];
233 /* spin lock to protect ra_list */
234 spinlock_t ra_list_spinlock;
99fec5de
JB
235 struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
236 enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
5e6e3a92 237 u32 drv_pkt_delay_max;
99fec5de 238 u8 queue_priority[IEEE80211_NUM_ACS];
5e6e3a92 239 u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1]; /* UP: 0 to 7 */
f699254c
MY
240 /* Number of transmit packets queued */
241 atomic_t tx_pkts_queued;
49729ff6
MY
242 /* Tracks highest priority with a packet queued */
243 atomic_t highest_queued_prio;
5e6e3a92
BZ
244};
245
246struct mwifiex_802_11_security {
247 u8 wpa_enabled;
248 u8 wpa2_enabled;
249 u8 wapi_enabled;
250 u8 wapi_key_on;
5eb02e44 251 u8 wep_enabled;
5e6e3a92 252 u32 authentication_mode;
a0f6d6ca 253 u8 is_authtype_auto;
5e6e3a92
BZ
254 u32 encryption_mode;
255};
256
257struct ieee_types_header {
258 u8 element_id;
259 u8 len;
260} __packed;
261
5e6e3a92
BZ
262struct ieee_types_vendor_specific {
263 struct ieee_types_vendor_header vend_hdr;
264 u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
265} __packed;
266
267struct ieee_types_generic {
268 struct ieee_types_header ieee_hdr;
269 u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
270} __packed;
271
b23bce29
AP
272struct ieee_types_bss_co_2040 {
273 struct ieee_types_header ieee_hdr;
274 u8 bss_2040co;
275} __packed;
276
277struct ieee_types_extcap {
278 struct ieee_types_header ieee_hdr;
279 u8 ext_capab[8];
280} __packed;
281
5f6d5983
AP
282struct ieee_types_vht_cap {
283 struct ieee_types_header ieee_hdr;
284 struct ieee80211_vht_cap vhtcap;
285} __packed;
286
287struct ieee_types_vht_oper {
288 struct ieee_types_header ieee_hdr;
289 struct ieee80211_vht_operation vhtoper;
290} __packed;
291
292struct ieee_types_aid {
293 struct ieee_types_header ieee_hdr;
294 u16 aid;
295} __packed;
296
5e6e3a92
BZ
297struct mwifiex_bssdescriptor {
298 u8 mac_address[ETH_ALEN];
b9be5f39 299 struct cfg80211_ssid ssid;
5e6e3a92
BZ
300 u32 privacy;
301 s32 rssi;
302 u32 channel;
303 u32 freq;
304 u16 beacon_period;
305 u8 erp_flags;
306 u32 bss_mode;
307 u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
308 u8 data_rates[MWIFIEX_SUPPORTED_RATES];
309 /* Network band.
310 * BAND_B(0x01): 'b' band
311 * BAND_G(0x02): 'g' band
312 * BAND_A(0X04): 'a' band
313 */
314 u16 bss_band;
b5abcf02
AK
315 u64 fw_tsf;
316 u64 timestamp;
5e6e3a92
BZ
317 union ieee_types_phy_param_set phy_param_set;
318 union ieee_types_ss_param_set ss_param_set;
319 u16 cap_info_bitmap;
320 struct ieee_types_wmm_parameter wmm_ie;
321 u8 disable_11n;
322 struct ieee80211_ht_cap *bcn_ht_cap;
323 u16 ht_cap_offset;
074d46d1 324 struct ieee80211_ht_operation *bcn_ht_oper;
5e6e3a92
BZ
325 u16 ht_info_offset;
326 u8 *bcn_bss_co_2040;
327 u16 bss_co_2040_offset;
328 u8 *bcn_ext_cap;
329 u16 ext_cap_offset;
a5f39056
YAP
330 struct ieee80211_vht_cap *bcn_vht_cap;
331 u16 vht_cap_offset;
332 struct ieee80211_vht_operation *bcn_vht_oper;
333 u16 vht_info_offset;
334 struct ieee_types_oper_mode_ntf *oper_mode;
335 u16 oper_mode_offset;
336 u8 disable_11ac;
5e6e3a92
BZ
337 struct ieee_types_vendor_specific *bcn_wpa_ie;
338 u16 wpa_offset;
339 struct ieee_types_generic *bcn_rsn_ie;
340 u16 rsn_offset;
341 struct ieee_types_generic *bcn_wapi_ie;
342 u16 wapi_offset;
343 u8 *beacon_buf;
344 u32 beacon_buf_size;
2a7305c8
AK
345 u8 sensed_11h;
346 u8 local_constraint;
347 u8 chan_sw_ie_present;
5e6e3a92
BZ
348};
349
350struct mwifiex_current_bss_params {
351 struct mwifiex_bssdescriptor bss_descriptor;
352 u8 wmm_enabled;
353 u8 wmm_uapsd_enabled;
354 u8 band;
355 u32 num_of_rates;
356 u8 data_rates[MWIFIEX_SUPPORTED_RATES];
357};
358
359struct mwifiex_sleep_params {
360 u16 sp_error;
361 u16 sp_offset;
362 u16 sp_stable_time;
363 u8 sp_cal_control;
364 u8 sp_ext_sleep_clk;
365 u16 sp_reserved;
366};
367
368struct mwifiex_sleep_period {
369 u16 period;
370 u16 reserved;
371};
372
373struct mwifiex_wep_key {
374 u32 length;
375 u32 key_index;
376 u32 key_length;
377 u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
378};
379
380#define MAX_REGION_CHANNEL_NUM 2
381
382struct mwifiex_chan_freq_power {
383 u16 channel;
384 u32 freq;
385 u16 max_tx_power;
386 u8 unsupported;
387};
388
389enum state_11d_t {
390 DISABLE_11D = 0,
391 ENABLE_11D = 1,
392};
393
394#define MWIFIEX_MAX_TRIPLET_802_11D 83
395
396struct mwifiex_802_11d_domain_reg {
397 u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
398 u8 no_of_triplet;
399 struct ieee80211_country_ie_triplet
400 triplet[MWIFIEX_MAX_TRIPLET_802_11D];
401};
402
403struct mwifiex_vendor_spec_cfg_ie {
404 u16 mask;
405 u16 flag;
406 u8 ie[MWIFIEX_MAX_VSIE_LEN];
407};
408
409struct wps {
410 u8 session_enable;
411};
412
7feb4c48
SP
413struct mwifiex_roc_cfg {
414 u64 cookie;
415 struct ieee80211_channel chan;
7feb4c48
SP
416};
417
92c2538f 418#define MWIFIEX_FW_DUMP_IDX 0xff
11cd07a9 419#define MWIFIEX_DRV_INFO_IDX 20
92c2538f
AK
420#define FW_DUMP_MAX_NAME_LEN 8
421#define FW_DUMP_HOST_READY 0xEE
422#define FW_DUMP_DONE 0xFF
7e174833 423#define FW_DUMP_READ_DONE 0xFE
92c2538f
AK
424
425struct memory_type_mapping {
426 u8 mem_name[FW_DUMP_MAX_NAME_LEN];
427 u8 *mem_ptr;
428 u32 mem_size;
429 u8 done_flag;
430};
431
432enum rdwr_status {
433 RDWR_STATUS_SUCCESS = 0,
434 RDWR_STATUS_FAILURE = 1,
435 RDWR_STATUS_DONE = 2
436};
437
438enum mwifiex_iface_work_flags {
439 MWIFIEX_IFACE_WORK_FW_DUMP,
8915d738 440 MWIFIEX_IFACE_WORK_CARD_RESET,
92c2538f
AK
441};
442
5e6e3a92
BZ
443struct mwifiex_adapter;
444struct mwifiex_private;
445
446struct mwifiex_private {
447 struct mwifiex_adapter *adapter;
5e6e3a92
BZ
448 u8 bss_type;
449 u8 bss_role;
450 u8 bss_priority;
451 u8 bss_num;
d6bffe8b 452 u8 bss_started;
5e6e3a92
BZ
453 u8 frame_type;
454 u8 curr_addr[ETH_ALEN];
455 u8 media_connected;
456 u32 num_tx_timeout;
8908c7d5
AN
457 /* track consecutive timeout */
458 u8 tx_timeout_cnt;
5e6e3a92
BZ
459 struct net_device *netdev;
460 struct net_device_stats stats;
461 u16 curr_pkt_filter;
462 u32 bss_mode;
463 u32 pkt_tx_ctrl;
464 u16 tx_power_level;
465 u8 max_tx_power_level;
466 u8 min_tx_power_level;
467 u8 tx_rate;
468 u8 tx_htinfo;
469 u8 rxpd_htinfo;
470 u8 rxpd_rate;
471 u16 rate_bitmap;
472 u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
473 u32 data_rate;
474 u8 is_data_rate_auto;
475 u16 bcn_avg_factor;
476 u16 data_avg_factor;
477 s16 data_rssi_last;
478 s16 data_nf_last;
479 s16 data_rssi_avg;
480 s16 data_nf_avg;
481 s16 bcn_rssi_last;
482 s16 bcn_nf_last;
483 s16 bcn_rssi_avg;
484 s16 bcn_nf_avg;
485 struct mwifiex_bssdescriptor *attempted_bss_desc;
b9be5f39 486 struct cfg80211_ssid prev_ssid;
5e6e3a92
BZ
487 u8 prev_bssid[ETH_ALEN];
488 struct mwifiex_current_bss_params curr_bss_params;
489 u16 beacon_period;
caf60a6c 490 u8 dtim_period;
5e6e3a92
BZ
491 u16 listen_interval;
492 u16 atim_window;
493 u8 adhoc_channel;
494 u8 adhoc_is_link_sensed;
495 u8 adhoc_state;
496 struct mwifiex_802_11_security sec_info;
497 struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
498 u16 wep_key_curr_index;
499 u8 wpa_ie[256];
500 u8 wpa_ie_len;
501 u8 wpa_is_gtk_set;
502 struct host_cmd_ds_802_11_key_material aes_key;
e57f1734 503 struct host_cmd_ds_802_11_key_material_v2 aes_key_v2;
5e6e3a92
BZ
504 u8 wapi_ie[256];
505 u8 wapi_ie_len;
13d7ba78
AP
506 u8 *wps_ie;
507 u8 wps_ie_len;
5e6e3a92
BZ
508 u8 wmm_required;
509 u8 wmm_enabled;
510 u8 wmm_qosinfo;
511 struct mwifiex_wmm_desc wmm;
47411a06 512 atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
017a92a1 513 struct list_head sta_list;
9927baa3 514 /* spin lock for associated station/TDLS peers list */
017a92a1 515 spinlock_t sta_list_spinlock;
9927baa3
AP
516 struct list_head auto_tdls_list;
517 /* spin lock for auto TDLS peer list */
518 spinlock_t auto_tdls_lock;
5e6e3a92
BZ
519 struct list_head tx_ba_stream_tbl_ptr;
520 /* spin lock for tx_ba_stream_tbl_ptr queue */
521 spinlock_t tx_ba_stream_tbl_lock;
522 struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
523 struct mwifiex_add_ba_param add_ba_param;
524 u16 rx_seq[MAX_NUM_TID];
41a24a29 525 u8 tos_to_tid_inv[MAX_NUM_TID];
5e6e3a92
BZ
526 struct list_head rx_reorder_tbl_ptr;
527 /* spin lock for rx_reorder_tbl_ptr queue */
528 spinlock_t rx_reorder_tbl_lock;
529 /* spin lock for Rx packets */
530 spinlock_t rx_pkt_lock;
531
532#define MWIFIEX_ASSOC_RSP_BUF_SIZE 500
533 u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
534 u32 assoc_rsp_size;
535
536#define MWIFIEX_GENIE_BUF_SIZE 256
537 u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
538 u8 gen_ie_buf_len;
539
540 struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
541
542#define MWIFIEX_ASSOC_TLV_BUF_SIZE 256
543 u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
544 u8 assoc_tlv_buf_len;
545
546 u8 *curr_bcn_buf;
547 u32 curr_bcn_size;
548 /* spin lock for beacon buffer */
549 spinlock_t curr_bcn_buf_lock;
4facc34a 550 struct wireless_dev wdev;
5e6e3a92
BZ
551 struct mwifiex_chan_freq_power cfp;
552 char version_str[128];
553#ifdef CONFIG_DEBUG_FS
554 struct dentry *dfs_dev_dir;
555#endif
5e6e3a92
BZ
556 u16 current_key_index;
557 struct semaphore async_sem;
5e6e3a92 558 struct cfg80211_scan_request *scan_request;
5e6e3a92 559 u8 cfg_bssid[6];
5e6e3a92
BZ
560 struct wps wps;
561 u8 scan_block;
fa444bf8
AK
562 s32 cqm_rssi_thold;
563 u32 cqm_rssi_hyst;
564 u8 subsc_evt_rssi_state;
908fe113 565 struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
ede98bfa 566 struct mwifiex_ie mgmt_ie[MAX_MGMT_IE_INDEX];
f31acabe
AP
567 u16 beacon_idx;
568 u16 proberesp_idx;
569 u16 assocresp_idx;
570 u16 rsn_idx;
c8258913 571 u8 ap_11n_enabled;
a5f39056 572 u8 ap_11ac_enabled;
3cec6870 573 u32 mgmt_frame_mask;
7feb4c48 574 struct mwifiex_roc_cfg roc_cfg;
75ab753d 575 bool scan_aborting;
b887664d
AK
576 u8 csa_chan;
577 unsigned long csa_expire_time;
61c87304 578 u8 del_list_idx;
587b36d3 579 bool hs2_enabled;
1f4dfd8a 580 struct station_parameters *sta_params;
56bd24a1 581 struct sk_buff_head tdls_txq;
9927baa3
AP
582 u8 check_tdls_tx;
583 struct timer_list auto_tdls_timer;
584 bool auto_tdls_timer_active;
808bbebc
AK
585 struct idr ack_status_frames;
586 /* spin lock for ack status */
587 spinlock_t ack_status_lock;
cbf6e055
XH
588 /** rx histogram data */
589 struct mwifiex_histogram_data *hist_data;
5e6e3a92
BZ
590};
591
592enum mwifiex_ba_status {
3e822635
YAP
593 BA_SETUP_NONE = 0,
594 BA_SETUP_INPROGRESS,
595 BA_SETUP_COMPLETE
5e6e3a92
BZ
596};
597
598struct mwifiex_tx_ba_stream_tbl {
599 struct list_head list;
600 int tid;
601 u8 ra[ETH_ALEN];
602 enum mwifiex_ba_status ba_status;
4c9f9fb2 603 u8 amsdu;
5e6e3a92
BZ
604};
605
606struct mwifiex_rx_reorder_tbl;
607
608struct reorder_tmr_cnxt {
609 struct timer_list timer;
610 struct mwifiex_rx_reorder_tbl *ptr;
611 struct mwifiex_private *priv;
3a8fede1 612 u8 timer_is_set;
5e6e3a92
BZ
613};
614
615struct mwifiex_rx_reorder_tbl {
616 struct list_head list;
617 int tid;
618 u8 ta[ETH_ALEN];
8acbea61 619 int init_win;
5e6e3a92
BZ
620 int start_win;
621 int win_size;
622 void **rx_reorder_ptr;
623 struct reorder_tmr_cnxt timer_context;
4c9f9fb2 624 u8 amsdu;
2db96c3d 625 u8 flags;
5e6e3a92
BZ
626};
627
628struct mwifiex_bss_prio_node {
629 struct list_head list;
630 struct mwifiex_private *priv;
631};
632
633struct mwifiex_bss_prio_tbl {
634 struct list_head bss_prio_head;
635 /* spin lock for bss priority */
636 spinlock_t bss_prio_lock;
637 struct mwifiex_bss_prio_node *bss_prio_cur;
638};
639
640struct cmd_ctrl_node {
641 struct list_head list;
642 struct mwifiex_private *priv;
643 u32 cmd_oid;
644 u32 cmd_flag;
645 struct sk_buff *cmd_skb;
646 struct sk_buff *resp_skb;
647 void *data_buf;
600f5d90 648 u32 wait_q_enabled;
5e6e3a92 649 struct sk_buff *skb;
efaaa8b8
AK
650 u8 *condition;
651 u8 cmd_wait_q_woken;
5e6e3a92
BZ
652};
653
b5abcf02
AK
654struct mwifiex_bss_priv {
655 u8 band;
656 u64 fw_tsf;
657};
658
5f2caaf3
AP
659struct mwifiex_tdls_capab {
660 __le16 capab;
661 u8 rates[32];
662 u8 rates_len;
663 u8 qos_info;
664 u8 coex_2040;
5f6d5983 665 u16 aid;
5f2caaf3
AP
666 struct ieee80211_ht_cap ht_capb;
667 struct ieee80211_ht_operation ht_oper;
668 struct ieee_types_extcap extcap;
669 struct ieee_types_generic rsn_ie;
5f6d5983
AP
670 struct ieee80211_vht_cap vhtcap;
671 struct ieee80211_vht_operation vhtoper;
5f2caaf3
AP
672};
673
674/* This is AP/TDLS specific structure which stores information
675 * about associated/peer STA
017a92a1
AP
676 */
677struct mwifiex_sta_node {
678 struct list_head list;
679 u8 mac_addr[ETH_ALEN];
680 u8 is_wmm_enabled;
681 u8 is_11n_enabled;
5f6d5983 682 u8 is_11ac_enabled;
017a92a1
AP
683 u8 ampdu_sta[MAX_NUM_TID];
684 u16 rx_seq[MAX_NUM_TID];
685 u16 max_amsdu;
429d90d2 686 u8 tdls_status;
5f2caaf3 687 struct mwifiex_tdls_capab tdls_cap;
017a92a1
AP
688};
689
9927baa3
AP
690struct mwifiex_auto_tdls_peer {
691 struct list_head list;
692 u8 mac_addr[ETH_ALEN];
693 u8 tdls_status;
694 int rssi;
695 long rssi_jiffies;
696 u8 failure_count;
697 u8 do_discover;
698 u8 do_setup;
699};
700
5e6e3a92
BZ
701struct mwifiex_if_ops {
702 int (*init_if) (struct mwifiex_adapter *);
703 void (*cleanup_if) (struct mwifiex_adapter *);
d930faee 704 int (*check_fw_status) (struct mwifiex_adapter *, u32);
5e6e3a92
BZ
705 int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
706 int (*register_dev) (struct mwifiex_adapter *);
707 void (*unregister_dev) (struct mwifiex_adapter *);
708 int (*enable_int) (struct mwifiex_adapter *);
232fde06 709 void (*disable_int) (struct mwifiex_adapter *);
5e6e3a92 710 int (*process_int_status) (struct mwifiex_adapter *);
d930faee 711 int (*host_to_card) (struct mwifiex_adapter *, u8, struct sk_buff *,
5e6e3a92
BZ
712 struct mwifiex_tx_param *);
713 int (*wakeup) (struct mwifiex_adapter *);
714 int (*wakeup_complete) (struct mwifiex_adapter *);
715
d930faee 716 /* Interface specific functions */
5e6e3a92
BZ
717 void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
718 void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
d930faee
AK
719 int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
720 int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
c6d1d87a 721 int (*init_fw_port) (struct mwifiex_adapter *);
4daffe35 722 int (*dnld_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
d31ab357 723 void (*card_reset) (struct mwifiex_adapter *);
1c09bf68 724 void (*fw_dump)(struct mwifiex_adapter *);
809c6ea8 725 int (*reg_dump)(struct mwifiex_adapter *, char *);
fbd7e7ac 726 int (*clean_pcie_ring) (struct mwifiex_adapter *adapter);
92c2538f 727 void (*iface_work)(struct work_struct *work);
cf6a64fd 728 void (*submit_rem_rx_urbs)(struct mwifiex_adapter *adapter);
5e6e3a92
BZ
729};
730
731struct mwifiex_adapter {
d930faee 732 u8 iface_type;
5e6e3a92
BZ
733 struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
734 u8 priv_num;
5e6e3a92 735 const struct firmware *firmware;
4a7f5db1 736 char fw_name[32];
d930faee 737 int winner;
5e6e3a92 738 struct device *dev;
d6bffe8b 739 struct wiphy *wiphy;
5e6e3a92
BZ
740 bool surprise_removed;
741 u32 fw_release_number;
5e6e3a92
BZ
742 u16 init_wait_q_woken;
743 wait_queue_head_t init_wait_q;
744 void *card;
745 struct mwifiex_if_ops if_ops;
746 atomic_t rx_pending;
747 atomic_t tx_pending;
600f5d90 748 atomic_t cmd_pending;
5e6e3a92
BZ
749 struct workqueue_struct *workqueue;
750 struct work_struct main_work;
6e251174
AP
751 struct workqueue_struct *rx_workqueue;
752 struct work_struct rx_work;
753 bool rx_work_enabled;
754 bool rx_processing;
755 bool delay_main_work;
756 bool rx_locked;
5e6e3a92
BZ
757 struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
758 /* spin lock for init/shutdown */
759 spinlock_t mwifiex_lock;
760 /* spin lock for main process */
761 spinlock_t main_proc_lock;
762 u32 mwifiex_processing;
5e6e3a92
BZ
763 u16 tx_buf_size;
764 u16 curr_tx_buf_size;
765 u32 ioport;
766 enum MWIFIEX_HARDWARE_STATUS hw_status;
5e6e3a92
BZ
767 u16 number_of_antenna;
768 u32 fw_cap_info;
769 /* spin lock for interrupt handling */
770 spinlock_t int_lock;
771 u8 int_status;
772 u32 event_cause;
773 struct sk_buff *event_skb;
774 u8 upld_buf[MWIFIEX_UPLD_SIZE];
775 u8 data_sent;
776 u8 cmd_sent;
777 u8 cmd_resp_received;
778 u8 event_received;
779 u8 data_received;
780 u16 seq_num;
781 struct cmd_ctrl_node *cmd_pool;
782 struct cmd_ctrl_node *curr_cmd;
783 /* spin lock for command */
784 spinlock_t mwifiex_cmd_lock;
0c9c4a09 785 u8 is_cmd_timedout;
5e6e3a92
BZ
786 u16 last_init_cmd;
787 struct timer_list cmd_timer;
788 struct list_head cmd_free_q;
789 /* spin lock for cmd_free_q */
790 spinlock_t cmd_free_q_lock;
791 struct list_head cmd_pending_q;
792 /* spin lock for cmd_pending_q */
793 spinlock_t cmd_pending_q_lock;
794 struct list_head scan_pending_q;
795 /* spin lock for scan_pending_q */
796 spinlock_t scan_pending_q_lock;
6e251174
AP
797 /* spin lock for RX processing routine */
798 spinlock_t rx_proc_lock;
5e6e3a92
BZ
799 u32 scan_processing;
800 u16 region_code;
801 struct mwifiex_802_11d_domain_reg domain_reg;
5e6e3a92
BZ
802 u16 scan_probes;
803 u32 scan_mode;
804 u16 specific_scan_time;
805 u16 active_scan_time;
806 u16 passive_scan_time;
cb91be87 807 u16 scan_chan_gap_time;
5e6e3a92
BZ
808 u8 fw_bands;
809 u8 adhoc_start_band;
810 u8 config_bands;
811 struct mwifiex_chan_scan_param_set *scan_channels;
812 u8 tx_lock_flag;
813 struct mwifiex_sleep_params sleep_params;
814 struct mwifiex_sleep_period sleep_period;
815 u16 ps_mode;
816 u32 ps_state;
817 u8 need_to_wakeup;
818 u16 multiple_dtim;
819 u16 local_listen_interval;
820 u16 null_pkt_interval;
821 struct sk_buff *sleep_cfm;
822 u16 bcn_miss_time_out;
823 u16 adhoc_awake_period;
824 u8 is_deep_sleep;
825 u8 delay_null_pkt;
826 u16 delay_to_ps;
827 u16 enhanced_ps_mode;
828 u8 pm_wakeup_card_req;
829 u16 gen_null_pkt;
830 u16 pps_uapsd_mode;
831 u32 pm_wakeup_fw_try;
4636187d 832 struct timer_list wakeup_timer;
5e6e3a92
BZ
833 u8 is_hs_configured;
834 struct mwifiex_hs_config_param hs_cfg;
835 u8 hs_activated;
836 u16 hs_activate_wait_q_woken;
837 wait_queue_head_t hs_activate_wait_q;
838 bool is_suspended;
c0dbba66 839 bool hs_enabling;
5e6e3a92
BZ
840 u8 event_body[MAX_EVENT_SIZE];
841 u32 hw_dot_11n_dev_cap;
842 u8 hw_dev_mcs_support;
a5333914 843 u8 user_dev_mcs_support;
5e6e3a92 844 u8 adhoc_11n_enabled;
21c3ba34 845 u8 sec_chan_offset;
5e6e3a92
BZ
846 struct mwifiex_dbg dbg;
847 u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
848 u32 arp_filter_size;
600f5d90 849 struct mwifiex_wait_queue cmd_wait_q;
efaaa8b8 850 u8 scan_wait_q_woken;
bbea3bc4 851 spinlock_t queue_lock; /* lock for tx queues */
67fdf39e 852 u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
ede98bfa 853 u16 max_mgmt_ie_index;
388ec385 854 const struct firmware *cal_data;
699b027b 855 struct device_node *dt_node;
a5f39056
YAP
856
857 /* 11AC */
858 u32 is_hw_11ac_capable;
859 u32 hw_dot_11ac_dev_cap;
860 u32 hw_dot_11ac_mcs_support;
861 u32 usr_dot_11ac_dev_cap_bg;
862 u32 usr_dot_11ac_dev_cap_a;
863 u32 usr_dot_11ac_mcs_support;
864
838e4f44 865 atomic_t pending_bridged_pkts;
6b41f941 866 struct semaphore *card_sem;
21f58d20 867 bool ext_scan;
8e17ea25 868 u8 fw_api_ver;
4b9fede5 869 u8 key_api_major_ver, key_api_minor_ver;
92c2538f
AK
870 struct work_struct iface_work;
871 unsigned long iface_work_flags;
872 struct memory_type_mapping *mem_type_mapping_tbl;
873 u8 num_mem_types;
874 u8 curr_mem_idx;
11cd07a9
XH
875 void *drv_info_dump;
876 u32 drv_info_size;
cb91be87 877 bool scan_chan_gap_enabled;
6e251174 878 struct sk_buff_head rx_data_q;
bf354433
AP
879 struct mwifiex_chan_stats *chan_stats;
880 u32 num_in_chan_stats;
881 int survey_idx;
9927baa3 882 bool auto_tdls;
5e6e3a92
BZ
883};
884
885int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
5e6e3a92 886
bbea3bc4
AP
887void mwifiex_set_trans_start(struct net_device *dev);
888
889void mwifiex_stop_net_dev_queue(struct net_device *netdev,
890 struct mwifiex_adapter *adapter);
891
892void mwifiex_wake_up_net_dev_queue(struct net_device *netdev,
893 struct mwifiex_adapter *adapter);
894
9197ab9e
SP
895int mwifiex_init_priv(struct mwifiex_private *priv);
896void mwifiex_free_priv(struct mwifiex_private *priv);
897
5e6e3a92
BZ
898int mwifiex_init_fw(struct mwifiex_adapter *adapter);
899
900int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
901
902int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
903
904int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
905
906int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
907
f3b369e4 908int mwifiex_recv_packet(struct mwifiex_private *priv, struct sk_buff *skb);
5e6e3a92 909
f3b369e4 910int mwifiex_process_mgmt_packet(struct mwifiex_private *priv,
2dbaf751
SP
911 struct sk_buff *skb);
912
5e6e3a92
BZ
913int mwifiex_process_event(struct mwifiex_adapter *adapter);
914
efaaa8b8
AK
915int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
916 struct cmd_ctrl_node *cmd_node);
5e6e3a92 917
fa0ecbb9
BZ
918int mwifiex_send_cmd(struct mwifiex_private *priv, u16 cmd_no,
919 u16 cmd_action, u32 cmd_oid, void *data_buf, bool sync);
5e6e3a92
BZ
920
921void mwifiex_cmd_timeout_func(unsigned long function_context);
922
5e6e3a92
BZ
923int mwifiex_get_debug_info(struct mwifiex_private *,
924 struct mwifiex_debug_info *);
925
926int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
927int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
928void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
600f5d90 929void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter);
5e6e3a92
BZ
930
931void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
932 struct cmd_ctrl_node *cmd_node);
9908b074
BZ
933void mwifiex_recycle_cmd_node(struct mwifiex_adapter *adapter,
934 struct cmd_ctrl_node *cmd_node);
5e6e3a92
BZ
935
936void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
937 struct cmd_ctrl_node *cmd_node,
938 u32 addtail);
939
940int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
941int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
942int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
943 struct sk_buff *skb);
944int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
945 struct mwifiex_tx_param *tx_param);
946int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
947int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
47411a06 948 struct sk_buff *skb, int aggr, int status);
5e6e3a92
BZ
949void mwifiex_clean_txrx(struct mwifiex_private *priv);
950u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
951void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
952void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
953 u32);
954int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
955 struct host_cmd_ds_command *cmd,
956 u16 cmd_action, uint16_t ps_bitmap,
a5ffddb7 957 struct mwifiex_ds_auto_ds *auto_ds);
5e6e3a92
BZ
958int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
959 struct host_cmd_ds_command *resp,
a5ffddb7 960 struct mwifiex_ds_pm_cfg *pm_cfg);
5e6e3a92
BZ
961void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
962void mwifiex_hs_activated_event(struct mwifiex_private *priv,
963 u8 activated);
937a5045
XH
964int mwifiex_set_hs_params(struct mwifiex_private *priv, u16 action,
965 int cmd_type, struct mwifiex_ds_hs_cfg *hs_cfg);
5e6e3a92
BZ
966int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
967 struct host_cmd_ds_command *resp);
f3b369e4 968int mwifiex_process_rx_packet(struct mwifiex_private *priv,
5e6e3a92
BZ
969 struct sk_buff *skb);
970int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
971 u16 cmd_action, u32 cmd_oid,
972 void *data_buf, void *cmd_buf);
40d07030
AP
973int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
974 u16 cmd_action, u32 cmd_oid,
975 void *data_buf, void *cmd_buf);
5e6e3a92 976int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
a5ffddb7 977 struct host_cmd_ds_command *resp);
f3b369e4 978int mwifiex_process_sta_rx_packet(struct mwifiex_private *,
5e6e3a92 979 struct sk_buff *skb);
f3b369e4 980int mwifiex_process_uap_rx_packet(struct mwifiex_private *priv,
838e4f44
AP
981 struct sk_buff *skb);
982int mwifiex_handle_uap_rx_forward(struct mwifiex_private *priv,
983 struct sk_buff *skb);
5e6e3a92 984int mwifiex_process_sta_event(struct mwifiex_private *);
3d99d987 985int mwifiex_process_uap_event(struct mwifiex_private *);
017a92a1 986void mwifiex_delete_all_station_list(struct mwifiex_private *priv);
9817fffb
AP
987void mwifiex_wmm_del_peer_ra_list(struct mwifiex_private *priv,
988 const u8 *ra_addr);
5e6e3a92 989void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
4ac8764a 990void *mwifiex_process_uap_txpd(struct mwifiex_private *, struct sk_buff *skb);
5e6e3a92 991int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
572e8f3e 992int mwifiex_cmd_802_11_scan(struct host_cmd_ds_command *cmd,
a5ffddb7 993 struct mwifiex_scan_cmd_config *scan_cfg);
5e6e3a92
BZ
994void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
995 struct cmd_ctrl_node *cmd_node);
996int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
600f5d90 997 struct host_cmd_ds_command *resp);
b9be5f39 998s32 mwifiex_ssid_cmp(struct cfg80211_ssid *ssid1, struct cfg80211_ssid *ssid2);
600f5d90 999int mwifiex_associate(struct mwifiex_private *priv,
5e6e3a92
BZ
1000 struct mwifiex_bssdescriptor *bss_desc);
1001int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
a5ffddb7
AK
1002 struct host_cmd_ds_command *cmd,
1003 struct mwifiex_bssdescriptor *bss_desc);
5e6e3a92 1004int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
600f5d90 1005 struct host_cmd_ds_command *resp);
8cc1d523 1006void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
5e6e3a92 1007u8 mwifiex_band_to_radio_type(u8 band);
600f5d90 1008int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
848819f4 1009void mwifiex_deauthenticate_all(struct mwifiex_adapter *adapter);
600f5d90 1010int mwifiex_adhoc_start(struct mwifiex_private *priv,
b9be5f39 1011 struct cfg80211_ssid *adhoc_ssid);
600f5d90 1012int mwifiex_adhoc_join(struct mwifiex_private *priv,
5e6e3a92
BZ
1013 struct mwifiex_bssdescriptor *bss_desc);
1014int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
1015 struct host_cmd_ds_command *cmd,
b9be5f39 1016 struct cfg80211_ssid *req_ssid);
5e6e3a92
BZ
1017int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
1018 struct host_cmd_ds_command *cmd,
a5ffddb7 1019 struct mwifiex_bssdescriptor *bss_desc);
5e6e3a92 1020int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
600f5d90 1021 struct host_cmd_ds_command *resp);
572e8f3e 1022int mwifiex_cmd_802_11_bg_scan_query(struct host_cmd_ds_command *cmd);
6685d109
YAP
1023struct mwifiex_chan_freq_power *mwifiex_get_cfp(struct mwifiex_private *priv,
1024 u8 band, u16 channel, u32 freq);
a5f39056
YAP
1025u32 mwifiex_index_to_data_rate(struct mwifiex_private *priv,
1026 u8 index, u8 ht_info);
1027u32 mwifiex_index_to_acs_data_rate(struct mwifiex_private *priv,
1028 u8 index, u8 ht_info);
5e6e3a92
BZ
1029u32 mwifiex_find_freq_from_band_chan(u8, u8);
1030int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
1031 u8 **buffer);
5e6e3a92
BZ
1032u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
1033 u8 *rates);
1034u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
78dfca62
AP
1035u32 mwifiex_get_rates_from_cfg80211(struct mwifiex_private *priv,
1036 u8 *rates, u8 radio_type);
5e6e3a92 1037u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
5e6e3a92
BZ
1038extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
1039void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
1040void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
1041int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
1042 struct host_cmd_ds_command *cmd);
1043int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
1044 struct host_cmd_ds_command *resp);
1045int is_command_pending(struct mwifiex_adapter *adapter);
93a1df48
YAP
1046void mwifiex_init_priv_params(struct mwifiex_private *priv,
1047 struct net_device *dev);
f752dcd5
AP
1048int mwifiex_set_secure_params(struct mwifiex_private *priv,
1049 struct mwifiex_uap_bss_param *bss_config,
1050 struct cfg80211_ap_settings *params);
22281256
AP
1051void mwifiex_set_ht_params(struct mwifiex_private *priv,
1052 struct mwifiex_uap_bss_param *bss_cfg,
1053 struct cfg80211_ap_settings *params);
83c78da9
YAP
1054void mwifiex_set_vht_params(struct mwifiex_private *priv,
1055 struct mwifiex_uap_bss_param *bss_cfg,
1056 struct cfg80211_ap_settings *params);
a3c2c4f6
AP
1057void mwifiex_set_uap_rates(struct mwifiex_uap_bss_param *bss_cfg,
1058 struct cfg80211_ap_settings *params);
83c78da9
YAP
1059void mwifiex_set_vht_width(struct mwifiex_private *priv,
1060 enum nl80211_chan_width width,
1061 bool ap_11ac_disable);
54428c57
AP
1062void
1063mwifiex_set_wmm_params(struct mwifiex_private *priv,
1064 struct mwifiex_uap_bss_param *bss_cfg,
1065 struct cfg80211_ap_settings *params);
04abc0a3 1066void mwifiex_set_ba_params(struct mwifiex_private *priv);
2b6254da 1067void mwifiex_set_11ac_ba_params(struct mwifiex_private *priv);
21f58d20
AK
1068int mwifiex_cmd_802_11_scan_ext(struct mwifiex_private *priv,
1069 struct host_cmd_ds_command *cmd,
1070 void *data_buf);
bf354433
AP
1071int mwifiex_ret_802_11_scan_ext(struct mwifiex_private *priv,
1072 struct host_cmd_ds_command *resp);
21f58d20
AK
1073int mwifiex_handle_event_ext_scan_report(struct mwifiex_private *priv,
1074 void *buf);
5e6e3a92
BZ
1075
1076/*
1077 * This function checks if the queuing is RA based or not.
1078 */
1079static inline u8
1080mwifiex_queuing_ra_based(struct mwifiex_private *priv)
1081{
1082 /*
1083 * Currently we assume if we are in Infra, then DA=RA. This might not be
1084 * true in the future
1085 */
eecd8250 1086 if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
5e6e3a92
BZ
1087 (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
1088 return false;
1089
1090 return true;
1091}
1092
1093/*
1094 * This function copies rates.
1095 */
1096static inline u32
1097mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
1098{
1099 int i;
1100
1101 for (i = 0; i < len && src[i]; i++, pos++) {
1102 if (pos >= MWIFIEX_SUPPORTED_RATES)
1103 break;
1104 dest[pos] = src[i];
1105 }
1106
1107 return pos;
1108}
1109
1110/*
1111 * This function returns the correct private structure pointer based
1112 * upon the BSS type and BSS number.
1113 */
1114static inline struct mwifiex_private *
1115mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
2be7859f 1116 u8 bss_num, u8 bss_type)
5e6e3a92
BZ
1117{
1118 int i;
1119
1120 for (i = 0; i < adapter->priv_num; i++) {
1121 if (adapter->priv[i]) {
f57c1edc
YAP
1122 if ((adapter->priv[i]->bss_num == bss_num) &&
1123 (adapter->priv[i]->bss_type == bss_type))
5e6e3a92
BZ
1124 break;
1125 }
1126 }
1127 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1128}
1129
1130/*
1131 * This function returns the first available private structure pointer
1132 * based upon the BSS role.
1133 */
1134static inline struct mwifiex_private *
1135mwifiex_get_priv(struct mwifiex_adapter *adapter,
1136 enum mwifiex_bss_role bss_role)
1137{
1138 int i;
1139
1140 for (i = 0; i < adapter->priv_num; i++) {
1141 if (adapter->priv[i]) {
1142 if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
1143 GET_BSS_ROLE(adapter->priv[i]) == bss_role)
1144 break;
1145 }
1146 }
1147
1148 return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
1149}
1150
1151/*
1152 * This function returns the driver private structure of a network device.
1153 */
1154static inline struct mwifiex_private *
1155mwifiex_netdev_get_priv(struct net_device *dev)
1156{
1157 return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
1158}
1159
e39faa73
SP
1160/*
1161 * This function checks if a skb holds a management frame.
1162 */
1163static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
1164{
cfcd926e 1165 return (le32_to_cpu(*(__le32 *)skb->data) == PKT_TYPE_MGMT);
e39faa73
SP
1166}
1167
b887664d
AK
1168/* This function retrieves channel closed for operation by Channel
1169 * Switch Announcement.
1170 */
1171static inline u8
1172mwifiex_11h_get_csa_closed_channel(struct mwifiex_private *priv)
1173{
1174 if (!priv->csa_chan)
1175 return 0;
1176
1177 /* Clear csa channel, if DFS channel move time has passed */
55fdb858 1178 if (time_after(jiffies, priv->csa_expire_time)) {
b887664d
AK
1179 priv->csa_chan = 0;
1180 priv->csa_expire_time = 0;
1181 }
1182
1183 return priv->csa_chan;
1184}
1185
cb91be87
AP
1186static inline u8 mwifiex_is_any_intf_active(struct mwifiex_private *priv)
1187{
1188 struct mwifiex_private *priv_num;
1189 int i;
1190
1191 for (i = 0; i < priv->adapter->priv_num; i++) {
1192 priv_num = priv->adapter->priv[i];
1193 if (priv_num) {
1194 if ((GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_UAP &&
1195 priv_num->bss_started) ||
1196 (GET_BSS_ROLE(priv_num) == MWIFIEX_BSS_ROLE_STA &&
1197 priv_num->media_connected))
1198 return 1;
1199 }
1200 }
1201
1202 return 0;
1203}
1204
600f5d90
AK
1205int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
1206 u32 func_init_shutdown);
d930faee 1207int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
5e6e3a92
BZ
1208int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
1209
1210void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
1211 int maxlen);
600f5d90
AK
1212int mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
1213 struct mwifiex_multicast_list *mcast_list);
1214int mwifiex_copy_mcast_addr(struct mwifiex_multicast_list *mlist,
1215 struct net_device *dev);
00d7ea11
AK
1216int mwifiex_wait_queue_complete(struct mwifiex_adapter *adapter,
1217 struct cmd_ctrl_node *cmd_queued);
7c6fa2a8 1218int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
b9be5f39 1219 struct cfg80211_ssid *req_ssid);
600f5d90 1220int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
5e6e3a92 1221int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
a0490936 1222int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
006606c0 1223int mwifiex_drv_get_data_rate(struct mwifiex_private *priv, u32 *rate);
5e6e3a92 1224int mwifiex_request_scan(struct mwifiex_private *priv,
b9be5f39 1225 struct cfg80211_ssid *req_ssid);
1a1fb970
AK
1226int mwifiex_scan_networks(struct mwifiex_private *priv,
1227 const struct mwifiex_user_scan_cfg *user_scan_in);
5e6e3a92
BZ
1228int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
1229
53b11231
YL
1230int mwifiex_set_encode(struct mwifiex_private *priv, struct key_params *kp,
1231 const u8 *key, int key_len, u8 key_index,
1232 const u8 *mac_addr, int disable);
5e6e3a92 1233
4b5800fe 1234int mwifiex_set_gen_ie(struct mwifiex_private *priv, const u8 *ie, int ie_len);
5e6e3a92
BZ
1235
1236int mwifiex_get_ver_ext(struct mwifiex_private *priv);
1237
7feb4c48
SP
1238int mwifiex_remain_on_chan_cfg(struct mwifiex_private *priv, u16 action,
1239 struct ieee80211_channel *chan,
7feb4c48
SP
1240 unsigned int duration);
1241
9197ab9e
SP
1242int mwifiex_set_bss_role(struct mwifiex_private *priv, u8 bss_role);
1243
5e6e3a92
BZ
1244int mwifiex_get_stats_info(struct mwifiex_private *priv,
1245 struct mwifiex_ds_get_stats *log);
1246
1247int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1248 u32 reg_offset, u32 reg_value);
1249
1250int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1251 u32 reg_offset, u32 *value);
1252
1253int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1254 u8 *value);
1255
1256int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1257
1258int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1259
1260int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1261
1262int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1263
600f5d90 1264int mwifiex_drv_set_power(struct mwifiex_private *priv, u32 *ps_mode);
5e6e3a92
BZ
1265
1266int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1267 char *version, int max_len);
1268
600f5d90
AK
1269int mwifiex_set_tx_power(struct mwifiex_private *priv,
1270 struct mwifiex_power_cfg *power_cfg);
5e6e3a92
BZ
1271
1272int mwifiex_main_process(struct mwifiex_adapter *);
1273
e39faa73
SP
1274int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
1275
5e6e3a92
BZ
1276int mwifiex_get_bss_info(struct mwifiex_private *,
1277 struct mwifiex_bss_info *);
7c6fa2a8 1278int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
9558a407 1279 struct cfg80211_bss *bss,
7c6fa2a8
AK
1280 struct mwifiex_bssdescriptor *bss_desc);
1281int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
9558a407 1282 struct mwifiex_bssdescriptor *bss_entry);
7c6fa2a8
AK
1283int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
1284 struct mwifiex_bssdescriptor *bss_desc);
5e6e3a92 1285
7feb4c48
SP
1286u8 mwifiex_chan_type_to_sec_chan_offset(enum nl80211_channel_type chan_type);
1287
84efbb84 1288struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
552bff0c 1289 const char *name,
84efbb84
JB
1290 enum nl80211_iftype type,
1291 u32 *flags,
1292 struct vif_params *params);
1293int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev);
93a1df48 1294
9b930eae
AP
1295void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config);
1296
7da060c1
AK
1297int mwifiex_add_wowlan_magic_pkt_filter(struct mwifiex_adapter *adapter);
1298
f31acabe 1299int mwifiex_set_mgmt_ies(struct mwifiex_private *priv,
adb6ed0c 1300 struct cfg80211_beacon_data *data);
40bbc21a 1301int mwifiex_del_mgmt_ies(struct mwifiex_private *priv);
9e04a7c6 1302u8 *mwifiex_11d_code_2_region(u8 code);
0f9e9b8b
AP
1303void mwifiex_uap_del_sta_data(struct mwifiex_private *priv,
1304 struct mwifiex_sta_node *node);
93a1df48 1305
2a7305c8
AK
1306void mwifiex_11h_process_join(struct mwifiex_private *priv, u8 **buffer,
1307 struct mwifiex_bssdescriptor *bss_desc);
1308int mwifiex_11h_handle_event_chanswann(struct mwifiex_private *priv);
82efa16a
BZ
1309int mwifiex_dnld_dt_cfgdata(struct mwifiex_private *priv,
1310 struct device_node *node, const char *prefix);
b58df446 1311void mwifiex_dnld_txpwr_table(struct mwifiex_private *priv);
2a7305c8 1312
0d7f53e3
AK
1313extern const struct ethtool_ops mwifiex_ethtool_ops;
1314
4bcf93d3 1315void mwifiex_del_all_sta_list(struct mwifiex_private *priv);
3b3a0162 1316void mwifiex_del_sta_entry(struct mwifiex_private *priv, const u8 *mac);
4bcf93d3
AP
1317void
1318mwifiex_set_sta_ht_cap(struct mwifiex_private *priv, const u8 *ies,
1319 int ies_len, struct mwifiex_sta_node *node);
1320struct mwifiex_sta_node *
3b3a0162 1321mwifiex_add_sta_entry(struct mwifiex_private *priv, const u8 *mac);
4bcf93d3 1322struct mwifiex_sta_node *
3b3a0162
JB
1323mwifiex_get_sta_entry(struct mwifiex_private *priv, const u8 *mac);
1324int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer,
b23bce29
AP
1325 u8 action_code, u8 dialog_token,
1326 u16 status_code, const u8 *extra_ies,
1327 size_t extra_ies_len);
3b3a0162
JB
1328int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
1329 u8 action_code, u8 dialog_token,
1330 u16 status_code, const u8 *extra_ies,
1331 size_t extra_ies_len);
5f2caaf3
AP
1332void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
1333 u8 *buf, int len);
3b3a0162
JB
1334int mwifiex_tdls_oper(struct mwifiex_private *priv, const u8 *peer, u8 action);
1335int mwifiex_get_tdls_link_status(struct mwifiex_private *priv, const u8 *mac);
72df6310
XH
1336int mwifiex_get_tdls_list(struct mwifiex_private *priv,
1337 struct tdls_peer_info *buf);
be104b91 1338void mwifiex_disable_all_tdls_links(struct mwifiex_private *priv);
5f6d5983
AP
1339bool mwifiex_is_bss_in_11ac_mode(struct mwifiex_private *priv);
1340u8 mwifiex_get_center_freq_index(struct mwifiex_private *priv, u8 band,
1341 u32 pri_chan, u8 chan_bw);
cb91be87 1342int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter);
4bcf93d3 1343
9927baa3
AP
1344int mwifiex_tdls_check_tx(struct mwifiex_private *priv, struct sk_buff *skb);
1345void mwifiex_flush_auto_tdls_list(struct mwifiex_private *priv);
1346void mwifiex_auto_tdls_update_peer_status(struct mwifiex_private *priv,
1347 const u8 *mac, u8 link_status);
1348void mwifiex_auto_tdls_update_peer_signal(struct mwifiex_private *priv,
1349 u8 *mac, s8 snr, s8 nflr);
1350void mwifiex_check_auto_tdls(unsigned long context);
1351void mwifiex_add_auto_tdls_peer(struct mwifiex_private *priv, const u8 *mac);
1352void mwifiex_setup_auto_tdls_timer(struct mwifiex_private *priv);
1353void mwifiex_clean_auto_tdls(struct mwifiex_private *priv);
1354
808bbebc
AK
1355void mwifiex_parse_tx_status_event(struct mwifiex_private *priv,
1356 void *event_body);
1357
18ca4382
AK
1358struct sk_buff *
1359mwifiex_clone_skb_for_tx_status(struct mwifiex_private *priv,
1360 struct sk_buff *skb, u8 flag, u64 *cookie);
1361
cbf6e055
XH
1362void mwifiex_hist_data_set(struct mwifiex_private *priv, u8 rx_rate, s8 snr,
1363 s8 nflr);
1364void mwifiex_hist_data_reset(struct mwifiex_private *priv);
1365void mwifiex_hist_data_add(struct mwifiex_private *priv,
1366 u8 rx_rate, s8 snr, s8 nflr);
1367u8 mwifiex_adjust_data_rate(struct mwifiex_private *priv,
1368 u8 rx_rate, u8 ht_info);
1369
11cd07a9
XH
1370void mwifiex_dump_drv_info(struct mwifiex_adapter *adapter);
1371
5e6e3a92
BZ
1372#ifdef CONFIG_DEBUG_FS
1373void mwifiex_debugfs_init(void);
1374void mwifiex_debugfs_remove(void);
1375
1376void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1377void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1378#endif
1379#endif /* !_MWIFIEX_MAIN_H_ */