Commit 65b94a4a authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

iwlwifi: pass response packet directly

When CMD_WANT_SKB is set for a (synchronous)
command, the response is passed back to the
caller which is then responsible for freeing
it. Make this more abstract with real API,
passing directly the response packet in the
new cmd.resp_pkt member and also introduce
iwl_free_resp() to free the pages -- this
way the upper layers don't have to directly
touch the page implementation.

NOTE: This breaks IDI -- the new code isn't reflected there yet!
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 2c6ab7ff
...@@ -160,7 +160,7 @@ int iwl_send_add_sta(struct iwl_priv *priv, ...@@ -160,7 +160,7 @@ int iwl_send_add_sta(struct iwl_priv *priv,
/*else the command was successfully sent in SYNC mode, need to free /*else the command was successfully sent in SYNC mode, need to free
* the reply page */ * the reply page */
iwl_free_pages(priv->shrd, cmd.reply_page); iwl_free_resp(&cmd);
if (cmd.handler_status) if (cmd.handler_status)
IWL_ERR(priv, "%s - error in the CMD response %d", __func__, IWL_ERR(priv, "%s - error in the CMD response %d", __func__,
...@@ -415,7 +415,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, ...@@ -415,7 +415,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
if (ret) if (ret)
return ret; return ret;
pkt = (struct iwl_rx_packet *)cmd.reply_page; pkt = cmd.resp_pkt;
if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) { if (pkt->hdr.flags & IWL_CMD_FAILED_MSK) {
IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n", IWL_ERR(priv, "Bad return from REPLY_REMOVE_STA (0x%08X)\n",
pkt->hdr.flags); pkt->hdr.flags);
...@@ -438,7 +438,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv, ...@@ -438,7 +438,7 @@ static int iwl_send_remove_station(struct iwl_priv *priv,
break; break;
} }
} }
iwl_free_pages(priv->shrd, cmd.reply_page); iwl_free_resp(&cmd);
return ret; return ret;
} }
......
...@@ -76,7 +76,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) ...@@ -76,7 +76,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
if (ret) if (ret)
return ret; return ret;
pkt = (struct iwl_rx_packet *)cmd.reply_page; pkt = cmd.resp_pkt;
if (pkt->u.status != CAN_ABORT_STATUS) { if (pkt->u.status != CAN_ABORT_STATUS) {
/* The scan abort will return 1 for success or /* The scan abort will return 1 for success or
* 2 for "failure". A failure condition can be * 2 for "failure". A failure condition can be
...@@ -88,7 +88,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv) ...@@ -88,7 +88,7 @@ static int iwl_send_scan_abort(struct iwl_priv *priv)
ret = -EIO; ret = -EIO;
} }
iwl_free_pages(priv->shrd, cmd.reply_page); iwl_free_resp(&cmd);
return ret; return ret;
} }
......
...@@ -413,11 +413,6 @@ static inline bool iwl_have_debug_level(u32 level) ...@@ -413,11 +413,6 @@ static inline bool iwl_have_debug_level(u32 level)
return iwlagn_mod_params.debug_level & level; return iwlagn_mod_params.debug_level & level;
} }
static inline void iwl_free_pages(struct iwl_shared *shrd, unsigned long page)
{
free_pages(page, shrd->hw_params.rx_page_order);
}
/** /**
* iwl_queue_inc_wrap - increment queue index, wrap back to beginning * iwl_queue_inc_wrap - increment queue index, wrap back to beginning
* @index -- current index * @index -- current index
......
...@@ -292,7 +292,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) ...@@ -292,7 +292,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
return ret; return ret;
/* Handling return of SKB to the user */ /* Handling return of SKB to the user */
pkt = (struct iwl_rx_packet *)cmd.reply_page; pkt = cmd.resp_pkt;
if (!pkt) { if (!pkt) {
IWL_ERR(priv, "HCMD received a null response packet\n"); IWL_ERR(priv, "HCMD received a null response packet\n");
return ret; return ret;
...@@ -309,7 +309,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb) ...@@ -309,7 +309,7 @@ static int iwl_testmode_ucode(struct ieee80211_hw *hw, struct nlattr **tb)
/* The reply is in a page, that we cannot send to user space. */ /* The reply is in a page, that we cannot send to user space. */
memcpy(reply_buf, &(pkt->hdr), reply_len); memcpy(reply_buf, &(pkt->hdr), reply_len);
iwl_free_pages(priv->shrd, cmd.reply_page); iwl_free_resp(&cmd);
NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT); NLA_PUT_U32(skb, IWL_TM_ATTR_COMMAND, IWL_TM_CMD_DEV2APP_UCODE_RX_PKT);
NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf); NLA_PUT(skb, IWL_TM_ATTR_UCODE_RX_PKT, reply_len, reply_buf);
......
...@@ -879,9 +879,13 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb, ...@@ -879,9 +879,13 @@ void iwl_tx_cmd_complete(struct iwl_trans *trans, struct iwl_rx_mem_buffer *rxb,
/* Input error checking is done when commands are added to queue. */ /* Input error checking is done when commands are added to queue. */
if (meta->flags & CMD_WANT_SKB) { if (meta->flags & CMD_WANT_SKB) {
meta->source->reply_page = (unsigned long)rxb_addr(rxb); struct page *p = rxb->page;
meta->source->handler_status = handler_status;
rxb->page = NULL; rxb->page = NULL;
meta->source->resp_pkt = pkt;
meta->source->_rx_page_addr = (unsigned long)page_address(p);
meta->source->_rx_page_order = hw_params(trans).rx_page_order;
meta->source->handler_status = handler_status;
} }
iwl_hcmd_queue_reclaim(trans, txq_id, index); iwl_hcmd_queue_reclaim(trans, txq_id, index);
...@@ -985,7 +989,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ...@@ -985,7 +989,7 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
} }
} }
if ((cmd->flags & CMD_WANT_SKB) && !cmd->reply_page) { if ((cmd->flags & CMD_WANT_SKB) && !cmd->resp_pkt) {
IWL_ERR(trans, "Error: Response NULL in '%s'\n", IWL_ERR(trans, "Error: Response NULL in '%s'\n",
get_cmd_string(cmd->id)); get_cmd_string(cmd->id));
ret = -EIO; ret = -EIO;
...@@ -1006,9 +1010,9 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd) ...@@ -1006,9 +1010,9 @@ static int iwl_send_cmd_sync(struct iwl_trans *trans, struct iwl_host_cmd *cmd)
~CMD_WANT_SKB; ~CMD_WANT_SKB;
} }
if (cmd->reply_page) { if (cmd->resp_pkt) {
iwl_free_pages(trans->shrd, cmd->reply_page); iwl_free_resp(cmd);
cmd->reply_page = 0; cmd->resp_pkt = NULL;
} }
return ret; return ret;
......
...@@ -173,7 +173,9 @@ enum iwl_hcmd_dataflag { ...@@ -173,7 +173,9 @@ enum iwl_hcmd_dataflag {
* struct iwl_host_cmd - Host command to the uCode * struct iwl_host_cmd - Host command to the uCode
* *
* @data: array of chunks that composes the data of the host command * @data: array of chunks that composes the data of the host command
* @reply_page: pointer to the page that holds the response to the host command * @resp_pkt: response packet, if %CMD_WANT_SKB was set
* @_rx_page_order: (internally used to free response packet)
* @_rx_page_addr: (internally used to free response packet)
* @handler_status: return value of the handler of the command * @handler_status: return value of the handler of the command
* (put in setup_rx_handlers) - valid for SYNC mode only * (put in setup_rx_handlers) - valid for SYNC mode only
* @flags: can be CMD_* * @flags: can be CMD_*
...@@ -183,7 +185,9 @@ enum iwl_hcmd_dataflag { ...@@ -183,7 +185,9 @@ enum iwl_hcmd_dataflag {
*/ */
struct iwl_host_cmd { struct iwl_host_cmd {
const void *data[IWL_MAX_CMD_TFDS]; const void *data[IWL_MAX_CMD_TFDS];
unsigned long reply_page; struct iwl_rx_packet *resp_pkt;
unsigned long _rx_page_addr;
u32 _rx_page_order;
int handler_status; int handler_status;
u32 flags; u32 flags;
...@@ -192,6 +196,11 @@ struct iwl_host_cmd { ...@@ -192,6 +196,11 @@ struct iwl_host_cmd {
u8 id; u8 id;
}; };
static inline void iwl_free_resp(struct iwl_host_cmd *cmd)
{
free_pages(cmd->_rx_page_addr, cmd->_rx_page_order);
}
/** /**
* struct iwl_trans_ops - transport specific operations * struct iwl_trans_ops - transport specific operations
* *
......
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