Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[pandora-kernel.git] / drivers / net / wireless / mwifiex / main.h
1 /*
2  * Marvell Wireless LAN device driver: major data structures and prototypes
3  *
4  * Copyright (C) 2011, 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/firmware.h>
34 #include <linux/ctype.h>
35
36 #include "decl.h"
37 #include "ioctl.h"
38 #include "util.h"
39 #include "fw.h"
40
41 extern const char driver_version[];
42 extern struct mwifiex_adapter *g_adapter;
43
44 enum {
45         MWIFIEX_NO_WAIT,
46         MWIFIEX_IOCTL_WAIT,
47         MWIFIEX_CMD_WAIT,
48         MWIFIEX_PROC_WAIT,
49         MWIFIEX_WSTATS_WAIT
50 };
51
52 #define DRV_MODE_STA       0x1
53
54 #define SD8787_W0   0x30
55 #define SD8787_W1   0x31
56 #define SD8787_A0   0x40
57 #define SD8787_A1   0x41
58
59 #define DEFAULT_FW_NAME "mrvl/sd8787_uapsta.bin"
60 #define SD8787_W1_FW_NAME "mrvl/sd8787_uapsta_w1.bin"
61 #define SD8787_AX_FW_NAME "mrvl/sd8787_uapsta.bin"
62
63 struct mwifiex_drv_mode {
64         u16 drv_mode;
65         u16 intf_num;
66         struct mwifiex_bss_attr *bss_attr;
67 };
68
69
70 #define MWIFIEX_DEFAULT_WATCHDOG_TIMEOUT        (5 * HZ)
71
72 #define MWIFIEX_TIMER_10S                       10000
73 #define MWIFIEX_TIMER_1S                        1000
74
75 #define MAX_TX_PENDING      60
76
77 #define MWIFIEX_UPLD_SIZE               (2312)
78
79 #define MAX_EVENT_SIZE                  1024
80
81 #define ARP_FILTER_MAX_BUF_SIZE         68
82
83 #define MWIFIEX_KEY_BUFFER_SIZE                 16
84 #define MWIFIEX_DEFAULT_LISTEN_INTERVAL 10
85 #define MWIFIEX_MAX_REGION_CODE         7
86
87 #define DEFAULT_BCN_AVG_FACTOR          8
88 #define DEFAULT_DATA_AVG_FACTOR         8
89
90 #define FIRST_VALID_CHANNEL                             0xff
91 #define DEFAULT_AD_HOC_CHANNEL                  6
92 #define DEFAULT_AD_HOC_CHANNEL_A                36
93
94 #define DEFAULT_BCN_MISS_TIMEOUT                5
95
96 #define MAX_SCAN_BEACON_BUFFER                  8000
97
98 #define SCAN_BEACON_ENTRY_PAD                   6
99
100 #define MWIFIEX_PASSIVE_SCAN_CHAN_TIME  200
101 #define MWIFIEX_ACTIVE_SCAN_CHAN_TIME   200
102 #define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME 110
103
104 #define SCAN_RSSI(RSSI)                                 (0x100 - ((u8)(RSSI)))
105
106 #define MWIFIEX_MAX_TOTAL_SCAN_TIME     (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
107
108 #define RSN_GTK_OUI_OFFSET                              2
109
110 #define MWIFIEX_OUI_NOT_PRESENT                 0
111 #define MWIFIEX_OUI_PRESENT                             1
112
113 #define IS_CARD_RX_RCVD(adapter) (adapter->cmd_resp_received || \
114                                         adapter->event_received || \
115                                         adapter->data_received)
116
117 #define MWIFIEX_TYPE_CMD                                1
118 #define MWIFIEX_TYPE_DATA                               0
119 #define MWIFIEX_TYPE_EVENT                              3
120
121 #define DBG_CMD_NUM                                             5
122
123 #define MAX_BITMAP_RATES_SIZE                   10
124
125 #define MAX_CHANNEL_BAND_BG     14
126
127 #define MAX_FREQUENCY_BAND_BG   2484
128
129 struct mwifiex_dbg {
130         u32 num_cmd_host_to_card_failure;
131         u32 num_cmd_sleep_cfm_host_to_card_failure;
132         u32 num_tx_host_to_card_failure;
133         u32 num_event_deauth;
134         u32 num_event_disassoc;
135         u32 num_event_link_lost;
136         u32 num_cmd_deauth;
137         u32 num_cmd_assoc_success;
138         u32 num_cmd_assoc_failure;
139         u32 num_tx_timeout;
140         u32 num_cmd_timeout;
141         u16 timeout_cmd_id;
142         u16 timeout_cmd_act;
143         u16 last_cmd_id[DBG_CMD_NUM];
144         u16 last_cmd_act[DBG_CMD_NUM];
145         u16 last_cmd_index;
146         u16 last_cmd_resp_id[DBG_CMD_NUM];
147         u16 last_cmd_resp_index;
148         u16 last_event[DBG_CMD_NUM];
149         u16 last_event_index;
150 };
151
152 enum MWIFIEX_HARDWARE_STATUS {
153         MWIFIEX_HW_STATUS_READY,
154         MWIFIEX_HW_STATUS_INITIALIZING,
155         MWIFIEX_HW_STATUS_FW_READY,
156         MWIFIEX_HW_STATUS_INIT_DONE,
157         MWIFIEX_HW_STATUS_RESET,
158         MWIFIEX_HW_STATUS_CLOSING,
159         MWIFIEX_HW_STATUS_NOT_READY
160 };
161
162 enum MWIFIEX_802_11_POWER_MODE {
163         MWIFIEX_802_11_POWER_MODE_CAM,
164         MWIFIEX_802_11_POWER_MODE_PSP
165 };
166
167 struct mwifiex_tx_param {
168         u32 next_pkt_len;
169 };
170
171 enum MWIFIEX_PS_STATE {
172         PS_STATE_AWAKE,
173         PS_STATE_PRE_SLEEP,
174         PS_STATE_SLEEP_CFM,
175         PS_STATE_SLEEP
176 };
177
178 struct mwifiex_add_ba_param {
179         u32 tx_win_size;
180         u32 rx_win_size;
181         u32 timeout;
182 };
183
184 struct mwifiex_tx_aggr {
185         u8 ampdu_user;
186         u8 ampdu_ap;
187         u8 amsdu;
188 };
189
190 struct mwifiex_ra_list_tbl {
191         struct list_head list;
192         struct sk_buff_head skb_head;
193         u8 ra[ETH_ALEN];
194         u32 total_pkts_size;
195         u32 is_11n_enabled;
196 };
197
198 struct mwifiex_tid_tbl {
199         struct list_head ra_list;
200         /* spin lock for tid table */
201         spinlock_t tid_tbl_lock;
202         struct mwifiex_ra_list_tbl *ra_list_curr;
203 };
204
205 #define WMM_HIGHEST_PRIORITY            7
206 #define HIGH_PRIO_TID                           7
207 #define LOW_PRIO_TID                            0
208
209 struct mwifiex_wmm_desc {
210         struct mwifiex_tid_tbl tid_tbl_ptr[MAX_NUM_TID];
211         u32 packets_out[MAX_NUM_TID];
212         /* spin lock to protect ra_list */
213         spinlock_t ra_list_spinlock;
214         struct mwifiex_wmm_ac_status ac_status[IEEE80211_MAX_QUEUES];
215         enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_MAX_QUEUES];
216         u32 drv_pkt_delay_max;
217         u8 queue_priority[IEEE80211_MAX_QUEUES];
218         u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1];     /* UP: 0 to 7 */
219
220 };
221
222 struct mwifiex_802_11_security {
223         u8 wpa_enabled;
224         u8 wpa2_enabled;
225         u8 wapi_enabled;
226         u8 wapi_key_on;
227         enum MWIFIEX_802_11_WEP_STATUS wep_status;
228         u32 authentication_mode;
229         u32 encryption_mode;
230 };
231
232 struct ieee_types_header {
233         u8 element_id;
234         u8 len;
235 } __packed;
236
237 struct ieee_obss_scan_param {
238         u16 obss_scan_passive_dwell;
239         u16 obss_scan_active_dwell;
240         u16 bss_chan_width_trigger_scan_int;
241         u16 obss_scan_passive_total;
242         u16 obss_scan_active_total;
243         u16 bss_width_chan_trans_delay;
244         u16 obss_scan_active_threshold;
245 } __packed;
246
247 struct ieee_types_obss_scan_param {
248         struct ieee_types_header ieee_hdr;
249         struct ieee_obss_scan_param obss_scan;
250 } __packed;
251
252 #define MWIFIEX_SUPPORTED_RATES                 14
253
254 #define MWIFIEX_SUPPORTED_RATES_EXT             32
255
256 #define IEEE_MAX_IE_SIZE                        256
257
258 struct ieee_types_vendor_specific {
259         struct ieee_types_vendor_header vend_hdr;
260         u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_vendor_header)];
261 } __packed;
262
263 struct ieee_types_generic {
264         struct ieee_types_header ieee_hdr;
265         u8 data[IEEE_MAX_IE_SIZE - sizeof(struct ieee_types_header)];
266 } __packed;
267
268 struct mwifiex_bssdescriptor {
269         u8 mac_address[ETH_ALEN];
270         struct mwifiex_802_11_ssid ssid;
271         u32 privacy;
272         s32 rssi;
273         u32 channel;
274         u32 freq;
275         u16 beacon_period;
276         u8 erp_flags;
277         u32 bss_mode;
278         u8 supported_rates[MWIFIEX_SUPPORTED_RATES];
279         u8 data_rates[MWIFIEX_SUPPORTED_RATES];
280         /* Network band.
281          * BAND_B(0x01): 'b' band
282          * BAND_G(0x02): 'g' band
283          * BAND_A(0X04): 'a' band
284          */
285         u16 bss_band;
286         long long network_tsf;
287         u8 time_stamp[8];
288         union ieee_types_phy_param_set phy_param_set;
289         union ieee_types_ss_param_set ss_param_set;
290         u16 cap_info_bitmap;
291         struct ieee_types_wmm_parameter wmm_ie;
292         u8  disable_11n;
293         struct ieee80211_ht_cap *bcn_ht_cap;
294         u16 ht_cap_offset;
295         struct ieee80211_ht_info *bcn_ht_info;
296         u16 ht_info_offset;
297         u8 *bcn_bss_co_2040;
298         u16 bss_co_2040_offset;
299         u8 *bcn_ext_cap;
300         u16 ext_cap_offset;
301         struct ieee_types_obss_scan_param *bcn_obss_scan;
302         u16 overlap_bss_offset;
303         struct ieee_types_vendor_specific *bcn_wpa_ie;
304         u16 wpa_offset;
305         struct ieee_types_generic *bcn_rsn_ie;
306         u16 rsn_offset;
307         struct ieee_types_generic *bcn_wapi_ie;
308         u16 wapi_offset;
309         u8 *beacon_buf;
310         u32 beacon_buf_size;
311         u32 beacon_buf_size_max;
312
313 };
314
315 struct mwifiex_current_bss_params {
316         struct mwifiex_bssdescriptor bss_descriptor;
317         u8 wmm_enabled;
318         u8 wmm_uapsd_enabled;
319         u8 band;
320         u32 num_of_rates;
321         u8 data_rates[MWIFIEX_SUPPORTED_RATES];
322 };
323
324 struct mwifiex_sleep_params {
325         u16 sp_error;
326         u16 sp_offset;
327         u16 sp_stable_time;
328         u8 sp_cal_control;
329         u8 sp_ext_sleep_clk;
330         u16 sp_reserved;
331 };
332
333 struct mwifiex_sleep_period {
334         u16 period;
335         u16 reserved;
336 };
337
338 struct mwifiex_wep_key {
339         u32 length;
340         u32 key_index;
341         u32 key_length;
342         u8 key_material[MWIFIEX_KEY_BUFFER_SIZE];
343 };
344
345 #define MAX_REGION_CHANNEL_NUM  2
346
347 struct mwifiex_chan_freq_power {
348         u16 channel;
349         u32 freq;
350         u16 max_tx_power;
351         u8 unsupported;
352 };
353
354 enum state_11d_t {
355         DISABLE_11D = 0,
356         ENABLE_11D = 1,
357 };
358
359 #define MWIFIEX_MAX_TRIPLET_802_11D             83
360
361 struct mwifiex_802_11d_domain_reg {
362         u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
363         u8 no_of_triplet;
364         struct ieee80211_country_ie_triplet
365                 triplet[MWIFIEX_MAX_TRIPLET_802_11D];
366 };
367
368 struct mwifiex_vendor_spec_cfg_ie {
369         u16 mask;
370         u16 flag;
371         u8 ie[MWIFIEX_MAX_VSIE_LEN];
372 };
373
374 struct wps {
375         u8 session_enable;
376 };
377
378 struct mwifiex_adapter;
379 struct mwifiex_private;
380
381 struct mwifiex_private {
382         struct mwifiex_adapter *adapter;
383         u8 bss_index;
384         u8 bss_type;
385         u8 bss_role;
386         u8 bss_priority;
387         u8 bss_num;
388         u8 frame_type;
389         u8 curr_addr[ETH_ALEN];
390         u8 media_connected;
391         u32 num_tx_timeout;
392         struct net_device *netdev;
393         struct net_device_stats stats;
394         u16 curr_pkt_filter;
395         u32 bss_mode;
396         u32 pkt_tx_ctrl;
397         u16 tx_power_level;
398         u8 max_tx_power_level;
399         u8 min_tx_power_level;
400         u8 tx_rate;
401         u8 tx_htinfo;
402         u8 rxpd_htinfo;
403         u8 rxpd_rate;
404         u16 rate_bitmap;
405         u16 bitmap_rates[MAX_BITMAP_RATES_SIZE];
406         u32 data_rate;
407         u8 is_data_rate_auto;
408         u16 bcn_avg_factor;
409         u16 data_avg_factor;
410         s16 data_rssi_last;
411         s16 data_nf_last;
412         s16 data_rssi_avg;
413         s16 data_nf_avg;
414         s16 bcn_rssi_last;
415         s16 bcn_nf_last;
416         s16 bcn_rssi_avg;
417         s16 bcn_nf_avg;
418         struct mwifiex_bssdescriptor *attempted_bss_desc;
419         struct mwifiex_802_11_ssid prev_ssid;
420         u8 prev_bssid[ETH_ALEN];
421         struct mwifiex_current_bss_params curr_bss_params;
422         u16 beacon_period;
423         u16 listen_interval;
424         u16 atim_window;
425         u8 adhoc_channel;
426         u8 adhoc_is_link_sensed;
427         u8 adhoc_state;
428         struct mwifiex_802_11_security sec_info;
429         struct mwifiex_wep_key wep_key[NUM_WEP_KEYS];
430         u16 wep_key_curr_index;
431         u8 wpa_ie[256];
432         u8 wpa_ie_len;
433         u8 wpa_is_gtk_set;
434         struct host_cmd_ds_802_11_key_material aes_key;
435         u8 wapi_ie[256];
436         u8 wapi_ie_len;
437         u8 wmm_required;
438         u8 wmm_enabled;
439         u8 wmm_qosinfo;
440         struct mwifiex_wmm_desc wmm;
441         struct list_head tx_ba_stream_tbl_ptr;
442         /* spin lock for tx_ba_stream_tbl_ptr queue */
443         spinlock_t tx_ba_stream_tbl_lock;
444         struct mwifiex_tx_aggr aggr_prio_tbl[MAX_NUM_TID];
445         struct mwifiex_add_ba_param add_ba_param;
446         u16 rx_seq[MAX_NUM_TID];
447         struct list_head rx_reorder_tbl_ptr;
448         /* spin lock for rx_reorder_tbl_ptr queue */
449         spinlock_t rx_reorder_tbl_lock;
450         /* spin lock for Rx packets */
451         spinlock_t rx_pkt_lock;
452
453 #define MWIFIEX_ASSOC_RSP_BUF_SIZE  500
454         u8 assoc_rsp_buf[MWIFIEX_ASSOC_RSP_BUF_SIZE];
455         u32 assoc_rsp_size;
456
457 #define MWIFIEX_GENIE_BUF_SIZE      256
458         u8 gen_ie_buf[MWIFIEX_GENIE_BUF_SIZE];
459         u8 gen_ie_buf_len;
460
461         struct mwifiex_vendor_spec_cfg_ie vs_ie[MWIFIEX_MAX_VSIE_NUM];
462
463 #define MWIFIEX_ASSOC_TLV_BUF_SIZE  256
464         u8 assoc_tlv_buf[MWIFIEX_ASSOC_TLV_BUF_SIZE];
465         u8 assoc_tlv_buf_len;
466
467         u8 *curr_bcn_buf;
468         u32 curr_bcn_size;
469         /* spin lock for beacon buffer */
470         spinlock_t curr_bcn_buf_lock;
471         u16 ioctl_wait_q_woken;
472         wait_queue_head_t ioctl_wait_q;
473         u16 cmd_wait_q_woken;
474         wait_queue_head_t cmd_wait_q;
475         struct wireless_dev *wdev;
476         struct mwifiex_chan_freq_power cfp;
477         char version_str[128];
478 #ifdef CONFIG_DEBUG_FS
479         struct dentry *dfs_dev_dir;
480 #endif
481         u8 nick_name[16];
482         struct iw_statistics w_stats;
483         u16 w_stats_wait_q_woken;
484         wait_queue_head_t w_stats_wait_q;
485         u16 current_key_index;
486         struct semaphore async_sem;
487         u8 scan_pending_on_block;
488         u8 report_scan_result;
489         struct cfg80211_scan_request *scan_request;
490         int scan_result_status;
491         bool assoc_request;
492         u16 assoc_result;
493         bool ibss_join_request;
494         u16 ibss_join_result;
495         bool disconnect;
496         u8 cfg_bssid[6];
497         struct workqueue_struct *workqueue;
498         struct work_struct cfg_workqueue;
499         u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
500         struct wps wps;
501         u8 scan_block;
502 };
503
504 enum mwifiex_ba_status {
505         BA_STREAM_NOT_SETUP = 0,
506         BA_STREAM_SETUP_INPROGRESS,
507         BA_STREAM_SETUP_COMPLETE
508 };
509
510 struct mwifiex_tx_ba_stream_tbl {
511         struct list_head list;
512         int tid;
513         u8 ra[ETH_ALEN];
514         enum mwifiex_ba_status ba_status;
515 };
516
517 struct mwifiex_rx_reorder_tbl;
518
519 struct reorder_tmr_cnxt {
520         struct timer_list timer;
521         struct mwifiex_rx_reorder_tbl *ptr;
522         struct mwifiex_private *priv;
523 };
524
525 struct mwifiex_rx_reorder_tbl {
526         struct list_head list;
527         int tid;
528         u8 ta[ETH_ALEN];
529         int start_win;
530         int win_size;
531         void **rx_reorder_ptr;
532         struct reorder_tmr_cnxt timer_context;
533 };
534
535 struct mwifiex_bss_prio_node {
536         struct list_head list;
537         struct mwifiex_private *priv;
538 };
539
540 struct mwifiex_bss_prio_tbl {
541         struct list_head bss_prio_head;
542         /* spin lock for bss priority  */
543         spinlock_t bss_prio_lock;
544         struct mwifiex_bss_prio_node *bss_prio_cur;
545 };
546
547 struct cmd_ctrl_node {
548         struct list_head list;
549         struct mwifiex_private *priv;
550         u32 cmd_oid;
551         u32 cmd_flag;
552         struct sk_buff *cmd_skb;
553         struct sk_buff *resp_skb;
554         void *data_buf;
555         void *wq_buf;
556         struct sk_buff *skb;
557 };
558
559 struct mwifiex_if_ops {
560         int (*init_if) (struct mwifiex_adapter *);
561         void (*cleanup_if) (struct mwifiex_adapter *);
562         int (*check_fw_status) (struct mwifiex_adapter *, u32, int *);
563         int (*prog_fw) (struct mwifiex_adapter *, struct mwifiex_fw_image *);
564         int (*register_dev) (struct mwifiex_adapter *);
565         void (*unregister_dev) (struct mwifiex_adapter *);
566         int (*enable_int) (struct mwifiex_adapter *);
567         int (*process_int_status) (struct mwifiex_adapter *);
568         int (*host_to_card) (struct mwifiex_adapter *, u8,
569                              u8 *payload, u32 pkt_len,
570                              struct mwifiex_tx_param *);
571         int (*wakeup) (struct mwifiex_adapter *);
572         int (*wakeup_complete) (struct mwifiex_adapter *);
573
574         void (*update_mp_end_port) (struct mwifiex_adapter *, u16);
575         void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
576 };
577
578 struct mwifiex_adapter {
579         struct mwifiex_private *priv[MWIFIEX_MAX_BSS_NUM];
580         u8 priv_num;
581         struct mwifiex_drv_mode *drv_mode;
582         const struct firmware *firmware;
583         struct device *dev;
584         bool surprise_removed;
585         u32 fw_release_number;
586         u32 revision_id;
587         u16 init_wait_q_woken;
588         wait_queue_head_t init_wait_q;
589         void *card;
590         struct mwifiex_if_ops if_ops;
591         atomic_t rx_pending;
592         atomic_t tx_pending;
593         atomic_t ioctl_pending;
594         struct workqueue_struct *workqueue;
595         struct work_struct main_work;
596         struct mwifiex_bss_prio_tbl bss_prio_tbl[MWIFIEX_MAX_BSS_NUM];
597         /* spin lock for init/shutdown */
598         spinlock_t mwifiex_lock;
599         /* spin lock for main process */
600         spinlock_t main_proc_lock;
601         u32 mwifiex_processing;
602         u16 max_tx_buf_size;
603         u16 tx_buf_size;
604         u16 curr_tx_buf_size;
605         u32 ioport;
606         enum MWIFIEX_HARDWARE_STATUS hw_status;
607         u16 number_of_antenna;
608         u32 fw_cap_info;
609         /* spin lock for interrupt handling */
610         spinlock_t int_lock;
611         u8 int_status;
612         u32 event_cause;
613         struct sk_buff *event_skb;
614         u8 upld_buf[MWIFIEX_UPLD_SIZE];
615         u8 data_sent;
616         u8 cmd_sent;
617         u8 cmd_resp_received;
618         u8 event_received;
619         u8 data_received;
620         u16 seq_num;
621         struct cmd_ctrl_node *cmd_pool;
622         struct cmd_ctrl_node *curr_cmd;
623         /* spin lock for command */
624         spinlock_t mwifiex_cmd_lock;
625         u32 num_cmd_timeout;
626         u16 last_init_cmd;
627         struct timer_list cmd_timer;
628         struct list_head cmd_free_q;
629         /* spin lock for cmd_free_q */
630         spinlock_t cmd_free_q_lock;
631         struct list_head cmd_pending_q;
632         /* spin lock for cmd_pending_q */
633         spinlock_t cmd_pending_q_lock;
634         struct list_head scan_pending_q;
635         /* spin lock for scan_pending_q */
636         spinlock_t scan_pending_q_lock;
637         u32 scan_processing;
638         u16 region_code;
639         struct mwifiex_802_11d_domain_reg domain_reg;
640         struct mwifiex_bssdescriptor *scan_table;
641         u32 num_in_scan_table;
642         u16 scan_probes;
643         u32 scan_mode;
644         u16 specific_scan_time;
645         u16 active_scan_time;
646         u16 passive_scan_time;
647         u8 bcn_buf[MAX_SCAN_BEACON_BUFFER];
648         u8 *bcn_buf_end;
649         u8 fw_bands;
650         u8 adhoc_start_band;
651         u8 config_bands;
652         struct mwifiex_chan_scan_param_set *scan_channels;
653         u8 tx_lock_flag;
654         struct mwifiex_sleep_params sleep_params;
655         struct mwifiex_sleep_period sleep_period;
656         u16 ps_mode;
657         u32 ps_state;
658         u8 need_to_wakeup;
659         u16 multiple_dtim;
660         u16 local_listen_interval;
661         u16 null_pkt_interval;
662         struct sk_buff *sleep_cfm;
663         u16 bcn_miss_time_out;
664         u16 adhoc_awake_period;
665         u8 is_deep_sleep;
666         u8 delay_null_pkt;
667         u16 delay_to_ps;
668         u16 enhanced_ps_mode;
669         u8 pm_wakeup_card_req;
670         u16 gen_null_pkt;
671         u16 pps_uapsd_mode;
672         u32 pm_wakeup_fw_try;
673         u8 is_hs_configured;
674         struct mwifiex_hs_config_param hs_cfg;
675         u8 hs_activated;
676         u16 hs_activate_wait_q_woken;
677         wait_queue_head_t hs_activate_wait_q;
678         bool is_suspended;
679         u8 event_body[MAX_EVENT_SIZE];
680         u32 hw_dot_11n_dev_cap;
681         u8 hw_dev_mcs_support;
682         u8 adhoc_11n_enabled;
683         u8 chan_offset;
684         struct mwifiex_dbg dbg;
685         u8 arp_filter[ARP_FILTER_MAX_BUF_SIZE];
686         u32 arp_filter_size;
687 };
688
689 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
690 void mwifiex_free_lock_list(struct mwifiex_adapter *adapter);
691
692 int mwifiex_init_fw(struct mwifiex_adapter *adapter);
693
694 int mwifiex_init_fw_complete(struct mwifiex_adapter *adapter);
695
696 int mwifiex_shutdown_drv(struct mwifiex_adapter *adapter);
697
698 int mwifiex_shutdown_fw_complete(struct mwifiex_adapter *adapter);
699
700 int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
701
702 int mwifiex_recv_complete(struct mwifiex_adapter *,
703                           struct sk_buff *skb,
704                           int status);
705
706 int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
707
708 int mwifiex_process_event(struct mwifiex_adapter *adapter);
709
710 int mwifiex_ioctl_complete(struct mwifiex_adapter *adapter,
711                            struct mwifiex_wait_queue *ioctl_wq,
712                            int status);
713
714 int mwifiex_prepare_cmd(struct mwifiex_private *priv,
715                         uint16_t cmd_no,
716                         u16 cmd_action,
717                         u32 cmd_oid,
718                         void *wait_queue, void *data_buf);
719
720 void mwifiex_cmd_timeout_func(unsigned long function_context);
721
722 int mwifiex_misc_ioctl_init_shutdown(struct mwifiex_adapter *adapter,
723                                      struct mwifiex_wait_queue *wait_queue,
724                                      u32 func_init_shutdown);
725 int mwifiex_get_debug_info(struct mwifiex_private *,
726                            struct mwifiex_debug_info *);
727
728 int mwifiex_alloc_cmd_buffer(struct mwifiex_adapter *adapter);
729 int mwifiex_free_cmd_buffer(struct mwifiex_adapter *adapter);
730 void mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter);
731 void mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter,
732                                   struct mwifiex_wait_queue *ioctl_wq);
733
734 void mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
735                                   struct cmd_ctrl_node *cmd_node);
736
737 void mwifiex_insert_cmd_to_pending_q(struct mwifiex_adapter *adapter,
738                                      struct cmd_ctrl_node *cmd_node,
739                                      u32 addtail);
740
741 int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter);
742 int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter);
743 int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter,
744                              struct sk_buff *skb);
745 int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
746                        struct mwifiex_tx_param *tx_param);
747 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
748 int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
749                                 struct sk_buff *skb, int status);
750 int mwifiex_recv_packet_complete(struct mwifiex_adapter *,
751                                  struct sk_buff *skb, int status);
752 void mwifiex_clean_txrx(struct mwifiex_private *priv);
753 u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
754 void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
755 void mwifiex_process_sleep_confirm_resp(struct mwifiex_adapter *, u8 *,
756                                         u32);
757 int mwifiex_cmd_enh_power_mode(struct mwifiex_private *priv,
758                                struct host_cmd_ds_command *cmd,
759                                u16 cmd_action, uint16_t ps_bitmap,
760                                void *data_buf);
761 int mwifiex_ret_enh_power_mode(struct mwifiex_private *priv,
762                                struct host_cmd_ds_command *resp,
763                                void *data_buf);
764 void mwifiex_process_hs_config(struct mwifiex_adapter *adapter);
765 void mwifiex_hs_activated_event(struct mwifiex_private *priv,
766                                         u8 activated);
767 int mwifiex_ret_802_11_hs_cfg(struct mwifiex_private *priv,
768                               struct host_cmd_ds_command *resp);
769 int mwifiex_process_rx_packet(struct mwifiex_adapter *adapter,
770                               struct sk_buff *skb);
771 int mwifiex_sta_prepare_cmd(struct mwifiex_private *, uint16_t cmd_no,
772                             u16 cmd_action, u32 cmd_oid,
773                             void *data_buf, void *cmd_buf);
774 int mwifiex_process_sta_cmdresp(struct mwifiex_private *, u16 cmdresp_no,
775                                 void *cmd_buf, void *ioctl);
776 int mwifiex_process_sta_rx_packet(struct mwifiex_adapter *,
777                                   struct sk_buff *skb);
778 int mwifiex_process_sta_event(struct mwifiex_private *);
779 void *mwifiex_process_sta_txpd(struct mwifiex_private *, struct sk_buff *skb);
780 int mwifiex_sta_init_cmd(struct mwifiex_private *, u8 first_sta);
781 int mwifiex_scan_networks(struct mwifiex_private *priv, void *wait_queue,
782                           u16 action,
783                           const struct mwifiex_user_scan_cfg
784                           *user_scan_in, struct mwifiex_scan_resp *);
785 int mwifiex_cmd_802_11_scan(struct mwifiex_private *priv,
786                             struct host_cmd_ds_command *cmd,
787                             void *data_buf);
788 void mwifiex_queue_scan_cmd(struct mwifiex_private *priv,
789                             struct cmd_ctrl_node *cmd_node);
790 int mwifiex_ret_802_11_scan(struct mwifiex_private *priv,
791                             struct host_cmd_ds_command *resp,
792                             void *wait_queue);
793 s32 mwifiex_find_ssid_in_list(struct mwifiex_private *priv,
794                                 struct mwifiex_802_11_ssid *ssid, u8 *bssid,
795                                 u32 mode);
796 s32 mwifiex_find_bssid_in_list(struct mwifiex_private *priv, u8 *bssid,
797                                  u32 mode);
798 int mwifiex_find_best_network(struct mwifiex_private *priv,
799                               struct mwifiex_ssid_bssid *req_ssid_bssid);
800 s32 mwifiex_ssid_cmp(struct mwifiex_802_11_ssid *ssid1,
801                        struct mwifiex_802_11_ssid *ssid2);
802 int mwifiex_associate(struct mwifiex_private *priv, void *wait_queue,
803                       struct mwifiex_bssdescriptor *bss_desc);
804 int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
805                                  struct host_cmd_ds_command
806                                  *cmd, void *data_buf);
807 int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
808                                  struct host_cmd_ds_command *resp,
809                                  void *wait_queue);
810 void mwifiex_reset_connect_state(struct mwifiex_private *priv);
811 void mwifiex_2040_coex_event(struct mwifiex_private *priv);
812 u8 mwifiex_band_to_radio_type(u8 band);
813 int mwifiex_deauthenticate(struct mwifiex_private *priv,
814                            struct mwifiex_wait_queue *wait_queue,
815                            u8 *mac);
816 int mwifiex_adhoc_start(struct mwifiex_private *priv, void *wait_queue,
817                         struct mwifiex_802_11_ssid *adhoc_ssid);
818 int mwifiex_adhoc_join(struct mwifiex_private *priv, void *wait_queue,
819                        struct mwifiex_bssdescriptor *bss_desc);
820 int mwifiex_cmd_802_11_ad_hoc_start(struct mwifiex_private *priv,
821                                     struct host_cmd_ds_command *cmd,
822                                     void *data_buf);
823 int mwifiex_cmd_802_11_ad_hoc_join(struct mwifiex_private *priv,
824                                    struct host_cmd_ds_command *cmd,
825                                    void *data_buf);
826 int mwifiex_ret_802_11_ad_hoc(struct mwifiex_private *priv,
827                               struct host_cmd_ds_command *resp,
828                               void *wait_queue);
829 int mwifiex_cmd_802_11_bg_scan_query(struct mwifiex_private *priv,
830                                      struct host_cmd_ds_command *cmd,
831                                      void *data_buf);
832 struct mwifiex_chan_freq_power *
833                         mwifiex_get_cfp_by_band_and_channel_from_cfg80211(
834                                                 struct mwifiex_private *priv,
835                                                 u8 band, u16 channel);
836 struct mwifiex_chan_freq_power *mwifiex_get_cfp_by_band_and_freq_from_cfg80211(
837                                                 struct mwifiex_private *priv,
838                                                 u8 band, u32 freq);
839 u32 mwifiex_index_to_data_rate(struct mwifiex_adapter *adapter, u8 index,
840                                  u8 ht_info);
841 u32 mwifiex_find_freq_from_band_chan(u8, u8);
842 int mwifiex_cmd_append_vsie_tlv(struct mwifiex_private *priv, u16 vsie_mask,
843                                 u8 **buffer);
844 u32 mwifiex_index_to_data_rate(struct mwifiex_adapter *adapter, u8 index,
845                                  u8 ht_info);
846 u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv,
847                                     u8 *rates);
848 u32 mwifiex_get_supported_rates(struct mwifiex_private *priv, u8 *rates);
849 u8 mwifiex_data_rate_to_index(struct mwifiex_adapter *adapter, u32 rate);
850 u8 mwifiex_is_rate_auto(struct mwifiex_private *priv);
851 int mwifiex_get_rate_index(struct mwifiex_adapter *adapter,
852                            u16 *rateBitmap, int size);
853 extern u16 region_code_index[MWIFIEX_MAX_REGION_CODE];
854 void mwifiex_save_curr_bcn(struct mwifiex_private *priv);
855 void mwifiex_free_curr_bcn(struct mwifiex_private *priv);
856 int mwifiex_cmd_get_hw_spec(struct mwifiex_private *priv,
857                             struct host_cmd_ds_command *cmd);
858 int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv,
859                             struct host_cmd_ds_command *resp);
860 int is_command_pending(struct mwifiex_adapter *adapter);
861
862 /*
863  * This function checks if the queuing is RA based or not.
864  */
865 static inline u8
866 mwifiex_queuing_ra_based(struct mwifiex_private *priv)
867 {
868         /*
869          * Currently we assume if we are in Infra, then DA=RA. This might not be
870          * true in the future
871          */
872         if ((priv->bss_mode == NL80211_IFTYPE_STATION) &&
873             (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA))
874                 return false;
875
876         return true;
877 }
878
879 /*
880  * This function copies rates.
881  */
882 static inline u32
883 mwifiex_copy_rates(u8 *dest, u32 pos, u8 *src, int len)
884 {
885         int i;
886
887         for (i = 0; i < len && src[i]; i++, pos++) {
888                 if (pos >= MWIFIEX_SUPPORTED_RATES)
889                         break;
890                 dest[pos] = src[i];
891         }
892
893         return pos;
894 }
895
896 /*
897  * This function returns the correct private structure pointer based
898  * upon the BSS type and BSS number.
899  */
900 static inline struct mwifiex_private *
901 mwifiex_get_priv_by_id(struct mwifiex_adapter *adapter,
902                        u32 bss_num, u32 bss_type)
903 {
904         int i;
905
906         for (i = 0; i < adapter->priv_num; i++) {
907                 if (adapter->priv[i]) {
908                         if ((adapter->priv[i]->bss_num == bss_num)
909                             && (adapter->priv[i]->bss_type == bss_type))
910                                 break;
911                 }
912         }
913         return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
914 }
915
916 /*
917  * This function returns the first available private structure pointer
918  * based upon the BSS role.
919  */
920 static inline struct mwifiex_private *
921 mwifiex_get_priv(struct mwifiex_adapter *adapter,
922                  enum mwifiex_bss_role bss_role)
923 {
924         int i;
925
926         for (i = 0; i < adapter->priv_num; i++) {
927                 if (adapter->priv[i]) {
928                         if (bss_role == MWIFIEX_BSS_ROLE_ANY ||
929                             GET_BSS_ROLE(adapter->priv[i]) == bss_role)
930                                 break;
931                 }
932         }
933
934         return ((i < adapter->priv_num) ? adapter->priv[i] : NULL);
935 }
936
937 /*
938  * This function returns the driver private structure of a network device.
939  */
940 static inline struct mwifiex_private *
941 mwifiex_netdev_get_priv(struct net_device *dev)
942 {
943         return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
944 }
945
946 struct mwifiex_wait_queue *mwifiex_alloc_fill_wait_queue(
947                                 struct mwifiex_private *,
948                                 u8 wait_option);
949 struct mwifiex_private *mwifiex_bss_index_to_priv(struct mwifiex_adapter
950                                                 *adapter, u8 bss_index);
951 int mwifiex_shutdown_fw(struct mwifiex_private *, u8);
952
953 int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *);
954 int mwifiex_remove_card(struct mwifiex_adapter *, struct semaphore *);
955
956 void mwifiex_get_version(struct mwifiex_adapter *adapter, char *version,
957                          int maxlen);
958 int mwifiex_request_set_mac_address(struct mwifiex_private *priv);
959 void mwifiex_request_set_multicast_list(struct mwifiex_private *priv,
960                                         struct net_device *dev);
961 int mwifiex_request_ioctl(struct mwifiex_private *priv,
962                           struct mwifiex_wait_queue *req,
963                           int, u8 wait_option);
964 int mwifiex_disconnect(struct mwifiex_private *, u8, u8 *);
965 int mwifiex_bss_start(struct mwifiex_private *priv,
966                       u8 wait_option,
967                       struct mwifiex_ssid_bssid *ssid_bssid);
968 int mwifiex_set_hs_params(struct mwifiex_private *priv,
969                               u16 action, u8 wait_option,
970                               struct mwifiex_ds_hs_cfg *hscfg);
971 int mwifiex_cancel_hs(struct mwifiex_private *priv, u8 wait_option);
972 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
973 void mwifiex_process_ioctl_resp(struct mwifiex_private *priv,
974                                 struct mwifiex_wait_queue *req);
975 u32 mwifiex_get_mode(struct mwifiex_private *priv, u8 wait_option);
976 int mwifiex_get_signal_info(struct mwifiex_private *priv,
977                             u8 wait_option,
978                             struct mwifiex_ds_get_signal *signal);
979 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
980                               struct mwifiex_rate_cfg *rate);
981 int mwifiex_get_channel_list(struct mwifiex_private *priv,
982                              u8 wait_option,
983                              struct mwifiex_chan_list *chanlist);
984 int mwifiex_get_scan_table(struct mwifiex_private *priv,
985                            u8 wait_option,
986                            struct mwifiex_scan_resp *scanresp);
987 int mwifiex_enable_wep_key(struct mwifiex_private *priv, u8 wait_option);
988 int mwifiex_find_best_bss(struct mwifiex_private *priv, u8 wait_option,
989                           struct mwifiex_ssid_bssid *ssid_bssid);
990 int mwifiex_request_scan(struct mwifiex_private *priv,
991                          u8 wait_option,
992                          struct mwifiex_802_11_ssid *req_ssid);
993 int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
994                                 struct mwifiex_user_scan_cfg *scan_req);
995 int mwifiex_change_adhoc_chan(struct mwifiex_private *priv, int channel);
996 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
997
998 int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, int channel);
999
1000 int mwifiex_set_encode(struct mwifiex_private *priv, const u8 *key,
1001                        int key_len, u8 key_index, int disable);
1002
1003 int mwifiex_set_gen_ie(struct mwifiex_private *priv, u8 *ie, int ie_len);
1004
1005 int mwifiex_get_ver_ext(struct mwifiex_private *priv);
1006
1007 int mwifiex_get_stats_info(struct mwifiex_private *priv,
1008                            struct mwifiex_ds_get_stats *log);
1009
1010 int mwifiex_reg_write(struct mwifiex_private *priv, u32 reg_type,
1011                       u32 reg_offset, u32 reg_value);
1012
1013 int mwifiex_reg_read(struct mwifiex_private *priv, u32 reg_type,
1014                      u32 reg_offset, u32 *value);
1015
1016 int mwifiex_eeprom_read(struct mwifiex_private *priv, u16 offset, u16 bytes,
1017                         u8 *value);
1018
1019 int mwifiex_set_11n_httx_cfg(struct mwifiex_private *priv, int data);
1020
1021 int mwifiex_get_11n_httx_cfg(struct mwifiex_private *priv, int *data);
1022
1023 int mwifiex_set_tx_rate_cfg(struct mwifiex_private *priv, int tx_rate_index);
1024
1025 int mwifiex_get_tx_rate_cfg(struct mwifiex_private *priv, int *tx_rate_index);
1026
1027 int mwifiex_drv_set_power(struct mwifiex_private *priv, bool power_on);
1028
1029 int mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter,
1030                                    char *version, int max_len);
1031
1032 int mwifiex_set_tx_power(struct mwifiex_private *priv, int type, int dbm);
1033
1034 int mwifiex_main_process(struct mwifiex_adapter *);
1035
1036 int mwifiex_bss_ioctl_channel(struct mwifiex_private *,
1037                               u16 action,
1038                               struct mwifiex_chan_freq_power *cfp);
1039 int mwifiex_bss_ioctl_find_bss(struct mwifiex_private *,
1040                                struct mwifiex_wait_queue *,
1041                                struct mwifiex_ssid_bssid *);
1042 int mwifiex_radio_ioctl_band_cfg(struct mwifiex_private *,
1043                                  u16 action,
1044                                  struct mwifiex_ds_band_cfg *);
1045 int mwifiex_snmp_mib_ioctl(struct mwifiex_private *,
1046                            struct mwifiex_wait_queue *,
1047                            u32 cmd_oid, u16 action, u32 *value);
1048 int mwifiex_get_bss_info(struct mwifiex_private *,
1049                          struct mwifiex_bss_info *);
1050
1051 #ifdef CONFIG_DEBUG_FS
1052 void mwifiex_debugfs_init(void);
1053 void mwifiex_debugfs_remove(void);
1054
1055 void mwifiex_dev_debugfs_init(struct mwifiex_private *priv);
1056 void mwifiex_dev_debugfs_remove(struct mwifiex_private *priv);
1057 #endif
1058 #endif /* !_MWIFIEX_MAIN_H_ */