diff options
Diffstat (limited to 'drivers/net/netxen/netxen_nic_main.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 79 |
1 files changed, 50 insertions, 29 deletions
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index 08780ef1c1f8..b665b420a4f2 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -23,6 +23,7 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/slab.h> | ||
26 | #include <linux/vmalloc.h> | 27 | #include <linux/vmalloc.h> |
27 | #include <linux/interrupt.h> | 28 | #include <linux/interrupt.h> |
28 | #include "netxen_nic_hw.h" | 29 | #include "netxen_nic_hw.h" |
@@ -604,16 +605,14 @@ netxen_cleanup_pci_map(struct netxen_adapter *adapter) | |||
604 | static int | 605 | static int |
605 | netxen_setup_pci_map(struct netxen_adapter *adapter) | 606 | netxen_setup_pci_map(struct netxen_adapter *adapter) |
606 | { | 607 | { |
607 | void __iomem *mem_ptr0 = NULL; | ||
608 | void __iomem *mem_ptr1 = NULL; | ||
609 | void __iomem *mem_ptr2 = NULL; | ||
610 | void __iomem *db_ptr = NULL; | 608 | void __iomem *db_ptr = NULL; |
611 | 609 | ||
612 | resource_size_t mem_base, db_base; | 610 | resource_size_t mem_base, db_base; |
613 | unsigned long mem_len, db_len = 0, pci_len0 = 0; | 611 | unsigned long mem_len, db_len = 0; |
614 | 612 | ||
615 | struct pci_dev *pdev = adapter->pdev; | 613 | struct pci_dev *pdev = adapter->pdev; |
616 | int pci_func = adapter->ahw.pci_func; | 614 | int pci_func = adapter->ahw.pci_func; |
615 | struct netxen_hardware_context *ahw = &adapter->ahw; | ||
617 | 616 | ||
618 | int err = 0; | 617 | int err = 0; |
619 | 618 | ||
@@ -630,24 +629,40 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) | |||
630 | 629 | ||
631 | /* 128 Meg of memory */ | 630 | /* 128 Meg of memory */ |
632 | if (mem_len == NETXEN_PCI_128MB_SIZE) { | 631 | if (mem_len == NETXEN_PCI_128MB_SIZE) { |
633 | mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); | 632 | |
634 | mem_ptr1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, | 633 | ahw->pci_base0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE); |
634 | ahw->pci_base1 = ioremap(mem_base + SECOND_PAGE_GROUP_START, | ||
635 | SECOND_PAGE_GROUP_SIZE); | 635 | SECOND_PAGE_GROUP_SIZE); |
636 | mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, | 636 | ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START, |
637 | THIRD_PAGE_GROUP_SIZE); | 637 | THIRD_PAGE_GROUP_SIZE); |
638 | pci_len0 = FIRST_PAGE_GROUP_SIZE; | 638 | if (ahw->pci_base0 == NULL || ahw->pci_base1 == NULL || |
639 | ahw->pci_base2 == NULL) { | ||
640 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); | ||
641 | err = -EIO; | ||
642 | goto err_out; | ||
643 | } | ||
644 | |||
645 | ahw->pci_len0 = FIRST_PAGE_GROUP_SIZE; | ||
646 | |||
639 | } else if (mem_len == NETXEN_PCI_32MB_SIZE) { | 647 | } else if (mem_len == NETXEN_PCI_32MB_SIZE) { |
640 | mem_ptr1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); | 648 | |
641 | mem_ptr2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - | 649 | ahw->pci_base1 = ioremap(mem_base, SECOND_PAGE_GROUP_SIZE); |
650 | ahw->pci_base2 = ioremap(mem_base + THIRD_PAGE_GROUP_START - | ||
642 | SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); | 651 | SECOND_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); |
652 | if (ahw->pci_base1 == NULL || ahw->pci_base2 == NULL) { | ||
653 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); | ||
654 | err = -EIO; | ||
655 | goto err_out; | ||
656 | } | ||
657 | |||
643 | } else if (mem_len == NETXEN_PCI_2MB_SIZE) { | 658 | } else if (mem_len == NETXEN_PCI_2MB_SIZE) { |
644 | 659 | ||
645 | mem_ptr0 = pci_ioremap_bar(pdev, 0); | 660 | ahw->pci_base0 = pci_ioremap_bar(pdev, 0); |
646 | if (mem_ptr0 == NULL) { | 661 | if (ahw->pci_base0 == NULL) { |
647 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); | 662 | dev_err(&pdev->dev, "failed to map PCI bar 0\n"); |
648 | return -EIO; | 663 | return -EIO; |
649 | } | 664 | } |
650 | pci_len0 = mem_len; | 665 | ahw->pci_len0 = mem_len; |
651 | } else { | 666 | } else { |
652 | return -EIO; | 667 | return -EIO; |
653 | } | 668 | } |
@@ -656,11 +671,6 @@ netxen_setup_pci_map(struct netxen_adapter *adapter) | |||
656 | 671 | ||
657 | dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); | 672 | dev_info(&pdev->dev, "%dMB memory map\n", (int)(mem_len>>20)); |
658 | 673 | ||
659 | adapter->ahw.pci_base0 = mem_ptr0; | ||
660 | adapter->ahw.pci_len0 = pci_len0; | ||
661 | adapter->ahw.pci_base1 = mem_ptr1; | ||
662 | adapter->ahw.pci_base2 = mem_ptr2; | ||
663 | |||
664 | if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) { | 674 | if (NX_IS_REVISION_P3P(adapter->ahw.revision_id)) { |
665 | adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter, | 675 | adapter->ahw.ocm_win_crb = netxen_get_ioaddr(adapter, |
666 | NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func))); | 676 | NETXEN_PCIX_PS_REG(PCIX_OCM_WINDOW_REG(pci_func))); |
@@ -772,15 +782,22 @@ netxen_check_options(struct netxen_adapter *adapter) | |||
772 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { | 782 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { |
773 | adapter->msix_supported = !!use_msi_x; | 783 | adapter->msix_supported = !!use_msi_x; |
774 | adapter->rss_supported = !!use_msi_x; | 784 | adapter->rss_supported = !!use_msi_x; |
775 | } else if (adapter->fw_version >= NETXEN_VERSION_CODE(3, 4, 336)) { | 785 | } else { |
776 | switch (adapter->ahw.board_type) { | 786 | u32 flashed_ver = 0; |
777 | case NETXEN_BRDTYPE_P2_SB31_10G: | 787 | netxen_rom_fast_read(adapter, |
778 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: | 788 | NX_FW_VERSION_OFFSET, (int *)&flashed_ver); |
779 | adapter->msix_supported = !!use_msi_x; | 789 | flashed_ver = NETXEN_DECODE_VERSION(flashed_ver); |
780 | adapter->rss_supported = !!use_msi_x; | 790 | |
781 | break; | 791 | if (flashed_ver >= NETXEN_VERSION_CODE(3, 4, 336)) { |
782 | default: | 792 | switch (adapter->ahw.board_type) { |
783 | break; | 793 | case NETXEN_BRDTYPE_P2_SB31_10G: |
794 | case NETXEN_BRDTYPE_P2_SB31_10G_CX4: | ||
795 | adapter->msix_supported = !!use_msi_x; | ||
796 | adapter->rss_supported = !!use_msi_x; | ||
797 | break; | ||
798 | default: | ||
799 | break; | ||
800 | } | ||
784 | } | 801 | } |
785 | } | 802 | } |
786 | 803 | ||
@@ -1246,8 +1263,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1246 | int pci_func_id = PCI_FUNC(pdev->devfn); | 1263 | int pci_func_id = PCI_FUNC(pdev->devfn); |
1247 | uint8_t revision_id; | 1264 | uint8_t revision_id; |
1248 | 1265 | ||
1249 | if (pdev->revision >= NX_P3_A0 && pdev->revision < NX_P3_B1) { | 1266 | if (pdev->revision >= NX_P3_A0 && pdev->revision <= NX_P3_B1) { |
1250 | pr_warning("%s: chip revisions between 0x%x-0x%x" | 1267 | pr_warning("%s: chip revisions between 0x%x-0x%x " |
1251 | "will not be enabled.\n", | 1268 | "will not be enabled.\n", |
1252 | module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1); | 1269 | module_name(THIS_MODULE), NX_P3_A0, NX_P3_B1); |
1253 | return -ENODEV; | 1270 | return -ENODEV; |
@@ -2294,6 +2311,7 @@ netxen_fwinit_work(struct work_struct *work) | |||
2294 | } | 2311 | } |
2295 | break; | 2312 | break; |
2296 | 2313 | ||
2314 | case NX_DEV_NEED_RESET: | ||
2297 | case NX_DEV_INITALIZING: | 2315 | case NX_DEV_INITALIZING: |
2298 | if (++adapter->fw_wait_cnt < FW_POLL_THRESH) { | 2316 | if (++adapter->fw_wait_cnt < FW_POLL_THRESH) { |
2299 | netxen_schedule_work(adapter, | 2317 | netxen_schedule_work(adapter, |
@@ -2337,6 +2355,9 @@ netxen_detach_work(struct work_struct *work) | |||
2337 | 2355 | ||
2338 | ref_cnt = nx_decr_dev_ref_cnt(adapter); | 2356 | ref_cnt = nx_decr_dev_ref_cnt(adapter); |
2339 | 2357 | ||
2358 | if (ref_cnt == -EIO) | ||
2359 | goto err_ret; | ||
2360 | |||
2340 | delay = (ref_cnt == 0) ? 0 : (2 * FW_POLL_DELAY); | 2361 | delay = (ref_cnt == 0) ? 0 : (2 * FW_POLL_DELAY); |
2341 | 2362 | ||
2342 | adapter->fw_wait_cnt = 0; | 2363 | adapter->fw_wait_cnt = 0; |