Netdev List
 help / color / mirror / Atom feed
From: Nathan Fontenot <nfont@linux.vnet.ibm.com>
To: netdev@vger.kernel.org
Cc: brking@linux.vnet.ibm.com, jallen@linux.vnet.ibm.com,
	muvic@linux.vnet.ibm.com, tlfalcon@linux.vnet.ibm.com
Subject: [PATCH v4 net-next 01/11] ibmvnic: Move resource initialization to its own routine
Date: Wed, 03 May 2017 14:04:26 -0400	[thread overview]
Message-ID: <20170503180426.29742.74240.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com> (raw)
In-Reply-To: <20170503180246.29742.64039.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com>

Move all of the calls to initialize resources for the driver to
a separate routine.

Signed-off-by: Nathan Fontenot <nfont@linux.vnet.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c |   71 ++++++++++++++++++++----------------
 1 file changed, 39 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 4fcd2f0..c67f1d6 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -624,22 +624,10 @@ static int set_real_num_queues(struct net_device *netdev)
 	return rc;
 }
 
-static int ibmvnic_open(struct net_device *netdev)
+static int init_resources(struct ibmvnic_adapter *adapter)
 {
-	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
-	struct device *dev = &adapter->vdev->dev;
-	int rc = 0;
-	int i;
-
-	if (adapter->is_closed) {
-		rc = ibmvnic_init(adapter);
-		if (rc)
-			return rc;
-	}
-
-	rc = ibmvnic_login(netdev);
-	if (rc)
-		return rc;
+	struct net_device *netdev = adapter->netdev;
+	int i, rc;
 
 	rc = set_real_num_queues(netdev);
 	if (rc)
@@ -647,7 +635,7 @@ static int ibmvnic_open(struct net_device *netdev)
 
 	rc = init_sub_crq_irqs(adapter);
 	if (rc) {
-		dev_err(dev, "failed to initialize sub crq irqs\n");
+		netdev_err(netdev, "failed to initialize sub crq irqs\n");
 		return -1;
 	}
 
@@ -659,25 +647,47 @@ static int ibmvnic_open(struct net_device *netdev)
 	adapter->napi = kcalloc(adapter->req_rx_queues,
 				sizeof(struct napi_struct), GFP_KERNEL);
 	if (!adapter->napi)
-		goto ibmvnic_open_fail;
+		return -ENOMEM;
+
 	for (i = 0; i < adapter->req_rx_queues; i++) {
 		netif_napi_add(netdev, &adapter->napi[i], ibmvnic_poll,
 			       NAPI_POLL_WEIGHT);
-		napi_enable(&adapter->napi[i]);
 	}
 
 	send_map_query(adapter);
 
 	rc = init_rx_pools(netdev);
 	if (rc)
-		goto ibmvnic_open_fail;
+		return rc;
 
 	rc = init_tx_pools(netdev);
+	return rc;
+}
+
+static int ibmvnic_open(struct net_device *netdev)
+{
+	struct ibmvnic_adapter *adapter = netdev_priv(netdev);
+	int i, rc;
+
+	if (adapter->is_closed) {
+		rc = ibmvnic_init(adapter);
+		if (rc)
+			return rc;
+	}
+
+	rc = ibmvnic_login(netdev);
 	if (rc)
-		goto ibmvnic_open_fail;
+		return rc;
+
+	rc = init_resources(adapter);
+	if (rc)
+		return rc;
 
 	replenish_pools(adapter);
 
+	for (i = 0; i < adapter->req_rx_queues; i++)
+		napi_enable(&adapter->napi[i]);
+
 	/* We're ready to receive frames, enable the sub-crq interrupts and
 	 * set the logical link state to up
 	 */
@@ -688,19 +698,16 @@ static int ibmvnic_open(struct net_device *netdev)
 		enable_scrq_irq(adapter, adapter->tx_scrq[i]);
 
 	rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_UP);
-	if (rc)
-		goto ibmvnic_open_fail;
-
-	netif_tx_start_all_queues(netdev);
-	adapter->is_closed = false;
-
-	return 0;
+	if (rc) {
+		for (i = 0; i < adapter->req_rx_queues; i++)
+			napi_disable(&adapter->napi[i]);
+		release_resources(adapter);
+	} else {
+		netif_tx_start_all_queues(netdev);
+		adapter->is_closed = false;
+	}
 
-ibmvnic_open_fail:
-	for (i = 0; i < adapter->req_rx_queues; i++)
-		napi_disable(&adapter->napi[i]);
-	release_resources(adapter);
-	return -ENOMEM;
+	return rc;
 }
 
 static void disable_sub_crqs(struct ibmvnic_adapter *adapter)

  parent reply	other threads:[~2017-05-03 14:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-03 18:04 [PATCH v4 net-next 00/11] ibmvnic: Updated reset handler and code fixes Nathan Fontenot
2017-05-03 15:33 ` David Miller
2017-05-03 18:04 ` Nathan Fontenot [this message]
2017-05-03 18:04 ` [PATCH v4 net-next 02/11] ibmvnic: Replace is_closed with state field Nathan Fontenot
2017-05-03 18:04 ` [PATCH v4 net-next 03/11] ibmvnic: Updated reset handling Nathan Fontenot
2017-05-03 18:04 ` [PATCH v4 net-next 04/11] ibmvnic: Delete napi's when releasing driver resources Nathan Fontenot
2017-05-03 18:04 ` [PATCH v4 net-next 05/11] ibmvnic: Whitespace correction in release_rx_pools Nathan Fontenot
2017-05-03 18:04 ` [PATCH v4 net-next 06/11] ibmvnic: Clean up tx pools when closing Nathan Fontenot
2017-05-03 18:05 ` [PATCH v4 net-next 07/11] ibmvnic: Wait for any pending scrqs entries at driver close Nathan Fontenot
2017-05-03 18:05 ` [PATCH v4 net-next 08/11] ibmvnic: Check for driver reset first in ibmvnic_xmit Nathan Fontenot
2017-05-03 18:05 ` [PATCH v4 net-next 09/11] ibmvnic: Continue skb processing after skb completion error Nathan Fontenot
2017-05-03 18:05 ` [PATCH v4 net-next 10/11] ibmvnic: Record SKB RX queue during poll Nathan Fontenot
2017-05-03 18:05 ` [PATCH v4 net-next 11/11] ibmvnic: Move queue restarting in ibmvnic_tx_complete Nathan Fontenot

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=20170503180426.29742.74240.stgit@ltcalpine2-lp23.aus.stglabs.ibm.com \
    --to=nfont@linux.vnet.ibm.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=jallen@linux.vnet.ibm.com \
    --cc=muvic@linux.vnet.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=tlfalcon@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