netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Falcon <tlfalcon@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org, dnbanerg@us.ibm.com,
	brking@linux.vnet.ibm.com, pradeep@us.ibm.com,
	drt@linux.vnet.ibm.com, sukadev@linux.vnet.ibm.com,
	ljp@linux.vnet.ibm.com, cforno12@linux.ibm.com,
	tlfalcon@linux.ibm.com, ricklind@linux.ibm.com
Subject: [PATCH net-next 10/12] ibmvnic: Correctly re-enable interrupts in NAPI polling routine
Date: Thu, 12 Nov 2020 13:10:05 -0600	[thread overview]
Message-ID: <1605208207-1896-11-git-send-email-tlfalcon@linux.ibm.com> (raw)
In-Reply-To: <1605208207-1896-1-git-send-email-tlfalcon@linux.ibm.com>

From: "Dwip N. Banerjee" <dnbanerg@us.ibm.com>

If the current NAPI polling loop exits without completing it's
budget, only re-enable interrupts if there are no entries remaining
in the queue and napi_complete_done is successful. If there are entries
remaining on the queue that were missed, restart the polling loop.

Signed-off-by: Dwip N. Banerjee <dnbanerg@us.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 37 +++++++++++++++++++-----------
 1 file changed, 23 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index dc42bdc6d3e1..e48a44d8884c 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -2387,10 +2387,17 @@ static void remove_buff_from_pool(struct ibmvnic_adapter *adapter,
 
 static int ibmvnic_poll(struct napi_struct *napi, int budget)
 {
-	struct net_device *netdev = napi->dev;
-	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
-	int scrq_num = (int)(napi - adapter->napi);
-	int frames_processed = 0;
+	struct ibmvnic_sub_crq_queue *rx_scrq;
+	struct ibmvnic_adapter *adapter;
+	struct net_device *netdev;
+	int frames_processed;
+	int scrq_num;
+
+	netdev = napi->dev;
+	adapter = netdev_priv(netdev);
+	scrq_num = (int)(napi - adapter->napi);
+	frames_processed = 0;
+	rx_scrq = adapter->rx_scrq[scrq_num];
 
 restart_poll:
 	while (frames_processed < budget) {
@@ -2403,16 +2410,16 @@ static int ibmvnic_poll(struct napi_struct *napi, int budget)
 
 		if (unlikely(test_bit(0, &adapter->resetting) &&
 			     adapter->reset_reason != VNIC_RESET_NON_FATAL)) {
-			enable_scrq_irq(adapter, adapter->rx_scrq[scrq_num]);
+			enable_scrq_irq(adapter, rx_scrq);
 			napi_complete_done(napi, frames_processed);
 			return frames_processed;
 		}
 
-		if (!pending_scrq(adapter, adapter->rx_scrq[scrq_num]))
+		if (!pending_scrq(adapter, rx_scrq))
 			break;
 		/* ensure that we do not prematurely exit the polling loop */
 		dma_rmb();
-		next = ibmvnic_next_scrq(adapter, adapter->rx_scrq[scrq_num]);
+		next = ibmvnic_next_scrq(adapter, rx_scrq);
 		rx_buff =
 		    (struct ibmvnic_rx_buff *)be64_to_cpu(next->
 							  rx_comp.correlator);
@@ -2471,14 +2478,16 @@ static int ibmvnic_poll(struct napi_struct *napi, int budget)
 
 	if (adapter->state != VNIC_CLOSING)
 		replenish_rx_pool(adapter, &adapter->rx_pool[scrq_num]);
-
 	if (frames_processed < budget) {
-		enable_scrq_irq(adapter, adapter->rx_scrq[scrq_num]);
-		napi_complete_done(napi, frames_processed);
-		if (pending_scrq(adapter, adapter->rx_scrq[scrq_num]) &&
-		    napi_reschedule(napi)) {
-			disable_scrq_irq(adapter, adapter->rx_scrq[scrq_num]);
-			goto restart_poll;
+		if (napi_complete_done(napi, frames_processed)) {
+			enable_scrq_irq(adapter, rx_scrq);
+			if (pending_scrq(adapter, rx_scrq)) {
+				rmb();
+				if (napi_reschedule(napi)) {
+					disable_scrq_irq(adapter, rx_scrq);
+					goto restart_poll;
+				}
+			}
 		}
 	}
 	return frames_processed;
-- 
2.26.2


  parent reply	other threads:[~2020-11-12 19:10 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 19:09 [PATCH net-next 00/12] ibmvnic: Performance improvements and other updates Thomas Falcon
2020-11-12 19:09 ` [PATCH net-next 01/12] ibmvnic: Ensure that subCRQ entry reads are ordered Thomas Falcon
2020-11-13  5:45   ` drt
2020-11-13 16:14   ` Brian King
2020-11-14 23:35   ` Jakub Kicinski
2020-11-16 18:28     ` Thomas Falcon
2020-11-16 18:30       ` Jakub Kicinski
2020-11-12 19:09 ` [PATCH net-next 02/12] ibmvnic: Introduce indirect subordinate Command Response Queue buffer Thomas Falcon
2020-11-13 16:17   ` Brian King
2020-11-14 23:35   ` Jakub Kicinski
2020-11-16 18:18     ` Thomas Falcon
2020-11-12 19:09 ` [PATCH net-next 03/12] ibmvnic: Introduce batched RX buffer descriptor transmission Thomas Falcon
2020-11-12 19:09 ` [PATCH net-next 04/12] ibmvnic: Introduce xmit_more support using batched subCRQ hcalls Thomas Falcon
2020-11-14 23:46   ` Jakub Kicinski
2020-11-16 18:40     ` Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 05/12] ibmvnic: Fix TX completion error handling Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 06/12] ibmvnic: Clean up TX code and TX buffer data structure Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 07/12] ibmvnic: Clean up TX error handling and statistics tracking Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 08/12] ibmvnic: Remove send_subcrq function Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 09/12] ibmvnic: Ensure that device queue memory is cache-line aligned Thomas Falcon
2020-11-12 19:10 ` Thomas Falcon [this message]
2020-11-12 19:10 ` [PATCH net-next 11/12] ibmvnic: Use netdev_alloc_skb instead of alloc_skb to replenish RX buffers Thomas Falcon
2020-11-12 19:10 ` [PATCH net-next 12/12] ibmvnic: Do not replenish RX buffers after every polling loop Thomas Falcon
2020-11-13  5:52   ` drt

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=1605208207-1896-11-git-send-email-tlfalcon@linux.ibm.com \
    --to=tlfalcon@linux.ibm.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=cforno12@linux.ibm.com \
    --cc=dnbanerg@us.ibm.com \
    --cc=drt@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=ljp@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=pradeep@us.ibm.com \
    --cc=ricklind@linux.ibm.com \
    --cc=sukadev@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).