diff options
author | Scott Feldman <scofeldm@cisco.com> | 2009-09-03 13:01:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-03 23:19:09 -0400 |
commit | 27e6c7d33835e7f347cdfb5025766b7d9a6596d1 (patch) | |
tree | 70ba8cc0b46da5e7035d2bd230869d5d716c9e9b /drivers/net/enic/enic_main.c | |
parent | 1a123a3168566b10f87f228ae963770b26f27420 (diff) |
enic: add support for multiple BARs
Nic firmware can place resources (queues, intrs, etc) on multiple BARs, so
allow driver to discover/map resources beyond BAR0.
Signed-off-by: Scott Feldman <scofeldm@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/enic/enic_main.c')
-rw-r--r-- | drivers/net/enic/enic_main.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 2ea036333db2..2821a1db547d 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c | |||
@@ -1609,12 +1609,6 @@ static void enic_clear_intr_mode(struct enic *enic) | |||
1609 | vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN); | 1609 | vnic_dev_set_intr_mode(enic->vdev, VNIC_DEV_INTR_MODE_UNKNOWN); |
1610 | } | 1610 | } |
1611 | 1611 | ||
1612 | static void enic_iounmap(struct enic *enic) | ||
1613 | { | ||
1614 | if (enic->bar0.vaddr) | ||
1615 | iounmap(enic->bar0.vaddr); | ||
1616 | } | ||
1617 | |||
1618 | static const struct net_device_ops enic_netdev_ops = { | 1612 | static const struct net_device_ops enic_netdev_ops = { |
1619 | .ndo_open = enic_open, | 1613 | .ndo_open = enic_open, |
1620 | .ndo_stop = enic_stop, | 1614 | .ndo_stop = enic_stop, |
@@ -1633,6 +1627,15 @@ static const struct net_device_ops enic_netdev_ops = { | |||
1633 | #endif | 1627 | #endif |
1634 | }; | 1628 | }; |
1635 | 1629 | ||
1630 | static void enic_iounmap(struct enic *enic) | ||
1631 | { | ||
1632 | unsigned int i; | ||
1633 | |||
1634 | for (i = 0; i < ARRAY_SIZE(enic->bar); i++) | ||
1635 | if (enic->bar[i].vaddr) | ||
1636 | iounmap(enic->bar[i].vaddr); | ||
1637 | } | ||
1638 | |||
1636 | static int __devinit enic_probe(struct pci_dev *pdev, | 1639 | static int __devinit enic_probe(struct pci_dev *pdev, |
1637 | const struct pci_device_id *ent) | 1640 | const struct pci_device_id *ent) |
1638 | { | 1641 | { |
@@ -1710,31 +1713,28 @@ static int __devinit enic_probe(struct pci_dev *pdev, | |||
1710 | using_dac = 1; | 1713 | using_dac = 1; |
1711 | } | 1714 | } |
1712 | 1715 | ||
1713 | /* Map vNIC resources from BAR0 | 1716 | /* Map vNIC resources from BAR0-5 |
1714 | */ | 1717 | */ |
1715 | 1718 | ||
1716 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { | 1719 | for (i = 0; i < ARRAY_SIZE(enic->bar); i++) { |
1717 | printk(KERN_ERR PFX | 1720 | if (!(pci_resource_flags(pdev, i) & IORESOURCE_MEM)) |
1718 | "BAR0 not memory-map'able, aborting.\n"); | 1721 | continue; |
1719 | err = -ENODEV; | 1722 | enic->bar[i].len = pci_resource_len(pdev, i); |
1720 | goto err_out_release_regions; | 1723 | enic->bar[i].vaddr = pci_iomap(pdev, i, enic->bar[i].len); |
1721 | } | 1724 | if (!enic->bar[i].vaddr) { |
1722 | 1725 | printk(KERN_ERR PFX | |
1723 | enic->bar0.vaddr = pci_iomap(pdev, 0, enic->bar0.len); | 1726 | "Cannot memory-map BAR %d, aborting.\n", i); |
1724 | enic->bar0.bus_addr = pci_resource_start(pdev, 0); | 1727 | err = -ENODEV; |
1725 | enic->bar0.len = pci_resource_len(pdev, 0); | 1728 | goto err_out_iounmap; |
1726 | 1729 | } | |
1727 | if (!enic->bar0.vaddr) { | 1730 | enic->bar[i].bus_addr = pci_resource_start(pdev, i); |
1728 | printk(KERN_ERR PFX | ||
1729 | "Cannot memory-map BAR0 res hdr, aborting.\n"); | ||
1730 | err = -ENODEV; | ||
1731 | goto err_out_release_regions; | ||
1732 | } | 1731 | } |
1733 | 1732 | ||
1734 | /* Register vNIC device | 1733 | /* Register vNIC device |
1735 | */ | 1734 | */ |
1736 | 1735 | ||
1737 | enic->vdev = vnic_dev_register(NULL, enic, pdev, &enic->bar0); | 1736 | enic->vdev = vnic_dev_register(NULL, enic, pdev, enic->bar, |
1737 | ARRAY_SIZE(enic->bar)); | ||
1738 | if (!enic->vdev) { | 1738 | if (!enic->vdev) { |
1739 | printk(KERN_ERR PFX | 1739 | printk(KERN_ERR PFX |
1740 | "vNIC registration failed, aborting.\n"); | 1740 | "vNIC registration failed, aborting.\n"); |