// SPDX-License-Identifier: GPL-2.0-only
/*
* nxpwifi: commands and events
*
* Copyright 2011-2024 NXP
*/
#include "cfg.h"
#include "util.h"
#include "fw.h"
#include "main.h"
#include "cmdevt.h"
#include "wmm.h"
#include "11n.h"
static void nxpwifi_cancel_pending_ioctl(struct nxpwifi_adapter *adapter);
/* Initialize command node; set defaults; buffers are supplied by caller. */
static void
nxpwifi_init_cmd_node(struct nxpwifi_private *priv,
struct cmd_ctrl_node *cmd_node,
u32 cmd_no, void *data_buf, bool sync)
{
cmd_node->priv = priv;
cmd_node->cmd_no = cmd_no;
if (sync) {
cmd_node->wait_q_enabled = true;
cmd_node->cmd_wait_q_woken = false;
cmd_node->condition = &cmd_node->cmd_wait_q_woken;
}
cmd_node->data_buf = data_buf;
cmd_node->cmd_skb = cmd_node->skb;
cmd_node->cmd_resp = NULL;
}
/* Get a free command node from cmd_free_q; return NULL if none. */
static struct cmd_ctrl_node *
nxpwifi_get_cmd_node(struct nxpwifi_adapter *adapter)
{
struct cmd_ctrl_node *cmd_node;
spin_lock_bh(&adapter->cmd_free_q_lock);
if (list_empty(&adapter->cmd_free_q)) {
nxpwifi_dbg(adapter, ERROR,
"GET_CMD_NODE: cmd node not available\n");
spin_unlock_bh(&adapter->cmd_free_q_lock);
return NULL;
}
cmd_node = list_first_entry(&adapter->cmd_free_q,
struct cmd_ctrl_node, list);
list_del(&cmd_node->list);
spin_unlock_bh(&adapter->cmd_free_q_lock);
return cmd_node;
}
/* Reset cmd node state; trim cmd skb; complete and clear resp_skb if present. */
static void
nxpwifi_clean_cmd_node(struct nxpwifi_adapter *adapter,
struct cmd_ctrl_node *cmd_node)
{
cmd_node->cmd_no = 0;
cmd_node->cmd_flag = 0;
cmd_node->data_buf = NULL;
cmd_node->wait_q_enabled = false;
if (cmd_node->cmd_skb)
skb_trim(cmd_node->cmd_skb, 0);
if (cmd_node->resp_skb) {
adapter->if_ops.cmdrsp_complete(