All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org,
	Sara Sharon <sara.sharon@intel.com>,
	Luca Coelho <luciano.coelho@intel.com>
Subject: [PATCH 05/16] iwlwifi: pcie: move rxb retrieval to a helper function
Date: Fri, 27 Jul 2018 15:48:27 +0300	[thread overview]
Message-ID: <20180727124838.25910-6-luca@coelho.fi> (raw)
In-Reply-To: <20180727124838.25910-1-luca@coelho.fi>

From: Sara Sharon <sara.sharon@intel.com>

This makes code less indented and more readable.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/pcie/rx.c | 75 +++++++++++---------
 1 file changed, 42 insertions(+), 33 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
index 284946653e27..59bedb461a8c 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/rx.c
@@ -1332,6 +1332,45 @@ static void iwl_pcie_rx_handle_rb(struct iwl_trans *trans,
 		iwl_pcie_rx_reuse_rbd(trans, rxb, rxq, emergency);
 }
 
+static struct iwl_rx_mem_buffer *iwl_pcie_get_rxb(struct iwl_trans *trans,
+						  struct iwl_rxq *rxq, int i)
+{
+	struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
+	struct iwl_rx_mem_buffer *rxb;
+	u16 vid;
+
+	if (!trans->cfg->mq_rx_supported) {
+		rxb = rxq->queue[i];
+		rxq->queue[i] = NULL;
+		return rxb;
+	}
+
+	/* used_bd is a 32/16 bit but only 12 are used to retrieve the vid */
+	if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560)
+		vid = le16_to_cpu(rxq->cd[i].rbid) & 0x0FFF;
+	else
+		vid = le32_to_cpu(rxq->bd_32[i]) & 0x0FFF;
+
+	if (!vid || vid > ARRAY_SIZE(trans_pcie->global_table))
+		goto out_err;
+
+	rxb = trans_pcie->global_table[vid - 1];
+	if (rxb->invalid)
+		goto out_err;
+
+	if (trans->cfg->device_family >= IWL_DEVICE_FAMILY_22560)
+		rxb->size = le32_to_cpu(rxq->cd[i].size) & IWL_RX_CD_SIZE;
+
+	rxb->invalid = true;
+
+	return rxb;
+
+out_err:
+	WARN(1, "Invalid rxb from HW %u\n", (u32)vid);
+	iwl_force_nmi(trans);
+	return NULL;
+}
+
 /*
  * iwl_pcie_rx_handle - Main entry function for receiving responses from fw
  */
@@ -1362,39 +1401,9 @@ static void iwl_pcie_rx_handle(struct iwl_trans *trans, int queue)
 		if (unlikely(rxq->used_count == rxq->queue_size / 2))
 			emergency = true;
 
-		if (trans->cfg->mq_rx_supported) {
-			u16 vid;
-			/*
-			 * used_bd is a 32/16 bit but only 12 are used
-			 * to retrieve the vid
-			 */
-			if (trans->cfg->device_family >=
-			    IWL_DEVICE_FAMILY_22560)
-				vid = le16_to_cpu(rxq->cd[i].rbid) & 0x0FFF;
-			else
-				vid = le32_to_cpu(rxq->bd_32[i]) & 0x0FFF;
-
-			if (WARN(!vid ||
-				 vid > ARRAY_SIZE(trans_pcie->global_table),
-				 "Invalid rxb index from HW %u\n", (u32)vid)) {
-				iwl_force_nmi(trans);
-				goto out;
-			}
-			rxb = trans_pcie->global_table[vid - 1];
-			if (WARN(rxb->invalid,
-				 "Invalid rxb from HW %u\n", (u32)vid)) {
-				iwl_force_nmi(trans);
-				goto out;
-			}
-			if (trans->cfg->device_family >=
-			    IWL_DEVICE_FAMILY_22560)
-				rxb->size = le32_to_cpu(rxq->cd[i].size) &
-					IWL_RX_CD_SIZE;
-			rxb->invalid = true;
-		} else {
-			rxb = rxq->queue[i];
-			rxq->queue[i] = NULL;
-		}
+		rxb = iwl_pcie_get_rxb(trans, rxq, i);
+		if (!rxb)
+			goto out;
 
 		IWL_DEBUG_RX(trans, "Q %d: HW = %d, SW = %d\n", rxq->id, r, i);
 		iwl_pcie_rx_handle_rb(trans, rxq, rxb, emergency);
-- 
2.18.0

  parent reply	other threads:[~2018-07-27 14:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-27 12:48 [PATCH 00/16] iwlwifi: updates intended for v4.19 2018-07-27 Luca Coelho
2018-07-27 12:48 ` [PATCH 01/16] iwlwifi: pcie: add a bunch of PCI IDs for 22000 and 22560 Luca Coelho
2018-07-27 12:48 ` [PATCH 02/16] iwlwifi: pcie: support rx structures for 22560 devices Luca Coelho
2018-07-27 12:48 ` [PATCH 03/16] iwlwifi: support new rx_mpdu_desc api Luca Coelho
2018-07-27 12:48 ` [PATCH 04/16] iwlwifi: pcie: unionize used bd and completion descriptor Luca Coelho
2018-07-27 12:48 ` Luca Coelho [this message]
2018-07-27 12:48 ` [PATCH 06/16] iwlwifi: trans: add a new op for getting DMA data Luca Coelho
2018-07-27 12:48 ` [PATCH 07/16] iwlwifi: allow masking out memory areas from the fw dump Luca Coelho
2018-07-27 12:48 ` [PATCH 08/16] iwlwifi: d3: disable dbg recording before entering D3 Luca Coelho
2018-07-27 12:48 ` [PATCH 09/16] iwlwifi: mvm: configure multi RX queue Luca Coelho
2018-07-27 12:48 ` [PATCH 10/16] iwlwifi: pcie: don't access periphery registers when not available Luca Coelho
2018-07-27 12:48 ` [PATCH 11/16] Revert "iwlwifi: implement fseq version mismatch warning" Luca Coelho
2018-07-27 12:48 ` [PATCH 12/16] iwlwifi: hard code power save mode to CAM for 22560 devices Luca Coelho
2018-07-27 12:48 ` [PATCH 13/16] iwlwifi: mvm: remove dead gscan code Luca Coelho
2018-07-27 13:05 ` [PATCH 14/16] iwlwifi: pcie: include tcp.h implicitly Luca Coelho
2018-07-27 13:05 ` [PATCH 15/16] iwlwifi: move some msix and rx functions to a common place Luca Coelho
2018-07-27 13:06 ` [PATCH 16/16] iwlwifi: pcie: split tx to amsdu and non amsdu Luca Coelho
2018-08-01  7:56 ` [PATCH 00/16] iwlwifi: updates intended for v4.19 2018-07-27 Kalle Valo
2018-08-01  8:11   ` Luciano Coelho
2018-08-01  8:17     ` Kalle Valo
2018-08-01  8:19       ` Luciano Coelho

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180727124838.25910-6-luca@coelho.fi \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=luciano.coelho@intel.com \
    --cc=sara.sharon@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.