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