+/* 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)
+{
+ u8 *tlv;
+ struct host_cmd_ds_sys_config *sys_config = &cmd->params.uap_sys_config;
+ struct host_cmd_tlv_channel_band *chan_band;
+ 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;
+
+ if (bss_cfg->channel && bss_cfg->channel <= MAX_CHANNEL_BAND_BG) {
+ chan_band = (struct host_cmd_tlv_channel_band *)tlv;
+ chan_band->tlv.type = cpu_to_le16(TLV_TYPE_CHANNELBANDLIST);
+ chan_band->tlv.len =
+ cpu_to_le16(sizeof(struct host_cmd_tlv_channel_band) -
+ sizeof(struct host_cmd_tlv));
+ chan_band->band_config = bss_cfg->band_cfg;
+ chan_band->channel = bss_cfg->channel;
+ cmd_size += sizeof(struct host_cmd_tlv_channel_band);
+ tlv += sizeof(struct host_cmd_tlv_channel_band);
+ }
+
+ cmd->size = cpu_to_le16(cmd_size);
+ return 0;
+}
+