igb: Tidy vf initialisation
Subsystems (2)
PATCH 1/1 igb: Tidy vf initialisation
This is purely cosmetic, but to my mind it makes the code a lot easier to follow.
Signed-off-by Simon Horman <[email protected]>
drivers/net/igb/igb_main.c +39 -39
@@ -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 pcif (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)
------------------------------------------------------------------------------
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