mwifiex: rearrange AP sys configure code
authorAvinash Patil <patila@marvell.com>
Wed, 9 May 2012 01:30:27 +0000 (18:30 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 16 May 2012 16:46:36 +0000 (12:46 -0400)
This patch takes into account AP config_type
(bss config/custom ie config) while preparing AP
sys_configure command buffer.

Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Kiran Divekar <dkiran@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mwifiex/cfg80211.c
drivers/net/wireless/mwifiex/fw.h
drivers/net/wireless/mwifiex/uap_cmd.c

index 6c343218d9f0fbc4d38c6e878326524e1e873834..d305b373aee020c68a5fe13482f3882f9c764afe 100644 (file)
@@ -502,7 +502,7 @@ mwifiex_cfg80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
                        ret = mwifiex_send_cmd_async(priv,
                                                     HostCmd_CMD_UAP_SYS_CONFIG,
                                                     HostCmd_ACT_GEN_SET,
-                                                    0, bss_cfg);
+                                                    UAP_BSS_PARAMS_I, bss_cfg);
 
                        kfree(bss_cfg);
 
@@ -983,7 +983,8 @@ static int mwifiex_cfg80211_start_ap(struct wiphy *wiphy,
        }
 
        if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG,
-                                  HostCmd_ACT_GEN_SET, 0, bss_cfg)) {
+                                  HostCmd_ACT_GEN_SET,
+                                  UAP_BSS_PARAMS_I, bss_cfg)) {
                wiphy_err(wiphy, "Failed to set the SSID\n");
                kfree(bss_cfg);
                return -1;
index 57fd0ca6e42812b74249a9fc40ee6f2aa4f0b54f..4fd7a05fee18a3403453a6fc4f5631a9470d2155 100644 (file)
@@ -93,6 +93,8 @@ enum MWIFIEX_802_11_PRIVACY_FILTER {
 
 #define CAL_SNR(RSSI, NF)              ((s16)((s16)(RSSI)-(s16)(NF)))
 
+#define UAP_BSS_PARAMS_I                       0
+
 #define TLV_TYPE_UAP_SSID                      0x0000
 
 #define PROPRIETARY_TLV_BASE_ID                 0x0100
index 0cfe88849e942982e72f9b89787f68e4b78280f1..e43bcaafa1bdef8dd77d49d490aa5699a77d5f7c 100644 (file)
@@ -123,14 +123,12 @@ void mwifiex_set_sys_config_invalid_data(struct mwifiex_uap_bss_param *config)
        config->retry_limit = 0x7F;
 }
 
-/* Parse AP config structure and prepare TLV based command structure
- * to be sent to FW for uAP configuration
- */
-static int mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd,
-                                     u16 cmd_action, void *cmd_buf)
+/* This function parses BSS related parameters from structure
+ * and prepares TLVs. These TLVs are appended to command buffer.
+*/
+static int
+mwifiex_uap_bss_param_prepare(u8 *tlv, void *cmd_buf, u16 *param_size)
 {
-       u8 *tlv;
-       struct host_cmd_ds_sys_config *sys_config = &cmd->params.uap_sys_config;
        struct host_cmd_tlv_dtim_period *dtim_period;
        struct host_cmd_tlv_beacon_period *beacon_period;
        struct host_cmd_tlv_ssid *ssid;
@@ -145,14 +143,7 @@ static int mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd,
        struct host_cmd_tlv_passphrase *passphrase;
        struct host_cmd_tlv_akmp *tlv_akmp;
        struct mwifiex_uap_bss_param *bss_cfg = cmd_buf;
-       u16 cmd_size;
-
-       cmd->command = cpu_to_le16(HostCmd_CMD_UAP_SYS_CONFIG);
-       cmd_size = (u16)(sizeof(struct host_cmd_ds_sys_config) + S_DS_GEN);
-
-       sys_config->action = cpu_to_le16(cmd_action);
-
-       tlv = sys_config->tlv;
+       u16 cmd_size = *param_size;
 
        if (bss_cfg->ssid.ssid_len) {
                ssid = (struct host_cmd_tlv_ssid *)tlv;
@@ -319,7 +310,39 @@ static int mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd,
                tlv += sizeof(struct host_cmd_tlv_encrypt_protocol);
        }
 
-       cmd->size = cpu_to_le16(cmd_size);
+       *param_size = cmd_size;
+
+       return 0;
+}
+
+/* Parse AP config structure and prepare TLV based command structure
+ * to be sent to FW for uAP configuration
+ */
+static int
+mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd, u16 cmd_action,
+                          u32 type, void *cmd_buf)
+{
+       u8 *tlv;
+       u16 cmd_size, param_size;
+       struct host_cmd_ds_sys_config *sys_cfg;
+
+       cmd->command = cpu_to_le16(HostCmd_CMD_UAP_SYS_CONFIG);
+       cmd_size = (u16)(sizeof(struct host_cmd_ds_sys_config) + S_DS_GEN);
+       sys_cfg = (struct host_cmd_ds_sys_config *)&cmd->params.uap_sys_config;
+       sys_cfg->action = cpu_to_le16(cmd_action);
+       tlv = sys_cfg->tlv;
+
+       switch (type) {
+       case UAP_BSS_PARAMS_I:
+               param_size = cmd_size;
+               if (mwifiex_uap_bss_param_prepare(tlv, cmd_buf, &param_size))
+                       return -1;
+               cmd->size = cpu_to_le16(param_size);
+               break;
+       default:
+               return -1;
+       }
+
        return 0;
 }
 
@@ -329,14 +352,14 @@ static int mwifiex_cmd_uap_sys_config(struct host_cmd_ds_command *cmd,
  * routines based upon the command number.
  */
 int mwifiex_uap_prepare_cmd(struct mwifiex_private *priv, u16 cmd_no,
-                           u16 cmd_action, u32 cmd_oid,
+                           u16 cmd_action, u32 type,
                            void *data_buf, void *cmd_buf)
 {
        struct host_cmd_ds_command *cmd = cmd_buf;
 
        switch (cmd_no) {
        case HostCmd_CMD_UAP_SYS_CONFIG:
-               if (mwifiex_cmd_uap_sys_config(cmd, cmd_action, data_buf))
+               if (mwifiex_cmd_uap_sys_config(cmd, cmd_action, type, data_buf))
                        return -1;
                break;
        case HostCmd_CMD_UAP_BSS_START:
@@ -371,7 +394,8 @@ int mwifiex_uap_set_channel(struct mwifiex_private *priv, int channel)
        bss_cfg->channel = channel;
 
        if (mwifiex_send_cmd_async(priv, HostCmd_CMD_UAP_SYS_CONFIG,
-                                  HostCmd_ACT_GEN_SET, 0, bss_cfg)) {
+                                  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;