mwifiex: remove global user_scan_cfg variable
[cascardo/linux.git] / drivers / net / wireless / mwifiex / main.h
index 35225e9..315f07e 100644 (file)
@@ -32,6 +32,7 @@
 #include <net/lib80211.h>
 #include <linux/firmware.h>
 #include <linux/ctype.h>
+#include <linux/regulator/machine.h>
 
 #include "decl.h"
 #include "ioctl.h"
@@ -79,14 +80,20 @@ enum {
 
 #define SCAN_BEACON_ENTRY_PAD                  6
 
-#define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 200
-#define MWIFIEX_ACTIVE_SCAN_CHAN_TIME  200
-#define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME        110
+#define MWIFIEX_PASSIVE_SCAN_CHAN_TIME 110
+#define MWIFIEX_ACTIVE_SCAN_CHAN_TIME  30
+#define MWIFIEX_SPECIFIC_SCAN_CHAN_TIME        30
 
 #define SCAN_RSSI(RSSI)                                        (0x100 - ((u8)(RSSI)))
 
 #define MWIFIEX_MAX_TOTAL_SCAN_TIME    (MWIFIEX_TIMER_10S - MWIFIEX_TIMER_1S)
 
+#define MWIFIEX_MAX_SCAN_DELAY_CNT                     50
+#define MWIFIEX_MAX_EMPTY_TX_Q_CNT                     10
+#define MWIFIEX_SCAN_DELAY_MSEC                                20
+
+#define MWIFIEX_MIN_TX_PENDING_TO_CANCEL_SCAN          2
+
 #define RSN_GTK_OUI_OFFSET                             2
 
 #define MWIFIEX_OUI_NOT_PRESENT                        0
@@ -110,6 +117,9 @@ enum {
 
 #define MWIFIEX_EVENT_HEADER_LEN           4
 
+/* Threshold for tx_timeout_cnt before we trigger a card reset */
+#define TX_TIMEOUT_THRESHOLD   6
+
 struct mwifiex_dbg {
        u32 num_cmd_host_to_card_failure;
        u32 num_cmd_sleep_cfm_host_to_card_failure;
@@ -201,10 +211,10 @@ struct mwifiex_wmm_desc {
        u32 packets_out[MAX_NUM_TID];
        /* spin lock to protect ra_list */
        spinlock_t ra_list_spinlock;
-       struct mwifiex_wmm_ac_status ac_status[IEEE80211_MAX_QUEUES];
-       enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_MAX_QUEUES];
+       struct mwifiex_wmm_ac_status ac_status[IEEE80211_NUM_ACS];
+       enum mwifiex_wmm_ac_e ac_down_graded_vals[IEEE80211_NUM_ACS];
        u32 drv_pkt_delay_max;
-       u8 queue_priority[IEEE80211_MAX_QUEUES];
+       u8 queue_priority[IEEE80211_NUM_ACS];
        u32 user_pri_pkt_tx_ctrl[WMM_HIGHEST_PRIORITY + 1];     /* UP: 0 to 7 */
        /* Number of transmit packets queued */
        atomic_t tx_pkts_queued;
@@ -260,8 +270,8 @@ struct mwifiex_bssdescriptor {
         * BAND_A(0X04): 'a' band
         */
        u16 bss_band;
-       u64 network_tsf;
-       u8 time_stamp[8];
+       u64 fw_tsf;
+       u64 timestamp;
        union ieee_types_phy_param_set phy_param_set;
        union ieee_types_ss_param_set ss_param_set;
        u16 cap_info_bitmap;
@@ -361,6 +371,8 @@ struct mwifiex_private {
        u8 curr_addr[ETH_ALEN];
        u8 media_connected;
        u32 num_tx_timeout;
+       /* track consecutive timeout */
+       u8 tx_timeout_cnt;
        struct net_device *netdev;
        struct net_device_stats stats;
        u16 curr_pkt_filter;
@@ -407,10 +419,13 @@ struct mwifiex_private {
        struct host_cmd_ds_802_11_key_material aes_key;
        u8 wapi_ie[256];
        u8 wapi_ie_len;
+       u8 *wps_ie;
+       u8 wps_ie_len;
        u8 wmm_required;
        u8 wmm_enabled;
        u8 wmm_qosinfo;
        struct mwifiex_wmm_desc wmm;
+       atomic_t wmm_tx_pending[IEEE80211_NUM_ACS];
        struct list_head tx_ba_stream_tbl_ptr;
        /* spin lock for tx_ba_stream_tbl_ptr queue */
        spinlock_t tx_ba_stream_tbl_lock;
@@ -448,17 +463,22 @@ struct mwifiex_private {
        struct dentry *dfs_dev_dir;
 #endif
        u8 nick_name[16];
-       u8 qual_level, qual_noise;
        u16 current_key_index;
        struct semaphore async_sem;
-       u8 scan_pending_on_block;
        u8 report_scan_result;
        struct cfg80211_scan_request *scan_request;
-       struct mwifiex_user_scan_cfg *user_scan_cfg;
        u8 cfg_bssid[6];
        u8 country_code[IEEE80211_COUNTRY_STRING_LEN];
        struct wps wps;
        u8 scan_block;
+       s32 cqm_rssi_thold;
+       u32 cqm_rssi_hyst;
+       u8 subsc_evt_rssi_state;
+       struct timer_list scan_delay_timer;
+       struct mwifiex_ds_misc_subsc_evt async_subsc_evt_storage;
+       u32 mgmt_frame_mask;
+       u32 mgmt_rx_freq;
+       bool scan_aborting;
 };
 
 enum mwifiex_ba_status {
@@ -518,6 +538,11 @@ struct cmd_ctrl_node {
        u8 cmd_wait_q_woken;
 };
 
+struct mwifiex_bss_priv {
+       u8 band;
+       u64 fw_tsf;
+};
+
 struct mwifiex_if_ops {
        int (*init_if) (struct mwifiex_adapter *);
        void (*cleanup_if) (struct mwifiex_adapter *);
@@ -537,6 +562,8 @@ struct mwifiex_if_ops {
        void (*cleanup_mpa_buf) (struct mwifiex_adapter *);
        int (*cmdrsp_complete) (struct mwifiex_adapter *, struct sk_buff *);
        int (*event_complete) (struct mwifiex_adapter *, struct sk_buff *);
+       void (*reg_dbg) (struct mwifiex_adapter *);
+       void (*card_reset) (struct mwifiex_adapter *);
 };
 
 struct mwifiex_adapter {
@@ -651,6 +678,10 @@ struct mwifiex_adapter {
        u8 scan_wait_q_woken;
        struct cmd_ctrl_node *cmd_queued;
        spinlock_t queue_lock;          /* lock for tx queues */
+       struct completion fw_load;
+       u8 scan_delay_cnt;
+       u8 empty_tx_q_cnt;
+       atomic_t is_tx_received;
 };
 
 int mwifiex_init_lock_list(struct mwifiex_adapter *adapter);
@@ -675,6 +706,9 @@ int mwifiex_dnld_fw(struct mwifiex_adapter *, struct mwifiex_fw_image *);
 
 int mwifiex_recv_packet(struct mwifiex_adapter *, struct sk_buff *skb);
 
+int mwifiex_process_mgmt_packet(struct mwifiex_adapter *adapter,
+                               struct sk_buff *skb);
+
 int mwifiex_process_event(struct mwifiex_adapter *adapter);
 
 int mwifiex_complete_cmd(struct mwifiex_adapter *adapter,
@@ -711,7 +745,7 @@ int mwifiex_process_tx(struct mwifiex_private *priv, struct sk_buff *skb,
                       struct mwifiex_tx_param *tx_param);
 int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags);
 int mwifiex_write_data_complete(struct mwifiex_adapter *adapter,
-                               struct sk_buff *skb, int status);
+                               struct sk_buff *skb, int aggr, int status);
 void mwifiex_clean_txrx(struct mwifiex_private *priv);
 u8 mwifiex_check_last_packet_indication(struct mwifiex_private *priv);
 void mwifiex_check_ps_cond(struct mwifiex_adapter *adapter);
@@ -755,7 +789,7 @@ int mwifiex_cmd_802_11_associate(struct mwifiex_private *priv,
                                 struct mwifiex_bssdescriptor *bss_desc);
 int mwifiex_ret_802_11_associate(struct mwifiex_private *priv,
                                 struct host_cmd_ds_command *resp);
-void mwifiex_reset_connect_state(struct mwifiex_private *priv);
+void mwifiex_reset_connect_state(struct mwifiex_private *priv, u16 reason);
 u8 mwifiex_band_to_radio_type(u8 band);
 int mwifiex_deauthenticate(struct mwifiex_private *priv, u8 *mac);
 int mwifiex_adhoc_start(struct mwifiex_private *priv,
@@ -795,6 +829,8 @@ int is_command_pending(struct mwifiex_adapter *adapter);
 void mwifiex_init_priv_params(struct mwifiex_private *priv,
                                                struct net_device *dev);
 
+#define PKT_TYPE_MGMT  0xE5
+
 /*
  * This function checks if the queuing is RA based or not.
  */
@@ -879,6 +915,14 @@ mwifiex_netdev_get_priv(struct net_device *dev)
        return (struct mwifiex_private *) (*(unsigned long *) netdev_priv(dev));
 }
 
+/*
+ * This function checks if a skb holds a management frame.
+ */
+static inline bool mwifiex_is_skb_mgmt_frame(struct sk_buff *skb)
+{
+       return (*(u32 *)skb->data == PKT_TYPE_MGMT);
+}
+
 int mwifiex_init_shutdown_fw(struct mwifiex_private *priv,
                             u32 func_init_shutdown);
 int mwifiex_add_card(void *, struct semaphore *, struct mwifiex_if_ops *, u8);
@@ -896,14 +940,12 @@ int mwifiex_bss_start(struct mwifiex_private *priv, struct cfg80211_bss *bss,
 int mwifiex_cancel_hs(struct mwifiex_private *priv, int cmd_type);
 int mwifiex_enable_hs(struct mwifiex_adapter *adapter);
 int mwifiex_disable_auto_ds(struct mwifiex_private *priv);
-int mwifiex_get_signal_info(struct mwifiex_private *priv,
-                           struct mwifiex_ds_get_signal *signal);
 int mwifiex_drv_get_data_rate(struct mwifiex_private *priv,
                              struct mwifiex_rate_cfg *rate);
 int mwifiex_request_scan(struct mwifiex_private *priv,
                         struct cfg80211_ssid *req_ssid);
-int mwifiex_set_user_scan_ioctl(struct mwifiex_private *priv,
-                               struct mwifiex_user_scan_cfg *scan_req);
+int mwifiex_scan_networks(struct mwifiex_private *priv,
+                         const struct mwifiex_user_scan_cfg *user_scan_in);
 int mwifiex_set_radio(struct mwifiex_private *priv, u8 option);
 
 int mwifiex_drv_change_adhoc_chan(struct mwifiex_private *priv, u16 channel);
@@ -945,18 +987,18 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
 
 int mwifiex_main_process(struct mwifiex_adapter *);
 
+int mwifiex_queue_tx_pkt(struct mwifiex_private *priv, struct sk_buff *skb);
+
 int mwifiex_bss_set_channel(struct mwifiex_private *,
                            struct mwifiex_chan_freq_power *cfp);
 int mwifiex_get_bss_info(struct mwifiex_private *,
                         struct mwifiex_bss_info *);
 int mwifiex_fill_new_bss_desc(struct mwifiex_private *priv,
-                             u8 *bssid, s32 rssi, u8 *ie_buf,
-                             size_t ie_len, u16 beacon_period,
-                             u16 cap_info_bitmap, u8 band,
-                             struct mwifiex_bssdescriptor *bss_desc);
+                             struct cfg80211_bss *bss,
+                             struct mwifiex_bssdescriptor *bss_desc,
+                             u8 *beacon_ie, size_t beacon_ie_len);
 int mwifiex_update_bss_desc_with_ie(struct mwifiex_adapter *adapter,
-                               struct mwifiex_bssdescriptor *bss_entry,
-                               u8 *ie_buf, u32 ie_len);
+                                   struct mwifiex_bssdescriptor *bss_entry);
 int mwifiex_check_network_compatibility(struct mwifiex_private *priv,
                                        struct mwifiex_bssdescriptor *bss_desc);
 
@@ -965,6 +1007,7 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
                                        u32 *flags, struct vif_params *params);
 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev);
 
+u8 *mwifiex_11d_code_2_region(u8 code);
 
 #ifdef CONFIG_DEBUG_FS
 void mwifiex_debugfs_init(void);