mwifiex: remove unnecessary enum MWIFIEX_802_11_WEP_STATUS
[deliverable/linux.git] / drivers / net / wireless / mwifiex / cfg80211.c
index c3b6c4652cd6cd87d6a5fd8e22506013bcfe1e92..503717c5935803bed2ab7ed6e80f0b2b5c55f77e 100644 (file)
@@ -79,7 +79,7 @@ static int
 mwifiex_cfg80211_del_key(struct wiphy *wiphy, struct net_device *netdev,
                         u8 key_index, bool pairwise, const u8 *mac_addr)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
 
        if (mwifiex_set_encode(priv, NULL, 0, key_index, 1)) {
                wiphy_err(wiphy, "deleting the crypto keys\n");
@@ -122,7 +122,7 @@ mwifiex_cfg80211_set_power_mgmt(struct wiphy *wiphy,
                                struct net_device *dev,
                                bool enabled, int timeout)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
        u32 ps_mode;
 
        if (timeout)
@@ -143,10 +143,10 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
                                 u8 key_index, bool unicast,
                                 bool multicast)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
 
        /* Return if WEP key not configured */
-       if (priv->sec_info.wep_status == MWIFIEX_802_11_WEP_DISABLED)
+       if (!priv->sec_info.wep_enabled)
                return 0;
 
        if (mwifiex_set_encode(priv, NULL, 0, key_index, 0)) {
@@ -165,7 +165,7 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev,
                         u8 key_index, bool pairwise, const u8 *mac_addr,
                         struct key_params *params)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
 
        if (mwifiex_set_encode(priv, params->key, params->key_len,
                                                        key_index, 0)) {
@@ -376,7 +376,12 @@ mwifiex_cfg80211_set_channel(struct wiphy *wiphy, struct net_device *dev,
                             struct ieee80211_channel *chan,
                             enum nl80211_channel_type channel_type)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv;
+
+       if (dev)
+               priv = mwifiex_netdev_get_priv(dev);
+       else
+               priv = mwifiex_cfg80211_get_priv(wiphy);
 
        if (priv->media_connected) {
                wiphy_err(wiphy, "This setting is valid only when station "
@@ -534,6 +539,11 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
                ret = -EFAULT;
        }
 
+       /* Get DTIM period information from firmware */
+       mwifiex_send_cmd_sync(priv, HostCmd_CMD_802_11_SNMP_MIB,
+                             HostCmd_ACT_GEN_GET, DTIM_PERIOD_I,
+                             &priv->dtim_period);
+
        /*
         * Bit 0 in tx_htinfo indicates that current Tx rate is 11n rate. Valid
         * MCS index values for us are 0 to 7.
@@ -557,6 +567,22 @@ mwifiex_dump_station_info(struct mwifiex_private *priv,
        /* bit rate is in 500 kb/s units. Convert it to 100kb/s units */
        sinfo->txrate.legacy = rate.rate * 5;
 
+       if (priv->bss_mode == NL80211_IFTYPE_STATION) {
+               sinfo->filled |= STATION_INFO_BSS_PARAM;
+               sinfo->bss_param.flags = 0;
+               if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap &
+                                               WLAN_CAPABILITY_SHORT_PREAMBLE)
+                       sinfo->bss_param.flags |=
+                                       BSS_PARAM_FLAGS_SHORT_PREAMBLE;
+               if (priv->curr_bss_params.bss_descriptor.cap_info_bitmap &
+                                               WLAN_CAPABILITY_SHORT_SLOT_TIME)
+                       sinfo->bss_param.flags |=
+                                       BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
+               sinfo->bss_param.dtim_period = priv->dtim_period;
+               sinfo->bss_param.beacon_interval =
+                       priv->curr_bss_params.bss_descriptor.beacon_period;
+       }
+
        return ret;
 }
 
@@ -841,7 +867,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
                ret = mwifiex_set_rf_channel(priv, channel,
                                                priv->adapter->channel_type);
 
-       ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);  /* Disable keys */
+       /* As this is new association, clear locally stored
+        * keys and security related flags */
+       priv->sec_info.wpa_enabled = false;
+       priv->sec_info.wpa2_enabled = false;
+       priv->wep_key_curr_index = 0;
+       ret = mwifiex_set_encode(priv, NULL, 0, 0, 1);
 
        if (mode == NL80211_IFTYPE_ADHOC) {
                /* "privacy" is set only for ad-hoc mode */
@@ -886,17 +917,12 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
                        dev_dbg(priv->adapter->dev,
                                "info: setting wep encryption"
                                " with key len %d\n", sme->key_len);
+                       priv->wep_key_curr_index = sme->key_idx;
                        ret = mwifiex_set_encode(priv, sme->key, sme->key_len,
                                                        sme->key_idx, 0);
                }
        }
 done:
-       /* Do specific SSID scanning */
-       if (mwifiex_request_scan(priv, &req_ssid)) {
-               dev_err(priv->adapter->dev, "scan error\n");
-               return -EFAULT;
-       }
-
        /*
         * Scan entries are valid for some time (15 sec). So we can save one
         * active scan time if we just try cfg80211_get_bss first. If it fails
@@ -1004,7 +1030,7 @@ static int
 mwifiex_cfg80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
                           struct cfg80211_ibss_params *params)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
        int ret = 0;
 
        if (priv->bss_mode != NL80211_IFTYPE_ADHOC) {
@@ -1042,7 +1068,7 @@ done:
 static int
 mwifiex_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
 
        wiphy_dbg(wiphy, "info: disconnecting from essid %pM\n",
                        priv->cfg_bssid);
@@ -1217,7 +1243,6 @@ struct net_device *mwifiex_add_virtual_intf(struct wiphy *wiphy,
                priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
                priv->bss_priority = 0;
                priv->bss_role = MWIFIEX_BSS_ROLE_STA;
-               priv->bss_index = 0;
                priv->bss_num = 0;
 
                break;
@@ -1281,10 +1306,7 @@ EXPORT_SYMBOL_GPL(mwifiex_add_virtual_intf);
  */
 int mwifiex_del_virtual_intf(struct wiphy *wiphy, struct net_device *dev)
 {
-       struct mwifiex_private *priv = mwifiex_cfg80211_get_priv(wiphy);
-
-       if (!priv || !dev)
-               return 0;
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
 
 #ifdef CONFIG_DEBUG_FS
        mwifiex_dev_debugfs_remove(priv);
This page took 0.027952 seconds and 5 git commands to generate.