Commit 4492bb6b authored by Johannes Berg's avatar Johannes Berg Committed by Emmanuel Grumbach

iwlwifi: dvm: move ADD_STA response handling to sync command

This driver currently has some very confusing ADD_STA response handling
that runs asynchronously in the background for all of the commands, but
is only really necessary for synchronous ones (the really asynchronous
ones can only be done for already existing stations), and for the sync
ones it actually waits for the RX handler to return a status code.

Rework this to keep the debug printing in the handler, but do the code
that's supposed to have an effect only for sync commands in the command
sending function.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
parent 2dc2a15e
...@@ -66,12 +66,11 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, ...@@ -66,12 +66,11 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
{ {
struct iwl_add_sta_resp *add_sta_resp = (void *)pkt->data; struct iwl_add_sta_resp *add_sta_resp = (void *)pkt->data;
u8 sta_id = addsta->sta.sta_id; u8 sta_id = addsta->sta.sta_id;
int ret = -EIO;
if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n", IWL_ERR(priv, "Bad return from REPLY_ADD_STA (0x%08X)\n",
pkt->hdr.flags); pkt->hdr.flags);
return ret; return 0;
} }
IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n", IWL_DEBUG_INFO(priv, "Processing response for adding station %u\n",
...@@ -82,7 +81,6 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, ...@@ -82,7 +81,6 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
switch (add_sta_resp->status) { switch (add_sta_resp->status) {
case ADD_STA_SUCCESS_MSK: case ADD_STA_SUCCESS_MSK:
IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n"); IWL_DEBUG_INFO(priv, "REPLY_ADD_STA PASSED\n");
ret = iwl_sta_ucode_activate(priv, sta_id);
break; break;
case ADD_STA_NO_ROOM_IN_TABLE: case ADD_STA_NO_ROOM_IN_TABLE:
IWL_ERR(priv, "Adding station %d failed, no room in table.\n", IWL_ERR(priv, "Adding station %d failed, no room in table.\n",
...@@ -121,7 +119,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv, ...@@ -121,7 +119,7 @@ static int iwl_process_add_sta_resp(struct iwl_priv *priv,
addsta->sta.addr); addsta->sta.addr);
spin_unlock_bh(&priv->sta_lock); spin_unlock_bh(&priv->sta_lock);
return ret; return 0;
} }
int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb, int iwl_add_sta_callback(struct iwl_priv *priv, struct iwl_rx_cmd_buffer *rxb,
...@@ -146,6 +144,8 @@ int iwl_send_add_sta(struct iwl_priv *priv, ...@@ -146,6 +144,8 @@ int iwl_send_add_sta(struct iwl_priv *priv,
.len = { sizeof(*sta), }, .len = { sizeof(*sta), },
}; };
u8 sta_id __maybe_unused = sta->sta.sta_id; u8 sta_id __maybe_unused = sta->sta.sta_id;
struct iwl_rx_packet *pkt;
struct iwl_add_sta_resp *add_sta_resp;
IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n", IWL_DEBUG_INFO(priv, "Adding sta %u (%pM) %ssynchronously\n",
sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : ""); sta_id, sta->sta.addr, flags & CMD_ASYNC ? "a" : "");
...@@ -159,16 +159,23 @@ int iwl_send_add_sta(struct iwl_priv *priv, ...@@ -159,16 +159,23 @@ int iwl_send_add_sta(struct iwl_priv *priv,
if (ret || (flags & CMD_ASYNC)) if (ret || (flags & CMD_ASYNC))
return ret; return ret;
/*else the command was successfully sent in SYNC mode, need to free
* the reply page */
iwl_free_resp(&cmd); pkt = cmd.resp_pkt;
add_sta_resp = (void *)pkt->data;
if (cmd.handler_status) /* debug messages are printed in the handler */
IWL_ERR(priv, "%s - error in the CMD response %d\n", __func__, if (!(pkt->hdr.flags & IWL_CMD_FAILED_MSK) &&
cmd.handler_status); add_sta_resp->status == ADD_STA_SUCCESS_MSK) {
spin_lock_bh(&priv->sta_lock);
ret = iwl_sta_ucode_activate(priv, sta_id);
spin_unlock_bh(&priv->sta_lock);
} else {
ret = -EIO;
}
iwl_free_resp(&cmd);
return cmd.handler_status; return ret;
} }
bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv, bool iwl_is_ht40_tx_allowed(struct iwl_priv *priv,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment