Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Marvell Wireless LAN device driver: station command response handling |
| 3 | * |
| 4 | * Copyright (C) 2011, Marvell International Ltd. |
| 5 | * |
| 6 | * This software file (the "File") is distributed by Marvell International |
| 7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 |
| 8 | * (the "License"). You may use, redistribute and/or modify this File in |
| 9 | * accordance with the terms and conditions of the License, a copy of which |
| 10 | * is available by writing to the Free Software Foundation, Inc., |
| 11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the |
| 12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
| 13 | * |
| 14 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE |
| 16 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about |
| 17 | * this warranty disclaimer. |
| 18 | */ |
| 19 | |
| 20 | #include "decl.h" |
| 21 | #include "ioctl.h" |
| 22 | #include "util.h" |
| 23 | #include "fw.h" |
| 24 | #include "main.h" |
| 25 | #include "wmm.h" |
| 26 | #include "11n.h" |
| 27 | |
| 28 | |
| 29 | /* |
| 30 | * This function handles the command response error case. |
| 31 | * |
| 32 | * For scan response error, the function cancels all the pending |
| 33 | * scan commands and generates an event to inform the applications |
| 34 | * of the scan completion. |
| 35 | * |
| 36 | * For Power Save command failure, we do not retry enter PS |
| 37 | * command in case of Ad-hoc mode. |
| 38 | * |
| 39 | * For all other response errors, the current command buffer is freed |
| 40 | * and returned to the free command queue. |
| 41 | */ |
| 42 | static void |
| 43 | mwifiex_process_cmdresp_error(struct mwifiex_private *priv, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 44 | struct host_cmd_ds_command *resp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 45 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 46 | struct cmd_ctrl_node *cmd_node = NULL, *tmp_node; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 47 | struct mwifiex_adapter *adapter = priv->adapter; |
Marc Yang | 2b06bdb | 2011-03-30 18:12:44 -0700 | [diff] [blame] | 48 | struct host_cmd_ds_802_11_ps_mode_enh *pm; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 49 | unsigned long flags; |
| 50 | |
| 51 | dev_err(adapter->dev, "CMD_RESP: cmd %#x error, result=%#x\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 52 | resp->command, resp->result); |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 53 | |
| 54 | if (adapter->curr_cmd->wait_q_enabled) |
| 55 | adapter->cmd_wait_q.status = -1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 56 | |
| 57 | switch (le16_to_cpu(resp->command)) { |
| 58 | case HostCmd_CMD_802_11_PS_MODE_ENH: |
Marc Yang | 2b06bdb | 2011-03-30 18:12:44 -0700 | [diff] [blame] | 59 | pm = &resp->params.psmode_enh; |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 60 | dev_err(adapter->dev, |
| 61 | "PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n", |
| 62 | resp->result, le16_to_cpu(pm->action)); |
Marc Yang | 2b06bdb | 2011-03-30 18:12:44 -0700 | [diff] [blame] | 63 | /* We do not re-try enter-ps command in ad-hoc mode. */ |
| 64 | if (le16_to_cpu(pm->action) == EN_AUTO_PS && |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 65 | (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) && |
| 66 | priv->bss_mode == NL80211_IFTYPE_ADHOC) |
Marc Yang | 2b06bdb | 2011-03-30 18:12:44 -0700 | [diff] [blame] | 67 | adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM; |
| 68 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 69 | break; |
| 70 | case HostCmd_CMD_802_11_SCAN: |
| 71 | /* Cancel all pending scan command */ |
| 72 | spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); |
| 73 | list_for_each_entry_safe(cmd_node, tmp_node, |
| 74 | &adapter->scan_pending_q, list) { |
| 75 | list_del(&cmd_node->list); |
| 76 | spin_unlock_irqrestore(&adapter->scan_pending_q_lock, |
| 77 | flags); |
| 78 | mwifiex_insert_cmd_to_free_q(adapter, cmd_node); |
| 79 | spin_lock_irqsave(&adapter->scan_pending_q_lock, flags); |
| 80 | } |
| 81 | spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags); |
| 82 | |
| 83 | spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); |
| 84 | adapter->scan_processing = false; |
| 85 | spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); |
| 86 | if (priv->report_scan_result) |
| 87 | priv->report_scan_result = false; |
| 88 | if (priv->scan_pending_on_block) { |
| 89 | priv->scan_pending_on_block = false; |
| 90 | up(&priv->async_sem); |
| 91 | } |
| 92 | break; |
| 93 | |
| 94 | case HostCmd_CMD_MAC_CONTROL: |
| 95 | break; |
| 96 | |
| 97 | default: |
| 98 | break; |
| 99 | } |
| 100 | /* Handling errors here */ |
| 101 | mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd); |
| 102 | |
| 103 | spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags); |
| 104 | adapter->curr_cmd = NULL; |
| 105 | spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | /* |
| 109 | * This function handles the command response of get RSSI info. |
| 110 | * |
| 111 | * Handling includes changing the header fields into CPU format |
| 112 | * and saving the following parameters in driver - |
| 113 | * - Last data and beacon RSSI value |
| 114 | * - Average data and beacon RSSI value |
| 115 | * - Last data and beacon NF value |
| 116 | * - Average data and beacon NF value |
| 117 | * |
| 118 | * The parameters are send to the application as well, along with |
| 119 | * calculated SNR values. |
| 120 | */ |
| 121 | static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv, |
Amitkumar Karwar | 958a4a8 | 2012-03-15 20:51:49 -0700 | [diff] [blame^] | 122 | struct host_cmd_ds_command *resp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 123 | { |
| 124 | struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 125 | &resp->params.rssi_info_rsp; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 126 | |
| 127 | priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last); |
| 128 | priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last); |
| 129 | |
| 130 | priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg); |
| 131 | priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg); |
| 132 | |
| 133 | priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last); |
| 134 | priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last); |
| 135 | |
| 136 | priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg); |
| 137 | priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg); |
| 138 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | /* |
| 143 | * This function handles the command response of set/get SNMP |
| 144 | * MIB parameters. |
| 145 | * |
| 146 | * Handling includes changing the header fields into CPU format |
| 147 | * and saving the parameter in driver. |
| 148 | * |
| 149 | * The following parameters are supported - |
| 150 | * - Fragmentation threshold |
| 151 | * - RTS threshold |
| 152 | * - Short retry limit |
| 153 | */ |
| 154 | static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv, |
| 155 | struct host_cmd_ds_command *resp, |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 156 | u32 *data_buf) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 157 | { |
| 158 | struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib; |
| 159 | u16 oid = le16_to_cpu(smib->oid); |
| 160 | u16 query_type = le16_to_cpu(smib->query_type); |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 161 | u32 ul_temp; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 162 | |
| 163 | dev_dbg(priv->adapter->dev, "info: SNMP_RESP: oid value = %#x," |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 164 | " query_type = %#x, buf size = %#x\n", |
| 165 | oid, query_type, le16_to_cpu(smib->buf_size)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 166 | if (query_type == HostCmd_ACT_GEN_GET) { |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 167 | ul_temp = le16_to_cpu(*((__le16 *) (smib->value))); |
| 168 | if (data_buf) |
| 169 | *data_buf = ul_temp; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 170 | switch (oid) { |
| 171 | case FRAG_THRESH_I: |
| 172 | dev_dbg(priv->adapter->dev, |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 173 | "info: SNMP_RESP: FragThsd =%u\n", ul_temp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 174 | break; |
| 175 | case RTS_THRESH_I: |
| 176 | dev_dbg(priv->adapter->dev, |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 177 | "info: SNMP_RESP: RTSThsd =%u\n", ul_temp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 178 | break; |
| 179 | case SHORT_RETRY_LIM_I: |
| 180 | dev_dbg(priv->adapter->dev, |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 181 | "info: SNMP_RESP: TxRetryCount=%u\n", ul_temp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 182 | break; |
Amitkumar Karwar | caf60a6 | 2012-02-02 20:48:58 -0800 | [diff] [blame] | 183 | case DTIM_PERIOD_I: |
| 184 | dev_dbg(priv->adapter->dev, |
| 185 | "info: SNMP_RESP: DTIM period=%u\n", ul_temp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 186 | default: |
| 187 | break; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | return 0; |
| 192 | } |
| 193 | |
| 194 | /* |
| 195 | * This function handles the command response of get log request |
| 196 | * |
| 197 | * Handling includes changing the header fields into CPU format |
| 198 | * and sending the received parameters to application. |
| 199 | */ |
| 200 | static int mwifiex_ret_get_log(struct mwifiex_private *priv, |
| 201 | struct host_cmd_ds_command *resp, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 202 | struct mwifiex_ds_get_stats *stats) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 203 | { |
| 204 | struct host_cmd_ds_802_11_get_log *get_log = |
| 205 | (struct host_cmd_ds_802_11_get_log *) &resp->params.get_log; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 206 | |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 207 | if (stats) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 208 | stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame); |
| 209 | stats->failed = le32_to_cpu(get_log->failed); |
| 210 | stats->retry = le32_to_cpu(get_log->retry); |
| 211 | stats->multi_retry = le32_to_cpu(get_log->multi_retry); |
| 212 | stats->frame_dup = le32_to_cpu(get_log->frame_dup); |
| 213 | stats->rts_success = le32_to_cpu(get_log->rts_success); |
| 214 | stats->rts_failure = le32_to_cpu(get_log->rts_failure); |
| 215 | stats->ack_failure = le32_to_cpu(get_log->ack_failure); |
| 216 | stats->rx_frag = le32_to_cpu(get_log->rx_frag); |
| 217 | stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame); |
| 218 | stats->fcs_error = le32_to_cpu(get_log->fcs_error); |
| 219 | stats->tx_frame = le32_to_cpu(get_log->tx_frame); |
| 220 | stats->wep_icv_error[0] = |
| 221 | le32_to_cpu(get_log->wep_icv_err_cnt[0]); |
| 222 | stats->wep_icv_error[1] = |
| 223 | le32_to_cpu(get_log->wep_icv_err_cnt[1]); |
| 224 | stats->wep_icv_error[2] = |
| 225 | le32_to_cpu(get_log->wep_icv_err_cnt[2]); |
| 226 | stats->wep_icv_error[3] = |
| 227 | le32_to_cpu(get_log->wep_icv_err_cnt[3]); |
| 228 | } |
| 229 | |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | /* |
| 234 | * This function handles the command response of set/get Tx rate |
| 235 | * configurations. |
| 236 | * |
| 237 | * Handling includes changing the header fields into CPU format |
| 238 | * and saving the following parameters in driver - |
| 239 | * - DSSS rate bitmap |
| 240 | * - OFDM rate bitmap |
| 241 | * - HT MCS rate bitmaps |
| 242 | * |
| 243 | * Based on the new rate bitmaps, the function re-evaluates if |
| 244 | * auto data rate has been activated. If not, it sends another |
| 245 | * query to the firmware to get the current Tx data rate and updates |
| 246 | * the driver value. |
| 247 | */ |
| 248 | static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv, |
| 249 | struct host_cmd_ds_command *resp, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 250 | struct mwifiex_rate_cfg *ds_rate) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 251 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 252 | struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg; |
| 253 | struct mwifiex_rate_scope *rate_scope; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 254 | struct mwifiex_ie_types_header *head; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 255 | u16 tlv, tlv_buf_len; |
| 256 | u8 *tlv_buf; |
| 257 | u32 i; |
| 258 | int ret = 0; |
| 259 | |
| 260 | tlv_buf = (u8 *) ((u8 *) rate_cfg) + |
| 261 | sizeof(struct host_cmd_ds_tx_rate_cfg); |
| 262 | tlv_buf_len = *(u16 *) (tlv_buf + sizeof(u16)); |
| 263 | |
| 264 | while (tlv_buf && tlv_buf_len > 0) { |
| 265 | tlv = (*tlv_buf); |
| 266 | tlv = tlv | (*(tlv_buf + 1) << 8); |
| 267 | |
| 268 | switch (tlv) { |
| 269 | case TLV_TYPE_RATE_SCOPE: |
| 270 | rate_scope = (struct mwifiex_rate_scope *) tlv_buf; |
| 271 | priv->bitmap_rates[0] = |
| 272 | le16_to_cpu(rate_scope->hr_dsss_rate_bitmap); |
| 273 | priv->bitmap_rates[1] = |
| 274 | le16_to_cpu(rate_scope->ofdm_rate_bitmap); |
| 275 | for (i = 0; |
| 276 | i < |
| 277 | sizeof(rate_scope->ht_mcs_rate_bitmap) / |
| 278 | sizeof(u16); i++) |
| 279 | priv->bitmap_rates[2 + i] = |
| 280 | le16_to_cpu(rate_scope-> |
| 281 | ht_mcs_rate_bitmap[i]); |
| 282 | break; |
| 283 | /* Add RATE_DROP tlv here */ |
| 284 | } |
| 285 | |
| 286 | head = (struct mwifiex_ie_types_header *) tlv_buf; |
| 287 | tlv_buf += le16_to_cpu(head->len) + sizeof(*head); |
| 288 | tlv_buf_len -= le16_to_cpu(head->len); |
| 289 | } |
| 290 | |
| 291 | priv->is_data_rate_auto = mwifiex_is_rate_auto(priv); |
| 292 | |
| 293 | if (priv->is_data_rate_auto) |
| 294 | priv->data_rate = 0; |
| 295 | else |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 296 | ret = mwifiex_send_cmd_async(priv, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 297 | HostCmd_CMD_802_11_TX_RATE_QUERY, |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 298 | HostCmd_ACT_GEN_GET, 0, NULL); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 299 | |
Yogesh Ashok Powar | bb7de2b | 2012-03-12 19:35:12 -0700 | [diff] [blame] | 300 | if (!ds_rate) |
| 301 | return ret; |
| 302 | |
| 303 | if (le16_to_cpu(rate_cfg->action) == HostCmd_ACT_GEN_GET) { |
| 304 | if (priv->is_data_rate_auto) { |
| 305 | ds_rate->is_rate_auto = 1; |
| 306 | return ret; |
| 307 | } |
| 308 | ds_rate->rate = mwifiex_get_rate_index(priv->bitmap_rates, |
| 309 | sizeof(priv->bitmap_rates)); |
| 310 | |
| 311 | if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_OFDM0 && |
| 312 | ds_rate->rate <= MWIFIEX_RATE_BITMAP_OFDM7) |
| 313 | ds_rate->rate -= (MWIFIEX_RATE_BITMAP_OFDM0 - |
| 314 | MWIFIEX_RATE_INDEX_OFDM0); |
| 315 | |
| 316 | if (ds_rate->rate >= MWIFIEX_RATE_BITMAP_MCS0 && |
| 317 | ds_rate->rate <= MWIFIEX_RATE_BITMAP_MCS127) |
| 318 | ds_rate->rate -= (MWIFIEX_RATE_BITMAP_MCS0 - |
| 319 | MWIFIEX_RATE_INDEX_MCS0); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | return ret; |
| 323 | } |
| 324 | |
| 325 | /* |
| 326 | * This function handles the command response of get Tx power level. |
| 327 | * |
| 328 | * Handling includes saving the maximum and minimum Tx power levels |
| 329 | * in driver, as well as sending the values to user. |
| 330 | */ |
| 331 | static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf) |
| 332 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 333 | int length, max_power = -1, min_power = -1; |
| 334 | struct mwifiex_types_power_group *pg_tlv_hdr; |
| 335 | struct mwifiex_power_group *pg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 336 | |
Yogesh Ashok Powar | bb7de2b | 2012-03-12 19:35:12 -0700 | [diff] [blame] | 337 | if (!data_buf) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 338 | return -1; |
Yogesh Ashok Powar | bb7de2b | 2012-03-12 19:35:12 -0700 | [diff] [blame] | 339 | |
| 340 | pg_tlv_hdr = (struct mwifiex_types_power_group *) |
| 341 | ((u8 *) data_buf + sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 342 | pg = (struct mwifiex_power_group *) |
| 343 | ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group)); |
| 344 | length = pg_tlv_hdr->length; |
| 345 | if (length > 0) { |
| 346 | max_power = pg->power_max; |
| 347 | min_power = pg->power_min; |
| 348 | length -= sizeof(struct mwifiex_power_group); |
| 349 | } |
| 350 | while (length) { |
| 351 | pg++; |
| 352 | if (max_power < pg->power_max) |
| 353 | max_power = pg->power_max; |
| 354 | |
| 355 | if (min_power > pg->power_min) |
| 356 | min_power = pg->power_min; |
| 357 | |
| 358 | length -= sizeof(struct mwifiex_power_group); |
| 359 | } |
| 360 | if (pg_tlv_hdr->length > 0) { |
| 361 | priv->min_tx_power_level = (u8) min_power; |
| 362 | priv->max_tx_power_level = (u8) max_power; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | /* |
| 369 | * This function handles the command response of set/get Tx power |
| 370 | * configurations. |
| 371 | * |
| 372 | * Handling includes changing the header fields into CPU format |
| 373 | * and saving the current Tx power level in driver. |
| 374 | */ |
| 375 | static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 376 | struct host_cmd_ds_command *resp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 377 | { |
| 378 | struct mwifiex_adapter *adapter = priv->adapter; |
| 379 | struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg; |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 380 | struct mwifiex_types_power_group *pg_tlv_hdr; |
| 381 | struct mwifiex_power_group *pg; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 382 | u16 action = le16_to_cpu(txp_cfg->action); |
| 383 | |
| 384 | switch (action) { |
| 385 | case HostCmd_ACT_GEN_GET: |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 386 | pg_tlv_hdr = (struct mwifiex_types_power_group *) |
| 387 | ((u8 *) txp_cfg + |
| 388 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 389 | |
| 390 | pg = (struct mwifiex_power_group *) |
| 391 | ((u8 *) pg_tlv_hdr + |
| 392 | sizeof(struct mwifiex_types_power_group)); |
| 393 | |
| 394 | if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING) |
| 395 | mwifiex_get_power_level(priv, txp_cfg); |
| 396 | |
| 397 | priv->tx_power_level = (u16) pg->power_min; |
| 398 | break; |
| 399 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 400 | case HostCmd_ACT_GEN_SET: |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 401 | if (!le32_to_cpu(txp_cfg->mode)) |
| 402 | break; |
| 403 | |
| 404 | pg_tlv_hdr = (struct mwifiex_types_power_group *) |
| 405 | ((u8 *) txp_cfg + |
| 406 | sizeof(struct host_cmd_ds_txpwr_cfg)); |
| 407 | |
| 408 | pg = (struct mwifiex_power_group *) |
| 409 | ((u8 *) pg_tlv_hdr + |
| 410 | sizeof(struct mwifiex_types_power_group)); |
| 411 | |
| 412 | if (pg->power_max == pg->power_min) |
| 413 | priv->tx_power_level = (u16) pg->power_min; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 414 | break; |
| 415 | default: |
| 416 | dev_err(adapter->dev, "CMD_RESP: unknown cmd action %d\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 417 | action); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 418 | return 0; |
| 419 | } |
| 420 | dev_dbg(adapter->dev, |
| 421 | "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n", |
| 422 | priv->tx_power_level, priv->max_tx_power_level, |
| 423 | priv->min_tx_power_level); |
| 424 | |
| 425 | return 0; |
| 426 | } |
| 427 | |
| 428 | /* |
| 429 | * This function handles the command response of set/get MAC address. |
| 430 | * |
| 431 | * Handling includes saving the MAC address in driver. |
| 432 | */ |
| 433 | static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv, |
| 434 | struct host_cmd_ds_command *resp) |
| 435 | { |
| 436 | struct host_cmd_ds_802_11_mac_address *cmd_mac_addr = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 437 | &resp->params.mac_addr; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 438 | |
| 439 | memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN); |
| 440 | |
| 441 | dev_dbg(priv->adapter->dev, |
| 442 | "info: set mac address: %pM\n", priv->curr_addr); |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | /* |
| 448 | * This function handles the command response of set/get MAC multicast |
| 449 | * address. |
| 450 | */ |
| 451 | static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv, |
| 452 | struct host_cmd_ds_command *resp) |
| 453 | { |
| 454 | return 0; |
| 455 | } |
| 456 | |
| 457 | /* |
| 458 | * This function handles the command response of get Tx rate query. |
| 459 | * |
| 460 | * Handling includes changing the header fields into CPU format |
| 461 | * and saving the Tx rate and HT information parameters in driver. |
| 462 | * |
| 463 | * Both rate configuration and current data rate can be retrieved |
| 464 | * with this request. |
| 465 | */ |
| 466 | static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv, |
| 467 | struct host_cmd_ds_command *resp) |
| 468 | { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 469 | priv->tx_rate = resp->params.tx_rate.tx_rate; |
| 470 | priv->tx_htinfo = resp->params.tx_rate.ht_info; |
| 471 | if (!priv->is_data_rate_auto) |
| 472 | priv->data_rate = |
Bing Zhao | e3bea1c | 2011-11-16 20:40:35 -0800 | [diff] [blame] | 473 | mwifiex_index_to_data_rate(priv, priv->tx_rate, |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 474 | priv->tx_htinfo); |
| 475 | |
| 476 | return 0; |
| 477 | } |
| 478 | |
| 479 | /* |
| 480 | * This function handles the command response of a deauthenticate |
| 481 | * command. |
| 482 | * |
| 483 | * If the deauthenticated MAC matches the current BSS MAC, the connection |
| 484 | * state is reset. |
| 485 | */ |
| 486 | static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv, |
| 487 | struct host_cmd_ds_command *resp) |
| 488 | { |
| 489 | struct mwifiex_adapter *adapter = priv->adapter; |
| 490 | |
| 491 | adapter->dbg.num_cmd_deauth++; |
| 492 | if (!memcmp(resp->params.deauth.mac_addr, |
| 493 | &priv->curr_bss_params.bss_descriptor.mac_address, |
| 494 | sizeof(resp->params.deauth.mac_addr))) |
| 495 | mwifiex_reset_connect_state(priv); |
| 496 | |
| 497 | return 0; |
| 498 | } |
| 499 | |
| 500 | /* |
| 501 | * This function handles the command response of ad-hoc stop. |
| 502 | * |
| 503 | * The function resets the connection state in driver. |
| 504 | */ |
| 505 | static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv, |
| 506 | struct host_cmd_ds_command *resp) |
| 507 | { |
| 508 | mwifiex_reset_connect_state(priv); |
| 509 | return 0; |
| 510 | } |
| 511 | |
| 512 | /* |
| 513 | * This function handles the command response of set/get key material. |
| 514 | * |
| 515 | * Handling includes updating the driver parameters to reflect the |
| 516 | * changes. |
| 517 | */ |
| 518 | static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv, |
| 519 | struct host_cmd_ds_command *resp) |
| 520 | { |
| 521 | struct host_cmd_ds_802_11_key_material *key = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 522 | &resp->params.key_material; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 523 | |
| 524 | if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) { |
Yogesh Ashok Powar | 6a35a0a | 2011-04-06 16:46:56 -0700 | [diff] [blame] | 525 | if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 526 | dev_dbg(priv->adapter->dev, "info: key: GTK is set\n"); |
| 527 | priv->wpa_is_gtk_set = true; |
| 528 | priv->scan_block = false; |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | memset(priv->aes_key.key_param_set.key, 0, |
| 533 | sizeof(key->key_param_set.key)); |
| 534 | priv->aes_key.key_param_set.key_len = key->key_param_set.key_len; |
| 535 | memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key, |
| 536 | le16_to_cpu(priv->aes_key.key_param_set.key_len)); |
| 537 | |
| 538 | return 0; |
| 539 | } |
| 540 | |
| 541 | /* |
| 542 | * This function handles the command response of get 11d domain information. |
| 543 | */ |
| 544 | static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv, |
| 545 | struct host_cmd_ds_command *resp) |
| 546 | { |
| 547 | struct host_cmd_ds_802_11d_domain_info_rsp *domain_info = |
| 548 | &resp->params.domain_info_resp; |
| 549 | struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain; |
| 550 | u16 action = le16_to_cpu(domain_info->action); |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 551 | u8 no_of_triplet; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 552 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 553 | no_of_triplet = (u8) ((le16_to_cpu(domain->header.len) |
| 554 | - IEEE80211_COUNTRY_STRING_LEN) |
| 555 | / sizeof(struct ieee80211_country_ie_triplet)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 556 | |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 557 | dev_dbg(priv->adapter->dev, |
| 558 | "info: 11D Domain Info Resp: no_of_triplet=%d\n", |
| 559 | no_of_triplet); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 560 | |
| 561 | if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) { |
| 562 | dev_warn(priv->adapter->dev, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 563 | "11D: invalid number of triplets %d returned\n", |
| 564 | no_of_triplet); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 565 | return -1; |
| 566 | } |
| 567 | |
| 568 | switch (action) { |
| 569 | case HostCmd_ACT_GEN_SET: /* Proc Set Action */ |
| 570 | break; |
| 571 | case HostCmd_ACT_GEN_GET: |
| 572 | break; |
| 573 | default: |
| 574 | dev_err(priv->adapter->dev, |
| 575 | "11D: invalid action:%d\n", domain_info->action); |
| 576 | return -1; |
| 577 | } |
| 578 | |
| 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | /* |
| 583 | * This function handles the command response of get RF channel. |
| 584 | * |
| 585 | * Handling includes changing the header fields into CPU format |
| 586 | * and saving the new channel in driver. |
| 587 | */ |
| 588 | static int mwifiex_ret_802_11_rf_channel(struct mwifiex_private *priv, |
| 589 | struct host_cmd_ds_command *resp, |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 590 | u16 *data_buf) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 591 | { |
| 592 | struct host_cmd_ds_802_11_rf_channel *rf_channel = |
| 593 | &resp->params.rf_channel; |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 594 | u16 new_channel = le16_to_cpu(rf_channel->current_channel); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 595 | |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 596 | if (priv->curr_bss_params.bss_descriptor.channel != new_channel) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 597 | dev_dbg(priv->adapter->dev, "cmd: Channel Switch: %d to %d\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 598 | priv->curr_bss_params.bss_descriptor.channel, |
| 599 | new_channel); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 600 | /* Update the channel again */ |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 601 | priv->curr_bss_params.bss_descriptor.channel = new_channel; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 602 | } |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 603 | |
Dan Carpenter | a5e5aa6 | 2011-06-24 16:33:35 +0300 | [diff] [blame] | 604 | if (data_buf) |
| 605 | *data_buf = new_channel; |
| 606 | |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 607 | return 0; |
| 608 | } |
| 609 | |
| 610 | /* |
| 611 | * This function handles the command response of get extended version. |
| 612 | * |
| 613 | * Handling includes forming the extended version string and sending it |
| 614 | * to application. |
| 615 | */ |
| 616 | static int mwifiex_ret_ver_ext(struct mwifiex_private *priv, |
| 617 | struct host_cmd_ds_command *resp, |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 618 | struct host_cmd_ds_version_ext *version_ext) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 619 | { |
| 620 | struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 621 | |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 622 | if (version_ext) { |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 623 | version_ext->version_str_sel = ver_ext->version_str_sel; |
| 624 | memcpy(version_ext->version_str, ver_ext->version_str, |
| 625 | sizeof(char) * 128); |
| 626 | memcpy(priv->version_str, ver_ext->version_str, 128); |
| 627 | } |
| 628 | return 0; |
| 629 | } |
| 630 | |
| 631 | /* |
| 632 | * This function handles the command response of register access. |
| 633 | * |
| 634 | * The register value and offset are returned to the user. For EEPROM |
| 635 | * access, the byte count is also returned. |
| 636 | */ |
| 637 | static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp, |
| 638 | void *data_buf) |
| 639 | { |
Yogesh Ashok Powar | 270e58e | 2011-05-03 20:11:46 -0700 | [diff] [blame] | 640 | struct mwifiex_ds_reg_rw *reg_rw; |
| 641 | struct mwifiex_ds_read_eeprom *eeprom; |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 642 | union reg { |
| 643 | struct host_cmd_ds_mac_reg_access *mac; |
| 644 | struct host_cmd_ds_bbp_reg_access *bbp; |
| 645 | struct host_cmd_ds_rf_reg_access *rf; |
| 646 | struct host_cmd_ds_pmic_reg_access *pmic; |
| 647 | struct host_cmd_ds_802_11_eeprom_access *eeprom; |
| 648 | } r; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 649 | |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 650 | if (!data_buf) |
| 651 | return 0; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 652 | |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 653 | reg_rw = data_buf; |
| 654 | eeprom = data_buf; |
| 655 | switch (type) { |
| 656 | case HostCmd_CMD_MAC_REG_ACCESS: |
| 657 | r.mac = (struct host_cmd_ds_mac_reg_access *) |
| 658 | &resp->params.mac_reg; |
| 659 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset)); |
| 660 | reg_rw->value = r.mac->value; |
| 661 | break; |
| 662 | case HostCmd_CMD_BBP_REG_ACCESS: |
| 663 | r.bbp = (struct host_cmd_ds_bbp_reg_access *) |
| 664 | &resp->params.bbp_reg; |
| 665 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset)); |
| 666 | reg_rw->value = cpu_to_le32((u32) r.bbp->value); |
| 667 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 668 | |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 669 | case HostCmd_CMD_RF_REG_ACCESS: |
| 670 | r.rf = (struct host_cmd_ds_rf_reg_access *) |
| 671 | &resp->params.rf_reg; |
| 672 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset)); |
| 673 | reg_rw->value = cpu_to_le32((u32) r.bbp->value); |
| 674 | break; |
| 675 | case HostCmd_CMD_PMIC_REG_ACCESS: |
| 676 | r.pmic = (struct host_cmd_ds_pmic_reg_access *) |
| 677 | &resp->params.pmic_reg; |
| 678 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset)); |
| 679 | reg_rw->value = cpu_to_le32((u32) r.pmic->value); |
| 680 | break; |
| 681 | case HostCmd_CMD_CAU_REG_ACCESS: |
| 682 | r.rf = (struct host_cmd_ds_rf_reg_access *) |
| 683 | &resp->params.rf_reg; |
| 684 | reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset)); |
| 685 | reg_rw->value = cpu_to_le32((u32) r.rf->value); |
| 686 | break; |
| 687 | case HostCmd_CMD_802_11_EEPROM_ACCESS: |
| 688 | r.eeprom = (struct host_cmd_ds_802_11_eeprom_access *) |
| 689 | &resp->params.eeprom; |
| 690 | pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count); |
| 691 | if (le16_to_cpu(eeprom->byte_count) < |
| 692 | le16_to_cpu(r.eeprom->byte_count)) { |
| 693 | eeprom->byte_count = cpu_to_le16(0); |
| 694 | pr_debug("info: EEPROM read length is too big\n"); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 695 | return -1; |
| 696 | } |
Yogesh Ashok Powar | 985d68a | 2012-03-12 19:35:09 -0700 | [diff] [blame] | 697 | eeprom->offset = r.eeprom->offset; |
| 698 | eeprom->byte_count = r.eeprom->byte_count; |
| 699 | if (le16_to_cpu(eeprom->byte_count) > 0) |
| 700 | memcpy(&eeprom->value, &r.eeprom->value, |
| 701 | le16_to_cpu(r.eeprom->byte_count)); |
| 702 | |
| 703 | break; |
| 704 | default: |
| 705 | return -1; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 706 | } |
| 707 | return 0; |
| 708 | } |
| 709 | |
| 710 | /* |
| 711 | * This function handles the command response of get IBSS coalescing status. |
| 712 | * |
| 713 | * If the received BSSID is different than the current one, the current BSSID, |
| 714 | * beacon interval, ATIM window and ERP information are updated, along with |
| 715 | * changing the ad-hoc state accordingly. |
| 716 | */ |
| 717 | static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv, |
| 718 | struct host_cmd_ds_command *resp) |
| 719 | { |
| 720 | struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp = |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 721 | &(resp->params.ibss_coalescing); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 722 | u8 zero_mac[ETH_ALEN] = { 0, 0, 0, 0, 0, 0 }; |
| 723 | |
| 724 | if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET) |
| 725 | return 0; |
| 726 | |
| 727 | dev_dbg(priv->adapter->dev, |
| 728 | "info: new BSSID %pM\n", ibss_coal_resp->bssid); |
| 729 | |
| 730 | /* If rsp has NULL BSSID, Just return..... No Action */ |
| 731 | if (!memcmp(ibss_coal_resp->bssid, zero_mac, ETH_ALEN)) { |
| 732 | dev_warn(priv->adapter->dev, "new BSSID is NULL\n"); |
| 733 | return 0; |
| 734 | } |
| 735 | |
| 736 | /* If BSSID is diff, modify current BSS parameters */ |
| 737 | if (memcmp(priv->curr_bss_params.bss_descriptor.mac_address, |
| 738 | ibss_coal_resp->bssid, ETH_ALEN)) { |
| 739 | /* BSSID */ |
| 740 | memcpy(priv->curr_bss_params.bss_descriptor.mac_address, |
| 741 | ibss_coal_resp->bssid, ETH_ALEN); |
| 742 | |
| 743 | /* Beacon Interval */ |
| 744 | priv->curr_bss_params.bss_descriptor.beacon_period |
| 745 | = le16_to_cpu(ibss_coal_resp->beacon_interval); |
| 746 | |
| 747 | /* ERP Information */ |
| 748 | priv->curr_bss_params.bss_descriptor.erp_flags = |
| 749 | (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect); |
| 750 | |
| 751 | priv->adhoc_state = ADHOC_COALESCED; |
| 752 | } |
| 753 | |
| 754 | return 0; |
| 755 | } |
| 756 | |
| 757 | /* |
| 758 | * This function handles the command responses. |
| 759 | * |
| 760 | * This is a generic function, which calls command specific |
| 761 | * response handlers based on the command ID. |
| 762 | */ |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 763 | int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no, |
| 764 | struct host_cmd_ds_command *resp) |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 765 | { |
| 766 | int ret = 0; |
| 767 | struct mwifiex_adapter *adapter = priv->adapter; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 768 | void *data_buf = adapter->curr_cmd->data_buf; |
| 769 | |
| 770 | /* If the command is not successful, cleanup and return failure */ |
| 771 | if (resp->result != HostCmd_RESULT_OK) { |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 772 | mwifiex_process_cmdresp_error(priv, resp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 773 | return -1; |
| 774 | } |
| 775 | /* Command successful, handle response */ |
| 776 | switch (cmdresp_no) { |
| 777 | case HostCmd_CMD_GET_HW_SPEC: |
| 778 | ret = mwifiex_ret_get_hw_spec(priv, resp); |
| 779 | break; |
| 780 | case HostCmd_CMD_MAC_CONTROL: |
| 781 | break; |
| 782 | case HostCmd_CMD_802_11_MAC_ADDRESS: |
| 783 | ret = mwifiex_ret_802_11_mac_address(priv, resp); |
| 784 | break; |
| 785 | case HostCmd_CMD_MAC_MULTICAST_ADR: |
| 786 | ret = mwifiex_ret_mac_multicast_adr(priv, resp); |
| 787 | break; |
| 788 | case HostCmd_CMD_TX_RATE_CFG: |
| 789 | ret = mwifiex_ret_tx_rate_cfg(priv, resp, data_buf); |
| 790 | break; |
| 791 | case HostCmd_CMD_802_11_SCAN: |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 792 | ret = mwifiex_ret_802_11_scan(priv, resp); |
| 793 | adapter->curr_cmd->wait_q_enabled = false; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 794 | break; |
| 795 | case HostCmd_CMD_802_11_BG_SCAN_QUERY: |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 796 | ret = mwifiex_ret_802_11_scan(priv, resp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 797 | dev_dbg(adapter->dev, |
| 798 | "info: CMD_RESP: BG_SCAN result is ready!\n"); |
| 799 | break; |
| 800 | case HostCmd_CMD_TXPWR_CFG: |
Amitkumar Karwar | a5ffddb | 2011-06-20 15:21:48 -0700 | [diff] [blame] | 801 | ret = mwifiex_ret_tx_power_cfg(priv, resp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 802 | break; |
| 803 | case HostCmd_CMD_802_11_PS_MODE_ENH: |
| 804 | ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf); |
| 805 | break; |
| 806 | case HostCmd_CMD_802_11_HS_CFG_ENH: |
| 807 | ret = mwifiex_ret_802_11_hs_cfg(priv, resp); |
| 808 | break; |
| 809 | case HostCmd_CMD_802_11_ASSOCIATE: |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 810 | ret = mwifiex_ret_802_11_associate(priv, resp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 811 | break; |
| 812 | case HostCmd_CMD_802_11_DEAUTHENTICATE: |
| 813 | ret = mwifiex_ret_802_11_deauthenticate(priv, resp); |
| 814 | break; |
| 815 | case HostCmd_CMD_802_11_AD_HOC_START: |
| 816 | case HostCmd_CMD_802_11_AD_HOC_JOIN: |
Amitkumar Karwar | 600f5d9 | 2011-04-13 17:27:06 -0700 | [diff] [blame] | 817 | ret = mwifiex_ret_802_11_ad_hoc(priv, resp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 818 | break; |
| 819 | case HostCmd_CMD_802_11_AD_HOC_STOP: |
| 820 | ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp); |
| 821 | break; |
| 822 | case HostCmd_CMD_802_11_GET_LOG: |
| 823 | ret = mwifiex_ret_get_log(priv, resp, data_buf); |
| 824 | break; |
| 825 | case HostCmd_CMD_RSSI_INFO: |
Amitkumar Karwar | 958a4a8 | 2012-03-15 20:51:49 -0700 | [diff] [blame^] | 826 | ret = mwifiex_ret_802_11_rssi_info(priv, resp); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 827 | break; |
| 828 | case HostCmd_CMD_802_11_SNMP_MIB: |
| 829 | ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf); |
| 830 | break; |
| 831 | case HostCmd_CMD_802_11_TX_RATE_QUERY: |
| 832 | ret = mwifiex_ret_802_11_tx_rate_query(priv, resp); |
| 833 | break; |
| 834 | case HostCmd_CMD_802_11_RF_CHANNEL: |
| 835 | ret = mwifiex_ret_802_11_rf_channel(priv, resp, data_buf); |
| 836 | break; |
| 837 | case HostCmd_CMD_VERSION_EXT: |
| 838 | ret = mwifiex_ret_ver_ext(priv, resp, data_buf); |
| 839 | break; |
| 840 | case HostCmd_CMD_FUNC_INIT: |
| 841 | case HostCmd_CMD_FUNC_SHUTDOWN: |
| 842 | break; |
| 843 | case HostCmd_CMD_802_11_KEY_MATERIAL: |
| 844 | ret = mwifiex_ret_802_11_key_material(priv, resp); |
| 845 | break; |
| 846 | case HostCmd_CMD_802_11D_DOMAIN_INFO: |
| 847 | ret = mwifiex_ret_802_11d_domain_info(priv, resp); |
| 848 | break; |
| 849 | case HostCmd_CMD_11N_ADDBA_REQ: |
| 850 | ret = mwifiex_ret_11n_addba_req(priv, resp); |
| 851 | break; |
| 852 | case HostCmd_CMD_11N_DELBA: |
| 853 | ret = mwifiex_ret_11n_delba(priv, resp); |
| 854 | break; |
| 855 | case HostCmd_CMD_11N_ADDBA_RSP: |
| 856 | ret = mwifiex_ret_11n_addba_resp(priv, resp); |
| 857 | break; |
| 858 | case HostCmd_CMD_RECONFIGURE_TX_BUFF: |
| 859 | adapter->tx_buf_size = (u16) le16_to_cpu(resp->params. |
| 860 | tx_buf.buff_size); |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 861 | adapter->tx_buf_size = (adapter->tx_buf_size |
| 862 | / MWIFIEX_SDIO_BLOCK_SIZE) |
| 863 | * MWIFIEX_SDIO_BLOCK_SIZE; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 864 | adapter->curr_tx_buf_size = adapter->tx_buf_size; |
| 865 | dev_dbg(adapter->dev, |
| 866 | "cmd: max_tx_buf_size=%d, tx_buf_size=%d\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 867 | adapter->max_tx_buf_size, adapter->tx_buf_size); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 868 | |
| 869 | if (adapter->if_ops.update_mp_end_port) |
| 870 | adapter->if_ops.update_mp_end_port(adapter, |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 871 | le16_to_cpu(resp->params.tx_buf.mp_end_port)); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 872 | break; |
| 873 | case HostCmd_CMD_AMSDU_AGGR_CTRL: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 874 | ret = mwifiex_ret_amsdu_aggr_ctrl(resp, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 875 | break; |
| 876 | case HostCmd_CMD_WMM_GET_STATUS: |
| 877 | ret = mwifiex_ret_wmm_get_status(priv, resp); |
| 878 | break; |
| 879 | case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS: |
| 880 | ret = mwifiex_ret_ibss_coalescing_status(priv, resp); |
| 881 | break; |
| 882 | case HostCmd_CMD_MAC_REG_ACCESS: |
| 883 | case HostCmd_CMD_BBP_REG_ACCESS: |
| 884 | case HostCmd_CMD_RF_REG_ACCESS: |
| 885 | case HostCmd_CMD_PMIC_REG_ACCESS: |
| 886 | case HostCmd_CMD_CAU_REG_ACCESS: |
| 887 | case HostCmd_CMD_802_11_EEPROM_ACCESS: |
| 888 | ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf); |
| 889 | break; |
| 890 | case HostCmd_CMD_SET_BSS_MODE: |
| 891 | break; |
| 892 | case HostCmd_CMD_11N_CFG: |
Amitkumar Karwar | 572e8f3 | 2011-04-13 17:27:08 -0700 | [diff] [blame] | 893 | ret = mwifiex_ret_11n_cfg(resp, data_buf); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 894 | break; |
Amitkumar Karwar | d930fae | 2011-10-11 17:41:21 -0700 | [diff] [blame] | 895 | case HostCmd_CMD_PCIE_DESC_DETAILS: |
| 896 | break; |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 897 | default: |
| 898 | dev_err(adapter->dev, "CMD_RESP: unknown cmd response %#x\n", |
Yogesh Ashok Powar | 9c05fd7 | 2012-03-13 19:22:40 -0700 | [diff] [blame] | 899 | resp->command); |
Bing Zhao | 5e6e3a9 | 2011-03-21 18:00:50 -0700 | [diff] [blame] | 900 | break; |
| 901 | } |
| 902 | |
| 903 | return ret; |
| 904 | } |