diff options
-rw-r--r-- | drivers/net/netxen/netxen_nic.h | 5 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_hw.c | 25 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_main.c | 44 |
3 files changed, 63 insertions, 11 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 174ac8ef82fa..ffa1b9ce1cc5 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -95,6 +95,9 @@ | |||
95 | #define ADDR_IN_WINDOW1(off) \ | 95 | #define ADDR_IN_WINDOW1(off) \ |
96 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 | 96 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 |
97 | 97 | ||
98 | #define ADDR_IN_RANGE(addr, low, high) \ | ||
99 | (((addr) < (high)) && ((addr) >= (low))) | ||
100 | |||
98 | /* | 101 | /* |
99 | * normalize a 64MB crb address to 32MB PCI window | 102 | * normalize a 64MB crb address to 32MB PCI window |
100 | * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 | 103 | * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 |
@@ -1352,6 +1355,8 @@ int netxen_config_rss(struct netxen_adapter *adapter, int enable); | |||
1352 | int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd); | 1355 | int netxen_config_ipaddr(struct netxen_adapter *adapter, u32 ip, int cmd); |
1353 | int netxen_linkevent_request(struct netxen_adapter *adapter, int enable); | 1356 | int netxen_linkevent_request(struct netxen_adapter *adapter, int enable); |
1354 | void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup); | 1357 | void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup); |
1358 | void netxen_pci_camqm_read_2M(struct netxen_adapter *, u64, u64 *); | ||
1359 | void netxen_pci_camqm_write_2M(struct netxen_adapter *, u64, u64); | ||
1355 | 1360 | ||
1356 | int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu); | 1361 | int nx_fw_cmd_set_mtu(struct netxen_adapter *adapter, int mtu); |
1357 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); | 1362 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index be6398860781..5c496f8d7c49 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -62,9 +62,6 @@ static inline void writeq(u64 val, void __iomem *addr) | |||
62 | } | 62 | } |
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | #define ADDR_IN_RANGE(addr, low, high) \ | ||
66 | (((addr) < (high)) && ((addr) >= (low))) | ||
67 | |||
68 | #define PCI_OFFSET_FIRST_RANGE(adapter, off) \ | 65 | #define PCI_OFFSET_FIRST_RANGE(adapter, off) \ |
69 | ((adapter)->ahw.pci_base0 + (off)) | 66 | ((adapter)->ahw.pci_base0 + (off)) |
70 | #define PCI_OFFSET_SECOND_RANGE(adapter, off) \ | 67 | #define PCI_OFFSET_SECOND_RANGE(adapter, off) \ |
@@ -1448,6 +1445,28 @@ unlock: | |||
1448 | return ret; | 1445 | return ret; |
1449 | } | 1446 | } |
1450 | 1447 | ||
1448 | void | ||
1449 | netxen_pci_camqm_read_2M(struct netxen_adapter *adapter, u64 off, u64 *data) | ||
1450 | { | ||
1451 | void __iomem *addr = adapter->ahw.pci_base0 + | ||
1452 | NETXEN_PCI_CAMQM_2M_BASE + (off - NETXEN_PCI_CAMQM); | ||
1453 | |||
1454 | spin_lock(&adapter->ahw.mem_lock); | ||
1455 | *data = readq(addr); | ||
1456 | spin_unlock(&adapter->ahw.mem_lock); | ||
1457 | } | ||
1458 | |||
1459 | void | ||
1460 | netxen_pci_camqm_write_2M(struct netxen_adapter *adapter, u64 off, u64 data) | ||
1461 | { | ||
1462 | void __iomem *addr = adapter->ahw.pci_base0 + | ||
1463 | NETXEN_PCI_CAMQM_2M_BASE + (off - NETXEN_PCI_CAMQM); | ||
1464 | |||
1465 | spin_lock(&adapter->ahw.mem_lock); | ||
1466 | writeq(data, addr); | ||
1467 | spin_unlock(&adapter->ahw.mem_lock); | ||
1468 | } | ||
1469 | |||
1451 | #define MAX_CTL_CHECK 1000 | 1470 | #define MAX_CTL_CHECK 1000 |
1452 | 1471 | ||
1453 | static int | 1472 | static int |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index b665b420a4f2..692e672d303d 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -2537,14 +2537,24 @@ static int | |||
2537 | netxen_sysfs_validate_crb(struct netxen_adapter *adapter, | 2537 | netxen_sysfs_validate_crb(struct netxen_adapter *adapter, |
2538 | loff_t offset, size_t size) | 2538 | loff_t offset, size_t size) |
2539 | { | 2539 | { |
2540 | size_t crb_size = 4; | ||
2541 | |||
2540 | if (!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)) | 2542 | if (!(adapter->flags & NETXEN_NIC_DIAG_ENABLED)) |
2541 | return -EIO; | 2543 | return -EIO; |
2542 | 2544 | ||
2543 | if ((size != 4) || (offset & 0x3)) | 2545 | if (offset < NETXEN_PCI_CRBSPACE) { |
2544 | return -EINVAL; | 2546 | if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) |
2547 | return -EINVAL; | ||
2545 | 2548 | ||
2546 | if (offset < NETXEN_PCI_CRBSPACE) | 2549 | if (ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM, |
2547 | return -EINVAL; | 2550 | NETXEN_PCI_CAMQM_2M_END)) |
2551 | crb_size = 8; | ||
2552 | else | ||
2553 | return -EINVAL; | ||
2554 | } | ||
2555 | |||
2556 | if ((size != crb_size) || (offset & (crb_size-1))) | ||
2557 | return -EINVAL; | ||
2548 | 2558 | ||
2549 | return 0; | 2559 | return 0; |
2550 | } | 2560 | } |
@@ -2556,14 +2566,23 @@ netxen_sysfs_read_crb(struct kobject *kobj, struct bin_attribute *attr, | |||
2556 | struct device *dev = container_of(kobj, struct device, kobj); | 2566 | struct device *dev = container_of(kobj, struct device, kobj); |
2557 | struct netxen_adapter *adapter = dev_get_drvdata(dev); | 2567 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
2558 | u32 data; | 2568 | u32 data; |
2569 | u64 qmdata; | ||
2559 | int ret; | 2570 | int ret; |
2560 | 2571 | ||
2561 | ret = netxen_sysfs_validate_crb(adapter, offset, size); | 2572 | ret = netxen_sysfs_validate_crb(adapter, offset, size); |
2562 | if (ret != 0) | 2573 | if (ret != 0) |
2563 | return ret; | 2574 | return ret; |
2564 | 2575 | ||
2565 | data = NXRD32(adapter, offset); | 2576 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && |
2566 | memcpy(buf, &data, size); | 2577 | ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM, |
2578 | NETXEN_PCI_CAMQM_2M_END)) { | ||
2579 | netxen_pci_camqm_read_2M(adapter, offset, &qmdata); | ||
2580 | memcpy(buf, &qmdata, size); | ||
2581 | } else { | ||
2582 | data = NXRD32(adapter, offset); | ||
2583 | memcpy(buf, &data, size); | ||
2584 | } | ||
2585 | |||
2567 | return size; | 2586 | return size; |
2568 | } | 2587 | } |
2569 | 2588 | ||
@@ -2574,14 +2593,23 @@ netxen_sysfs_write_crb(struct kobject *kobj, struct bin_attribute *attr, | |||
2574 | struct device *dev = container_of(kobj, struct device, kobj); | 2593 | struct device *dev = container_of(kobj, struct device, kobj); |
2575 | struct netxen_adapter *adapter = dev_get_drvdata(dev); | 2594 | struct netxen_adapter *adapter = dev_get_drvdata(dev); |
2576 | u32 data; | 2595 | u32 data; |
2596 | u64 qmdata; | ||
2577 | int ret; | 2597 | int ret; |
2578 | 2598 | ||
2579 | ret = netxen_sysfs_validate_crb(adapter, offset, size); | 2599 | ret = netxen_sysfs_validate_crb(adapter, offset, size); |
2580 | if (ret != 0) | 2600 | if (ret != 0) |
2581 | return ret; | 2601 | return ret; |
2582 | 2602 | ||
2583 | memcpy(&data, buf, size); | 2603 | if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && |
2584 | NXWR32(adapter, offset, data); | 2604 | ADDR_IN_RANGE(offset, NETXEN_PCI_CAMQM, |
2605 | NETXEN_PCI_CAMQM_2M_END)) { | ||
2606 | memcpy(&qmdata, buf, size); | ||
2607 | netxen_pci_camqm_write_2M(adapter, offset, qmdata); | ||
2608 | } else { | ||
2609 | memcpy(&data, buf, size); | ||
2610 | NXWR32(adapter, offset, data); | ||
2611 | } | ||
2612 | |||
2585 | return size; | 2613 | return size; |
2586 | } | 2614 | } |
2587 | 2615 | ||