Commit cafe8902 authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents a230e033 90648153
...@@ -53,8 +53,8 @@ ...@@ -53,8 +53,8 @@
#define _NETXEN_NIC_LINUX_MAJOR 4 #define _NETXEN_NIC_LINUX_MAJOR 4
#define _NETXEN_NIC_LINUX_MINOR 0 #define _NETXEN_NIC_LINUX_MINOR 0
#define _NETXEN_NIC_LINUX_SUBVERSION 80 #define _NETXEN_NIC_LINUX_SUBVERSION 81
#define NETXEN_NIC_LINUX_VERSIONID "4.0.80" #define NETXEN_NIC_LINUX_VERSIONID "4.0.81"
#define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) #define NETXEN_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c))
#define _major(v) (((v) >> 24) & 0xff) #define _major(v) (((v) >> 24) & 0xff)
...@@ -1855,7 +1855,7 @@ static const struct netxen_brdinfo netxen_boards[] = { ...@@ -1855,7 +1855,7 @@ static const struct netxen_brdinfo netxen_boards[] = {
#define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards) #define NUM_SUPPORTED_BOARDS ARRAY_SIZE(netxen_boards)
static inline void get_brd_name_by_type(u32 type, char *name) static inline int netxen_nic_get_brd_name_by_type(u32 type, char *name)
{ {
int i, found = 0; int i, found = 0;
for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) { 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,10 +1864,14 @@ static inline void get_brd_name_by_type(u32 type, char *name)
found = 1; found = 1;
break; break;
} }
}
if (!found) {
strcpy(name, "Unknown");
return -EINVAL;
} }
if (!found)
name = "Unknown"; return 0;
} }
static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring) static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring)
......
...@@ -734,6 +734,9 @@ enum { ...@@ -734,6 +734,9 @@ enum {
#define NIC_CRB_BASE_2 (NETXEN_CAM_RAM(0x700)) #define NIC_CRB_BASE_2 (NETXEN_CAM_RAM(0x700))
#define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X)) #define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X))
#define NETXEN_NIC_REG_2(X) (NIC_CRB_BASE_2+(X)) #define NETXEN_NIC_REG_2(X) (NIC_CRB_BASE_2+(X))
#define NETXEN_INTR_MODE_REG NETXEN_NIC_REG(0x44)
#define NETXEN_MSI_MODE 0x1
#define NETXEN_INTX_MODE 0x2
#define NX_CDRP_CRB_OFFSET (NETXEN_NIC_REG(0x18)) #define NX_CDRP_CRB_OFFSET (NETXEN_NIC_REG(0x18))
#define NX_ARG1_CRB_OFFSET (NETXEN_NIC_REG(0x1c)) #define NX_ARG1_CRB_OFFSET (NETXEN_NIC_REG(0x1c))
......
...@@ -592,31 +592,38 @@ static const struct net_device_ops netxen_netdev_ops = { ...@@ -592,31 +592,38 @@ static const struct net_device_ops netxen_netdev_ops = {
#endif #endif
}; };
static void static inline bool netxen_function_zero(struct pci_dev *pdev)
netxen_setup_intr(struct netxen_adapter *adapter)
{ {
struct netxen_legacy_intr_set *legacy_intrp; return (PCI_FUNC(pdev->devfn) == 0) ? true : false;
struct pci_dev *pdev = adapter->pdev; }
int err, num_msix;
if (adapter->rss_supported) { static inline void netxen_set_interrupt_mode(struct netxen_adapter *adapter,
num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ? u32 mode)
MSIX_ENTRIES_PER_ADAPTER : 2; {
} else NXWR32(adapter, NETXEN_INTR_MODE_REG, mode);
num_msix = 1; }
adapter->max_sds_rings = 1; static inline u32 netxen_get_interrupt_mode(struct netxen_adapter *adapter)
{
return NXRD32(adapter, NETXEN_INTR_MODE_REG);
}
adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED); static void
netxen_initialize_interrupt_registers(struct netxen_adapter *adapter)
{
struct netxen_legacy_intr_set *legacy_intrp;
u32 tgt_status_reg, int_state_reg;
if (adapter->ahw.revision_id >= NX_P3_B0) if (adapter->ahw.revision_id >= NX_P3_B0)
legacy_intrp = &legacy_intr[adapter->ahw.pci_func]; legacy_intrp = &legacy_intr[adapter->ahw.pci_func];
else else
legacy_intrp = &legacy_intr[0]; legacy_intrp = &legacy_intr[0];
tgt_status_reg = legacy_intrp->tgt_status_reg;
int_state_reg = ISR_INT_STATE_REG;
adapter->int_vec_bit = legacy_intrp->int_vec_bit; adapter->int_vec_bit = legacy_intrp->int_vec_bit;
adapter->tgt_status_reg = netxen_get_ioaddr(adapter, adapter->tgt_status_reg = netxen_get_ioaddr(adapter, tgt_status_reg);
legacy_intrp->tgt_status_reg);
adapter->tgt_mask_reg = netxen_get_ioaddr(adapter, adapter->tgt_mask_reg = netxen_get_ioaddr(adapter,
legacy_intrp->tgt_mask_reg); legacy_intrp->tgt_mask_reg);
adapter->pci_int_reg = netxen_get_ioaddr(adapter, adapter->pci_int_reg = netxen_get_ioaddr(adapter,
...@@ -625,15 +632,20 @@ netxen_setup_intr(struct netxen_adapter *adapter) ...@@ -625,15 +632,20 @@ netxen_setup_intr(struct netxen_adapter *adapter)
if (adapter->ahw.revision_id >= NX_P3_B1) if (adapter->ahw.revision_id >= NX_P3_B1)
adapter->crb_int_state_reg = netxen_get_ioaddr(adapter, adapter->crb_int_state_reg = netxen_get_ioaddr(adapter,
ISR_INT_STATE_REG); int_state_reg);
else else
adapter->crb_int_state_reg = netxen_get_ioaddr(adapter, adapter->crb_int_state_reg = netxen_get_ioaddr(adapter,
CRB_INT_VECTOR); CRB_INT_VECTOR);
}
netxen_set_msix_bit(pdev, 0); static int netxen_setup_msi_interrupts(struct netxen_adapter *adapter,
int num_msix)
{
struct pci_dev *pdev = adapter->pdev;
u32 value;
int err;
if (adapter->msix_supported) { if (adapter->msix_supported) {
netxen_init_msix_entries(adapter, num_msix); netxen_init_msix_entries(adapter, num_msix);
err = pci_enable_msix(pdev, adapter->msix_entries, num_msix); err = pci_enable_msix(pdev, adapter->msix_entries, num_msix);
if (err == 0) { if (err == 0) {
...@@ -644,26 +656,59 @@ netxen_setup_intr(struct netxen_adapter *adapter) ...@@ -644,26 +656,59 @@ netxen_setup_intr(struct netxen_adapter *adapter)
adapter->max_sds_rings = num_msix; adapter->max_sds_rings = num_msix;
dev_info(&pdev->dev, "using msi-x interrupts\n"); dev_info(&pdev->dev, "using msi-x interrupts\n");
return; return 0;
} }
if (err > 0)
pci_disable_msix(pdev);
/* fall through for msi */ /* fall through for msi */
} }
if (use_msi && !pci_enable_msi(pdev)) { if (use_msi && !pci_enable_msi(pdev)) {
value = msi_tgt_status[adapter->ahw.pci_func];
adapter->flags |= NETXEN_NIC_MSI_ENABLED; adapter->flags |= NETXEN_NIC_MSI_ENABLED;
adapter->tgt_status_reg = netxen_get_ioaddr(adapter, adapter->tgt_status_reg = netxen_get_ioaddr(adapter, value);
msi_tgt_status[adapter->ahw.pci_func]);
dev_info(&pdev->dev, "using msi interrupts\n");
adapter->msix_entries[0].vector = pdev->irq; adapter->msix_entries[0].vector = pdev->irq;
return; dev_info(&pdev->dev, "using msi interrupts\n");
return 0;
} }
dev_info(&pdev->dev, "using legacy interrupts\n"); dev_err(&pdev->dev, "Failed to acquire MSI-X/MSI interrupt vector\n");
return -EIO;
}
static int netxen_setup_intr(struct netxen_adapter *adapter)
{
struct pci_dev *pdev = adapter->pdev;
int num_msix;
if (adapter->rss_supported)
num_msix = (num_online_cpus() >= MSIX_ENTRIES_PER_ADAPTER) ?
MSIX_ENTRIES_PER_ADAPTER : 2;
else
num_msix = 1;
adapter->max_sds_rings = 1;
adapter->flags &= ~(NETXEN_NIC_MSI_ENABLED | NETXEN_NIC_MSIX_ENABLED);
netxen_initialize_interrupt_registers(adapter);
netxen_set_msix_bit(pdev, 0);
if (netxen_function_zero(pdev)) {
if (!netxen_setup_msi_interrupts(adapter, num_msix))
netxen_set_interrupt_mode(adapter, NETXEN_MSI_MODE);
else
netxen_set_interrupt_mode(adapter, NETXEN_INTX_MODE);
} else {
if (netxen_get_interrupt_mode(adapter) == NETXEN_MSI_MODE &&
netxen_setup_msi_interrupts(adapter, num_msix)) {
dev_err(&pdev->dev, "Co-existence of MSI-X/MSI and INTx interrupts is not supported\n");
return -EIO;
}
}
if (!NETXEN_IS_MSI_FAMILY(adapter)) {
adapter->msix_entries[0].vector = pdev->irq; adapter->msix_entries[0].vector = pdev->irq;
dev_info(&pdev->dev, "using legacy interrupts\n");
}
return 0;
} }
static void static void
...@@ -841,7 +886,9 @@ netxen_check_options(struct netxen_adapter *adapter) ...@@ -841,7 +886,9 @@ netxen_check_options(struct netxen_adapter *adapter)
} }
if (adapter->portnum == 0) { if (adapter->portnum == 0) {
get_brd_name_by_type(adapter->ahw.board_type, brd_name); if (netxen_nic_get_brd_name_by_type(adapter->ahw.board_type,
brd_name))
strcpy(serial_num, "Unknown");
pr_info("%s: %s Board S/N %s Chip rev 0x%x\n", pr_info("%s: %s Board S/N %s Chip rev 0x%x\n",
module_name(THIS_MODULE), module_name(THIS_MODULE),
...@@ -860,8 +907,8 @@ netxen_check_options(struct netxen_adapter *adapter) ...@@ -860,8 +907,8 @@ netxen_check_options(struct netxen_adapter *adapter)
adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0; adapter->ahw.cut_through = (i & 0x8000) ? 1 : 0;
} }
dev_info(&pdev->dev, "firmware v%d.%d.%d [%s]\n", dev_info(&pdev->dev, "Driver v%s, firmware v%d.%d.%d [%s]\n",
fw_major, fw_minor, fw_build, NETXEN_NIC_LINUX_VERSIONID, fw_major, fw_minor, fw_build,
adapter->ahw.cut_through ? "cut-through" : "legacy"); adapter->ahw.cut_through ? "cut-through" : "legacy");
if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222)) if (adapter->fw_version >= NETXEN_VERSION_CODE(4, 0, 222))
...@@ -1508,7 +1555,13 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1508,7 +1555,13 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
netxen_nic_clear_stats(adapter); netxen_nic_clear_stats(adapter);
netxen_setup_intr(adapter); err = netxen_setup_intr(adapter);
if (err) {
dev_err(&adapter->pdev->dev,
"Failed to setup interrupts, error = %d\n", err);
goto err_out_disable_msi;
}
err = netxen_setup_netdev(adapter, netdev); err = netxen_setup_netdev(adapter, netdev);
if (err) if (err)
...@@ -1596,7 +1649,7 @@ static void netxen_nic_remove(struct pci_dev *pdev) ...@@ -1596,7 +1649,7 @@ static void netxen_nic_remove(struct pci_dev *pdev)
clear_bit(__NX_RESETTING, &adapter->state); clear_bit(__NX_RESETTING, &adapter->state);
netxen_teardown_intr(adapter); netxen_teardown_intr(adapter);
netxen_set_interrupt_mode(adapter, 0);
netxen_remove_diag_entries(adapter); netxen_remove_diag_entries(adapter);
netxen_cleanup_pci_map(adapter); netxen_cleanup_pci_map(adapter);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment