static void
mwifiex_init_cmd_node(struct mwifiex_private *priv,
struct cmd_ctrl_node *cmd_node,
- u32 cmd_oid, void *wait_queue, void *data_buf)
+ u32 cmd_oid, void *data_buf)
{
cmd_node->priv = priv;
cmd_node->cmd_oid = cmd_oid;
- cmd_node->wq_buf = wait_queue;
+ cmd_node->wait_q_enabled = priv->adapter->cmd_wait_q_required;
+ priv->adapter->cmd_wait_q_required = false;
cmd_node->data_buf = data_buf;
cmd_node->cmd_skb = cmd_node->skb;
}
{
cmd_node->cmd_oid = 0;
cmd_node->cmd_flag = 0;
- cmd_node->wq_buf = NULL;
cmd_node->data_buf = NULL;
+ cmd_node->wait_q_enabled = false;
if (cmd_node->resp_skb) {
- mwifiex_recv_complete(adapter, cmd_node->resp_skb, 0);
+ dev_kfree_skb_any(cmd_node->resp_skb);
cmd_node->resp_skb = NULL;
}
-
- return;
-}
-
-/*
- * This function returns a command node from the pending queue which
- * matches the given IOCTL request.
- */
-static struct cmd_ctrl_node *
-mwifiex_get_pending_ioctl_cmd(struct mwifiex_adapter *adapter,
- struct mwifiex_wait_queue *wait_queue)
-{
- unsigned long flags;
- struct cmd_ctrl_node *cmd_node;
-
- spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
- list_for_each_entry(cmd_node, &adapter->cmd_pending_q, list) {
- if (cmd_node->wq_buf == wait_queue) {
- spin_unlock_irqrestore(&adapter->cmd_pending_q_lock,
- flags);
- return cmd_node;
- }
- }
- spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
-
- return NULL;
}
/*
{
struct mwifiex_adapter *adapter = priv->adapter;
- int ret = 0;
+ int ret;
struct host_cmd_ds_command *host_cmd;
- struct mwifiex_wait_queue *wait_queue = NULL;
uint16_t cmd_code;
uint16_t cmd_size;
struct timeval tstamp;
return -1;
host_cmd = (struct host_cmd_ds_command *) (cmd_node->cmd_skb->data);
- if (cmd_node->wq_buf)
- wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf;
/* Sanity test */
if (host_cmd == NULL || host_cmd->size == 0) {
dev_err(adapter->dev, "DNLD_CMD: host_cmd is null"
" or cmd size is 0, not sending\n");
- if (wait_queue)
- wait_queue->status = MWIFIEX_ERROR_CMD_DNLD_FAIL;
+ if (cmd_node->wait_q_enabled)
+ adapter->cmd_wait_q.status = -1;
mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
return -1;
}
cmd_node->cmd_skb->data,
cmd_node->cmd_skb->len, NULL);
+ skb_pull(cmd_node->cmd_skb, INTF_HEADER_LEN);
+
if (ret == -1) {
dev_err(adapter->dev, "DNLD_CMD: host to card failed\n");
- if (wait_queue)
- wait_queue->status = MWIFIEX_ERROR_CMD_DNLD_FAIL;
+ if (cmd_node->wait_q_enabled)
+ adapter->cmd_wait_q.status = -1;
mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
*/
static int mwifiex_dnld_sleep_confirm_cmd(struct mwifiex_adapter *adapter)
{
- int ret = 0;
- u16 cmd_len = 0;
+ int ret;
struct mwifiex_private *priv;
- struct mwifiex_opt_sleep_confirm_buffer *sleep_cfm_buf =
- (struct mwifiex_opt_sleep_confirm_buffer *)
+ struct mwifiex_opt_sleep_confirm *sleep_cfm_buf =
+ (struct mwifiex_opt_sleep_confirm *)
adapter->sleep_cfm->data;
- cmd_len = sizeof(struct mwifiex_opt_sleep_confirm);
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
- sleep_cfm_buf->ps_cfm_sleep.seq_num =
+ sleep_cfm_buf->seq_num =
cpu_to_le16((HostCmd_SET_SEQ_NO_BSS_INFO
(adapter->seq_num, priv->bss_num,
priv->bss_type)));
adapter->seq_num++;
+ skb_push(adapter->sleep_cfm, INTF_HEADER_LEN);
ret = adapter->if_ops.host_to_card(adapter, MWIFIEX_TYPE_CMD,
adapter->sleep_cfm->data,
- adapter->sleep_cfm->len +
- INTF_HEADER_LEN, NULL);
+ adapter->sleep_cfm->len, NULL);
+ skb_pull(adapter->sleep_cfm, INTF_HEADER_LEN);
if (ret == -1) {
dev_err(adapter->dev, "SLEEP_CFM: failed\n");
}
if (GET_BSS_ROLE(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY))
== MWIFIEX_BSS_ROLE_STA) {
- if (!sleep_cfm_buf->ps_cfm_sleep.resp_ctrl)
+ if (!sleep_cfm_buf->resp_ctrl)
/* Response is not needed for sleep
confirm command */
adapter->ps_state = PS_STATE_SLEEP;
else
adapter->ps_state = PS_STATE_SLEEP_CFM;
- if (!sleep_cfm_buf->ps_cfm_sleep.resp_ctrl
+ if (!sleep_cfm_buf->resp_ctrl
&& (adapter->is_hs_configured
&& !adapter->sleep_period.period)) {
adapter->pm_wakeup_card_req = true;
if (!cmd_array) {
dev_err(adapter->dev, "%s: failed to alloc cmd_array\n",
__func__);
- return -1;
+ return -ENOMEM;
}
adapter->cmd_pool = cmd_array;
}
if (!cmd_array[i].resp_skb)
continue;
- mwifiex_recv_complete(adapter, cmd_array[i].resp_skb, 0);
+ dev_kfree_skb_any(cmd_array[i].resp_skb);
}
/* Release struct cmd_ctrl_node */
if (adapter->cmd_pool) {
*/
int mwifiex_process_event(struct mwifiex_adapter *adapter)
{
- int ret = 0;
+ int ret;
struct mwifiex_private *priv =
mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
struct sk_buff *skb = adapter->event_skb;
u32 eventcause = adapter->event_cause;
struct timeval tstamp;
- struct mwifiex_rxinfo *rx_info = NULL;
+ struct mwifiex_rxinfo *rx_info;
/* Save the last event to debug log */
adapter->dbg.last_event_index =
adapter->event_cause = 0;
adapter->event_skb = NULL;
- mwifiex_recv_complete(adapter, skb, 0);
+ dev_kfree_skb_any(skb);
+
+ return ret;
+}
+
+/*
+ * This function is used to send synchronous command to the firmware.
+ *
+ * it allocates a wait queue for the command and wait for the command
+ * response.
+ */
+int mwifiex_send_cmd_sync(struct mwifiex_private *priv, uint16_t cmd_no,
+ u16 cmd_action, u32 cmd_oid, void *data_buf)
+{
+ int ret = 0;
+ struct mwifiex_adapter *adapter = priv->adapter;
+
+ adapter->cmd_wait_q_required = true;
+ adapter->cmd_wait_q.condition = false;
+
+ ret = mwifiex_send_cmd_async(priv, cmd_no, cmd_action, cmd_oid,
+ data_buf);
+ if (!ret)
+ ret = mwifiex_wait_queue_complete(adapter);
return ret;
}
+
/*
- * This function prepares a command before sending it to the firmware.
+ * This function prepares a command and asynchronously send it to the firmware.
*
* Preparation includes -
* - Sanity tests to make sure the card is still present or the FW
* - Fill up the non-default parameters and buffer pointers
* - Add the command to pending queue
*/
-int mwifiex_prepare_cmd(struct mwifiex_private *priv, uint16_t cmd_no,
- u16 cmd_action, u32 cmd_oid,
- void *wait_queue, void *data_buf)
+int mwifiex_send_cmd_async(struct mwifiex_private *priv, uint16_t cmd_no,
+ u16 cmd_action, u32 cmd_oid, void *data_buf)
{
- int ret = 0;
+ int ret;
struct mwifiex_adapter *adapter = priv->adapter;
- struct cmd_ctrl_node *cmd_node = NULL;
- struct host_cmd_ds_command *cmd_ptr = NULL;
+ struct cmd_ctrl_node *cmd_node;
+ struct host_cmd_ds_command *cmd_ptr;
if (!adapter) {
pr_err("PREP_CMD: adapter is NULL\n");
}
/* Initialize the command node */
- mwifiex_init_cmd_node(priv, cmd_node, cmd_oid, wait_queue, data_buf);
+ mwifiex_init_cmd_node(priv, cmd_node, cmd_oid, data_buf);
if (!cmd_node->cmd_skb) {
dev_err(adapter->dev, "PREP_CMD: no free cmd buf\n");
mwifiex_insert_cmd_to_free_q(struct mwifiex_adapter *adapter,
struct cmd_ctrl_node *cmd_node)
{
- struct mwifiex_wait_queue *wait_queue = NULL;
unsigned long flags;
- if (cmd_node == NULL)
+ if (!cmd_node)
return;
- if (cmd_node->wq_buf) {
- wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf;
- if (wait_queue->status != MWIFIEX_ERROR_NO_ERROR)
- mwifiex_ioctl_complete(adapter, wait_queue, -1);
- else
- mwifiex_ioctl_complete(adapter, wait_queue, 0);
- }
+
+ if (cmd_node->wait_q_enabled)
+ mwifiex_complete_cmd(adapter);
/* Clean the node */
mwifiex_clean_cmd_node(adapter, cmd_node);
spin_lock_irqsave(&adapter->cmd_free_q_lock, flags);
list_add_tail(&cmd_node->list, &adapter->cmd_free_q);
spin_unlock_irqrestore(&adapter->cmd_free_q_lock, flags);
-
- return;
}
/*
spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
dev_dbg(adapter->dev, "cmd: QUEUE_CMD: cmd=%#x is queued\n", command);
-
- return;
}
/*
*/
int mwifiex_exec_next_cmd(struct mwifiex_adapter *adapter)
{
- struct mwifiex_private *priv = NULL;
- struct cmd_ctrl_node *cmd_node = NULL;
+ struct mwifiex_private *priv;
+ struct cmd_ctrl_node *cmd_node;
int ret = 0;
struct host_cmd_ds_command *host_cmd;
unsigned long cmd_flags;
*/
int mwifiex_process_cmdresp(struct mwifiex_adapter *adapter)
{
- struct host_cmd_ds_command *resp = NULL;
+ struct host_cmd_ds_command *resp;
struct mwifiex_private *priv =
mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
int ret = 0;
uint16_t orig_cmdresp_no;
uint16_t cmdresp_no;
uint16_t cmdresp_result;
- struct mwifiex_wait_queue *wait_queue = NULL;
struct timeval tstamp;
unsigned long flags;
return -1;
}
- if (adapter->curr_cmd->wq_buf)
- wait_queue = (struct mwifiex_wait_queue *)
- adapter->curr_cmd->wq_buf;
-
adapter->num_cmd_timeout = 0;
resp = (struct host_cmd_ds_command *) adapter->curr_cmd->resp_skb->data;
if (!(orig_cmdresp_no & HostCmd_RET_BIT)) {
dev_err(adapter->dev, "CMD_RESP: invalid cmd resp\n");
- if (wait_queue)
- wait_queue->status = MWIFIEX_ERROR_FW_CMDRESP;
+ if (adapter->curr_cmd->wait_q_enabled)
+ adapter->cmd_wait_q.status = -1;
mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
ret = mwifiex_ret_802_11_hs_cfg(priv, resp);
} else {
/* handle response */
- ret = mwifiex_process_sta_cmdresp(priv, cmdresp_no, resp,
- wait_queue);
+ ret = mwifiex_process_sta_cmdresp(priv, cmdresp_no, resp);
}
/* Check init command response */
}
if (adapter->curr_cmd) {
- if (wait_queue && (!ret))
- wait_queue->status = MWIFIEX_ERROR_NO_ERROR;
- else if (wait_queue && (ret == -1))
- wait_queue->status = MWIFIEX_ERROR_CMD_RESP_FAIL;
+ if (adapter->curr_cmd->wait_q_enabled && (!ret))
+ adapter->cmd_wait_q.status = 0;
+ else if (adapter->curr_cmd->wait_q_enabled && (ret == -1))
+ adapter->cmd_wait_q.status = -1;
/* Clean up and put current command back to cmd_free_q */
mwifiex_insert_cmd_to_free_q(adapter, adapter->curr_cmd);
{
struct mwifiex_adapter *adapter =
(struct mwifiex_adapter *) function_context;
- struct cmd_ctrl_node *cmd_node = NULL;
- struct mwifiex_wait_queue *wait_queue = NULL;
+ struct cmd_ctrl_node *cmd_node;
struct timeval tstamp;
adapter->num_cmd_timeout++;
return;
}
cmd_node = adapter->curr_cmd;
- if (cmd_node->wq_buf) {
- wait_queue = (struct mwifiex_wait_queue *) cmd_node->wq_buf;
- wait_queue->status = MWIFIEX_ERROR_CMD_TIMEOUT;
- }
+ if (cmd_node->wait_q_enabled)
+ adapter->cmd_wait_q.status = -ETIMEDOUT;
if (cmd_node) {
adapter->dbg.timeout_cmd_id =
}
if (adapter->hw_status == MWIFIEX_HW_STATUS_INITIALIZING)
mwifiex_init_fw_complete(adapter);
-
- return;
}
/*
void
mwifiex_cancel_all_pending_cmd(struct mwifiex_adapter *adapter)
{
- struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
- struct mwifiex_wait_queue *wait_queue = NULL;
+ struct cmd_ctrl_node *cmd_node = NULL, *tmp_node;
unsigned long flags;
/* Cancel current cmd */
- if ((adapter->curr_cmd) && (adapter->curr_cmd->wq_buf)) {
- wait_queue =
- (struct mwifiex_wait_queue *) adapter->curr_cmd->wq_buf;
+ if ((adapter->curr_cmd) && (adapter->curr_cmd->wait_q_enabled)) {
spin_lock_irqsave(&adapter->mwifiex_cmd_lock, flags);
- adapter->curr_cmd->wq_buf = NULL;
+ adapter->curr_cmd->wait_q_enabled = false;
spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, flags);
- wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL;
- mwifiex_ioctl_complete(adapter, wait_queue, -1);
+ adapter->cmd_wait_q.status = -1;
+ mwifiex_complete_cmd(adapter);
}
/* Cancel all pending command */
spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
list_del(&cmd_node->list);
spin_unlock_irqrestore(&adapter->cmd_pending_q_lock, flags);
- if (cmd_node->wq_buf) {
- wait_queue =
- (struct mwifiex_wait_queue *) cmd_node->wq_buf;
- wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL;
- mwifiex_ioctl_complete(adapter, wait_queue, -1);
- cmd_node->wq_buf = NULL;
+ if (cmd_node->wait_q_enabled) {
+ adapter->cmd_wait_q.status = -1;
+ mwifiex_complete_cmd(adapter);
+ cmd_node->wait_q_enabled = false;
}
mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
spin_lock_irqsave(&adapter->cmd_pending_q_lock, flags);
list_del(&cmd_node->list);
spin_unlock_irqrestore(&adapter->scan_pending_q_lock, flags);
- cmd_node->wq_buf = NULL;
+ cmd_node->wait_q_enabled = false;
mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
spin_lock_irqsave(&adapter->scan_pending_q_lock, flags);
}
* are cancelled.
*/
void
-mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter,
- struct mwifiex_wait_queue *wait_queue)
+mwifiex_cancel_pending_ioctl(struct mwifiex_adapter *adapter)
{
struct cmd_ctrl_node *cmd_node = NULL, *tmp_node = NULL;
unsigned long cmd_flags;
uint16_t cancel_scan_cmd = false;
if ((adapter->curr_cmd) &&
- (adapter->curr_cmd->wq_buf == wait_queue)) {
+ (adapter->curr_cmd->wait_q_enabled)) {
spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
cmd_node = adapter->curr_cmd;
- cmd_node->wq_buf = NULL;
+ cmd_node->wait_q_enabled = false;
cmd_node->cmd_flag |= CMD_F_CANCELED;
- spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
- }
-
- spin_lock_irqsave(&adapter->mwifiex_cmd_lock, cmd_flags);
- while (1) {
- cmd_node = mwifiex_get_pending_ioctl_cmd(adapter, wait_queue);
- if (!cmd_node)
- break;
-
spin_lock_irqsave(&adapter->cmd_pending_q_lock,
cmd_pending_q_flags);
list_del(&cmd_node->list);
spin_unlock_irqrestore(&adapter->cmd_pending_q_lock,
cmd_pending_q_flags);
-
- cmd_node->wq_buf = NULL;
mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
+ spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
}
- spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
+
/* Cancel all pending scan command */
spin_lock_irqsave(&adapter->scan_pending_q_lock,
scan_pending_q_flags);
list_for_each_entry_safe(cmd_node, tmp_node,
&adapter->scan_pending_q, list) {
- if (cmd_node->wq_buf == wait_queue) {
- list_del(&cmd_node->list);
- spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
- scan_pending_q_flags);
- cmd_node->wq_buf = NULL;
- mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
- spin_lock_irqsave(&adapter->scan_pending_q_lock,
- scan_pending_q_flags);
- cancel_scan_cmd = true;
- }
+ list_del(&cmd_node->list);
+ spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
+ scan_pending_q_flags);
+ cmd_node->wait_q_enabled = false;
+ mwifiex_insert_cmd_to_free_q(adapter, cmd_node);
+ spin_lock_irqsave(&adapter->scan_pending_q_lock,
+ scan_pending_q_flags);
+ cancel_scan_cmd = true;
}
spin_unlock_irqrestore(&adapter->scan_pending_q_lock,
scan_pending_q_flags);
adapter->scan_processing = false;
spin_unlock_irqrestore(&adapter->mwifiex_cmd_lock, cmd_flags);
}
- wait_queue->status = MWIFIEX_ERROR_CMD_CANCEL;
- mwifiex_ioctl_complete(adapter, wait_queue, -1);
-
- return;
+ adapter->cmd_wait_q.status = -1;
+ mwifiex_complete_cmd(adapter);
}
/*
adapter->is_hs_configured = false;
mwifiex_hs_activated_event(mwifiex_get_priv(adapter,
MWIFIEX_BSS_ROLE_ANY), false);
- return;
}
/*
{
struct host_cmd_ds_802_11_ps_mode_enh *psmode_enh =
&cmd->params.psmode_enh;
- u8 *tlv = NULL;
+ u8 *tlv;
u16 cmd_size = 0;
cmd->command = cpu_to_le16(HostCmd_CMD_802_11_PS_MODE_ENH);