Patchwork igb: Tidy vf initialisation

login
register
mail settings
Submitter Simon Horman
Date Sept. 11, 2009, 2:18 a.m.
Message ID <20090911021842.GC3221@verge.net.au>
Download mbox | patch
Permalink /patch/33406/
State Awaiting Upstream
Delegated to: David Miller
Headers show

Comments

Simon Horman - Sept. 11, 2009, 2:18 a.m.
This is purely cosmetic, but to my mind it makes the code a lot easier
to follow.

Signed-off-by: Simon Horman <horms@verge.net.au>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

Index: net-next-2.6/drivers/net/igb/igb_main.c
===================================================================
--- net-next-2.6.orig/drivers/net/igb/igb_main.c	2009-09-09 15:04:34.000000000 +1000
+++ net-next-2.6/drivers/net/igb/igb_main.c	2009-09-09 16:06:59.000000000 +1000
@@ -1194,6 +1194,44 @@  static const struct net_device_ops igb_n
 #endif
 };
 
+/* Since IOV functionality isn't critical to base device function we can
+ * accept failure.  If it fails we don't allow IOV to be enabled */
+static void __devinit igb_probe_vf(struct pci_dev *pdev,
+				   struct igb_adapter *adapter)
+{
+#ifdef CONFIG_PCI_IOV
+	/* 82576 supports a maximum of 7 VFs in addition to the PF */
+	unsigned int num_vfs = (max_vfs > 7) ? 7 : max_vfs;
+	int i;
+	unsigned char mac_addr[ETH_ALEN];
+
+	if (adapter->hw.mac.type != e1000_82576 || !num_vfs)
+		return;
+
+	adapter->vf_data = kcalloc(num_vfs, sizeof(struct vf_data_storage),
+				   GFP_KERNEL);
+	if (!adapter->vf_data) {
+		dev_err(&pdev->dev, "Could not allocate VF private data - "
+				    "IOV enable failed\n");
+		return;
+	}
+
+	if (pci_enable_sriov(pdev, num_vfs)) {
+		kfree(adapter->vf_data);
+		adapter->vf_data = NULL;
+		return;
+	}
+
+	adapter->vfs_allocated_count = num_vfs;
+	dev_info(&pdev->dev, "%d vfs allocated\n", num_vfs);
+	for (i = 0; i < adapter->vfs_allocated_count; i++) {
+		random_ether_addr(mac_addr);
+		igb_set_vf_mac(adapter, i, mac_addr);
+	}
+#endif
+	return;
+}
+
 /**
  * igb_probe - Device Initialization Routine
  * @pdev: PCI device information struct
@@ -1307,46 +1345,8 @@  static int __devinit igb_probe(struct pc
 	if (err)
 		goto err_sw_init;
 
-#ifdef CONFIG_PCI_IOV
-	/* since iov functionality isn't critical to base device function we
-	 * can accept failure.  If it fails we don't allow iov to be enabled */
-	if (hw->mac.type == e1000_82576) {
-		/* 82576 supports a maximum of 7 VFs in addition to the PF */
-		unsigned int num_vfs = (max_vfs > 7) ? 7 : max_vfs;
-		int i;
-		unsigned char mac_addr[ETH_ALEN];
-
-		if (num_vfs) {
-			adapter->vf_data = kcalloc(num_vfs,
-						sizeof(struct vf_data_storage),
-						GFP_KERNEL);
-			if (!adapter->vf_data) {
-				dev_err(&pdev->dev,
-				        "Could not allocate VF private data - "
-					"IOV enable failed\n");
-			} else {
-				err = pci_enable_sriov(pdev, num_vfs);
-				if (!err) {
-					adapter->vfs_allocated_count = num_vfs;
-					dev_info(&pdev->dev,
-					         "%d vfs allocated\n",
-					         num_vfs);
-					for (i = 0;
-					     i < adapter->vfs_allocated_count;
-					     i++) {
-						random_ether_addr(mac_addr);
-						igb_set_vf_mac(adapter, i,
-						               mac_addr);
-					}
-				} else {
-					kfree(adapter->vf_data);
-					adapter->vf_data = NULL;
-				}
-			}
-		}
-	}
+	igb_probe_vf(pdev, adapter);
 
-#endif
 	/* setup the private structure */
 	err = igb_sw_init(adapter);
 	if (err)