// SPDX-License-Identifier: GPL-2.0-only
/*
* NXP Wireless LAN device driver: station command response handling
*
* Copyright 2011-2020 NXP
*/
#include "decl.h"
#include "ioctl.h"
#include "util.h"
#include "fw.h"
#include "main.h"
#include "wmm.h"
#include "11n.h"
#include "11ac.h"
/*
* This function handles the command response error case.
*
* For scan response error, the function cancels all the pending
* scan commands and generates an event to inform the applications
* of the scan completion.
*
* For Power Save command failure, we do not retry enter PS
* command in case of Ad-hoc mode.
*
* For all other response errors, the current command buffer is freed
* and returned to the free command queue.
*/
static void
mwifiex_process_cmdresp_error(struct mwifiex_private *priv,
struct host_cmd_ds_command *resp)
{
struct mwifiex_adapter *adapter = priv->adapter;
struct host_cmd_ds_802_11_ps_mode_enh *pm;
mwifiex_dbg(adapter, ERROR,
"CMD_RESP: cmd %#x error, result=%#x\n",
resp->command, resp->result);
if (adapter->curr_cmd->wait_q_enabled)
adapter->cmd_wait_q.status = -1;
switch (le16_to_cpu(resp->command)) {
case HostCmd_CMD_802_11_PS_MODE_ENH:
pm = &resp->params.psmode_enh;
mwifiex_dbg(adapter, ERROR,
"PS_MODE_ENH cmd failed: result=0x%x action=0x%X\n",
resp->result, le16_to_cpu(pm->action));
/* We do not re-try enter-ps command in ad-hoc mode. */
if (le16_to_cpu(pm->action) == EN_AUTO_PS &&
(le16_to_cpu(pm->params.ps_bitmap) & BITMAP_STA_PS) &&
priv->bss_mode == NL80211_IFTYPE_ADHOC)
adapter->ps_mode = MWIFIEX_802_11_POWER_MODE_CAM;
break;
case