iwlwifi: block the queues when we send ADD_STA for uAPSD
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Tue, 24 Nov 2015 12:55:18 +0000 (14:55 +0200)
committerEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Sun, 13 Dec 2015 06:52:53 +0000 (08:52 +0200)
We send an ADD_STA to instruct the firmware to release
frames despite the peer being in PS.
Since the ADD_STA command and the Tx frame that comes
immediately afterwards can be reordered by the DMA engine,
we need to block the Tx queues until the firmware replies
with the ADD_STA response.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
drivers/net/wireless/intel/iwlwifi/mvm/ops.c
drivers/net/wireless/intel/iwlwifi/mvm/sta.c

index b71c85b244a023b2692b865f8fe40eaf7cc98862..4e417fd9beb64252f5af881759b32c6e5a35dab7 100644 (file)
@@ -839,6 +839,18 @@ static void iwl_mvm_stop_sw_queue(struct iwl_op_mode *op_mode, int queue)
        }
 }
 
+static void iwl_mvm_async_cb(struct iwl_op_mode *op_mode,
+                            const struct iwl_device_cmd *cmd)
+{
+       struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
+
+       /*
+        * For now, we only set the CMD_WANT_ASYNC_CALLBACK for ADD_STA
+        * commands that need to block the Tx queues.
+        */
+       iwl_trans_block_txq_ptrs(mvm->trans, false);
+}
+
 static void iwl_mvm_wake_sw_queue(struct iwl_op_mode *op_mode, int queue)
 {
        struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
@@ -1414,6 +1426,7 @@ int iwl_mvm_exit_d0i3(struct iwl_op_mode *op_mode)
 
 #define IWL_MVM_COMMON_OPS                                     \
        /* these could be differentiated */                     \
+       .async_cb = iwl_mvm_async_cb,                           \
        .queue_full = iwl_mvm_stop_sw_queue,                    \
        .queue_not_full = iwl_mvm_wake_sw_queue,                \
        .hw_rf_kill = iwl_mvm_set_hw_rfkill_state,              \
index dc3206a353e1277b9872461777dde82bd65b0964..566b65944fb8a08f78d0d9fd9480537f392a715c 100644 (file)
@@ -1708,7 +1708,12 @@ void iwl_mvm_sta_modify_sleep_tx_count(struct iwl_mvm *mvm,
                cmd.sleep_state_flags |= cpu_to_le16(STA_SLEEP_STATE_UAPSD);
        }
 
-       ret = iwl_mvm_send_cmd_pdu(mvm, ADD_STA, CMD_ASYNC, sizeof(cmd), &cmd);
+       /* block the Tx queues until the FW updated the sleep Tx count */
+       iwl_trans_block_txq_ptrs(mvm->trans, true);
+
+       ret = iwl_mvm_send_cmd_pdu(mvm, ADD_STA,
+                                  CMD_ASYNC | CMD_WANT_ASYNC_CALLBACK,
+                                  sizeof(cmd), &cmd);
        if (ret)
                IWL_ERR(mvm, "Failed to send ADD_STA command (%d)\n", ret);
 }