mwifiex: set HT capability based on cfg80211_ap_settings
[deliverable/linux.git] / drivers / net / wireless / mwifiex / uap_cmd.c
index 76dfbc42a732fc92530fc68a7b8573ea0f54d437..59e5ba4df02ba4fe7954f4a76258fec74b5674f7 100644 (file)
@@ -27,6 +27,17 @@ int mwifiex_set_secure_params(struct mwifiex_private *priv,
                              struct cfg80211_ap_settings *params) {
        int i;
 
+       if (!params->privacy) {
+               bss_config->protocol = PROTOCOL_NO_SECURITY;
+               bss_config->key_mgmt = KEY_MGMT_NONE;
+               bss_config->wpa_cfg.length = 0;
+               priv->sec_info.wep_enabled = 0;
+               priv->sec_info.wpa_enabled = 0;
+               priv->sec_info.wpa2_enabled = 0;
+
+               return 0;
+       }
+
        switch (params->auth_type) {
        case NL80211_AUTHTYPE_OPEN_SYSTEM:
                bss_config->auth_mode = WLAN_AUTH_OPEN;
@@ -107,6 +118,33 @@ int mwifiex_set_secure_params(struct mwifiex_private *priv,
        return 0;
 }
 
+/* This function updates 11n related parameters from IE and sets them into
+ * bss_config structure.
+ */
+void
+mwifiex_set_ht_params(struct mwifiex_private *priv,
+                     struct mwifiex_uap_bss_param *bss_cfg,
+                     struct cfg80211_ap_settings *params)
+{
+       const u8 *ht_ie;
+
+       if (!ISSUPP_11NENABLED(priv->adapter->fw_cap_info))
+               return;
+
+       ht_ie = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY, params->beacon.tail,
+                                params->beacon.tail_len);
+       if (ht_ie) {
+               memcpy(&bss_cfg->ht_cap, ht_ie + 2,
+                      sizeof(struct ieee80211_ht_cap));
+       } else {
+               memset(&bss_cfg->ht_cap , 0, sizeof(struct ieee80211_ht_cap));
+               bss_cfg->ht_cap.cap_info = cpu_to_le16(MWIFIEX_DEF_HT_CAP);
+               bss_cfg->ht_cap.ampdu_params_info = MWIFIEX_DEF_AMPDU;
+       }
+
+       return;
+}
+
 /* This function initializes some of mwifiex_uap_bss_param variables.
  * This helps FW in ignoring invalid values. These values may or may not
  * be get updated to valid ones at later stage.
@@ -132,6 +170,7 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
        struct host_cmd_tlv_dtim_period *dtim_period;
        struct host_cmd_tlv_beacon_period *beacon_period;
        struct host_cmd_tlv_ssid *ssid;
+       struct host_cmd_tlv_bcast_ssid *bcast_ssid;
        struct host_cmd_tlv_channel_band *chan_band;
        struct host_cmd_tlv_frag_threshold *frag_threshold;
        struct host_cmd_tlv_rts_threshold *rts_threshold;
@@ -142,6 +181,7 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
        struct host_cmd_tlv_auth_type *auth_type;
        struct host_cmd_tlv_passphrase *passphrase;
        struct host_cmd_tlv_akmp *tlv_akmp;
+       struct mwifiex_ie_types_htcap *htcap;
        struct mwifiex_uap_bss_param *bss_cfg = cmd_buf;
        u16 cmd_size = *param_size;
 
@@ -153,6 +193,14 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
                cmd_size += sizeof(struct host_cmd_tlv) +
                            bss_cfg->ssid.ssid_len;
                tlv += sizeof(struct host_cmd_tlv) + bss_cfg->ssid.ssid_len;
+
+               bcast_ssid = (struct host_cmd_tlv_bcast_ssid *)tlv;
+               bcast_ssid->tlv.type = cpu_to_le16(TLV_TYPE_UAP_BCAST_SSID);
+               bcast_ssid->tlv.len =
+                               cpu_to_le16(sizeof(bcast_ssid->bcast_ctl));
+               bcast_ssid->bcast_ctl = bss_cfg->bcast_ssid_ctl;
+               cmd_size += sizeof(struct host_cmd_tlv_bcast_ssid);
+               tlv += sizeof(struct host_cmd_tlv_bcast_ssid);
        }
        if (bss_cfg->channel && bss_cfg->channel <= MAX_CHANNEL_BAND_BG) {
                chan_band = (struct host_cmd_tlv_channel_band *)tlv;
@@ -310,6 +358,25 @@ mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
                tlv += sizeof(struct host_cmd_tlv_encrypt_protocol);
        }
 
+       if (bss_cfg->ht_cap.cap_info) {
+               htcap = (struct mwifiex_ie_types_htcap *)tlv;
+               htcap->header.type = cpu_to_le16(WLAN_EID_HT_CAPABILITY);
+               htcap->header.len =
+                               cpu_to_le16(sizeof(struct ieee80211_ht_cap));
+               htcap->ht_cap.cap_info = bss_cfg->ht_cap.cap_info;
+               htcap->ht_cap.ampdu_params_info =
+                                            bss_cfg->ht_cap.ampdu_params_info;
+               memcpy(&htcap->ht_cap.mcs, &bss_cfg->ht_cap.mcs,
+                      sizeof(struct ieee80211_mcs_info));
+               htcap->ht_cap.extended_ht_cap_info =
+                                       bss_cfg->ht_cap.extended_ht_cap_info;
+               htcap->ht_cap.tx_BF_cap_info = bss_cfg->ht_cap.tx_BF_cap_info;
+               htcap->ht_cap.antenna_selection_info =
+                                       bss_cfg->ht_cap.antenna_selection_info;
+               cmd_size += sizeof(struct mwifiex_ie_types_htcap);
+               tlv += sizeof(struct mwifiex_ie_types_htcap);
+       }
+
        *param_size = cmd_size;
 
        return 0;
@@ -401,32 +468,3 @@ int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, u16 cmd_no,
 
        return 0;
 }
-
-/* This function sets the RF channel for AP.
- *
- * This function populates channel information in AP config structure
- * and sends command to configure channel information in AP.
- */
-int mwifiex_uap_set_channel(struct mwifiex_private *priv, int channel)
-{
-       struct mwifiex_uap_bss_param *bss_cfg;
-       struct wiphy *wiphy = priv->wdev->wiphy;
-
-       bss_cfg = kzalloc(sizeof(struct mwifiex_uap_bss_param), GFP_KERNEL);
-       if (!bss_cfg)
-               return -ENOMEM;
-
-       bss_cfg->band_cfg = BAND_CONFIG_MANUAL;
-       bss_cfg->channel = channel;
-
-       if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG,
-                                  HostCmd_ACT_GEN_SET,
-                                  UAP_BSS_PARAMS_I, bss_cfg)) {
-               wiphy_err(wiphy, "Failed to set the uAP channel\n");
-               kfree(bss_cfg);
-               return -1;
-       }
-
-       kfree(bss_cfg);
-       return 0;
-}
This page took 0.026234 seconds and 5 git commands to generate.