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