From patchwork Fri Sep 11 02:18:42 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 33406 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 11F0AB70AD for ; Fri, 11 Sep 2009 12:21:25 +1000 (EST) Received: by ozlabs.org (Postfix) id 04737DDD0B; Fri, 11 Sep 2009 12:21:25 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 9B775DDD04 for ; Fri, 11 Sep 2009 12:21:24 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751913AbZIKCSl (ORCPT ); Thu, 10 Sep 2009 22:18:41 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751832AbZIKCSk (ORCPT ); Thu, 10 Sep 2009 22:18:40 -0400 Received: from kirsty.vergenet.net ([202.4.237.240]:44537 "EHLO kirsty.vergenet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751607AbZIKCSk (ORCPT ); Thu, 10 Sep 2009 22:18:40 -0400 Received: from yukiko.kent.sydney.vergenet.net (203-214-141-152.perm.iinet.net.au [203.214.141.152]) by kirsty.vergenet.net (Postfix) with ESMTP id DECB62404F; Fri, 11 Sep 2009 12:18:42 +1000 (EST) Received: by yukiko.kent.sydney.vergenet.net (Postfix, from userid 7100) id DB4BAC2367; Fri, 11 Sep 2009 12:18:42 +1000 (EST) Date: Fri, 11 Sep 2009 12:18:42 +1000 From: Simon Horman To: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org Cc: John Ronciak , PJ Waskiewicz , Bruce Allan , Jesse Brandeburg , Jeff Kirsher Subject: [patch] igb: Tidy vf initialisation Message-ID: <20090911021842.GC3221@verge.net.au> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is purely cosmetic, but to my mind it makes the code a lot easier to follow. Signed-off-by: Simon Horman --- 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 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)