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