Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / mwifiex / cfg80211.c
index 5c7fd185373cfb37c0ee57e62b9b54135af505b7..75843fddbad409c560bb4719f523f7dfc8025c0c 100644 (file)
@@ -170,7 +170,9 @@ mwifiex_cfg80211_set_default_key(struct wiphy *wiphy, struct net_device *netdev,
        if (!priv->sec_info.wep_enabled)
                return 0;
 
-       if (mwifiex_set_encode(priv, NULL, 0, key_index, NULL, 0)) {
+       if (priv->bss_type == MWIFIEX_BSS_TYPE_UAP) {
+               priv->wep_key_curr_index = key_index;
+       } else if (mwifiex_set_encode(priv, NULL, 0, key_index, NULL, 0)) {
                wiphy_err(wiphy, "set default Tx key index\n");
                return -EFAULT;
        }
@@ -187,9 +189,25 @@ mwifiex_cfg80211_add_key(struct wiphy *wiphy, struct net_device *netdev,
                         struct key_params *params)
 {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(netdev);
+       struct mwifiex_wep_key *wep_key;
        const u8 bc_mac[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
        const u8 *peer_mac = pairwise ? mac_addr : bc_mac;
 
+       if (GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_UAP &&
+           (params->cipher == WLAN_CIPHER_SUITE_WEP40 ||
+            params->cipher == WLAN_CIPHER_SUITE_WEP104)) {
+               if (params->key && params->key_len) {
+                       wep_key = &priv->wep_key[key_index];
+                       memset(wep_key, 0, sizeof(struct mwifiex_wep_key));
+                       memcpy(wep_key->key_material, params->key,
+                              params->key_len);
+                       wep_key->key_index = key_index;
+                       wep_key->key_length = params->key_len;
+                       priv->sec_info.wep_enabled = 1;
+               }
+               return 0;
+       }
+
        if (mwifiex_set_encode(priv, params->key, params->key_len,
                               key_index, peer_mac, 0)) {
                wiphy_err(wiphy, "crypto keys added\n");
@@ -242,13 +260,13 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy)
                        flag = 1;
                        first_chan = (u32) ch->hw_value;
                        next_chan = first_chan;
-                       max_pwr = ch->max_power;
+                       max_pwr = ch->max_reg_power;
                        no_of_parsed_chan = 1;
                        continue;
                }
 
                if (ch->hw_value == next_chan + 1 &&
-                   ch->max_power == max_pwr) {
+                   ch->max_reg_power == max_pwr) {
                        next_chan++;
                        no_of_parsed_chan++;
                } else {
@@ -259,7 +277,7 @@ static int mwifiex_send_domain_info_cmd_fw(struct wiphy *wiphy)
                        no_of_triplet++;
                        first_chan = (u32) ch->hw_value;
                        next_chan = first_chan;
-                       max_pwr = ch->max_power;
+                       max_pwr = ch->max_reg_power;
                        no_of_parsed_chan = 1;
                }
        }
@@ -384,13 +402,13 @@ mwifiex_set_rf_channel(struct mwifiex_private *priv,
        cfp.freq = chan->center_freq;
        cfp.channel = ieee80211_frequency_to_channel(chan->center_freq);
 
-       if (mwifiex_bss_set_channel(priv, &cfp))
-               return -EFAULT;
-
-       if (priv->bss_type == MWIFIEX_BSS_TYPE_STA)
+       if (priv->bss_type == MWIFIEX_BSS_TYPE_STA) {
+               if (mwifiex_bss_set_channel(priv, &cfp))
+                       return -EFAULT;
                return mwifiex_drv_change_adhoc_chan(priv, cfp.channel);
-       else
-               return mwifiex_uap_set_channel(priv, cfp.channel);
+       }
+
+       return 0;
 }
 
 /*
@@ -962,12 +980,25 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
                return -EINVAL;
        }
 
+       bss_cfg->channel =
+           (u8)ieee80211_frequency_to_channel(params->channel->center_freq);
+       bss_cfg->band_cfg = BAND_CONFIG_MANUAL;
+
+       if (mwifiex_set_rf_channel(priv, params->channel,
+                                  params->channel_type)) {
+               kfree(bss_cfg);
+               wiphy_err(wiphy, "Failed to set band config information!\n");
+               return -1;
+       }
+
        if (mwifiex_set_secure_params(priv, bss_cfg, params)) {
                kfree(bss_cfg);
                wiphy_err(wiphy, "Failed to parse secuirty parameters!\n");
                return -1;
        }
 
+       mwifiex_set_ht_params(priv, bss_cfg, params);
+
        if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_UAP_BSS_STOP,
                                  HostCmd_ACT_GEN_SET, 0, NULL)) {
                wiphy_err(wiphy, "Failed to stop the BSS\n");
@@ -991,6 +1022,16 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
                return -1;
        }
 
+       if (priv->sec_info.wep_enabled)
+               priv->curr_pkt_filter |= HostCmd_ACT_MAC_WEP_ENABLE;
+       else
+               priv->curr_pkt_filter &= ~HostCmd_ACT_MAC_WEP_ENABLE;
+
+       if (mwifiex_send_cmd_sync(priv, HostCmd_CMD_MAC_CONTROL,
+                                 HostCmd_ACT_GEN_SET, 0,
+                                 &priv->curr_pkt_filter))
+               return -1;
+
        return 0;
 }
 
@@ -1382,7 +1423,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy, struct net_device *dev,
 
                priv->user_scan_cfg->chan_list[i].scan_time = 0;
        }
-       if (mwifiex_set_user_scan_ioctl(priv, priv->user_scan_cfg))
+       if (mwifiex_scan_networks(priv, priv->user_scan_cfg))
                return -EFAULT;
 
        if (request->ie && request->ie_len) {
@@ -1703,7 +1744,7 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
 
        memcpy(wiphy->perm_addr, priv->curr_addr, ETH_ALEN);
        wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
-       wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME | WIPHY_FLAG_CUSTOM_REGULATORY;
+       wiphy->flags |= WIPHY_FLAG_HAVE_AP_SME;
 
        /* Reserve space for mwifiex specific private data for BSS */
        wiphy->bss_priv_size = sizeof(struct mwifiex_bss_priv);