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