aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2013-05-30 19:52:47 -0400
committerDavid S. Miller <davem@davemloft.net>2013-05-30 19:52:47 -0400
commitcafe89024bd0b1bd088f4c539bcc980cb37c7ce5 (patch)
tree06c382231dea71a60081b253087e998db608ea02 /drivers/net/ethernet
parenta230e033845853ebcfd21aae7a019a5392ebd30e (diff)
parent90648153754cc1ca2eb08cd19c7b13354a795183 (diff)
Merge branch 'netxen_nic'
Manish Chopra says: ==================== This patch series includes following changes: * Log driver version information with firmware version information. * Log "Unknown" adapter name and serial number in case of mismatched adapter type. * netxen_setup_intr() function code cleanup and changes to avoid attaching of multiple pci functions on an adapter with mixed interrupts mode [MSI-X/MSI + INTx]. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic.h14
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h3
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c127
3 files changed, 102 insertions, 42 deletions
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h
index 322a36b76727..3fe09ab2d7c9 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic.h
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic.h
@@ -53,8 +53,8 @@
53 53
54#define _NETXEN_NIC_LINUX_MAJOR 4 54#define _NETXEN_NIC_LINUX_MAJOR 4
55#define _NETXEN_NIC_LINUX_MINOR 0 55#define _NETXEN_NIC_LINUX_MINOR 0
56#define _NETXEN_NIC_LINUX_SUBVERSION 80 56#define _NETXEN_NIC_LINUX_SUBVERSION 81
57#define NETXEN_NIC_LINUX_VERSIONID "4.0.80" 57#define NETXEN_NIC_LINUX_VERSIONID "4.0.81"
58 58
59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) 59#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
60#define _major(v) (((v) >> 24) & 0xff) 60#define _major(v) (((v) >> 24) & 0xff)
@@ -1855,7 +1855,7 @@ static const struct netxen_brdinfo netxen_boards[] = {
1855 1855
1856#define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards) 1856#define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards)
1857 1857
1858static inline void get_brd_name_by_type(u32 type, char *name) 1858static inline int netxen_nic_get_brd_name_by_type(u32 type, char *name)
1859{ 1859{
1860 int i, found = 0; 1860 int i, found = 0;
1861 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) { 1861 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
@@ -1864,10 +1864,14 @@ static inline void get_brd_name_by_type(u32 type, char *name)
1864 found = 1; 1864 found = 1;
1865 break; 1865 break;
1866 } 1866 }
1867 }
1867 1868
1869 if (!found) {
1870 strcpy(name, "Unknown");
1871 return -EINVAL;
1868 } 1872 }
1869 if (!found) 1873
1870 name = "Unknown"; 1874 return 0;
1871} 1875}
1872 1876
1873static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring) 1877static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring)
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h
index 28e076960bcb..32c790659f9c 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_hdr.h
@@ -734,6 +734,9 @@ enum {
734#define NIC_CRB_BASE_2 (NETXEN_CAM_RAM(0x700)) 734#define NIC_CRB_BASE_2 (NETXEN_CAM_RAM(0x700))
735#define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X)) 735#define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X))
736#define NETXEN_NIC_REG_2(X) (NIC_CRB_BASE_2+(X)) 736#define NETXEN_NIC_REG_2(X) (NIC_CRB_BASE_2+(X))
737#define NETXEN_INTR_MODE_REG NETXEN_NIC_REG(0x44)
738#define NETXEN_MSI_MODE 0x1
739#define NETXEN_INTX_MODE 0x2
737 740
738#define NX_CDRP_CRB_OFFSET (NETXEN_NIC_REG(0x18)) 741#define NX_CDRP_CRB_OFFSET (NETXEN_NIC_REG(0x18))
739#define NX_ARG1_CRB_OFFSET (NETXEN_NIC_REG(0x1c)) 742#define NX_ARG1_CRB_OFFSET (NETXEN_NIC_REG(0x1c))
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 51e13d92761e..20c7b3c12b56 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -592,48 +592,60 @@ static const struct net_device_ops netxen_netdev_ops = {
592#endif 592#endif
593}; 593};
594 594
595static void 595static inline bool netxen_function_zero(struct pci_dev *pdev)
596netxen_setup_intr(struct netxen_adapter *adapter)
597{ 596{
598 struct netxen_legacy_intr_set *legacy_intrp; 597 return (PCI_FUNC(pdev->devfn) == 0) ? true : false;
599 struct pci_dev *pdev = adapter->pdev; 598}
600 int err, num_msix;
601 599
602 if (adapter->rss_supported) { 600static inline void netxen_set_interrupt_mode(struct netxen_adapter *adapter,
603 num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ? 601 u32 mode)
604 MSIX_ENTRIES_PER_ADAPTER : 2; 602{
605 } else 603 NXWR32(adapter, NETXEN_INTR_MODE_REG, mode);
606 num_msix = 1; 604}
607 605
608 adapter->max_sds_rings = 1; 606static inline u32 netxen_get_interrupt_mode(struct netxen_adapter *adapter)
607{
608 return NXRD32(adapter, NETXEN_INTR_MODE_REG);
609}
609 610
610 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED); 611static void
612netxen_initialize_interrupt_registers(struct netxen_adapter *adapter)
613{
614 struct netxen_legacy_intr_set *legacy_intrp;
615 u32 tgt_status_reg, int_state_reg;
611 616
612 if (adapter->ahw.revision_id >= NX_P3_B0) 617 if (adapter->ahw.revision_id >= NX_P3_B0)
613 legacy_intrp = &legacy_intr[adapter->ahw.pci_func]; 618 legacy_intrp = &legacy_intr[adapter->ahw.pci_func];
614 else 619 else
615 legacy_intrp = &legacy_intr[0]; 620 legacy_intrp = &legacy_intr[0];
616 621
622 tgt_status_reg = legacy_intrp->tgt_status_reg;
623 int_state_reg = ISR_INT_STATE_REG;
624
617 adapter->int_vec_bit = legacy_intrp->int_vec_bit; 625 adapter->int_vec_bit = legacy_intrp->int_vec_bit;
618 adapter->tgt_status_reg = netxen_get_ioaddr(adapter, 626 adapter->tgt_status_reg = netxen_get_ioaddr(adapter, tgt_status_reg);
619 legacy_intrp->tgt_status_reg);
620 adapter->tgt_mask_reg = netxen_get_ioaddr(adapter, 627 adapter->tgt_mask_reg = netxen_get_ioaddr(adapter,
621 legacy_intrp->tgt_mask_reg); 628 legacy_intrp->tgt_mask_reg);
622 adapter->pci_int_reg = netxen_get_ioaddr(adapter, 629 adapter->pci_int_reg = netxen_get_ioaddr(adapter,
623 legacy_intrp->pci_int_reg); 630 legacy_intrp->pci_int_reg);
624 adapter->isr_int_vec = netxen_get_ioaddr(adapter, ISR_INT_VECTOR); 631 adapter->isr_int_vec = netxen_get_ioaddr(adapter, ISR_INT_VECTOR);
625 632
626 if (adapter->ahw.revision_id >= NX_P3_B1) 633 if (adapter->ahw.revision_id >= NX_P3_B1)
627 adapter->crb_int_state_reg = netxen_get_ioaddr(adapter, 634 adapter->crb_int_state_reg = netxen_get_ioaddr(adapter,
628 ISR_INT_STATE_REG); 635 int_state_reg);
629 else 636 else
630 adapter->crb_int_state_reg = netxen_get_ioaddr(adapter, 637 adapter->crb_int_state_reg = netxen_get_ioaddr(adapter,
631 CRB_INT_VECTOR); 638 CRB_INT_VECTOR);
639}
632 640
633 netxen_set_msix_bit(pdev, 0); 641static int netxen_setup_msi_interrupts(struct netxen_adapter *adapter,
642 int num_msix)
643{
644 struct pci_dev *pdev = adapter->pdev;
645 u32 value;
646 int err;
634 647
635 if (adapter->msix_supported) { 648 if (adapter->msix_supported) {
636
637 netxen_init_msix_entries(adapter, num_msix); 649 netxen_init_msix_entries(adapter, num_msix);
638 err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); 650 err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
639 if (err == 0) { 651 if (err == 0) {
@@ -644,26 +656,59 @@ netxen_setup_intr(struct netxen_adapter *adapter)
644 adapter->max_sds_rings = num_msix; 656 adapter->max_sds_rings = num_msix;
645 657
646 dev_info(&pdev->dev, "using msi-x interrupts\n"); 658 dev_info(&pdev->dev, "using msi-x interrupts\n");
647 return; 659 return 0;
648 } 660 }
649
650 if (err > 0)
651 pci_disable_msix(pdev);
652
653 /* fall through for msi */ 661 /* fall through for msi */
654 } 662 }
655 663
656 if (use_msi && !pci_enable_msi(pdev)) { 664 if (use_msi && !pci_enable_msi(pdev)) {
665 value = msi_tgt_status[adapter->ahw.pci_func];
657 adapter->flags |= NETXEN_NIC_MSI_ENABLED; 666 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
658 adapter->tgt_status_reg = netxen_get_ioaddr(adapter, 667 adapter->tgt_status_reg = netxen_get_ioaddr(adapter, value);
659 msi_tgt_status[adapter->ahw.pci_func]);
660 dev_info(&pdev->dev, "using msi interrupts\n");
661 adapter->msix_entries[0].vector = pdev->irq; 668 adapter->msix_entries[0].vector = pdev->irq;
662 return; 669 dev_info(&pdev->dev, "using msi interrupts\n");
670 return 0;
663 } 671 }
664 672
665 dev_info(&pdev->dev, "using legacy interrupts\n"); 673 dev_err(&pdev->dev, "Failed to acquire MSI-X/MSI interrupt vector\n");
666 adapter->msix_entries[0].vector = pdev->irq; 674 return -EIO;
675}
676
677static int netxen_setup_intr(struct netxen_adapter *adapter)
678{
679 struct pci_dev *pdev = adapter->pdev;
680 int num_msix;
681
682 if (adapter->rss_supported)
683 num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ?
684 MSIX_ENTRIES_PER_ADAPTER : 2;
685 else
686 num_msix = 1;
687
688 adapter->max_sds_rings = 1;
689 adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);
690
691 netxen_initialize_interrupt_registers(adapter);
692 netxen_set_msix_bit(pdev, 0);
693
694 if (netxen_function_zero(pdev)) {
695 if (!netxen_setup_msi_interrupts(adapter, num_msix))
696 netxen_set_interrupt_mode(adapter, NETXEN_MSI_MODE);
697 else
698 netxen_set_interrupt_mode(adapter, NETXEN_INTX_MODE);
699 } else {
700 if (netxen_get_interrupt_mode(adapter) == NETXEN_MSI_MODE &&
701 netxen_setup_msi_interrupts(adapter, num_msix)) {
702 dev_err(&pdev->dev, "Co-existence of MSI-X/MSI and INTx interrupts is not supported\n");
703 return -EIO;
704 }
705 }
706
707 if (!NETXEN_IS_MSI_FAMILY(adapter)) {
708 adapter->msix_entries[0].vector = pdev->irq;
709 dev_info(&pdev->dev, "using legacy interrupts\n");
710 }
711 return 0;
667} 712}
668 713
669static void 714static void
@@ -841,7 +886,9 @@ netxen_check_options(struct netxen_adapter *adapter)
841 } 886 }
842 887
843 if (adapter->portnum == 0) { 888 if (adapter->portnum == 0) {
844 get_brd_name_by_type(adapter->ahw.board_type, brd_name); 889 if (netxen_nic_get_brd_name_by_type(adapter->ahw.board_type,
890 brd_name))
891 strcpy(serial_num, "Unknown");
845 892
846 pr_info("%s: %s Board S/N %s Chip rev 0x%x\n", 893 pr_info("%s: %s Board S/N %s Chip rev 0x%x\n",
847 module_name(THIS_MODULE), 894 module_name(THIS_MODULE),
@@ -860,9 +907,9 @@ netxen_check_options(struct netxen_adapter *adapter)
860 adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0; 907 adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0;
861 } 908 }
862 909
863 dev_info(&pdev->dev, "firmware v%d.%d.%d [%s]\n", 910 dev_info(&pdev->dev, "Driver v%s, firmware v%d.%d.%d [%s]\n",
864 fw_major, fw_minor, fw_build, 911 NETXEN_NIC_LINUX_VERSIONID, fw_major, fw_minor, fw_build,
865 adapter->ahw.cut_through ? "cut-through" : "legacy"); 912 adapter->ahw.cut_through ? "cut-through" : "legacy");
866 913
867 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) 914 if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222))
868 adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1); 915 adapter->capabilities = NXRD32(adapter, CRB_FW_CAPABILITIES_1);
@@ -1508,7 +1555,13 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1508 1555
1509 netxen_nic_clear_stats(adapter); 1556 netxen_nic_clear_stats(adapter);
1510 1557
1511 netxen_setup_intr(adapter); 1558 err = netxen_setup_intr(adapter);
1559
1560 if (err) {
1561 dev_err(&adapter->pdev->dev,
1562 "Failed to setup interrupts, error = %d\n", err);
1563 goto err_out_disable_msi;
1564 }
1512 1565
1513 err = netxen_setup_netdev(adapter, netdev); 1566 err = netxen_setup_netdev(adapter, netdev);
1514 if (err) 1567 if (err)
@@ -1596,7 +1649,7 @@ static void netxen_nic_remove(struct pci_dev *pdev)
1596 clear_bit(__NX_RESETTING, &adapter->state); 1649 clear_bit(__NX_RESETTING, &adapter->state);
1597 1650
1598 netxen_teardown_intr(adapter); 1651 netxen_teardown_intr(adapter);
1599 1652 netxen_set_interrupt_mode(adapter, 0);
1600 netxen_remove_diag_entries(adapter); 1653 netxen_remove_diag_entries(adapter);
1601 1654
1602 netxen_cleanup_pci_map(adapter); 1655 netxen_cleanup_pci_map(adapter);