Merge branch 'for-john' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac802...
[cascardo/linux.git] / drivers / net / wireless / mwifiex / cfg80211.c
index 49e2066..c24824f 100644 (file)
@@ -37,6 +37,36 @@ static const struct ieee80211_iface_combination mwifiex_iface_comb_ap_sta = {
        .beacon_int_infra_match = true,
 };
 
+static const struct ieee80211_regdomain mwifiex_world_regdom_custom = {
+       .n_reg_rules = 7,
+       .alpha2 =  "99",
+       .reg_rules = {
+               /* Channel 1 - 11 */
+               REG_RULE(2412-10, 2462+10, 40, 3, 20, 0),
+               /* Channel 12 - 13 */
+               REG_RULE(2467-10, 2472+10, 20, 3, 20,
+                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
+               /* Channel 14 */
+               REG_RULE(2484-10, 2484+10, 20, 3, 20,
+                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
+                        NL80211_RRF_NO_OFDM),
+               /* Channel 36 - 48 */
+               REG_RULE(5180-10, 5240+10, 40, 3, 20,
+                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
+               /* Channel 149 - 165 */
+               REG_RULE(5745-10, 5825+10, 40, 3, 20,
+                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
+               /* Channel 52 - 64 */
+               REG_RULE(5260-10, 5320+10, 40, 3, 30,
+                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
+                        NL80211_RRF_DFS),
+               /* Channel 100 - 140 */
+               REG_RULE(5500-10, 5700+10, 40, 3, 30,
+                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
+                        NL80211_RRF_DFS),
+       }
+};
+
 /*
  * This function maps the nl802.11 channel type into driver channel type.
  *
@@ -969,15 +999,18 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
 
        bss_cfg->channel =
            (u8)ieee80211_frequency_to_channel(params->channel->center_freq);
-       bss_cfg->band_cfg = BAND_CONFIG_MANUAL;
 
        /* Set appropriate bands */
        if (params->channel->band == IEEE80211_BAND_2GHZ) {
+               bss_cfg->band_cfg = BAND_CONFIG_BG;
+
                if (params->channel_type == NL80211_CHAN_NO_HT)
                        config_bands = BAND_B | BAND_G;
                else
                        config_bands = BAND_B | BAND_G | BAND_GN;
        } else {
+               bss_cfg->band_cfg = BAND_CONFIG_A;
+
                if (params->channel_type == NL80211_CHAN_NO_HT)
                        config_bands = BAND_A;
                else
@@ -988,6 +1021,7 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
              ~priv->adapter->fw_bands))
                priv->adapter->config_bands = config_bands;
 
+       mwifiex_set_uap_rates(bss_cfg, params);
        mwifiex_send_domain_info_cmd_fw(wiphy);
 
        if (mwifiex_set_secure_params(priv, bss_cfg, params)) {
@@ -1153,7 +1187,6 @@ mwifiex_cfg80211_assoc(struct mwifiex_private *priv, size_t ssid_len, u8 *ssid,
                              ~priv->adapter->fw_bands))
                                priv->adapter->config_bands = config_bands;
                }
-               mwifiex_send_domain_info_cmd_fw(priv->wdev->wiphy);
        }
 
        /* As this is new association, clear locally stored
@@ -1469,6 +1502,12 @@ mwifiex_cfg80211_scan(struct wiphy *wiphy,
 
        wiphy_dbg(wiphy, "info: received scan request on %s\n", dev->name);
 
+       if (atomic_read(&priv->wmm.tx_pkts_queued) >=
+           MWIFIEX_MIN_TX_PENDING_TO_CANCEL_SCAN) {
+               dev_dbg(priv->adapter->dev, "scan rejected due to traffic\n");
+               return -EBUSY;
+       }
+
        priv->scan_request = request;
 
        priv->user_scan_cfg = kzalloc(sizeof(struct mwifiex_user_scan_cfg),
@@ -1637,7 +1676,7 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
 
                priv->bss_type = MWIFIEX_BSS_TYPE_STA;
                priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
-               priv->bss_priority = MWIFIEX_BSS_ROLE_STA;
+               priv->bss_priority = 0;
                priv->bss_role = MWIFIEX_BSS_ROLE_STA;
                priv->bss_num = 0;
 
@@ -1660,7 +1699,7 @@ struct wireless_dev *mwifiex_add_virtual_intf(struct wiphy *wiphy,
 
                priv->bss_type = MWIFIEX_BSS_TYPE_UAP;
                priv->frame_type = MWIFIEX_DATA_FRAME_TYPE_ETH_II;
-               priv->bss_priority = MWIFIEX_BSS_ROLE_UAP;
+               priv->bss_priority = 0;
                priv->bss_role = MWIFIEX_BSS_ROLE_UAP;
                priv->bss_started = 0;
                priv->bss_num = 0;
@@ -1830,7 +1869,10 @@ 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_AP_PROBE_RESP_OFFLOAD;
+                       WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD |
+                       WIPHY_FLAG_CUSTOM_REGULATORY;
+
+       wiphy_apply_custom_regulatory(wiphy, &mwifiex_world_regdom_custom);
 
        wiphy->probe_resp_offload = NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS |
                                    NL80211_PROBE_RESP_OFFLOAD_SUPPORT_WPS2;
@@ -1859,8 +1901,9 @@ int mwifiex_register_cfg80211(struct mwifiex_adapter *adapter)
                return ret;
        }
        country_code = mwifiex_11d_code_2_region(priv->adapter->region_code);
-       if (country_code && regulatory_hint(wiphy, country_code))
-               dev_err(adapter->dev, "regulatory_hint() failed\n");
+       if (country_code)
+               dev_info(adapter->dev,
+                        "ignoring F/W country code %2.2s\n", country_code);
 
        adapter->wiphy = wiphy;
        return ret;