From: Simon Horman <horms@verge.net.au>
To: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org
Cc: Arnd Bergmann <arndbergmann@googlemail.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [rfc 2/4] igb: Initialise adapter->vfs_allocated_count in igb_init_vf()
Date: Thu, 05 Nov 2009 11:58:49 +1100 [thread overview]
Message-ID: <20091105010627.464560295@vergenet.net> (raw)
In-Reply-To: 20091105005847.941190065@vergenet.net
[-- Attachment #1: igb_init_vf-vfs_allocated_count.patch --]
[-- Type: text/plain, Size: 4095 bytes --]
Initialise adapter->vfs_allocated_count in igb_init_vf()
and only do so if the VFs are successfully created.
This seems a lot tidier to me, for starters igb_init_vf() is no longer
spliced in two by an #ifdef just to allow vfs_allocated_count to be reset to
0 if CONFIG_PCI_IOV is unset.
This change will break things if igb_init_interrupt_scheme() relies on
adapter->vfs_allocated_count, but on inspection it appears not to.
Signed-off-by: Simon Horman <horms@verge.net.au>
Index: net-next-2.6/drivers/net/igb/igb_main.c
===================================================================
--- net-next-2.6.orig/drivers/net/igb/igb_main.c 2009-11-05 04:46:06.000000000 +0900
+++ net-next-2.6/drivers/net/igb/igb_main.c 2009-11-05 04:51:10.000000000 +0900
@@ -1723,48 +1723,48 @@ static void __devexit igb_remove(struct
/**
* igb_init_vf - Initialize vf data storage and add VFs to pci config space
* @adapter: board private structure to initialize
+ * @vfn: requested number of virtual functions
*
* 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_init_vf(struct igb_adapter * adapter)
+static void __devinit igb_init_vf(struct igb_adapter * adapter, int vfn)
{
#ifdef CONFIG_PCI_IOV
struct pci_dev *pdev = adapter->pdev;
+ struct e1000_hw *hw = &adapter->hw;
- if (adapter->vfs_allocated_count > 7)
- adapter->vfs_allocated_count = 7;
+ if (hw->mac.type != e1000_82576 || !vfn)
+ return;
- 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 (vfn > 7)
+ vfn = 7;
+
+ adapter->vf_data = kcalloc(vfn, sizeof(struct vf_data_storage),
+ GFP_KERNEL);
+ /* if allocation failed then we do not support SR-IOV */
+ if (!adapter->vf_data) {
+ dev_err(&pdev->dev, "Unable to allocate memory for VF "
+ "Data Storage\n");
+ return;
}
- if (pci_enable_sriov(pdev, adapter->vfs_allocated_count)) {
+ if (pci_enable_sriov(pdev, vfn)) {
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++) {
+ dev_info(&pdev->dev, "%d vfs allocated\n", vfn);
+ for (i = 0; i < vfn; i++) {
random_ether_addr(mac_addr);
igb_set_vf_mac(adapter, i, mac_addr);
}
}
+
+ adapter->vfs_allocated_count = vfn;
#endif /* CONFIG_PCI_IOV */
}
@@ -1821,18 +1821,13 @@ static int __devinit igb_sw_init(struct
adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN;
-#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_init_vf(adapter);
+ igb_init_vf(adapter, max_vfs);
/* Explicitly disable IRQ since the NIC can be in any state. */
igb_irq_disable(adapter);
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
next prev parent reply other threads:[~2009-11-05 0:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 0:58 [rfc 0/4] igb: bandwidth allocation Simon Horman
2009-11-05 0:58 ` [rfc 1/4] igb: Add igb_cleanup_vf() Simon Horman
2009-11-05 0:58 ` Simon Horman [this message]
2009-11-05 0:58 ` [rfc 3/4] igb: Common error path in igb_init_vfs() Simon Horman
2009-11-05 0:58 ` [rfc 4/4] igb: expose 82576 bandiwidth allocation Simon Horman
2009-11-05 23:00 ` Alexander Duyck
2009-11-05 23:30 ` Simon Horman
2009-11-05 23:42 ` Alexander Duyck
2009-11-06 3:57 ` Simon Horman
2009-11-05 1:46 ` [rfc 0/4] igb: bandwidth allocation Jeff Kirsher
2009-11-05 2:21 ` Simon Horman
2009-11-14 8:01 ` Jeff Kirsher
2009-11-25 6:31 ` Simon Horman
2009-11-05 12:09 ` Andi Kleen
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=20091105010627.464560295@vergenet.net \
--to=horms@verge.net.au \
--cc=arndbergmann@googlemail.com \
--cc=e1000-devel@lists.sourceforge.net \
--cc=jeffrey.t.kirsher@intel.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).