netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
To: netdev@vger.kernel.org
Cc: jallen@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com,
	davem@davemloft.net, Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Subject: [PATCH net-next v5 7/8] ibmvnic: Update TX pool cleaning routine
Date: Fri, 16 Mar 2018 20:00:30 -0500	[thread overview]
Message-ID: <1521248431-6353-8-git-send-email-tlfalcon@linux.vnet.ibm.com> (raw)
In-Reply-To: <1521248431-6353-1-git-send-email-tlfalcon@linux.vnet.ibm.com>

Update routine that cleans up any outstanding transmits that
have not received completions when the device needs to close.
Introduces a helper function that cleans one TX pool to make
code more readable.

Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 40 +++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index af6f8193cb67..5632c030811b 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1128,34 +1128,42 @@ static void clean_rx_pools(struct ibmvnic_adapter *adapter)
 	}
 }
 
-static void clean_tx_pools(struct ibmvnic_adapter *adapter)
+static void clean_one_tx_pool(struct ibmvnic_adapter *adapter,
+			      struct ibmvnic_tx_pool *tx_pool)
 {
-	struct ibmvnic_tx_pool *tx_pool;
 	struct ibmvnic_tx_buff *tx_buff;
 	u64 tx_entries;
+	int i;
+
+	if (!tx_pool && !tx_pool->tx_buff)
+		return;
+
+	tx_entries = tx_pool->num_buffers;
+
+	for (i = 0; i < tx_entries; i++) {
+		tx_buff = &tx_pool->tx_buff[i];
+		if (tx_buff && tx_buff->skb) {
+			dev_kfree_skb_any(tx_buff->skb);
+			tx_buff->skb = NULL;
+		}
+	}
+}
+
+static void clean_tx_pools(struct ibmvnic_adapter *adapter)
+{
 	int tx_scrqs;
-	int i, j;
+	int i;
 
-	if (!adapter->tx_pool)
+	if (!adapter->tx_pool || !adapter->tso_pool)
 		return;
 
 	tx_scrqs = be32_to_cpu(adapter->login_rsp_buf->num_txsubm_subcrqs);
-	tx_entries = adapter->req_tx_entries_per_subcrq;
 
 	/* Free any remaining skbs in the tx buffer pools */
 	for (i = 0; i < tx_scrqs; i++) {
-		tx_pool = &adapter->tx_pool[i];
-		if (!tx_pool && !tx_pool->tx_buff)
-			continue;
-
 		netdev_dbg(adapter->netdev, "Cleaning tx_pool[%d]\n", i);
-		for (j = 0; j < tx_entries; j++) {
-			tx_buff = &tx_pool->tx_buff[j];
-			if (tx_buff && tx_buff->skb) {
-				dev_kfree_skb_any(tx_buff->skb);
-				tx_buff->skb = NULL;
-			}
-		}
+		clean_one_tx_pool(adapter, &adapter->tx_pool[i]);
+		clean_one_tx_pool(adapter, &adapter->tso_pool[i]);
 	}
 }
 
-- 
2.15.0

  parent reply	other threads:[~2018-03-17  1:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-17  1:00 [PATCH net-next v5 0/8] ibmvnic: Update TX pool and TX routines Thomas Falcon
2018-03-17  1:00 ` [PATCH net-next v5 1/8] ibmvnic: Generalize TX pool structure Thomas Falcon
2018-03-17  1:00 ` [PATCH net-next v5 2/8] ibmvnic: Update and clean up reset TX pool routine Thomas Falcon
2018-03-17  1:00 ` [PATCH net-next v5 3/8] ibmvnic: Update release " Thomas Falcon
2018-03-17  1:00 ` [PATCH net-next v5 4/8] ibmvnic: Update TX pool initialization routine Thomas Falcon
2018-03-17  1:00 ` [PATCH net-next v5 5/8] ibmvnic: Update TX and TX completion routines Thomas Falcon
2018-03-17  1:00 ` [PATCH net-next v5 6/8] ibmvnic: Improve TX buffer accounting Thomas Falcon
2018-03-17  1:00 ` Thomas Falcon [this message]
2018-03-17  1:00 ` [PATCH net-next v5 8/8] ibmvnic: Remove unused TSO resources in TX pool structure Thomas Falcon
2018-03-18  0:12 ` [PATCH net-next v5 0/8] ibmvnic: Update TX pool and TX routines David Miller

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=1521248431-6353-8-git-send-email-tlfalcon@linux.vnet.ibm.com \
    --to=tlfalcon@linux.vnet.ibm.com \
    --cc=davem@davemloft.net \
    --cc=jallen@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=nfont@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).