linux/drivers/net/wireless/marvell/mwifiex/sta_cmdresp.c
<<
>>
Prefs
   1/*
   2 * Marvell Wireless LAN device driver: station command response handling
   3 *
   4 * Copyright (C) 2011-2014, 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#include "11ac.h"
  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 */
  43static void
  44mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
  45                              struct host_cmd_ds_command *resp)
  46{
  47        struct mwifiex_adapter *adapter = priv->adapter;
  48        struct host_cmd_ds_802_11_ps_mode_enh *pm;
  49        unsigned long flags;
  50
  51        mwifiex_dbg(adapter, ERROR,
  52                    "CMD_RESP: cmd %#x error, result=%#x\n",
  53                    resp->command, resp->result);
  54
  55        if (adapter->curr_cmd->wait_q_enabled)
  56                adapter->cmd_wait_q.status = -1;
  57
  58        switch (le16_to_cpu(resp->command)) {
  59        case HostCmd_CMD_802_11_PS_MODE_ENH:
  60                pm = &resp->params.psmode_enh;
  61                mwifiex_dbg(adapter, ERROR,
  62                            "PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n",
  63                            resp->result, le16_to_cpu(pm->action));
  64                /* We do not re-try enter-ps command in ad-hoc mode. */
  65                if (le16_to_cpu(pm->action) == EN_AUTO_PS &&
  66                    (le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) &&
  67                    priv->bss_mode == NL80211_IFTYPE_ADHOC)
  68                        adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
  69
  70                break;
  71        case HostCmd_CMD_802_11_SCAN:
  72        case HostCmd_CMD_802_11_SCAN_EXT:
  73                mwifiex_cancel_pending_scan_cmd(adapter);
  74
  75                spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
  76                adapter->scan_processing = false;
  77                spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
  78                break;
  79
  80        case HostCmd_CMD_MAC_CONTROL:
  81                break;
  82
  83        case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
  84                mwifiex_dbg(adapter, MSG,
  85                            "SDIO RX single-port aggregation Not support\n");
  86                break;
  87
  88        default:
  89                break;
  90        }
  91        /* Handling errors here */
  92        mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd);
  93
  94        spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
  95        adapter->curr_cmd = NULL;
  96        spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
  97}
  98
  99/*
 100 * This function handles the command response of get RSSI info.
 101 *
 102 * Handling includes changing the header fields into CPU format
 103 * and saving the following parameters in driver -
 104 *      - Last data and beacon RSSI value
 105 *      - Average data and beacon RSSI value
 106 *      - Last data and beacon NF value
 107 *      - Average data and beacon NF value
 108 *
 109 * The parameters are send to the application as well, along with
 110 * calculated SNR values.
 111 */
 112static int mwifiex_ret_802_11_rssi_info(struct mwifiex_private *priv,
 113                                        struct host_cmd_ds_command *resp)
 114{
 115        struct host_cmd_ds_802_11_rssi_info_rsp *rssi_info_rsp =
 116                                                &resp->params.rssi_info_rsp;
 117        struct mwifiex_ds_misc_subsc_evt *subsc_evt =
 118                                                &priv->async_subsc_evt_storage;
 119
 120        priv->data_rssi_last = le16_to_cpu(rssi_info_rsp->data_rssi_last);
 121        priv->data_nf_last = le16_to_cpu(rssi_info_rsp->data_nf_last);
 122
 123        priv->data_rssi_avg = le16_to_cpu(rssi_info_rsp->data_rssi_avg);
 124        priv->data_nf_avg = le16_to_cpu(rssi_info_rsp->data_nf_avg);
 125
 126        priv->bcn_rssi_last = le16_to_cpu(rssi_info_rsp->bcn_rssi_last);
 127        priv->bcn_nf_last = le16_to_cpu(rssi_info_rsp->bcn_nf_last);
 128
 129        priv->bcn_rssi_avg = le16_to_cpu(rssi_info_rsp->bcn_rssi_avg);
 130        priv->bcn_nf_avg = le16_to_cpu(rssi_info_rsp->bcn_nf_avg);
 131
 132        if (priv->subsc_evt_rssi_state == EVENT_HANDLED)
 133                return 0;
 134
 135        memset(subsc_evt, 0x00, sizeof(struct mwifiex_ds_misc_subsc_evt));
 136
 137        /* Resubscribe low and high rssi events with new thresholds */
 138        subsc_evt->events = BITMASK_BCN_RSSI_LOW | BITMASK_BCN_RSSI_HIGH;
 139        subsc_evt->action = HostCmd_ACT_BITWISE_SET;
 140        if (priv->subsc_evt_rssi_state == RSSI_LOW_RECVD) {
 141                subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg -
 142                                priv->cqm_rssi_hyst);
 143                subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
 144        } else if (priv->subsc_evt_rssi_state == RSSI_HIGH_RECVD) {
 145                subsc_evt->bcn_l_rssi_cfg.abs_value = abs(priv->cqm_rssi_thold);
 146                subsc_evt->bcn_h_rssi_cfg.abs_value = abs(priv->bcn_rssi_avg +
 147                                priv->cqm_rssi_hyst);
 148        }
 149        subsc_evt->bcn_l_rssi_cfg.evt_freq = 1;
 150        subsc_evt->bcn_h_rssi_cfg.evt_freq = 1;
 151
 152        priv->subsc_evt_rssi_state = EVENT_HANDLED;
 153
 154        mwifiex_send_cmd(priv, HostCmd_CMD_802_11_SUBSCRIBE_EVENT,
 155                         0, 0, subsc_evt, false);
 156
 157        return 0;
 158}
 159
 160/*
 161 * This function handles the command response of set/get SNMP
 162 * MIB parameters.
 163 *
 164 * Handling includes changing the header fields into CPU format
 165 * and saving the parameter in driver.
 166 *
 167 * The following parameters are supported -
 168 *      - Fragmentation threshold
 169 *      - RTS threshold
 170 *      - Short retry limit
 171 */
 172static int mwifiex_ret_802_11_snmp_mib(struct mwifiex_private *priv,
 173                                       struct host_cmd_ds_command *resp,
 174                                       u32 *data_buf)
 175{
 176        struct host_cmd_ds_802_11_snmp_mib *smib = &resp->params.smib;
 177        u16 oid = le16_to_cpu(smib->oid);
 178        u16 query_type = le16_to_cpu(smib->query_type);
 179        u32 ul_temp;
 180
 181        mwifiex_dbg(priv->adapter, INFO,
 182                    "info: SNMP_RESP: oid value = %#x,\t"
 183                    "query_type = %#x, buf size = %#x\n",
 184                    oid, query_type, le16_to_cpu(smib->buf_size));
 185        if (query_type == HostCmd_ACT_GEN_GET) {
 186                ul_temp = le16_to_cpu(*((__le16 *) (smib->value)));
 187                if (data_buf)
 188                        *data_buf = ul_temp;
 189                switch (oid) {
 190                case FRAG_THRESH_I:
 191                        mwifiex_dbg(priv->adapter, INFO,
 192                                    "info: SNMP_RESP: FragThsd =%u\n",
 193                                    ul_temp);
 194                        break;
 195                case RTS_THRESH_I:
 196                        mwifiex_dbg(priv->adapter, INFO,
 197                                    "info: SNMP_RESP: RTSThsd =%u\n",
 198                                    ul_temp);
 199                        break;
 200                case SHORT_RETRY_LIM_I:
 201                        mwifiex_dbg(priv->adapter, INFO,
 202                                    "info: SNMP_RESP: TxRetryCount=%u\n",
 203                                    ul_temp);
 204                        break;
 205                case DTIM_PERIOD_I:
 206                        mwifiex_dbg(priv->adapter, INFO,
 207                                    "info: SNMP_RESP: DTIM period=%u\n",
 208                                    ul_temp);
 209                default:
 210                        break;
 211                }
 212        }
 213
 214        return 0;
 215}
 216
 217/*
 218 * This function handles the command response of get log request
 219 *
 220 * Handling includes changing the header fields into CPU format
 221 * and sending the received parameters to application.
 222 */
 223static int mwifiex_ret_get_log(struct mwifiex_private *priv,
 224                               struct host_cmd_ds_command *resp,
 225                               struct mwifiex_ds_get_stats *stats)
 226{
 227        struct host_cmd_ds_802_11_get_log *get_log =
 228                &resp->params.get_log;
 229
 230        if (stats) {
 231                stats->mcast_tx_frame = le32_to_cpu(get_log->mcast_tx_frame);
 232                stats->failed = le32_to_cpu(get_log->failed);
 233                stats->retry = le32_to_cpu(get_log->retry);
 234                stats->multi_retry = le32_to_cpu(get_log->multi_retry);
 235                stats->frame_dup = le32_to_cpu(get_log->frame_dup);
 236                stats->rts_success = le32_to_cpu(get_log->rts_success);
 237                stats->rts_failure = le32_to_cpu(get_log->rts_failure);
 238                stats->ack_failure = le32_to_cpu(get_log->ack_failure);
 239                stats->rx_frag = le32_to_cpu(get_log->rx_frag);
 240                stats->mcast_rx_frame = le32_to_cpu(get_log->mcast_rx_frame);
 241                stats->fcs_error = le32_to_cpu(get_log->fcs_error);
 242                stats->tx_frame = le32_to_cpu(get_log->tx_frame);
 243                stats->wep_icv_error[0] =
 244                        le32_to_cpu(get_log->wep_icv_err_cnt[0]);
 245                stats->wep_icv_error[1] =
 246                        le32_to_cpu(get_log->wep_icv_err_cnt[1]);
 247                stats->wep_icv_error[2] =
 248                        le32_to_cpu(get_log->wep_icv_err_cnt[2]);
 249                stats->wep_icv_error[3] =
 250                        le32_to_cpu(get_log->wep_icv_err_cnt[3]);
 251                stats->bcn_rcv_cnt = le32_to_cpu(get_log->bcn_rcv_cnt);
 252                stats->bcn_miss_cnt = le32_to_cpu(get_log->bcn_miss_cnt);
 253        }
 254
 255        return 0;
 256}
 257
 258/*
 259 * This function handles the command response of set/get Tx rate
 260 * configurations.
 261 *
 262 * Handling includes changing the header fields into CPU format
 263 * and saving the following parameters in driver -
 264 *      - DSSS rate bitmap
 265 *      - OFDM rate bitmap
 266 *      - HT MCS rate bitmaps
 267 *
 268 * Based on the new rate bitmaps, the function re-evaluates if
 269 * auto data rate has been activated. If not, it sends another
 270 * query to the firmware to get the current Tx data rate.
 271 */
 272static int mwifiex_ret_tx_rate_cfg(struct mwifiex_private *priv,
 273                                   struct host_cmd_ds_command *resp)
 274{
 275        struct host_cmd_ds_tx_rate_cfg *rate_cfg = &resp->params.tx_rate_cfg;
 276        struct mwifiex_rate_scope *rate_scope;
 277        struct mwifiex_ie_types_header *head;
 278        u16 tlv, tlv_buf_len, tlv_buf_left;
 279        u8 *tlv_buf;
 280        u32 i;
 281
 282        tlv_buf = ((u8 *)rate_cfg) + sizeof(struct host_cmd_ds_tx_rate_cfg);
 283        tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*rate_cfg);
 284
 285        while (tlv_buf_left >= sizeof(*head)) {
 286                head = (struct mwifiex_ie_types_header *)tlv_buf;
 287                tlv = le16_to_cpu(head->type);
 288                tlv_buf_len = le16_to_cpu(head->len);
 289
 290                if (tlv_buf_left < (sizeof(*head) + tlv_buf_len))
 291                        break;
 292
 293                switch (tlv) {
 294                case TLV_TYPE_RATE_SCOPE:
 295                        rate_scope = (struct mwifiex_rate_scope *) tlv_buf;
 296                        priv->bitmap_rates[0] =
 297                                le16_to_cpu(rate_scope->hr_dsss_rate_bitmap);
 298                        priv->bitmap_rates[1] =
 299                                le16_to_cpu(rate_scope->ofdm_rate_bitmap);
 300                        for (i = 0;
 301                             i <
 302                             sizeof(rate_scope->ht_mcs_rate_bitmap) /
 303                             sizeof(u16); i++)
 304                                priv->bitmap_rates[2 + i] =
 305                                        le16_to_cpu(rate_scope->
 306                                                    ht_mcs_rate_bitmap[i]);
 307
 308                        if (priv->adapter->fw_api_ver == MWIFIEX_FW_V15) {
 309                                for (i = 0; i < ARRAY_SIZE(rate_scope->
 310                                                           vht_mcs_rate_bitmap);
 311                                     i++)
 312                                        priv->bitmap_rates[10 + i] =
 313                                            le16_to_cpu(rate_scope->
 314                                                        vht_mcs_rate_bitmap[i]);
 315                        }
 316                        break;
 317                        /* Add RATE_DROP tlv here */
 318                }
 319
 320                tlv_buf += (sizeof(*head) + tlv_buf_len);
 321                tlv_buf_left -= (sizeof(*head) + tlv_buf_len);
 322        }
 323
 324        priv->is_data_rate_auto = mwifiex_is_rate_auto(priv);
 325
 326        if (priv->is_data_rate_auto)
 327                priv->data_rate = 0;
 328        else
 329                return mwifiex_send_cmd(priv, HostCmd_CMD_802_11_TX_RATE_QUERY,
 330                                        HostCmd_ACT_GEN_GET, 0, NULL, false);
 331
 332        return 0;
 333}
 334
 335/*
 336 * This function handles the command response of get Tx power level.
 337 *
 338 * Handling includes saving the maximum and minimum Tx power levels
 339 * in driver, as well as sending the values to user.
 340 */
 341static int mwifiex_get_power_level(struct mwifiex_private *priv, void *data_buf)
 342{
 343        int length, max_power = -1, min_power = -1;
 344        struct mwifiex_types_power_group *pg_tlv_hdr;
 345        struct mwifiex_power_group *pg;
 346
 347        if (!data_buf)
 348                return -1;
 349
 350        pg_tlv_hdr = (struct mwifiex_types_power_group *)((u8 *)data_buf);
 351        pg = (struct mwifiex_power_group *)
 352                ((u8 *) pg_tlv_hdr + sizeof(struct mwifiex_types_power_group));
 353        length = le16_to_cpu(pg_tlv_hdr->length);
 354
 355        /* At least one structure required to update power */
 356        if (length < sizeof(struct mwifiex_power_group))
 357                return 0;
 358
 359        max_power = pg->power_max;
 360        min_power = pg->power_min;
 361        length -= sizeof(struct mwifiex_power_group);
 362
 363        while (length >= sizeof(struct mwifiex_power_group)) {
 364                pg++;
 365                if (max_power < pg->power_max)
 366                        max_power = pg->power_max;
 367
 368                if (min_power > pg->power_min)
 369                        min_power = pg->power_min;
 370
 371                length -= sizeof(struct mwifiex_power_group);
 372        }
 373        priv->min_tx_power_level = (u8) min_power;
 374        priv->max_tx_power_level = (u8) max_power;
 375
 376        return 0;
 377}
 378
 379/*
 380 * This function handles the command response of set/get Tx power
 381 * configurations.
 382 *
 383 * Handling includes changing the header fields into CPU format
 384 * and saving the current Tx power level in driver.
 385 */
 386static int mwifiex_ret_tx_power_cfg(struct mwifiex_private *priv,
 387                                    struct host_cmd_ds_command *resp)
 388{
 389        struct mwifiex_adapter *adapter = priv->adapter;
 390        struct host_cmd_ds_txpwr_cfg *txp_cfg = &resp->params.txp_cfg;
 391        struct mwifiex_types_power_group *pg_tlv_hdr;
 392        struct mwifiex_power_group *pg;
 393        u16 action = le16_to_cpu(txp_cfg->action);
 394        u16 tlv_buf_left;
 395
 396        pg_tlv_hdr = (struct mwifiex_types_power_group *)
 397                ((u8 *)txp_cfg +
 398                 sizeof(struct host_cmd_ds_txpwr_cfg));
 399
 400        pg = (struct mwifiex_power_group *)
 401                ((u8 *)pg_tlv_hdr +
 402                 sizeof(struct mwifiex_types_power_group));
 403
 404        tlv_buf_left = le16_to_cpu(resp->size) - S_DS_GEN - sizeof(*txp_cfg);
 405        if (tlv_buf_left <
 406                        le16_to_cpu(pg_tlv_hdr->length) + sizeof(*pg_tlv_hdr))
 407                return 0;
 408
 409        switch (action) {
 410        case HostCmd_ACT_GEN_GET:
 411                if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
 412                        mwifiex_get_power_level(priv, pg_tlv_hdr);
 413
 414                priv->tx_power_level = (u16) pg->power_min;
 415                break;
 416
 417        case HostCmd_ACT_GEN_SET:
 418                if (!le32_to_cpu(txp_cfg->mode))
 419                        break;
 420
 421                if (pg->power_max == pg->power_min)
 422                        priv->tx_power_level = (u16) pg->power_min;
 423                break;
 424        default:
 425                mwifiex_dbg(adapter, ERROR,
 426                            "CMD_RESP: unknown cmd action %d\n",
 427                            action);
 428                return 0;
 429        }
 430        mwifiex_dbg(adapter, INFO,
 431                    "info: Current TxPower Level = %d, Max Power=%d, Min Power=%d\n",
 432                    priv->tx_power_level, priv->max_tx_power_level,
 433                    priv->min_tx_power_level);
 434
 435        return 0;
 436}
 437
 438/*
 439 * This function handles the command response of get RF Tx power.
 440 */
 441static int mwifiex_ret_rf_tx_power(struct mwifiex_private *priv,
 442                                   struct host_cmd_ds_command *resp)
 443{
 444        struct host_cmd_ds_rf_tx_pwr *txp = &resp->params.txp;
 445        u16 action = le16_to_cpu(txp->action);
 446
 447        priv->tx_power_level = le16_to_cpu(txp->cur_level);
 448
 449        if (action == HostCmd_ACT_GEN_GET) {
 450                priv->max_tx_power_level = txp->max_power;
 451                priv->min_tx_power_level = txp->min_power;
 452        }
 453
 454        mwifiex_dbg(priv->adapter, INFO,
 455                    "Current TxPower Level=%d, Max Power=%d, Min Power=%d\n",
 456                    priv->tx_power_level, priv->max_tx_power_level,
 457                    priv->min_tx_power_level);
 458
 459        return 0;
 460}
 461
 462/*
 463 * This function handles the command response of set rf antenna
 464 */
 465static int mwifiex_ret_rf_antenna(struct mwifiex_private *priv,
 466                                  struct host_cmd_ds_command *resp)
 467{
 468        struct host_cmd_ds_rf_ant_mimo *ant_mimo = &resp->params.ant_mimo;
 469        struct host_cmd_ds_rf_ant_siso *ant_siso = &resp->params.ant_siso;
 470        struct mwifiex_adapter *adapter = priv->adapter;
 471
 472        if (adapter->hw_dev_mcs_support == HT_STREAM_2X2)
 473                mwifiex_dbg(adapter, INFO,
 474                            "RF_ANT_RESP: Tx action = 0x%x, Tx Mode = 0x%04x\t"
 475                            "Rx action = 0x%x, Rx Mode = 0x%04x\n",
 476                            le16_to_cpu(ant_mimo->action_tx),
 477                            le16_to_cpu(ant_mimo->tx_ant_mode),
 478                            le16_to_cpu(ant_mimo->action_rx),
 479                            le16_to_cpu(ant_mimo->rx_ant_mode));
 480        else
 481                mwifiex_dbg(adapter, INFO,
 482                            "RF_ANT_RESP: action = 0x%x, Mode = 0x%04x\n",
 483                            le16_to_cpu(ant_siso->action),
 484                            le16_to_cpu(ant_siso->ant_mode));
 485
 486        return 0;
 487}
 488
 489/*
 490 * This function handles the command response of set/get MAC address.
 491 *
 492 * Handling includes saving the MAC address in driver.
 493 */
 494static int mwifiex_ret_802_11_mac_address(struct mwifiex_private *priv,
 495                                          struct host_cmd_ds_command *resp)
 496{
 497        struct host_cmd_ds_802_11_mac_address *cmd_mac_addr =
 498                                                        &resp->params.mac_addr;
 499
 500        memcpy(priv->curr_addr, cmd_mac_addr->mac_addr, ETH_ALEN);
 501
 502        mwifiex_dbg(priv->adapter, INFO,
 503                    "info: set mac address: %pM\n", priv->curr_addr);
 504
 505        return 0;
 506}
 507
 508/*
 509 * This function handles the command response of set/get MAC multicast
 510 * address.
 511 */
 512static int mwifiex_ret_mac_multicast_adr(struct mwifiex_private *priv,
 513                                         struct host_cmd_ds_command *resp)
 514{
 515        return 0;
 516}
 517
 518/*
 519 * This function handles the command response of get Tx rate query.
 520 *
 521 * Handling includes changing the header fields into CPU format
 522 * and saving the Tx rate and HT information parameters in driver.
 523 *
 524 * Both rate configuration and current data rate can be retrieved
 525 * with this request.
 526 */
 527static int mwifiex_ret_802_11_tx_rate_query(struct mwifiex_private *priv,
 528                                            struct host_cmd_ds_command *resp)
 529{
 530        priv->tx_rate = resp->params.tx_rate.tx_rate;
 531        priv->tx_htinfo = resp->params.tx_rate.ht_info;
 532        if (!priv->is_data_rate_auto)
 533                priv->data_rate =
 534                        mwifiex_index_to_data_rate(priv, priv->tx_rate,
 535                                                   priv->tx_htinfo);
 536
 537        return 0;
 538}
 539
 540/*
 541 * This function handles the command response of a deauthenticate
 542 * command.
 543 *
 544 * If the deauthenticated MAC matches the current BSS MAC, the connection
 545 * state is reset.
 546 */
 547static int mwifiex_ret_802_11_deauthenticate(struct mwifiex_private *priv,
 548                                             struct host_cmd_ds_command *resp)
 549{
 550        struct mwifiex_adapter *adapter = priv->adapter;
 551
 552        adapter->dbg.num_cmd_deauth++;
 553        if (!memcmp(resp->params.deauth.mac_addr,
 554                    &priv->curr_bss_params.bss_descriptor.mac_address,
 555                    sizeof(resp->params.deauth.mac_addr)))
 556                mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
 557
 558        return 0;
 559}
 560
 561/*
 562 * This function handles the command response of ad-hoc stop.
 563 *
 564 * The function resets the connection state in driver.
 565 */
 566static int mwifiex_ret_802_11_ad_hoc_stop(struct mwifiex_private *priv,
 567                                          struct host_cmd_ds_command *resp)
 568{
 569        mwifiex_reset_connect_state(priv, WLAN_REASON_DEAUTH_LEAVING);
 570        return 0;
 571}
 572
 573/*
 574 * This function handles the command response of set/get v1 key material.
 575 *
 576 * Handling includes updating the driver parameters to reflect the
 577 * changes.
 578 */
 579static int mwifiex_ret_802_11_key_material_v1(struct mwifiex_private *priv,
 580                                              struct host_cmd_ds_command *resp)
 581{
 582        struct host_cmd_ds_802_11_key_material *key =
 583                                                &resp->params.key_material;
 584
 585        if (le16_to_cpu(key->action) == HostCmd_ACT_GEN_SET) {
 586                if ((le16_to_cpu(key->key_param_set.key_info) & KEY_MCAST)) {
 587                        mwifiex_dbg(priv->adapter, INFO,
 588                                    "info: key: GTK is set\n");
 589                        priv->wpa_is_gtk_set = true;
 590                        priv->scan_block = false;
 591                        priv->port_open = true;
 592                }
 593        }
 594
 595        memset(priv->aes_key.key_param_set.key, 0,
 596               sizeof(key->key_param_set.key));
 597        priv->aes_key.key_param_set.key_len = key->key_param_set.key_len;
 598        memcpy(priv->aes_key.key_param_set.key, key->key_param_set.key,
 599               le16_to_cpu(priv->aes_key.key_param_set.key_len));
 600
 601        return 0;
 602}
 603
 604/*
 605 * This function handles the command response of set/get v2 key material.
 606 *
 607 * Handling includes updating the driver parameters to reflect the
 608 * changes.
 609 */
 610static int mwifiex_ret_802_11_key_material_v2(struct mwifiex_private *priv,
 611                                              struct host_cmd_ds_command *resp)
 612{
 613        struct host_cmd_ds_802_11_key_material_v2 *key_v2;
 614        __le16 len;
 615
 616        key_v2 = &resp->params.key_material_v2;
 617        if (le16_to_cpu(key_v2->action) == HostCmd_ACT_GEN_SET) {
 618                if ((le16_to_cpu(key_v2->key_param_set.key_info) & KEY_MCAST)) {
 619                        mwifiex_dbg(priv->adapter, INFO, "info: key: GTK is set\n");
 620                        priv->wpa_is_gtk_set = true;
 621                        priv->scan_block = false;
 622                        priv->port_open = true;
 623                }
 624        }
 625
 626        if (key_v2->key_param_set.key_type != KEY_TYPE_ID_AES)
 627                return 0;
 628
 629        memset(priv->aes_key_v2.key_param_set.key_params.aes.key, 0,
 630               WLAN_KEY_LEN_CCMP);
 631        priv->aes_key_v2.key_param_set.key_params.aes.key_len =
 632                                key_v2->key_param_set.key_params.aes.key_len;
 633        len = priv->aes_key_v2.key_param_set.key_params.aes.key_len;
 634        memcpy(priv->aes_key_v2.key_param_set.key_params.aes.key,
 635               key_v2->key_param_set.key_params.aes.key, le16_to_cpu(len));
 636
 637        return 0;
 638}
 639
 640/* Wrapper function for processing response of key material command */
 641static int mwifiex_ret_802_11_key_material(struct mwifiex_private *priv,
 642                                           struct host_cmd_ds_command *resp)
 643{
 644        if (priv->adapter->key_api_major_ver == KEY_API_VER_MAJOR_V2)
 645                return mwifiex_ret_802_11_key_material_v2(priv, resp);
 646        else
 647                return mwifiex_ret_802_11_key_material_v1(priv, resp);
 648}
 649
 650/*
 651 * This function handles the command response of get 11d domain information.
 652 */
 653static int mwifiex_ret_802_11d_domain_info(struct mwifiex_private *priv,
 654                                           struct host_cmd_ds_command *resp)
 655{
 656        struct host_cmd_ds_802_11d_domain_info_rsp *domain_info =
 657                &resp->params.domain_info_resp;
 658        struct mwifiex_ietypes_domain_param_set *domain = &domain_info->domain;
 659        u16 action = le16_to_cpu(domain_info->action);
 660        u8 no_of_triplet;
 661
 662        no_of_triplet = (u8) ((le16_to_cpu(domain->header.len)
 663                                - IEEE80211_COUNTRY_STRING_LEN)
 664                              / sizeof(struct ieee80211_country_ie_triplet));
 665
 666        mwifiex_dbg(priv->adapter, INFO,
 667                    "info: 11D Domain Info Resp: no_of_triplet=%d\n",
 668                    no_of_triplet);
 669
 670        if (no_of_triplet > MWIFIEX_MAX_TRIPLET_802_11D) {
 671                mwifiex_dbg(priv->adapter, FATAL,
 672                            "11D: invalid number of triplets %d returned\n",
 673                            no_of_triplet);
 674                return -1;
 675        }
 676
 677        switch (action) {
 678        case HostCmd_ACT_GEN_SET:  /* Proc Set Action */
 679                break;
 680        case HostCmd_ACT_GEN_GET:
 681                break;
 682        default:
 683                mwifiex_dbg(priv->adapter, ERROR,
 684                            "11D: invalid action:%d\n", domain_info->action);
 685                return -1;
 686        }
 687
 688        return 0;
 689}
 690
 691/*
 692 * This function handles the command response of get extended version.
 693 *
 694 * Handling includes forming the extended version string and sending it
 695 * to application.
 696 */
 697static int mwifiex_ret_ver_ext(struct mwifiex_private *priv,
 698                               struct host_cmd_ds_command *resp,
 699                               struct host_cmd_ds_version_ext *version_ext)
 700{
 701        struct host_cmd_ds_version_ext *ver_ext = &resp->params.verext;
 702
 703        if (version_ext) {
 704                version_ext->version_str_sel = ver_ext->version_str_sel;
 705                memcpy(version_ext->version_str, ver_ext->version_str,
 706                       sizeof(char) * 128);
 707                memcpy(priv->version_str, ver_ext->version_str, 128);
 708        }
 709        return 0;
 710}
 711
 712/*
 713 * This function handles the command response of remain on channel.
 714 */
 715static int
 716mwifiex_ret_remain_on_chan(struct mwifiex_private *priv,
 717                           struct host_cmd_ds_command *resp,
 718                           struct host_cmd_ds_remain_on_chan *roc_cfg)
 719{
 720        struct host_cmd_ds_remain_on_chan *resp_cfg = &resp->params.roc_cfg;
 721
 722        if (roc_cfg)
 723                memcpy(roc_cfg, resp_cfg, sizeof(*roc_cfg));
 724
 725        return 0;
 726}
 727
 728/*
 729 * This function handles the command response of P2P mode cfg.
 730 */
 731static int
 732mwifiex_ret_p2p_mode_cfg(struct mwifiex_private *priv,
 733                         struct host_cmd_ds_command *resp,
 734                         void *data_buf)
 735{
 736        struct host_cmd_ds_p2p_mode_cfg *mode_cfg = &resp->params.mode_cfg;
 737
 738        if (data_buf)
 739                *((u16 *)data_buf) = le16_to_cpu(mode_cfg->mode);
 740
 741        return 0;
 742}
 743
 744/* This function handles the command response of mem_access command
 745 */
 746static int
 747mwifiex_ret_mem_access(struct mwifiex_private *priv,
 748                       struct host_cmd_ds_command *resp, void *pioctl_buf)
 749{
 750        struct host_cmd_ds_mem_access *mem = (void *)&resp->params.mem;
 751
 752        priv->mem_rw.addr = le32_to_cpu(mem->addr);
 753        priv->mem_rw.value = le32_to_cpu(mem->value);
 754
 755        return 0;
 756}
 757/*
 758 * This function handles the command response of register access.
 759 *
 760 * The register value and offset are returned to the user. For EEPROM
 761 * access, the byte count is also returned.
 762 */
 763static int mwifiex_ret_reg_access(u16 type, struct host_cmd_ds_command *resp,
 764                                  void *data_buf)
 765{
 766        struct mwifiex_ds_reg_rw *reg_rw;
 767        struct mwifiex_ds_read_eeprom *eeprom;
 768        union reg {
 769                struct host_cmd_ds_mac_reg_access *mac;
 770                struct host_cmd_ds_bbp_reg_access *bbp;
 771                struct host_cmd_ds_rf_reg_access *rf;
 772                struct host_cmd_ds_pmic_reg_access *pmic;
 773                struct host_cmd_ds_802_11_eeprom_access *eeprom;
 774        } r;
 775
 776        if (!data_buf)
 777                return 0;
 778
 779        reg_rw = data_buf;
 780        eeprom = data_buf;
 781        switch (type) {
 782        case HostCmd_CMD_MAC_REG_ACCESS:
 783                r.mac = &resp->params.mac_reg;
 784                reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.mac->offset));
 785                reg_rw->value = r.mac->value;
 786                break;
 787        case HostCmd_CMD_BBP_REG_ACCESS:
 788                r.bbp = &resp->params.bbp_reg;
 789                reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.bbp->offset));
 790                reg_rw->value = cpu_to_le32((u32) r.bbp->value);
 791                break;
 792
 793        case HostCmd_CMD_RF_REG_ACCESS:
 794                r.rf = &resp->params.rf_reg;
 795                reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
 796                reg_rw->value = cpu_to_le32((u32) r.bbp->value);
 797                break;
 798        case HostCmd_CMD_PMIC_REG_ACCESS:
 799                r.pmic = &resp->params.pmic_reg;
 800                reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.pmic->offset));
 801                reg_rw->value = cpu_to_le32((u32) r.pmic->value);
 802                break;
 803        case HostCmd_CMD_CAU_REG_ACCESS:
 804                r.rf = &resp->params.rf_reg;
 805                reg_rw->offset = cpu_to_le32((u32) le16_to_cpu(r.rf->offset));
 806                reg_rw->value = cpu_to_le32((u32) r.rf->value);
 807                break;
 808        case HostCmd_CMD_802_11_EEPROM_ACCESS:
 809                r.eeprom = &resp->params.eeprom;
 810                pr_debug("info: EEPROM read len=%x\n", r.eeprom->byte_count);
 811                if (le16_to_cpu(eeprom->byte_count) <
 812                    le16_to_cpu(r.eeprom->byte_count)) {
 813                        eeprom->byte_count = cpu_to_le16(0);
 814                        pr_debug("info: EEPROM read length is too big\n");
 815                        return -1;
 816                }
 817                eeprom->offset = r.eeprom->offset;
 818                eeprom->byte_count = r.eeprom->byte_count;
 819                if (le16_to_cpu(eeprom->byte_count) > 0)
 820                        memcpy(&eeprom->value, &r.eeprom->value,
 821                               le16_to_cpu(r.eeprom->byte_count));
 822
 823                break;
 824        default:
 825                return -1;
 826        }
 827        return 0;
 828}
 829
 830/*
 831 * This function handles the command response of get IBSS coalescing status.
 832 *
 833 * If the received BSSID is different than the current one, the current BSSID,
 834 * beacon interval, ATIM window and ERP information are updated, along with
 835 * changing the ad-hoc state accordingly.
 836 */
 837static int mwifiex_ret_ibss_coalescing_status(struct mwifiex_private *priv,
 838                                              struct host_cmd_ds_command *resp)
 839{
 840        struct host_cmd_ds_802_11_ibss_status *ibss_coal_resp =
 841                                        &(resp->params.ibss_coalescing);
 842
 843        if (le16_to_cpu(ibss_coal_resp->action) == HostCmd_ACT_GEN_SET)
 844                return 0;
 845
 846        mwifiex_dbg(priv->adapter, INFO,
 847                    "info: new BSSID %pM\n", ibss_coal_resp->bssid);
 848
 849        /* If rsp has NULL BSSID, Just return..... No Action */
 850        if (is_zero_ether_addr(ibss_coal_resp->bssid)) {
 851                mwifiex_dbg(priv->adapter, FATAL, "new BSSID is NULL\n");
 852                return 0;
 853        }
 854
 855        /* If BSSID is diff, modify current BSS parameters */
 856        if (!ether_addr_equal(priv->curr_bss_params.bss_descriptor.mac_address, ibss_coal_resp->bssid)) {
 857                /* BSSID */
 858                memcpy(priv->curr_bss_params.bss_descriptor.mac_address,
 859                       ibss_coal_resp->bssid, ETH_ALEN);
 860
 861                /* Beacon Interval */
 862                priv->curr_bss_params.bss_descriptor.beacon_period
 863                        = le16_to_cpu(ibss_coal_resp->beacon_interval);
 864
 865                /* ERP Information */
 866                priv->curr_bss_params.bss_descriptor.erp_flags =
 867                        (u8) le16_to_cpu(ibss_coal_resp->use_g_rate_protect);
 868
 869                priv->adhoc_state = ADHOC_COALESCED;
 870        }
 871
 872        return 0;
 873}
 874static int mwifiex_ret_tdls_oper(struct mwifiex_private *priv,
 875                                 struct host_cmd_ds_command *resp)
 876{
 877        struct host_cmd_ds_tdls_oper *cmd_tdls_oper = &resp->params.tdls_oper;
 878        u16 reason = le16_to_cpu(cmd_tdls_oper->reason);
 879        u16 action = le16_to_cpu(cmd_tdls_oper->tdls_action);
 880        struct mwifiex_sta_node *node =
 881                           mwifiex_get_sta_entry(priv, cmd_tdls_oper->peer_mac);
 882
 883        switch (action) {
 884        case ACT_TDLS_DELETE:
 885                if (reason) {
 886                        if (!node || reason == TDLS_ERR_LINK_NONEXISTENT)
 887                                mwifiex_dbg(priv->adapter, MSG,
 888                                            "TDLS link delete for %pM failed: reason %d\n",
 889                                            cmd_tdls_oper->peer_mac, reason);
 890                        else
 891                                mwifiex_dbg(priv->adapter, ERROR,
 892                                            "TDLS link delete for %pM failed: reason %d\n",
 893                                            cmd_tdls_oper->peer_mac, reason);
 894                } else {
 895                        mwifiex_dbg(priv->adapter, MSG,
 896                                    "TDLS link delete for %pM successful\n",
 897                                    cmd_tdls_oper->peer_mac);
 898                }
 899                break;
 900        case ACT_TDLS_CREATE:
 901                if (reason) {
 902                        mwifiex_dbg(priv->adapter, ERROR,
 903                                    "TDLS link creation for %pM failed: reason %d",
 904                                    cmd_tdls_oper->peer_mac, reason);
 905                        if (node && reason != TDLS_ERR_LINK_EXISTS)
 906                                node->tdls_status = TDLS_SETUP_FAILURE;
 907                } else {
 908                        mwifiex_dbg(priv->adapter, MSG,
 909                                    "TDLS link creation for %pM successful",
 910                                    cmd_tdls_oper->peer_mac);
 911                }
 912                break;
 913        case ACT_TDLS_CONFIG:
 914                if (reason) {
 915                        mwifiex_dbg(priv->adapter, ERROR,
 916                                    "TDLS link config for %pM failed, reason %d\n",
 917                                    cmd_tdls_oper->peer_mac, reason);
 918                        if (node)
 919                                node->tdls_status = TDLS_SETUP_FAILURE;
 920                } else {
 921                        mwifiex_dbg(priv->adapter, MSG,
 922                                    "TDLS link config for %pM successful\n",
 923                                    cmd_tdls_oper->peer_mac);
 924                }
 925                break;
 926        default:
 927                mwifiex_dbg(priv->adapter, ERROR,
 928                            "Unknown TDLS command action response %d", action);
 929                return -1;
 930        }
 931
 932        return 0;
 933}
 934/*
 935 * This function handles the command response for subscribe event command.
 936 */
 937static int mwifiex_ret_subsc_evt(struct mwifiex_private *priv,
 938                                 struct host_cmd_ds_command *resp)
 939{
 940        struct host_cmd_ds_802_11_subsc_evt *cmd_sub_event =
 941                &resp->params.subsc_evt;
 942
 943        /* For every subscribe event command (Get/Set/Clear), FW reports the
 944         * current set of subscribed events*/
 945        mwifiex_dbg(priv->adapter, EVENT,
 946                    "Bitmap of currently subscribed events: %16x\n",
 947                    le16_to_cpu(cmd_sub_event->events));
 948
 949        return 0;
 950}
 951
 952static int mwifiex_ret_uap_sta_list(struct mwifiex_private *priv,
 953                                    struct host_cmd_ds_command *resp)
 954{
 955        struct host_cmd_ds_sta_list *sta_list =
 956                &resp->params.sta_list;
 957        struct mwifiex_ie_types_sta_info *sta_info = (void *)&sta_list->tlv;
 958        int i;
 959        struct mwifiex_sta_node *sta_node;
 960
 961        for (i = 0; i < sta_list->sta_count; i++) {
 962                sta_node = mwifiex_get_sta_entry(priv, sta_info->mac);
 963                if (unlikely(!sta_node))
 964                        continue;
 965
 966                sta_node->stats.rssi = sta_info->rssi;
 967                sta_info++;
 968        }
 969
 970        return 0;
 971}
 972
 973/* This function handles the command response of set_cfg_data */
 974static int mwifiex_ret_cfg_data(struct mwifiex_private *priv,
 975                                struct host_cmd_ds_command *resp)
 976{
 977        if (resp->result != HostCmd_RESULT_OK) {
 978                mwifiex_dbg(priv->adapter, ERROR, "Cal data cmd resp failed\n");
 979                return -1;
 980        }
 981
 982        return 0;
 983}
 984
 985/** This Function handles the command response of sdio rx aggr */
 986static int mwifiex_ret_sdio_rx_aggr_cfg(struct mwifiex_private *priv,
 987                                        struct host_cmd_ds_command *resp)
 988{
 989        struct mwifiex_adapter *adapter = priv->adapter;
 990        struct host_cmd_sdio_sp_rx_aggr_cfg *cfg =
 991                                &resp->params.sdio_rx_aggr_cfg;
 992
 993        adapter->sdio_rx_aggr_enable = cfg->enable;
 994        adapter->sdio_rx_block_size = le16_to_cpu(cfg->block_size);
 995
 996        return 0;
 997}
 998
 999static int mwifiex_ret_robust_coex(struct mwifiex_private *priv,
1000                                   struct host_cmd_ds_command *resp,
1001                                   bool *is_timeshare)
1002{
1003        struct host_cmd_ds_robust_coex *coex = &resp->params.coex;
1004        struct mwifiex_ie_types_robust_coex *coex_tlv;
1005        u16 action = le16_to_cpu(coex->action);
1006        u32 mode;
1007
1008        coex_tlv = (struct mwifiex_ie_types_robust_coex
1009                    *)((u8 *)coex + sizeof(struct host_cmd_ds_robust_coex));
1010        if (action == HostCmd_ACT_GEN_GET) {
1011                mode = le32_to_cpu(coex_tlv->mode);
1012                if (mode == MWIFIEX_COEX_MODE_TIMESHARE)
1013                        *is_timeshare = true;
1014                else
1015                        *is_timeshare = false;
1016        }
1017
1018        return 0;
1019}
1020
1021/*
1022 * This function handles the command responses.
1023 *
1024 * This is a generic function, which calls command specific
1025 * response handlers based on the command ID.
1026 */
1027int mwifiex_process_sta_cmdresp(struct mwifiex_private *priv, u16 cmdresp_no,
1028                                struct host_cmd_ds_command *resp)
1029{
1030        int ret = 0;
1031        struct mwifiex_adapter *adapter = priv->adapter;
1032        void *data_buf = adapter->curr_cmd->data_buf;
1033
1034        /* If the command is not successful, cleanup and return failure */
1035        if (resp->result != HostCmd_RESULT_OK) {
1036                mwifiex_process_cmdresp_error(priv, resp);
1037                return -1;
1038        }
1039        /* Command successful, handle response */
1040        switch (cmdresp_no) {
1041        case HostCmd_CMD_GET_HW_SPEC:
1042                ret = mwifiex_ret_get_hw_spec(priv, resp);
1043                break;
1044        case HostCmd_CMD_CFG_DATA:
1045                ret = mwifiex_ret_cfg_data(priv, resp);
1046                break;
1047        case HostCmd_CMD_MAC_CONTROL:
1048                break;
1049        case HostCmd_CMD_802_11_MAC_ADDRESS:
1050                ret = mwifiex_ret_802_11_mac_address(priv, resp);
1051                break;
1052        case HostCmd_CMD_MAC_MULTICAST_ADR:
1053                ret = mwifiex_ret_mac_multicast_adr(priv, resp);
1054                break;
1055        case HostCmd_CMD_TX_RATE_CFG:
1056                ret = mwifiex_ret_tx_rate_cfg(priv, resp);
1057                break;
1058        case HostCmd_CMD_802_11_SCAN:
1059                ret = mwifiex_ret_802_11_scan(priv, resp);
1060                adapter->curr_cmd->wait_q_enabled = false;
1061                break;
1062        case HostCmd_CMD_802_11_SCAN_EXT:
1063                ret = mwifiex_ret_802_11_scan_ext(priv, resp);
1064                adapter->curr_cmd->wait_q_enabled = false;
1065                break;
1066        case HostCmd_CMD_802_11_BG_SCAN_QUERY:
1067                ret = mwifiex_ret_802_11_scan(priv, resp);
1068                cfg80211_sched_scan_results(priv->wdev.wiphy);
1069                mwifiex_dbg(adapter, CMD,
1070                            "info: CMD_RESP: BG_SCAN result is ready!\n");
1071                break;
1072        case HostCmd_CMD_802_11_BG_SCAN_CONFIG:
1073                break;
1074        case HostCmd_CMD_TXPWR_CFG:
1075                ret = mwifiex_ret_tx_power_cfg(priv, resp);
1076                break;
1077        case HostCmd_CMD_RF_TX_PWR:
1078                ret = mwifiex_ret_rf_tx_power(priv, resp);
1079                break;
1080        case HostCmd_CMD_RF_ANTENNA:
1081                ret = mwifiex_ret_rf_antenna(priv, resp);
1082                break;
1083        case HostCmd_CMD_802_11_PS_MODE_ENH:
1084                ret = mwifiex_ret_enh_power_mode(priv, resp, data_buf);
1085                break;
1086        case HostCmd_CMD_802_11_HS_CFG_ENH:
1087                ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
1088                break;
1089        case HostCmd_CMD_802_11_ASSOCIATE:
1090                ret = mwifiex_ret_802_11_associate(priv, resp);
1091                break;
1092        case HostCmd_CMD_802_11_DEAUTHENTICATE:
1093                ret = mwifiex_ret_802_11_deauthenticate(priv, resp);
1094                break;
1095        case HostCmd_CMD_802_11_AD_HOC_START:
1096        case HostCmd_CMD_802_11_AD_HOC_JOIN:
1097                ret = mwifiex_ret_802_11_ad_hoc(priv, resp);
1098                break;
1099        case HostCmd_CMD_802_11_AD_HOC_STOP:
1100                ret = mwifiex_ret_802_11_ad_hoc_stop(priv, resp);
1101                break;
1102        case HostCmd_CMD_802_11_GET_LOG:
1103                ret = mwifiex_ret_get_log(priv, resp, data_buf);
1104                break;
1105        case HostCmd_CMD_RSSI_INFO:
1106                ret = mwifiex_ret_802_11_rssi_info(priv, resp);
1107                break;
1108        case HostCmd_CMD_802_11_SNMP_MIB:
1109                ret = mwifiex_ret_802_11_snmp_mib(priv, resp, data_buf);
1110                break;
1111        case HostCmd_CMD_802_11_TX_RATE_QUERY:
1112                ret = mwifiex_ret_802_11_tx_rate_query(priv, resp);
1113                break;
1114        case HostCmd_CMD_VERSION_EXT:
1115                ret = mwifiex_ret_ver_ext(priv, resp, data_buf);
1116                break;
1117        case HostCmd_CMD_REMAIN_ON_CHAN:
1118                ret = mwifiex_ret_remain_on_chan(priv, resp, data_buf);
1119                break;
1120        case HostCmd_CMD_11AC_CFG:
1121                break;
1122        case HostCmd_CMD_P2P_MODE_CFG:
1123                ret = mwifiex_ret_p2p_mode_cfg(priv, resp, data_buf);
1124                break;
1125        case HostCmd_CMD_MGMT_FRAME_REG:
1126        case HostCmd_CMD_FUNC_INIT:
1127        case HostCmd_CMD_FUNC_SHUTDOWN:
1128                break;
1129        case HostCmd_CMD_802_11_KEY_MATERIAL:
1130                ret = mwifiex_ret_802_11_key_material(priv, resp);
1131                break;
1132        case HostCmd_CMD_802_11D_DOMAIN_INFO:
1133                ret = mwifiex_ret_802_11d_domain_info(priv, resp);
1134                break;
1135        case HostCmd_CMD_11N_ADDBA_REQ:
1136                ret = mwifiex_ret_11n_addba_req(priv, resp);
1137                break;
1138        case HostCmd_CMD_11N_DELBA:
1139                ret = mwifiex_ret_11n_delba(priv, resp);
1140                break;
1141        case HostCmd_CMD_11N_ADDBA_RSP:
1142                ret = mwifiex_ret_11n_addba_resp(priv, resp);
1143                break;
1144        case HostCmd_CMD_RECONFIGURE_TX_BUFF:
1145                if (0xffff == (u16)le16_to_cpu(resp->params.tx_buf.buff_size)) {
1146                        if (adapter->iface_type == MWIFIEX_USB &&
1147                            adapter->usb_mc_setup) {
1148                                if (adapter->if_ops.multi_port_resync)
1149                                        adapter->if_ops.
1150                                                multi_port_resync(adapter);
1151                                adapter->usb_mc_setup = false;
1152                                adapter->tx_lock_flag = false;
1153                        }
1154                        break;
1155                }
1156                adapter->tx_buf_size = (u16) le16_to_cpu(resp->params.
1157                                                             tx_buf.buff_size);
1158                adapter->tx_buf_size = (adapter->tx_buf_size
1159                                        / MWIFIEX_SDIO_BLOCK_SIZE)
1160                                       * MWIFIEX_SDIO_BLOCK_SIZE;
1161                adapter->curr_tx_buf_size = adapter->tx_buf_size;
1162                mwifiex_dbg(adapter, CMD, "cmd: curr_tx_buf_size=%d\n",
1163                            adapter->curr_tx_buf_size);
1164
1165                if (adapter->if_ops.update_mp_end_port)
1166                        adapter->if_ops.update_mp_end_port(adapter,
1167                                le16_to_cpu(resp->params.tx_buf.mp_end_port));
1168                break;
1169        case HostCmd_CMD_AMSDU_AGGR_CTRL:
1170                break;
1171        case HostCmd_CMD_WMM_GET_STATUS:
1172                ret = mwifiex_ret_wmm_get_status(priv, resp);
1173                break;
1174        case HostCmd_CMD_802_11_IBSS_COALESCING_STATUS:
1175                ret = mwifiex_ret_ibss_coalescing_status(priv, resp);
1176                break;
1177        case HostCmd_CMD_MEM_ACCESS:
1178                ret = mwifiex_ret_mem_access(priv, resp, data_buf);
1179                break;
1180        case HostCmd_CMD_MAC_REG_ACCESS:
1181        case HostCmd_CMD_BBP_REG_ACCESS:
1182        case HostCmd_CMD_RF_REG_ACCESS:
1183        case HostCmd_CMD_PMIC_REG_ACCESS:
1184        case HostCmd_CMD_CAU_REG_ACCESS:
1185        case HostCmd_CMD_802_11_EEPROM_ACCESS:
1186                ret = mwifiex_ret_reg_access(cmdresp_no, resp, data_buf);
1187                break;
1188        case HostCmd_CMD_SET_BSS_MODE:
1189                break;
1190        case HostCmd_CMD_11N_CFG:
1191                break;
1192        case HostCmd_CMD_PCIE_DESC_DETAILS:
1193                break;
1194        case HostCmd_CMD_802_11_SUBSCRIBE_EVENT:
1195                ret = mwifiex_ret_subsc_evt(priv, resp);
1196                break;
1197        case HostCmd_CMD_UAP_SYS_CONFIG:
1198                break;
1199        case HOST_CMD_APCMD_STA_LIST:
1200                ret = mwifiex_ret_uap_sta_list(priv, resp);
1201                break;
1202        case HostCmd_CMD_UAP_BSS_START:
1203                adapter->tx_lock_flag = false;
1204                adapter->pps_uapsd_mode = false;
1205                adapter->delay_null_pkt = false;
1206                priv->bss_started = 1;
1207                break;
1208        case HostCmd_CMD_UAP_BSS_STOP:
1209                priv->bss_started = 0;
1210                break;
1211        case HostCmd_CMD_UAP_STA_DEAUTH:
1212                break;
1213        case HOST_CMD_APCMD_SYS_RESET:
1214                break;
1215        case HostCmd_CMD_MEF_CFG:
1216                break;
1217        case HostCmd_CMD_COALESCE_CFG:
1218                break;
1219        case HostCmd_CMD_TDLS_OPER:
1220                ret = mwifiex_ret_tdls_oper(priv, resp);
1221        case HostCmd_CMD_MC_POLICY:
1222                break;
1223        case HostCmd_CMD_CHAN_REPORT_REQUEST:
1224                break;
1225        case HostCmd_CMD_SDIO_SP_RX_AGGR_CFG:
1226                ret = mwifiex_ret_sdio_rx_aggr_cfg(priv, resp);
1227                break;
1228        case HostCmd_CMD_HS_WAKEUP_REASON:
1229                ret = mwifiex_ret_wakeup_reason(priv, resp, data_buf);
1230                break;
1231        case HostCmd_CMD_TDLS_CONFIG:
1232                break;
1233        case HostCmd_CMD_ROBUST_COEX:
1234                ret = mwifiex_ret_robust_coex(priv, resp, data_buf);
1235                break;
1236        case HostCmd_CMD_GTK_REKEY_OFFLOAD_CFG:
1237                break;
1238        default:
1239                mwifiex_dbg(adapter, ERROR,
1240                            "CMD_RESP: unknown cmd response %#x\n",
1241                            resp->command);
1242                break;
1243        }
1244
1245        return ret;
1246}
1247