From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, gospo@redhat.com,
Alexander Duyck <alexander.h.duyck@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next-2.6 PATCH 08/23] igb: move vf init into a seperate function
Date: Wed, 28 Oct 2009 02:47:53 -0700 [thread overview]
Message-ID: <20091028094752.13156.301.stgit@localhost.localdomain> (raw)
In-Reply-To: <20091028094540.13156.2637.stgit@localhost.localdomain>
From: Alexander Duyck <alexander.h.duyck@intel.com>
This patch moves VF initialization into a seperate function to help improve
the readability of igb_probe.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
drivers/net/igb/igb_main.c | 98 +++++++++++++++++++++++++-------------------
1 files changed, 56 insertions(+), 42 deletions(-)
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index 9170927..54e8f02 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1409,46 +1409,6 @@ static int __devinit igb_probe(struct pci_dev *pdev,
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;
- }
- }
- }
- }
-
-#endif
/* setup the private structure */
err = igb_sw_init(adapter);
if (err)
@@ -1772,6 +1732,54 @@ static void __devexit igb_remove(struct pci_dev *pdev)
}
/**
+ * igb_probe_vfs - Initialize vf data storage and add VFs to pci config space
+ * @adapter: board private structure to initialize
+ *
+ * This function initializes the vf specific data storage and then attempts to
+ * allocate the VFs. The reason for ordering it this way is because it is much
+ * mor expensive time wise to disable SR-IOV than it is to allocate and free
+ * the memory for the VFs.
+ **/
+static void __devinit igb_probe_vfs(struct igb_adapter * adapter)
+{
+#ifdef CONFIG_PCI_IOV
+ struct pci_dev *pdev = adapter->pdev;
+
+ if (adapter->vfs_allocated_count > 7)
+ adapter->vfs_allocated_count = 7;
+
+ if (adapter->vfs_allocated_count) {
+ adapter->vf_data = kcalloc(adapter->vfs_allocated_count,
+ sizeof(struct vf_data_storage),
+ GFP_KERNEL);
+ /* if allocation failed then we do not support SR-IOV */
+ if (!adapter->vf_data) {
+ adapter->vfs_allocated_count = 0;
+ dev_err(&pdev->dev, "Unable to allocate memory for VF "
+ "Data Storage\n");
+ }
+ }
+
+ if (pci_enable_sriov(pdev, adapter->vfs_allocated_count)) {
+ kfree(adapter->vf_data);
+ adapter->vf_data = NULL;
+#endif /* CONFIG_PCI_IOV */
+ adapter->vfs_allocated_count = 0;
+#ifdef CONFIG_PCI_IOV
+ } else {
+ unsigned char mac_addr[ETH_ALEN];
+ int i;
+ dev_info(&pdev->dev, "%d vfs allocated\n",
+ adapter->vfs_allocated_count);
+ for (i = 0; i < adapter->vfs_allocated_count; i++) {
+ random_ether_addr(mac_addr);
+ igb_set_vf_mac(adapter, i, mac_addr);
+ }
+ }
+#endif /* CONFIG_PCI_IOV */
+}
+
+/**
* igb_sw_init - Initialize general software structures (struct igb_adapter)
* @adapter: board private structure to initialize
*
@@ -1795,13 +1803,19 @@ static int __devinit igb_sw_init(struct igb_adapter *adapter)
adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
- /* This call may decrease the number of queues depending on
- * interrupt mode. */
+#ifdef CONFIG_PCI_IOV
+ if (hw->mac.type == e1000_82576)
+ adapter->vfs_allocated_count = max_vfs;
+
+#endif /* CONFIG_PCI_IOV */
+ /* This call may decrease the number of queues */
if (igb_init_interrupt_scheme(adapter)) {
dev_err(&pdev->dev, "Unable to allocate memory for queues\n");
return -ENOMEM;
}
+ igb_probe_vfs(adapter);
+
/* Explicitly disable IRQ since the NIC can be in any state. */
igb_irq_disable(adapter);
next prev parent reply other threads:[~2009-10-28 9:51 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-28 9:45 [net-next-2.6 PATCH 01/23] igb: add support for seperate tx-usecs setting in ethtool Jeff Kirsher
2009-10-28 9:46 ` [net-next-2.6 PATCH 02/23] igb: cleanup some of the code related to hw timestamping Jeff Kirsher
2009-10-28 9:46 ` [net-next-2.6 PATCH 03/23] igb: misc cleanups within igb_ethtool.c Jeff Kirsher
2009-10-28 9:46 ` [net-next-2.6 PATCH 04/23] igb: use packet buffer sizes from RXPBS register Jeff Kirsher
2009-10-28 9:46 ` [net-next-2.6 PATCH 05/23] igb: replace the VF clear_to_send with a flags value Jeff Kirsher
2009-10-28 9:47 ` [net-next-2.6 PATCH 06/23] igb: rework use of VMOLR in regards to PF and VFs Jeff Kirsher
2009-10-28 9:47 ` [net-next-2.6 PATCH 07/23] igb: rework handling of the vfta and vlvf registers in relation to mng_vlan Jeff Kirsher
2009-10-28 9:47 ` Jeff Kirsher [this message]
2009-10-28 9:48 ` [net-next-2.6 PATCH 09/23] igb: only process global stats in igb_update_stats Jeff Kirsher
2009-10-28 9:48 ` [net-next-2.6 PATCH 10/23] igb: move global_quad_port_a from global into local static define Jeff Kirsher
2009-10-28 9:48 ` [net-next-2.6 PATCH 11/23] igb: make tx hang check multiqueue, check eop descriptor Jeff Kirsher
2009-10-28 9:49 ` [net-next-2.6 PATCH 12/23] igb: cleanup code related to ring resource allocation and free Jeff Kirsher
2009-10-28 9:49 ` [net-next-2.6 PATCH 13/23] igb: change queue ordering for 82576 based adapters Jeff Kirsher
2009-10-28 9:49 ` [net-next-2.6 PATCH 14/23] igb: cleanup interrupt enablement in regards to msix_other Jeff Kirsher
2009-10-28 9:50 ` [net-next-2.6 PATCH 15/23] igb: Remove invalid stats counters Jeff Kirsher
2009-10-28 9:50 ` [net-next-2.6 PATCH 16/23] igb: cleanup igb.h header whitespace and some structure formatting Jeff Kirsher
2009-10-28 9:50 ` [net-next-2.6 PATCH 17/23] igb: cleanup igb xmit frame path Jeff Kirsher
2009-10-28 9:51 ` [net-next-2.6 PATCH 18/23] igb: cleanup clean_rx_irq_adv and alloc_rx_buffers_adv Jeff Kirsher
2009-10-28 9:51 ` [net-next-2.6 PATCH 19/23] igb: replace unecessary &adapter->hw with just hw where applicable Jeff Kirsher
2009-10-28 9:51 ` [net-next-2.6 PATCH 20/23] igb: add pci_dev in few spots to clean up use of dev_err/info/warn Jeff Kirsher
2009-10-28 9:52 ` [net-next-2.6 PATCH 21/23] igb: limit minimum mtu to 68 to keep ip bound to interface Jeff Kirsher
2009-10-28 9:52 ` [net-next-2.6 PATCH 22/23] igb: open up SCTP checksum offloads to all MACs 82576 and newer Jeff Kirsher
2009-10-28 9:52 ` [net-next-2.6 PATCH 23/23] igb: cleanup whitespace issues in igb_main.c Jeff Kirsher
2009-10-28 10:39 ` [net-next-2.6 PATCH 01/23] igb: add support for seperate tx-usecs setting in ethtool David Miller
2009-10-28 15:42 ` Stephen Hemminger
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=20091028094752.13156.301.stgit@localhost.localdomain \
--to=jeffrey.t.kirsher@intel.com \
--cc=alexander.h.duyck@intel.com \
--cc=davem@davemloft.net \
--cc=gospo@redhat.com \
--cc=netdev@vger.kernel.org \
/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).