aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmit S. Kale <amitkale@netxen.com>2006-11-29 12:00:10 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-02 00:16:36 -0500
commitcb8011ad53e0855ef088e0e5a4bcb98fa90c70b6 (patch)
tree2ea32fc89dab2257b359a0577ae06c6565cc99d1
parentedf901638144525a140c68be01be1b22e6041a6d (diff)
[PATCH] NetXen: temp monitoring, newer firmware support, mm footprint reduction
NetXen: 1G/10G Ethernet Driver updates - Temparature monitoring and device control - Memory footprint reduction - Driver changes to support newer version of firmware Signed-off-by: Amit S. Kale <amitkale@netxen.com> netxen_nic.h | 165 ++++++++++++++++++++++++++++++++-- netxen_nic_ethtool.c | 89 ++++++++++++------ netxen_nic_hdr.h | 71 +++++++++++++- netxen_nic_hw.c | 206 +++++++++++++++++++++++++++++-------------- netxen_nic_hw.h | 8 + netxen_nic_init.c | 239 +++++++++++++++++++++++++++++++++++++++++--------- netxen_nic_ioctl.h | 12 +- netxen_nic_isr.c | 54 +++++------ netxen_nic_main.c | 121 +++++++++++++++++-------- netxen_nic_niu.c | 172 +++++++++++++++++++++++++++-------- netxen_nic_phan_reg.h | 24 ++++- 11 files changed, 891 insertions(+), 270 deletions(-) Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/net/netxen/netxen_nic.h165
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c89
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h71
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c206
-rw-r--r--drivers/net/netxen/netxen_nic_hw.h8
-rw-r--r--drivers/net/netxen/netxen_nic_init.c239
-rw-r--r--drivers/net/netxen/netxen_nic_ioctl.h12
-rw-r--r--drivers/net/netxen/netxen_nic_isr.c54
-rw-r--r--drivers/net/netxen/netxen_nic_main.c121
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c172
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h24
11 files changed, 891 insertions, 270 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 0458db45e700..1bee560d7d0a 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -63,12 +63,12 @@
63 63
64#include "netxen_nic_hw.h" 64#include "netxen_nic_hw.h"
65 65
66#define NETXEN_NIC_BUILD_NO "232" 66#define NETXEN_NIC_BUILD_NO "5"
67#define _NETXEN_NIC_LINUX_MAJOR 2 67#define _NETXEN_NIC_LINUX_MAJOR 2
68#define _NETXEN_NIC_LINUX_MINOR 3 68#define _NETXEN_NIC_LINUX_MINOR 3
69#define _NETXEN_NIC_LINUX_SUBVERSION 57 69#define _NETXEN_NIC_LINUX_SUBVERSION 59
70#define NETXEN_NIC_LINUX_VERSIONID "2.3.57" 70#define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO
71#define NETXEN_NIC_FW_VERSIONID "2.3.57" 71#define NETXEN_NIC_FW_VERSIONID "2.3.59"
72 72
73#define RCV_DESC_RINGSIZE \ 73#define RCV_DESC_RINGSIZE \
74 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) 74 (sizeof(struct rcv_desc) * adapter->max_rx_desc_count)
@@ -89,9 +89,24 @@
89 * normalize a 64MB crb address to 32MB PCI window 89 * normalize a 64MB crb address to 32MB PCI window
90 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 90 * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1
91 */ 91 */
92#define NETXEN_CRB_NORMAL(reg) \
93 (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST
94
92#define NETXEN_CRB_NORMALIZE(adapter, reg) \ 95#define NETXEN_CRB_NORMALIZE(adapter, reg) \
93 ((adapter)->ahw.pci_base + (reg) \ 96 pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg))
94 - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST) 97
98#define FIRST_PAGE_GROUP_START 0
99#define FIRST_PAGE_GROUP_END 0x400000
100
101#define SECOND_PAGE_GROUP_START 0x4000000
102#define SECOND_PAGE_GROUP_END 0x66BC000
103
104#define THIRD_PAGE_GROUP_START 0x70E4000
105#define THIRD_PAGE_GROUP_END 0x8000000
106
107#define FIRST_PAGE_GROUP_SIZE FIRST_PAGE_GROUP_END - FIRST_PAGE_GROUP_START
108#define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START
109#define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START
95 110
96#define MAX_RX_BUFFER_LENGTH 2000 111#define MAX_RX_BUFFER_LENGTH 2000
97#define MAX_RX_JUMBO_BUFFER_LENGTH 9046 112#define MAX_RX_JUMBO_BUFFER_LENGTH 9046
@@ -328,6 +343,7 @@ typedef enum {
328 NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e, 343 NETXEN_BRDTYPE_P2_SB31_10G_HMEZ = 0x000e,
329 NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f 344 NETXEN_BRDTYPE_P2_SB31_10G_CX4 = 0x000f
330} netxen_brdtype_t; 345} netxen_brdtype_t;
346#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(netxen_brdinfo_t))
331 347
332typedef enum { 348typedef enum {
333 NETXEN_BRDMFG_INVENTEC = 1 349 NETXEN_BRDMFG_INVENTEC = 1
@@ -615,15 +631,23 @@ struct netxen_rx_buffer {
615 */ 631 */
616struct netxen_hardware_context { 632struct netxen_hardware_context {
617 struct pci_dev *pdev; 633 struct pci_dev *pdev;
618 void __iomem *pci_base; /* base of mapped phantom memory */ 634 void __iomem *pci_base0;
635 void __iomem *pci_base1;
636 void __iomem *pci_base2;
637
619 u8 revision_id; 638 u8 revision_id;
620 u16 board_type; 639 u16 board_type;
621 u16 max_ports; 640 u16 max_ports;
622 struct netxen_board_info boardcfg; 641 struct netxen_board_info boardcfg;
623 u32 xg_linkup; 642 u32 xg_linkup;
643 u32 qg_linksup;
624 /* Address of cmd ring in Phantom */ 644 /* Address of cmd ring in Phantom */
625 struct cmd_desc_type0 *cmd_desc_head; 645 struct cmd_desc_type0 *cmd_desc_head;
646 char *pauseaddr;
647 struct pci_dev *cmd_desc_pdev;
626 dma_addr_t cmd_desc_phys_addr; 648 dma_addr_t cmd_desc_phys_addr;
649 dma_addr_t pause_physaddr;
650 struct pci_dev *pause_pdev;
627 struct netxen_adapter *adapter; 651 struct netxen_adapter *adapter;
628}; 652};
629 653
@@ -654,6 +678,7 @@ struct netxen_rcv_desc_ctx {
654 u32 rcv_pending; /* Num of bufs posted in phantom */ 678 u32 rcv_pending; /* Num of bufs posted in phantom */
655 u32 rcv_free; /* Num of bufs in free list */ 679 u32 rcv_free; /* Num of bufs in free list */
656 dma_addr_t phys_addr; 680 dma_addr_t phys_addr;
681 struct pci_dev *phys_pdev;
657 struct rcv_desc *desc_head; /* address of rx ring in Phantom */ 682 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
658 u32 max_rx_desc_count; 683 u32 max_rx_desc_count;
659 u32 dma_size; 684 u32 dma_size;
@@ -673,6 +698,7 @@ struct netxen_recv_context {
673 u32 status_rx_producer; 698 u32 status_rx_producer;
674 u32 status_rx_consumer; 699 u32 status_rx_consumer;
675 dma_addr_t rcv_status_desc_phys_addr; 700 dma_addr_t rcv_status_desc_phys_addr;
701 struct pci_dev *rcv_status_desc_pdev;
676 struct status_desc *rcv_status_desc_head; 702 struct status_desc *rcv_status_desc_head;
677}; 703};
678 704
@@ -708,6 +734,7 @@ struct netxen_adapter {
708 u32 flags; 734 u32 flags;
709 u32 irq; 735 u32 irq;
710 int driver_mismatch; 736 int driver_mismatch;
737 u32 temp;
711 738
712 struct netxen_adapter_stats stats; 739 struct netxen_adapter_stats stats;
713 740
@@ -766,6 +793,43 @@ struct netxen_port {
766 struct netxen_port_stats stats; 793 struct netxen_port_stats stats;
767}; 794};
768 795
796#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
797 ((adapter)->ahw.pci_base0 + (off))
798#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
799 ((adapter)->ahw.pci_base1 + (off) - SECOND_PAGE_GROUP_START)
800#define PCI_OFFSET_THIRD_RANGE(adapter, off) \
801 ((adapter)->ahw.pci_base2 + (off) - THIRD_PAGE_GROUP_START)
802
803static inline void __iomem *pci_base_offset(struct netxen_adapter *adapter,
804 unsigned long off)
805{
806 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
807 return (adapter->ahw.pci_base0 + off);
808 } else if ((off < SECOND_PAGE_GROUP_END) &&
809 (off >= SECOND_PAGE_GROUP_START)) {
810 return (adapter->ahw.pci_base1 + off - SECOND_PAGE_GROUP_START);
811 } else if ((off < THIRD_PAGE_GROUP_END) &&
812 (off >= THIRD_PAGE_GROUP_START)) {
813 return (adapter->ahw.pci_base2 + off - THIRD_PAGE_GROUP_START);
814 }
815 return NULL;
816}
817
818static inline void __iomem *pci_base(struct netxen_adapter *adapter,
819 unsigned long off)
820{
821 if ((off < FIRST_PAGE_GROUP_END) && (off >= FIRST_PAGE_GROUP_START)) {
822 return adapter->ahw.pci_base0;
823 } else if ((off < SECOND_PAGE_GROUP_END) &&
824 (off >= SECOND_PAGE_GROUP_START)) {
825 return adapter->ahw.pci_base1;
826 } else if ((off < THIRD_PAGE_GROUP_END) &&
827 (off >= THIRD_PAGE_GROUP_START)) {
828 return adapter->ahw.pci_base2;
829 }
830 return NULL;
831}
832
769struct netxen_drvops { 833struct netxen_drvops {
770 int (*enable_phy_interrupts) (struct netxen_adapter *, int); 834 int (*enable_phy_interrupts) (struct netxen_adapter *, int);
771 int (*disable_phy_interrupts) (struct netxen_adapter *, int); 835 int (*disable_phy_interrupts) (struct netxen_adapter *, int);
@@ -809,7 +873,6 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy,
809 long reg, __le32 val); 873 long reg, __le32 val);
810 874
811/* Functions available from netxen_nic_hw.c */ 875/* Functions available from netxen_nic_hw.c */
812int netxen_niu_xginit(struct netxen_adapter *);
813int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu); 876int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu);
814int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu); 877int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu);
815void netxen_nic_init_niu_gb(struct netxen_adapter *adapter); 878void netxen_nic_init_niu_gb(struct netxen_adapter *adapter);
@@ -828,10 +891,13 @@ void netxen_crb_writelit_adapter(struct netxen_adapter *adapter,
828 unsigned long off, int data); 891 unsigned long off, int data);
829 892
830/* Functions from netxen_nic_init.c */ 893/* Functions from netxen_nic_init.c */
831void netxen_phantom_init(struct netxen_adapter *adapter); 894void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
832void netxen_load_firmware(struct netxen_adapter *adapter); 895void netxen_load_firmware(struct netxen_adapter *adapter);
833int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); 896int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
834int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp); 897int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp);
898int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data);
899int netxen_rom_se(struct netxen_adapter *adapter, int addr);
900int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);
835 901
836/* Functions from netxen_nic_isr.c */ 902/* Functions from netxen_nic_isr.c */
837void netxen_nic_isr_other(struct netxen_adapter *adapter); 903void netxen_nic_isr_other(struct netxen_adapter *adapter);
@@ -842,6 +908,8 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port,
842void netxen_nic_stop_all_ports(struct netxen_adapter *adapter); 908void netxen_nic_stop_all_ports(struct netxen_adapter *adapter);
843void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); 909void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
844void netxen_initialize_adapter_hw(struct netxen_adapter *adapter); 910void netxen_initialize_adapter_hw(struct netxen_adapter *adapter);
911void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
912 struct pci_dev **used_dev);
845void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); 913void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
846int netxen_init_firmware(struct netxen_adapter *adapter); 914int netxen_init_firmware(struct netxen_adapter *adapter);
847void netxen_free_hw_resources(struct netxen_adapter *adapter); 915void netxen_free_hw_resources(struct netxen_adapter *adapter);
@@ -869,7 +937,10 @@ static inline void netxen_nic_disable_int(struct netxen_adapter *adapter)
869 /* 937 /*
870 * ISR_INT_MASK: Can be read from window 0 or 1. 938 * ISR_INT_MASK: Can be read from window 0 or 1.
871 */ 939 */
872 writel(0x7ff, (void __iomem *)(adapter->ahw.pci_base + ISR_INT_MASK)); 940 writel(0x7ff,
941 (void __iomem
942 *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
943
873} 944}
874 945
875static inline void netxen_nic_enable_int(struct netxen_adapter *adapter) 946static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
@@ -888,13 +959,83 @@ static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
888 break; 959 break;
889 } 960 }
890 961
891 writel(mask, (void __iomem *)(adapter->ahw.pci_base + ISR_INT_MASK)); 962 writel(mask,
963 (void __iomem
964 *)(PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_MASK)));
892 965
893 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 966 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
894 mask = 0xbff; 967 mask = 0xbff;
895 writel(mask, (void __iomem *) 968 writel(mask, (void __iomem *)
896 (adapter->ahw.pci_base + ISR_INT_TARGET_MASK)); 969 (PCI_OFFSET_SECOND_RANGE(adapter, ISR_INT_TARGET_MASK)));
970 }
971}
972
973/*
974 * NetXen Board information
975 */
976
977#define NETXEN_MAX_SHORT_NAME 16
978typedef struct {
979 netxen_brdtype_t brdtype; /* type of board */
980 long ports; /* max no of physical ports */
981 char short_name[NETXEN_MAX_SHORT_NAME];
982} netxen_brdinfo_t;
983
984static const netxen_brdinfo_t netxen_boards[] = {
985 {NETXEN_BRDTYPE_P2_SB31_10G_CX4, 1, "XGb CX4"},
986 {NETXEN_BRDTYPE_P2_SB31_10G_HMEZ, 1, "XGb HMEZ"},
987 {NETXEN_BRDTYPE_P2_SB31_10G_IMEZ, 2, "XGb IMEZ"},
988 {NETXEN_BRDTYPE_P2_SB31_10G, 1, "XGb XFP"},
989 {NETXEN_BRDTYPE_P2_SB35_4G, 4, "Quad Gb"},
990 {NETXEN_BRDTYPE_P2_SB31_2G, 2, "Dual Gb"},
991};
992
993#define NUM_SUPPORTED_BOARDS (sizeof(netxen_boards)/sizeof(netxen_brdinfo_t))
994
995static inline void get_brd_ports_name_by_type(u32 type, int *ports, char *name)
996{
997 int i, found = 0;
998 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
999 if (netxen_boards[i].brdtype == type) {
1000 *ports = netxen_boards[i].ports;
1001 strcpy(name, netxen_boards[i].short_name);
1002 found = 1;
1003 break;
1004 }
1005 }
1006 if (!found) {
1007 *ports = 0;
1008 name = "Unknown";
1009 }
1010}
1011
1012static inline void get_brd_port_by_type(u32 type, int *ports)
1013{
1014 int i, found = 0;
1015 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1016 if (netxen_boards[i].brdtype == type) {
1017 *ports = netxen_boards[i].ports;
1018 found = 1;
1019 break;
1020 }
1021 }
1022 if (!found)
1023 *ports = 0;
1024}
1025
1026static inline void get_brd_name_by_type(u32 type, char *name)
1027{
1028 int i, found = 0;
1029 for (i = 0; i < NUM_SUPPORTED_BOARDS; ++i) {
1030 if (netxen_boards[i].brdtype == type) {
1031 strcpy(name, netxen_boards[i].short_name);
1032 found = 1;
1033 break;
1034 }
1035
897 } 1036 }
1037 if (!found)
1038 name = "Unknown";
898} 1039}
899 1040
900int netxen_is_flash_supported(struct netxen_adapter *adapter); 1041int netxen_is_flash_supported(struct netxen_adapter *adapter);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index caf6cc15b241..f3fc35cf8af7 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -53,6 +53,9 @@ struct netxen_nic_stats {
53#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \ 53#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \
54 offsetof(struct netxen_port, m) 54 offsetof(struct netxen_port, m)
55 55
56#define NETXEN_NIC_PORT_WINDOW 0x10000
57#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
58
56static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = { 59static const struct netxen_nic_stats netxen_nic_gstrings_stats[] = {
57 {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)}, 60 {"rcvd_bad_skb", NETXEN_NIC_STAT(stats.rcvdbadskb)},
58 {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)}, 61 {"xmit_called", NETXEN_NIC_STAT(stats.xmitcalled)},
@@ -111,9 +114,9 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
111{ 114{
112 struct netxen_port *port = netdev_priv(dev); 115 struct netxen_port *port = netdev_priv(dev);
113 struct netxen_adapter *adapter = port->adapter; 116 struct netxen_adapter *adapter = port->adapter;
114 uint32_t fw_major = 0; 117 u32 fw_major = 0;
115 uint32_t fw_minor = 0; 118 u32 fw_minor = 0;
116 uint32_t fw_build = 0; 119 u32 fw_build = 0;
117 120
118 strncpy(drvinfo->driver, "netxen_nic", 32); 121 strncpy(drvinfo->driver, "netxen_nic", 32);
119 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); 122 strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32);
@@ -136,6 +139,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
136{ 139{
137 struct netxen_port *port = netdev_priv(dev); 140 struct netxen_port *port = netdev_priv(dev);
138 struct netxen_adapter *adapter = port->adapter; 141 struct netxen_adapter *adapter = port->adapter;
142 struct netxen_board_info *boardinfo;
143 boardinfo = &adapter->ahw.boardcfg;
139 144
140 /* read which mode */ 145 /* read which mode */
141 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 146 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
@@ -144,16 +149,12 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
144 SUPPORTED_100baseT_Half | 149 SUPPORTED_100baseT_Half |
145 SUPPORTED_100baseT_Full | 150 SUPPORTED_100baseT_Full |
146 SUPPORTED_1000baseT_Half | 151 SUPPORTED_1000baseT_Half |
147 SUPPORTED_1000baseT_Full | 152 SUPPORTED_1000baseT_Full);
148 SUPPORTED_TP |
149 SUPPORTED_MII | SUPPORTED_Autoneg);
150 153
151 ecmd->advertising = (ADVERTISED_100baseT_Half | 154 ecmd->advertising = (ADVERTISED_100baseT_Half |
152 ADVERTISED_100baseT_Full | 155 ADVERTISED_100baseT_Full |
153 ADVERTISED_1000baseT_Half | 156 ADVERTISED_1000baseT_Half |
154 ADVERTISED_1000baseT_Full | 157 ADVERTISED_1000baseT_Full);
155 ADVERTISED_TP |
156 ADVERTISED_MII | ADVERTISED_Autoneg);
157 158
158 ecmd->port = PORT_TP; 159 ecmd->port = PORT_TP;
159 160
@@ -162,16 +163,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
162 ecmd->duplex = port->link_duplex; 163 ecmd->duplex = port->link_duplex;
163 } else 164 } else
164 return -EIO; /* link absent */ 165 return -EIO; /* link absent */
165 166 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
166 ecmd->phy_address = port->portnum;
167 ecmd->transceiver = XCVR_EXTERNAL;
168
169 /* get autoneg settings */
170 ecmd->autoneg = port->link_autoneg;
171 return 0;
172 }
173
174 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
175 ecmd->supported = (SUPPORTED_TP | 167 ecmd->supported = (SUPPORTED_TP |
176 SUPPORTED_1000baseT_Full | 168 SUPPORTED_1000baseT_Full |
177 SUPPORTED_10000baseT_Full); 169 SUPPORTED_10000baseT_Full);
@@ -182,13 +174,47 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
182 174
183 ecmd->speed = SPEED_10000; 175 ecmd->speed = SPEED_10000;
184 ecmd->duplex = DUPLEX_FULL; 176 ecmd->duplex = DUPLEX_FULL;
185 ecmd->phy_address = port->portnum;
186 ecmd->transceiver = XCVR_EXTERNAL;
187 ecmd->autoneg = AUTONEG_DISABLE; 177 ecmd->autoneg = AUTONEG_DISABLE;
188 return 0; 178 } else
179 return -EIO;
180
181 ecmd->phy_address = port->portnum;
182 ecmd->transceiver = XCVR_EXTERNAL;
183
184 switch ((netxen_brdtype_t) boardinfo->board_type) {
185 case NETXEN_BRDTYPE_P2_SB35_4G:
186 case NETXEN_BRDTYPE_P2_SB31_2G:
187 ecmd->supported |= SUPPORTED_Autoneg;
188 ecmd->advertising |= ADVERTISED_Autoneg;
189 case NETXEN_BRDTYPE_P2_SB31_10G_CX4:
190 ecmd->supported |= SUPPORTED_TP;
191 ecmd->advertising |= ADVERTISED_TP;
192 ecmd->port = PORT_TP;
193 ecmd->autoneg = (boardinfo->board_type ==
194 NETXEN_BRDTYPE_P2_SB31_10G_CX4) ?
195 (AUTONEG_DISABLE) : (port->link_autoneg);
196 break;
197 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
198 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
199 ecmd->supported |= SUPPORTED_MII;
200 ecmd->advertising |= ADVERTISED_MII;
201 ecmd->port = PORT_FIBRE;
202 ecmd->autoneg = AUTONEG_DISABLE;
203 break;
204 case NETXEN_BRDTYPE_P2_SB31_10G:
205 ecmd->supported |= SUPPORTED_FIBRE;
206 ecmd->advertising |= ADVERTISED_FIBRE;
207 ecmd->port = PORT_FIBRE;
208 ecmd->autoneg = AUTONEG_DISABLE;
209 break;
210 default:
211 printk("ERROR: Unsupported board model %d\n",
212 (netxen_brdtype_t) boardinfo->board_type);
213 return -EIO;
214
189 } 215 }
190 216
191 return -EIO; 217 return 0;
192} 218}
193 219
194static int 220static int
@@ -371,7 +397,7 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
371 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { 397 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
372 /* GB: port specific registers */ 398 /* GB: port specific registers */
373 if (mode == 0 && i >= 19) 399 if (mode == 0 && i >= 19)
374 window = port->portnum * 0x10000; 400 window = port->portnum * NETXEN_NIC_PORT_WINDOW;
375 401
376 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. 402 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode].
377 reg[i - 3] + window, 403 reg[i - 3] + window,
@@ -385,7 +411,8 @@ static void
385netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) 411netxen_nic_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
386{ 412{
387 wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC; 413 wol->supported = WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC;
388 wol->wolopts = 0; /* options can be added depending upon the mode */ 414 /* options can be added depending upon the mode */
415 wol->wolopts = 0;
389} 416}
390 417
391static u32 netxen_nic_get_link(struct net_device *dev) 418static u32 netxen_nic_get_link(struct net_device *dev)
@@ -531,9 +558,9 @@ static int netxen_nic_reg_test(struct net_device *dev)
531 558
532 save = data_read; 559 save = data_read;
533 if (data_read) 560 if (data_read)
534 data_written = data_read & 0xDEADBEEF; 561 data_written = data_read & NETXEN_NIC_INVALID_DATA;
535 else 562 else
536 data_written = 0xDEADBEEF; 563 data_written = NETXEN_NIC_INVALID_DATA;
537 netxen_nic_write_w0(adapter, 564 netxen_nic_write_w0(adapter,
538 NETXEN_NIU_GB_MII_MGMT_STATUS(port-> 565 NETXEN_NIU_GB_MII_MGMT_STATUS(port->
539 portnum), 566 portnum),
@@ -559,9 +586,9 @@ static int netxen_nic_reg_test(struct net_device *dev)
559 586
560 save = data_read; 587 save = data_read;
561 if (data_read) 588 if (data_read)
562 data_written = data_read & 0xDEADBEEF; 589 data_written = data_read & NETXEN_NIC_INVALID_DATA;
563 else 590 else
564 data_written = 0xDEADBEEF; 591 data_written = NETXEN_NIC_INVALID_DATA;
565 netxen_nic_write_w0(adapter, 592 netxen_nic_write_w0(adapter,
566 NETXEN_NIU_GB_MII_MGMT_INDICATE(port-> 593 NETXEN_NIU_GB_MII_MGMT_INDICATE(port->
567 portnum), 594 portnum),
@@ -587,9 +614,9 @@ static int netxen_nic_reg_test(struct net_device *dev)
587 614
588 save = data_read; 615 save = data_read;
589 if (data_read) 616 if (data_read)
590 data_written = data_read & 0xDEADBEEF; 617 data_written = data_read & NETXEN_NIC_INVALID_DATA;
591 else 618 else
592 data_written = 0xDEADBEEF; 619 data_written = NETXEN_NIC_INVALID_DATA;
593 netxen_nic_write_w0(adapter, 620 netxen_nic_write_w0(adapter,
594 NETXEN_NIU_GB_INTERFACE_STATUS(port-> 621 NETXEN_NIU_GB_INTERFACE_STATUS(port->
595 portnum), 622 portnum),
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 83bf28b372a4..72c6ec4ee2a0 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -6,12 +6,12 @@
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -397,6 +397,7 @@ enum {
397 397
398#define NETXEN_ROMUSB_ROM_INSTR_OPCODE (ROMUSB_ROM + 0x0004) 398#define NETXEN_ROMUSB_ROM_INSTR_OPCODE (ROMUSB_ROM + 0x0004)
399#define NETXEN_ROMUSB_ROM_ADDRESS (ROMUSB_ROM + 0x0008) 399#define NETXEN_ROMUSB_ROM_ADDRESS (ROMUSB_ROM + 0x0008)
400#define NETXEN_ROMUSB_ROM_WDATA (ROMUSB_ROM + 0x000c)
400#define NETXEN_ROMUSB_ROM_ABYTE_CNT (ROMUSB_ROM + 0x0010) 401#define NETXEN_ROMUSB_ROM_ABYTE_CNT (ROMUSB_ROM + 0x0010)
401#define NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014) 402#define NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT (ROMUSB_ROM + 0x0014)
402#define NETXEN_ROMUSB_ROM_RDATA (ROMUSB_ROM + 0x0018) 403#define NETXEN_ROMUSB_ROM_RDATA (ROMUSB_ROM + 0x0018)
@@ -404,7 +405,29 @@ enum {
404/* Lock IDs for ROM lock */ 405/* Lock IDs for ROM lock */
405#define ROM_LOCK_DRIVER 0x0d417340 406#define ROM_LOCK_DRIVER 0x0d417340
406 407
407#define NETXEN_PCI_CRB_WINDOWSIZE 0x00100000 /* all are 1MB windows */ 408/******************************************************************************
409*
410* Definitions specific to M25P flash
411*
412*******************************************************************************
413* Instructions
414*/
415#define M25P_INSTR_WREN 0x06
416#define M25P_INSTR_WRDI 0x04
417#define M25P_INSTR_RDID 0x9f
418#define M25P_INSTR_RDSR 0x05
419#define M25P_INSTR_WRSR 0x01
420#define M25P_INSTR_READ 0x03
421#define M25P_INSTR_FAST_READ 0x0b
422#define M25P_INSTR_PP 0x02
423#define M25P_INSTR_SE 0xd8
424#define M25P_INSTR_BE 0xc7
425#define M25P_INSTR_DP 0xb9
426#define M25P_INSTR_RES 0xab
427
428/* all are 1MB windows */
429
430#define NETXEN_PCI_CRB_WINDOWSIZE 0x00100000
408#define NETXEN_PCI_CRB_WINDOW(A) \ 431#define NETXEN_PCI_CRB_WINDOW(A) \
409 (NETXEN_PCI_CRBSPACE + (A)*NETXEN_PCI_CRB_WINDOWSIZE) 432 (NETXEN_PCI_CRBSPACE + (A)*NETXEN_PCI_CRB_WINDOWSIZE)
410 433
@@ -505,6 +528,12 @@ enum {
505#define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc) 528#define NETXEN_NIU_XG_PAUSE_LEVEL (NETXEN_CRB_NIU + 0x000dc)
506#define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128) 529#define NETXEN_NIU_XG_SEL (NETXEN_CRB_NIU + 0x00128)
507 530
531#define NETXEN_NIU_FULL_LEVEL_XG (NETXEN_CRB_NIU + 0x00450)
532
533#define NETXEN_NIU_XG1_RESET (NETXEN_CRB_NIU + 0x0011c)
534#define NETXEN_NIU_XG1_POWER_DOWN (NETXEN_CRB_NIU + 0x00120)
535#define NETXEN_NIU_XG1_RESET_PLL (NETXEN_CRB_NIU + 0x00124)
536
508#define NETXEN_MAC_ADDR_CNTL_REG (NETXEN_CRB_NIU + 0x1000) 537#define NETXEN_MAC_ADDR_CNTL_REG (NETXEN_CRB_NIU + 0x1000)
509 538
510#define NETXEN_MULTICAST_ADDR_HI_0 (NETXEN_CRB_NIU + 0x1010) 539#define NETXEN_MULTICAST_ADDR_HI_0 (NETXEN_CRB_NIU + 0x1010)
@@ -568,6 +597,29 @@ enum {
568#define NETXEN_NIU_XGE_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x70050) 597#define NETXEN_NIU_XGE_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x70050)
569#define NETXEN_NIU_XGE_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x70054) 598#define NETXEN_NIU_XGE_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x70054)
570#define NETXEN_NIU_XGE_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x70058) 599#define NETXEN_NIU_XGE_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x70058)
600#define NETXEN_NIU_XG1_CONFIG_0 (NETXEN_CRB_NIU + 0x80000)
601#define NETXEN_NIU_XG1_CONFIG_1 (NETXEN_CRB_NIU + 0x80004)
602#define NETXEN_NIU_XG1_IPG (NETXEN_CRB_NIU + 0x80008)
603#define NETXEN_NIU_XG1_STATION_ADDR_0_HI (NETXEN_CRB_NIU + 0x8000c)
604#define NETXEN_NIU_XG1_STATION_ADDR_0_1 (NETXEN_CRB_NIU + 0x80010)
605#define NETXEN_NIU_XG1_STATION_ADDR_1_LO (NETXEN_CRB_NIU + 0x80014)
606#define NETXEN_NIU_XG1_STATUS (NETXEN_CRB_NIU + 0x80018)
607#define NETXEN_NIU_XG1_MAX_FRAME_SIZE (NETXEN_CRB_NIU + 0x8001c)
608#define NETXEN_NIU_XG1_PAUSE_FRAME_VALUE (NETXEN_CRB_NIU + 0x80020)
609#define NETXEN_NIU_XG1_TX_BYTE_CNT (NETXEN_CRB_NIU + 0x80024)
610#define NETXEN_NIU_XG1_TX_FRAME_CNT (NETXEN_CRB_NIU + 0x80028)
611#define NETXEN_NIU_XG1_RX_BYTE_CNT (NETXEN_CRB_NIU + 0x8002c)
612#define NETXEN_NIU_XG1_RX_FRAME_CNT (NETXEN_CRB_NIU + 0x80030)
613#define NETXEN_NIU_XG1_AGGR_ERROR_CNT (NETXEN_CRB_NIU + 0x80034)
614#define NETXEN_NIU_XG1_MULTICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x80038)
615#define NETXEN_NIU_XG1_UNICAST_FRAME_CNT (NETXEN_CRB_NIU + 0x8003c)
616#define NETXEN_NIU_XG1_CRC_ERROR_CNT (NETXEN_CRB_NIU + 0x80040)
617#define NETXEN_NIU_XG1_OVERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80044)
618#define NETXEN_NIU_XG1_UNDERSIZE_FRAME_ERR (NETXEN_CRB_NIU + 0x80048)
619#define NETXEN_NIU_XG1_LOCAL_ERROR_CNT (NETXEN_CRB_NIU + 0x8004c)
620#define NETXEN_NIU_XG1_REMOTE_ERROR_CNT (NETXEN_CRB_NIU + 0x80050)
621#define NETXEN_NIU_XG1_CONTROL_CHAR_CNT (NETXEN_CRB_NIU + 0x80054)
622#define NETXEN_NIU_XG1_PAUSE_FRAME_CNT (NETXEN_CRB_NIU + 0x80058)
571 623
572/* XG Link status */ 624/* XG Link status */
573#define XG_LINK_UP 0x10 625#define XG_LINK_UP 0x10
@@ -580,8 +632,15 @@ enum {
580#define NETXEN_FW_VERSION_SUB (NETXEN_CAM_RAM(0x158)) 632#define NETXEN_FW_VERSION_SUB (NETXEN_CAM_RAM(0x158))
581#define NETXEN_ROM_LOCK_ID (NETXEN_CAM_RAM(0x100)) 633#define NETXEN_ROM_LOCK_ID (NETXEN_CAM_RAM(0x100))
582 634
583#define PCIX_PS_OP_ADDR_LO (0x10000) /* Used for PS PCI Memory access */ 635#define NETXEN_PHY_LOCK_ID (NETXEN_CAM_RAM(0x120))
584#define PCIX_PS_OP_ADDR_HI (0x10004) /* via CRB (PS side only) */ 636
637/* Lock IDs for PHY lock */
638#define PHY_LOCK_DRIVER 0x44524956
639
640/* Used for PS PCI Memory access */
641#define PCIX_PS_OP_ADDR_LO (0x10000)
642/* via CRB (PS side only) */
643#define PCIX_PS_OP_ADDR_HI (0x10004)
585 644
586#define PCIX_INT_VECTOR (0x10100) 645#define PCIX_INT_VECTOR (0x10100)
587#define PCIX_INT_MASK (0x10104) 646#define PCIX_INT_MASK (0x10104)
@@ -609,6 +668,8 @@ enum {
609 668
610#define PCIE_SEM2_LOCK (0x1c010) /* Flash lock */ 669#define PCIE_SEM2_LOCK (0x1c010) /* Flash lock */
611#define PCIE_SEM2_UNLOCK (0x1c014) /* Flash unlock */ 670#define PCIE_SEM2_UNLOCK (0x1c014) /* Flash unlock */
671#define PCIE_SEM3_LOCK (0x1c018) /* Phy lock */
672#define PCIE_SEM3_UNLOCK (0x1c01c) /* Phy unlock */
612 673
613#define PCIE_TGT_SPLIT_CHICKEN (0x12080) 674#define PCIE_TGT_SPLIT_CHICKEN (0x12080)
614 675
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 9603c635b054..99e647a5ae76 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -6,12 +6,12 @@
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -43,15 +43,26 @@
43#define NETXEN_FLASH_BASE (BOOTLD_START) 43#define NETXEN_FLASH_BASE (BOOTLD_START)
44#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE) 44#define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE)
45#define NETXEN_MAX_MTU 8000 45#define NETXEN_MAX_MTU 8000
46#define NETXEN_MIN_MTU 64 46#define NETXEN_MIN_MTU 64
47#define NETXEN_ETH_FCS_SIZE 4 47#define NETXEN_ETH_FCS_SIZE 4
48#define NETXEN_ENET_HEADER_SIZE 14 48#define NETXEN_ENET_HEADER_SIZE 14
49#define NETXEN_WINDOW_ONE 0x2000000 /* CRB Window: bit 25 of CRB address */ 49#define NETXEN_WINDOW_ONE 0x2000000 /*CRB Window: bit 25 of CRB address */
50#define NETXEN_FIRMWARE_LEN ((16 * 1024) / 4) 50#define NETXEN_FIRMWARE_LEN ((16 * 1024) / 4)
51#define NETXEN_NIU_HDRSIZE (0x1 << 6) 51#define NETXEN_NIU_HDRSIZE (0x1 << 6)
52#define NETXEN_NIU_TLRSIZE (0x1 << 5) 52#define NETXEN_NIU_TLRSIZE (0x1 << 5)
53 53
54unsigned long netxen_nic_pci_set_window(void __iomem * pci_base, 54#define lower32(x) ((u32)((x) & 0xffffffff))
55#define upper32(x) \
56 ((u32)(((unsigned long long)(x) >> 32) & 0xffffffff))
57
58#define NETXEN_NIC_ZERO_PAUSE_ADDR 0ULL
59#define NETXEN_NIC_UNIT_PAUSE_ADDR 0x200ULL
60#define NETXEN_NIC_EPG_PAUSE_ADDR1 0x2200010000c28001ULL
61#define NETXEN_NIC_EPG_PAUSE_ADDR2 0x0100088866554433ULL
62
63#define NETXEN_NIC_WINDOW_MARGIN 0x100000
64
65unsigned long netxen_nic_pci_set_window(struct netxen_adapter *adapter,
55 unsigned long long addr); 66 unsigned long long addr);
56void netxen_free_hw_resources(struct netxen_adapter *adapter); 67void netxen_free_hw_resources(struct netxen_adapter *adapter);
57 68
@@ -93,7 +104,9 @@ void netxen_nic_set_multi(struct net_device *netdev)
93 port->portnum, 104 port->portnum,
94 NETXEN_NIU_PROMISC_MODE); 105 NETXEN_NIU_PROMISC_MODE);
95 } else { 106 } else {
96 if (adapter->ops->unset_promisc) 107 if (adapter->ops->unset_promisc &&
108 adapter->ahw.boardcfg.board_type
109 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
97 adapter->ops->unset_promisc(adapter, 110 adapter->ops->unset_promisc(adapter,
98 port->portnum, 111 port->portnum,
99 NETXEN_NIU_NON_PROMISC_MODE); 112 NETXEN_NIU_NON_PROMISC_MODE);
@@ -161,26 +174,24 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
161int netxen_nic_hw_resources(struct netxen_adapter *adapter) 174int netxen_nic_hw_resources(struct netxen_adapter *adapter)
162{ 175{
163 struct netxen_hardware_context *hw = &adapter->ahw; 176 struct netxen_hardware_context *hw = &adapter->ahw;
164 int i;
165 u32 state = 0; 177 u32 state = 0;
166 void *addr; 178 void *addr;
179 void *pause_addr;
167 int loops = 0, err = 0; 180 int loops = 0, err = 0;
168 int ctx, ring; 181 int ctx, ring;
169 u32 card_cmdring = 0; 182 u32 card_cmdring = 0;
170 struct netxen_rcv_desc_crb *rcv_desc_crb = NULL; 183 struct netxen_rcv_desc_crb *rcv_desc_crb = NULL;
171 struct netxen_recv_context *recv_ctx; 184 struct netxen_recv_context *recv_ctx;
172 struct netxen_rcv_desc_ctx *rcv_desc; 185 struct netxen_rcv_desc_ctx *rcv_desc;
173 struct cmd_desc_type0 *pcmd;
174 186
175 DPRINTK(INFO, "pci_base: %lx\n", adapter->ahw.pci_base);
176 DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE, 187 DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE,
177 adapter->ahw.pci_base + NETXEN_PCI_CRBSPACE); 188 PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE));
178 DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM, 189 DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM,
179 adapter->ahw.pci_base + NETXEN_CRB_CAM); 190 pci_base_offset(adapter, NETXEN_CRB_CAM));
180 DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE, 191 DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE,
181 adapter->ahw.pci_base + NETXEN_CAM_RAM_BASE); 192 pci_base_offset(adapter, NETXEN_CAM_RAM_BASE));
182 DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1, 193 DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1,
183 adapter->ahw.pci_base + NIC_CRB_BASE_PORT1); 194 pci_base_offset(adapter, NIC_CRB_BASE_PORT1));
184 195
185 /* Window 1 call */ 196 /* Window 1 call */
186 card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING)); 197 card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING));
@@ -214,25 +225,34 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
214 } 225 }
215 DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n"); 226 DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n");
216 227
217 addr = pci_alloc_consistent(adapter->ahw.pdev, 228 addr = netxen_alloc(adapter->ahw.pdev,
218 sizeof(struct cmd_desc_type0) * 229 sizeof(struct cmd_desc_type0) *
219 adapter->max_tx_desc_count, 230 adapter->max_tx_desc_count,
220 &hw->cmd_desc_phys_addr); 231 &hw->cmd_desc_phys_addr, &hw->cmd_desc_pdev);
232
221 if (addr == NULL) { 233 if (addr == NULL) {
222 DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); 234 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
223 err = -ENOMEM; 235 return -ENOMEM;
224 return err; 236 }
237
238 pause_addr = netxen_alloc(adapter->ahw.pdev, 512,
239 (dma_addr_t *) & hw->pause_physaddr,
240 &hw->pause_pdev);
241 if (pause_addr == NULL) {
242 DPRINTK(1, ERR, "bad return from pci_alloc_consistent\n");
243 return -ENOMEM;
225 } 244 }
226 245
227 /* we need to prelink all of the cmd descriptors */ 246 hw->pauseaddr = (char *)pause_addr;
228 pcmd = (struct cmd_desc_type0 *)addr; 247 {
229 for (i = 1; i < adapter->max_tx_desc_count; i++) { 248 u64 *ptr = (u64 *) pause_addr;
230 pcmd->netxen_next = 249 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
231 (card_cmdring + i * sizeof(struct cmd_desc_type0)); 250 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
232 pcmd++; 251 *ptr++ = NETXEN_NIC_UNIT_PAUSE_ADDR;
252 *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR;
253 *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR1;
254 *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR2;
233 } 255 }
234 /* fill in last link (point to first) */
235 pcmd->netxen_next = card_cmdring;
236 256
237 hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; 257 hw->cmd_desc_head = (struct cmd_desc_type0 *)addr;
238 258
@@ -241,9 +261,10 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
241 261
242 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 262 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
243 rcv_desc = &recv_ctx->rcv_desc[ring]; 263 rcv_desc = &recv_ctx->rcv_desc[ring];
244 addr = pci_alloc_consistent(adapter->ahw.pdev, 264 addr = netxen_alloc(adapter->ahw.pdev,
245 RCV_DESC_RINGSIZE, 265 RCV_DESC_RINGSIZE,
246 &rcv_desc->phys_addr); 266 &rcv_desc->phys_addr,
267 &rcv_desc->phys_pdev);
247 if (addr == NULL) { 268 if (addr == NULL) {
248 DPRINTK(ERR, "bad return from " 269 DPRINTK(ERR, "bad return from "
249 "pci_alloc_consistent\n"); 270 "pci_alloc_consistent\n");
@@ -254,10 +275,11 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
254 rcv_desc->desc_head = (struct rcv_desc *)addr; 275 rcv_desc->desc_head = (struct rcv_desc *)addr;
255 } 276 }
256 277
257 addr = pci_alloc_consistent(adapter->ahw.pdev, 278 addr = netxen_alloc(adapter->ahw.pdev,
258 STATUS_DESC_RINGSIZE, 279 STATUS_DESC_RINGSIZE,
259 &recv_ctx-> 280 &recv_ctx->
260 rcv_status_desc_phys_addr); 281 rcv_status_desc_phys_addr,
282 &recv_ctx->rcv_status_desc_pdev);
261 if (addr == NULL) { 283 if (addr == NULL) {
262 DPRINTK(ERR, "bad return from" 284 DPRINTK(ERR, "bad return from"
263 " pci_alloc_consistent\n"); 285 " pci_alloc_consistent\n");
@@ -273,19 +295,20 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
273 DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n", 295 DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n",
274 ring, rcv_desc_crb->crb_globalrcv_ring); 296 ring, rcv_desc_crb->crb_globalrcv_ring);
275 /* Window = 1 */ 297 /* Window = 1 */
276 writel(rcv_desc->phys_addr, 298 writel(lower32(rcv_desc->phys_addr),
277 NETXEN_CRB_NORMALIZE(adapter, 299 NETXEN_CRB_NORMALIZE(adapter,
278 rcv_desc_crb-> 300 rcv_desc_crb->
279 crb_globalrcv_ring)); 301 crb_globalrcv_ring));
280 DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x" 302 DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x"
281 " val 0x%x," 303 " val 0x%llx,"
282 " virt %p\n", ctx, 304 " virt %p\n", ctx,
283 rcv_desc_crb->crb_globalrcv_ring, 305 rcv_desc_crb->crb_globalrcv_ring,
284 rcv_desc->phys_addr, rcv_desc->desc_head); 306 (unsigned long long)rcv_desc->phys_addr,
307 +rcv_desc->desc_head);
285 } 308 }
286 309
287 /* Window = 1 */ 310 /* Window = 1 */
288 writel(recv_ctx->rcv_status_desc_phys_addr, 311 writel(lower32(recv_ctx->rcv_status_desc_phys_addr),
289 NETXEN_CRB_NORMALIZE(adapter, 312 NETXEN_CRB_NORMALIZE(adapter,
290 recv_crb_registers[ctx]. 313 recv_crb_registers[ctx].
291 crb_rcvstatus_ring)); 314 crb_rcvstatus_ring));
@@ -293,13 +316,19 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
293 " val 0x%x,virt%p\n", 316 " val 0x%x,virt%p\n",
294 ctx, 317 ctx,
295 recv_crb_registers[ctx].crb_rcvstatus_ring, 318 recv_crb_registers[ctx].crb_rcvstatus_ring,
296 recv_ctx->rcv_status_desc_phys_addr, 319 (unsigned long long)recv_ctx->rcv_status_desc_phys_addr,
297 recv_ctx->rcv_status_desc_head); 320 recv_ctx->rcv_status_desc_head);
298 } 321 }
299 /* Window = 1 */ 322 /* Window = 1 */
300 writel(hw->cmd_desc_phys_addr, 323 writel(lower32(hw->pause_physaddr),
301 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); 324 NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_LO));
325 writel(upper32(hw->pause_physaddr),
326 NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_HI));
302 327
328 writel(lower32(hw->cmd_desc_phys_addr),
329 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
330 writel(upper32(hw->cmd_desc_phys_addr),
331 NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_HI));
303 return err; 332 return err;
304} 333}
305 334
@@ -310,13 +339,19 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
310 int ctx, ring; 339 int ctx, ring;
311 340
312 if (adapter->ahw.cmd_desc_head != NULL) { 341 if (adapter->ahw.cmd_desc_head != NULL) {
313 pci_free_consistent(adapter->ahw.pdev, 342 pci_free_consistent(adapter->ahw.cmd_desc_pdev,
314 sizeof(struct cmd_desc_type0) * 343 sizeof(struct cmd_desc_type0) *
315 adapter->max_tx_desc_count, 344 adapter->max_tx_desc_count,
316 adapter->ahw.cmd_desc_head, 345 adapter->ahw.cmd_desc_head,
317 adapter->ahw.cmd_desc_phys_addr); 346 adapter->ahw.cmd_desc_phys_addr);
318 adapter->ahw.cmd_desc_head = NULL; 347 adapter->ahw.cmd_desc_head = NULL;
319 } 348 }
349 if (adapter->ahw.pauseaddr != NULL) {
350 pci_free_consistent(adapter->ahw.pause_pdev, 512,
351 adapter->ahw.pauseaddr,
352 adapter->ahw.pause_physaddr);
353 adapter->ahw.pauseaddr = NULL;
354 }
320 355
321 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 356 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
322 recv_ctx = &adapter->recv_ctx[ctx]; 357 recv_ctx = &adapter->recv_ctx[ctx];
@@ -324,7 +359,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
324 rcv_desc = &recv_ctx->rcv_desc[ring]; 359 rcv_desc = &recv_ctx->rcv_desc[ring];
325 360
326 if (rcv_desc->desc_head != NULL) { 361 if (rcv_desc->desc_head != NULL) {
327 pci_free_consistent(adapter->ahw.pdev, 362 pci_free_consistent(rcv_desc->phys_pdev,
328 RCV_DESC_RINGSIZE, 363 RCV_DESC_RINGSIZE,
329 rcv_desc->desc_head, 364 rcv_desc->desc_head,
330 rcv_desc->phys_addr); 365 rcv_desc->phys_addr);
@@ -333,7 +368,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
333 } 368 }
334 369
335 if (recv_ctx->rcv_status_desc_head != NULL) { 370 if (recv_ctx->rcv_status_desc_head != NULL) {
336 pci_free_consistent(adapter->ahw.pdev, 371 pci_free_consistent(recv_ctx->rcv_status_desc_pdev,
337 STATUS_DESC_RINGSIZE, 372 STATUS_DESC_RINGSIZE,
338 recv_ctx->rcv_status_desc_head, 373 recv_ctx->rcv_status_desc_head,
339 recv_ctx-> 374 recv_ctx->
@@ -360,10 +395,10 @@ void netxen_tso_check(struct netxen_adapter *adapter,
360 return; 395 return;
361 } 396 }
362 } 397 }
398 adapter->stats.xmitcsummed++;
363 CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data); 399 CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data);
364 desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr); 400 desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr);
365 desc->ip_hdr_offset = skb->nh.raw - skb->data; 401 desc->ip_hdr_offset = skb->nh.raw - skb->data;
366 adapter->stats.xmitcsummed++;
367} 402}
368 403
369int netxen_is_flash_supported(struct netxen_adapter *adapter) 404int netxen_is_flash_supported(struct netxen_adapter *adapter)
@@ -373,7 +408,7 @@ int netxen_is_flash_supported(struct netxen_adapter *adapter)
373 408
374 /* if the flash size less than 4Mb, make huge war cry and die */ 409 /* if the flash size less than 4Mb, make huge war cry and die */
375 for (j = 1; j < 4; j++) { 410 for (j = 1; j < 4; j++) {
376 addr = j * 0x100000; 411 addr = j * NETXEN_NIC_WINDOW_MARGIN;
377 for (i = 0; i < (sizeof(locs) / sizeof(locs[0])); i++) { 412 for (i = 0; i < (sizeof(locs) / sizeof(locs[0])); i++) {
378 if (netxen_rom_fast_read(adapter, locs[i], &val01) == 0 413 if (netxen_rom_fast_read(adapter, locs[i], &val01) == 0
379 && netxen_rom_fast_read(adapter, (addr + locs[i]), 414 && netxen_rom_fast_read(adapter, (addr + locs[i]),
@@ -458,7 +493,9 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw)
458 * register address is received by PCI. The direct region bypasses 493 * register address is received by PCI. The direct region bypasses
459 * the CRB bus. 494 * the CRB bus.
460 */ 495 */
461 offset = adapter->ahw.pci_base + NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW); 496 offset =
497 PCI_OFFSET_SECOND_RANGE(adapter,
498 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW));
462 499
463 if (wndw & 0x1) 500 if (wndw & 0x1)
464 wndw = NETXEN_WINDOW_ONE; 501 wndw = NETXEN_WINDOW_ONE;
@@ -497,8 +534,8 @@ void netxen_load_firmware(struct netxen_adapter *adapter)
497 "loading flash image\n"); 534 "loading flash image\n");
498 return; 535 return;
499 } 536 }
500 off = netxen_nic_pci_set_window(adapter->ahw.pci_base, memaddr); 537 off = netxen_nic_pci_set_window(adapter, memaddr);
501 addr = (adapter->ahw.pci_base + off); 538 addr = pci_base_offset(adapter, off);
502 writel(data, addr); 539 writel(data, addr);
503 flashaddr += 4; 540 flashaddr += 4;
504 memaddr += 4; 541 memaddr += 4;
@@ -521,14 +558,19 @@ netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data,
521 if (ADDR_IN_WINDOW1(off)) { 558 if (ADDR_IN_WINDOW1(off)) {
522 addr = NETXEN_CRB_NORMALIZE(adapter, off); 559 addr = NETXEN_CRB_NORMALIZE(adapter, off);
523 } else { /* Window 0 */ 560 } else { /* Window 0 */
524 addr = adapter->ahw.pci_base + off; 561 addr = pci_base_offset(adapter, off);
525 netxen_nic_pci_change_crbwindow(adapter, 0); 562 netxen_nic_pci_change_crbwindow(adapter, 0);
526 } 563 }
527 564
528 DPRINTK(INFO, "writing to base %lx offset %llx addr %p" 565 DPRINTK(INFO, "writing to base %lx offset %llx addr %p"
529 " data %llx len %d\n", 566 " data %llx len %d\n",
530 adapter->ahw.pci_base, off, addr, 567 pci_base(adapter, off), off, addr,
531 *(unsigned long long *)data, len); 568 *(unsigned long long *)data, len);
569 if (!addr) {
570 netxen_nic_pci_change_crbwindow(adapter, 1);
571 return 1;
572 }
573
532 switch (len) { 574 switch (len) {
533 case 1: 575 case 1:
534 writeb(*(u8 *) data, addr); 576 writeb(*(u8 *) data, addr);
@@ -566,12 +608,16 @@ netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data,
566 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */ 608 if (ADDR_IN_WINDOW1(off)) { /* Window 1 */
567 addr = NETXEN_CRB_NORMALIZE(adapter, off); 609 addr = NETXEN_CRB_NORMALIZE(adapter, off);
568 } else { /* Window 0 */ 610 } else { /* Window 0 */
569 addr = adapter->ahw.pci_base + off; 611 addr = pci_base_offset(adapter, off);
570 netxen_nic_pci_change_crbwindow(adapter, 0); 612 netxen_nic_pci_change_crbwindow(adapter, 0);
571 } 613 }
572 614
573 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n", 615 DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n",
574 adapter->ahw.pci_base, off, addr); 616 pci_base(adapter, off), off, addr);
617 if (!addr) {
618 netxen_nic_pci_change_crbwindow(adapter, 1);
619 return 1;
620 }
575 switch (len) { 621 switch (len) {
576 case 1: 622 case 1:
577 *(u8 *) data = readb(addr); 623 *(u8 *) data = readb(addr);
@@ -604,7 +650,7 @@ void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val)
604 650
605 addr = NETXEN_CRB_NORMALIZE(adapter, off); 651 addr = NETXEN_CRB_NORMALIZE(adapter, off);
606 DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n", 652 DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n",
607 adapter->ahw.pci_base, off, addr, val); 653 pci_base(adapter, off), off, addr);
608 writel(val, addr); 654 writel(val, addr);
609 655
610} 656}
@@ -629,7 +675,7 @@ void netxen_nic_write_w0(struct netxen_adapter *adapter, u32 index, u32 value)
629 void __iomem *addr; 675 void __iomem *addr;
630 676
631 netxen_nic_pci_change_crbwindow(adapter, 0); 677 netxen_nic_pci_change_crbwindow(adapter, 0);
632 addr = (void __iomem *)(adapter->ahw.pci_base + index); 678 addr = (void __iomem *)(pci_base_offset(adapter, index));
633 writel(value, addr); 679 writel(value, addr);
634 netxen_nic_pci_change_crbwindow(adapter, 1); 680 netxen_nic_pci_change_crbwindow(adapter, 1);
635} 681}
@@ -639,7 +685,7 @@ void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value)
639{ 685{
640 void __iomem *addr; 686 void __iomem *addr;
641 687
642 addr = (void __iomem *)(adapter->ahw.pci_base + index); 688 addr = (void __iomem *)(pci_base_offset(adapter, index));
643 689
644 netxen_nic_pci_change_crbwindow(adapter, 0); 690 netxen_nic_pci_change_crbwindow(adapter, 0);
645 *value = readl(addr); 691 *value = readl(addr);
@@ -649,7 +695,8 @@ void netxen_nic_read_w0(struct netxen_adapter *adapter, u32 index, u32 * value)
649int netxen_pci_set_window_warning_count = 0; 695int netxen_pci_set_window_warning_count = 0;
650 696
651unsigned long 697unsigned long
652netxen_nic_pci_set_window(void __iomem * pci_base, unsigned long long addr) 698netxen_nic_pci_set_window(struct netxen_adapter *adapter,
699 unsigned long long addr)
653{ 700{
654 static int ddr_mn_window = -1; 701 static int ddr_mn_window = -1;
655 static int qdr_sn_window = -1; 702 static int qdr_sn_window = -1;
@@ -661,12 +708,15 @@ netxen_nic_pci_set_window(void __iomem * pci_base, unsigned long long addr)
661 window = (addr >> 25) & 0x3ff; 708 window = (addr >> 25) & 0x3ff;
662 if (ddr_mn_window != window) { 709 if (ddr_mn_window != window) {
663 ddr_mn_window = window; 710 ddr_mn_window = window;
664 writel(window, pci_base + 711 writel(window, PCI_OFFSET_SECOND_RANGE(adapter,
665 NETXEN_PCIX_PH_REG(PCIX_MN_WINDOW)); 712 NETXEN_PCIX_PH_REG
713 (PCIX_MN_WINDOW)));
666 /* MUST make sure window is set before we forge on... */ 714 /* MUST make sure window is set before we forge on... */
667 readl(pci_base + NETXEN_PCIX_PH_REG(PCIX_MN_WINDOW)); 715 readl(PCI_OFFSET_SECOND_RANGE(adapter,
716 NETXEN_PCIX_PH_REG
717 (PCIX_MN_WINDOW)));
668 } 718 }
669 addr -= (window * 0x2000000); 719 addr -= (window * NETXEN_WINDOW_ONE);
670 addr += NETXEN_PCI_DDR_NET; 720 addr += NETXEN_PCI_DDR_NET;
671 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) { 721 } else if (ADDR_IN_RANGE(addr, NETXEN_ADDR_OCM0, NETXEN_ADDR_OCM0_MAX)) {
672 addr -= NETXEN_ADDR_OCM0; 722 addr -= NETXEN_ADDR_OCM0;
@@ -682,10 +732,14 @@ netxen_nic_pci_set_window(void __iomem * pci_base, unsigned long long addr)
682 window = (addr >> 22) & 0x3f; 732 window = (addr >> 22) & 0x3f;
683 if (qdr_sn_window != window) { 733 if (qdr_sn_window != window) {
684 qdr_sn_window = window; 734 qdr_sn_window = window;
685 writel((window << 22), pci_base + 735 writel((window << 22),
686 NETXEN_PCIX_PH_REG(PCIX_SN_WINDOW)); 736 PCI_OFFSET_SECOND_RANGE(adapter,
737 NETXEN_PCIX_PH_REG
738 (PCIX_SN_WINDOW)));
687 /* MUST make sure window is set before we forge on... */ 739 /* MUST make sure window is set before we forge on... */
688 readl(pci_base + NETXEN_PCIX_PH_REG(PCIX_SN_WINDOW)); 740 readl(PCI_OFFSET_SECOND_RANGE(adapter,
741 NETXEN_PCIX_PH_REG
742 (PCIX_SN_WINDOW)));
689 } 743 }
690 addr -= (window * 0x400000); 744 addr -= (window * 0x400000);
691 addr += NETXEN_PCI_QDR_NET; 745 addr += NETXEN_PCI_QDR_NET;
@@ -811,7 +865,7 @@ netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off,
811 writel(data, NETXEN_CRB_NORMALIZE(adapter, off)); 865 writel(data, NETXEN_CRB_NORMALIZE(adapter, off));
812 } else { 866 } else {
813 netxen_nic_pci_change_crbwindow(adapter, 0); 867 netxen_nic_pci_change_crbwindow(adapter, 0);
814 addr = (void __iomem *)(adapter->ahw.pci_base + off); 868 addr = (void __iomem *)(pci_base_offset(adapter, off));
815 writel(data, addr); 869 writel(data, addr);
816 netxen_nic_pci_change_crbwindow(adapter, 1); 870 netxen_nic_pci_change_crbwindow(adapter, 1);
817 } 871 }
@@ -879,6 +933,10 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter)
879 u32 fw_major = 0; 933 u32 fw_major = 0;
880 u32 fw_minor = 0; 934 u32 fw_minor = 0;
881 u32 fw_build = 0; 935 u32 fw_build = 0;
936 char brd_name[NETXEN_MAX_SHORT_NAME];
937 struct netxen_new_user_info user_info;
938 int i, addr = USER_START;
939 u32 *ptr32;
882 940
883 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg); 941 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
884 if (board_info->magic != NETXEN_BDINFO_MAGIC) { 942 if (board_info->magic != NETXEN_BDINFO_MAGIC) {
@@ -894,6 +952,24 @@ void netxen_nic_flash_print(struct netxen_adapter *adapter)
894 valid = 0; 952 valid = 0;
895 } 953 }
896 if (valid) { 954 if (valid) {
955 ptr32 = (u32 *) & user_info;
956 for (i = 0;
957 i < sizeof(struct netxen_new_user_info) / sizeof(u32);
958 i++) {
959 if (netxen_rom_fast_read(adapter, addr, ptr32) == -1) {
960 printk("%s: ERROR reading %s board userarea.\n",
961 netxen_nic_driver_name,
962 netxen_nic_driver_name);
963 return;
964 }
965 ptr32++;
966 addr += sizeof(u32);
967 }
968 get_brd_name_by_type(board_info->board_type, brd_name);
969
970 printk("NetXen %s Board S/N %s Chip id 0x%x\n",
971 brd_name, user_info.serial_num, board_info->chip_id);
972
897 printk("NetXen %s Board #%d, Chip id 0x%x\n", 973 printk("NetXen %s Board #%d, Chip id 0x%x\n",
898 board_info->board_type == 0x0b ? "XGB" : "GBE", 974 board_info->board_type == 0x0b ? "XGB" : "GBE",
899 board_info->board_num, board_info->chip_id); 975 board_info->board_num, board_info->chip_id);
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h
index fb1a0253863f..201a636b7ab8 100644
--- a/drivers/net/netxen/netxen_nic_hw.h
+++ b/drivers/net/netxen/netxen_nic_hw.h
@@ -82,9 +82,9 @@ struct netxen_adapter;
82 82
83#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20) 83#define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20)
84 84
85#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \ 85#define NETXEN_NIC_LOCKED_READ_REG(X, Y) \
86 addr = (adapter->ahw.pci_base + X); \ 86 addr = pci_base_offset(adapter, (X)); \
87 *(u32 *)Y = readl((void __iomem*) addr); 87 *(u32 *)Y = readl(addr);
88 88
89struct netxen_port; 89struct netxen_port;
90void netxen_nic_set_link_parameters(struct netxen_port *port); 90void netxen_nic_set_link_parameters(struct netxen_port *port);
@@ -472,6 +472,8 @@ int netxen_niu_xg_macaddr_set(struct netxen_port *port,
472/* Generic enable for GbE ports. Will detect the speed of the link. */ 472/* Generic enable for GbE ports. Will detect the speed of the link. */
473int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port); 473int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
474 474
475int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
476
475/* Disable a GbE interface */ 477/* Disable a GbE interface */
476int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port); 478int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port);
477 479
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index d122e51e43ab..0dca029bc3e5 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -51,11 +51,13 @@ static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
51 crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \ 51 crb_addr_xform[NETXEN_HW_PX_MAP_CRB_##name] = \
52 NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20 52 NETXEN_HW_CRB_HUB_AGT_ADR_##name << 20
53 53
54#define NETXEN_NIC_XDMA_RESET 0x8000ff
55
54static inline void 56static inline void
55netxen_nic_locked_write_reg(struct netxen_adapter *adapter, 57netxen_nic_locked_write_reg(struct netxen_adapter *adapter,
56 unsigned long off, int *data) 58 unsigned long off, int *data)
57{ 59{
58 void __iomem *addr = (adapter->ahw.pci_base + off); 60 void __iomem *addr = pci_base_offset(adapter, off);
59 writel(*data, addr); 61 writel(*data, addr);
60} 62}
61 63
@@ -141,6 +143,24 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
141 return err; 143 return err;
142} 144}
143 145
146#define NETXEN_ADDR_LIMIT 0xffffffffULL
147
148void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
149 struct pci_dev **used_dev)
150{
151 void *addr;
152
153 addr = pci_alloc_consistent(pdev, sz, ptr);
154 if ((unsigned long long)(*ptr) < NETXEN_ADDR_LIMIT) {
155 *used_dev = pdev;
156 return addr;
157 }
158 pci_free_consistent(pdev, sz, addr, *ptr);
159 addr = pci_alloc_consistent(NULL, sz, ptr);
160 *used_dev = NULL;
161 return addr;
162}
163
144void netxen_initialize_adapter_sw(struct netxen_adapter *adapter) 164void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
145{ 165{
146 int ctxid, ring; 166 int ctxid, ring;
@@ -177,23 +197,17 @@ void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
177 197
178void netxen_initialize_adapter_hw(struct netxen_adapter *adapter) 198void netxen_initialize_adapter_hw(struct netxen_adapter *adapter)
179{ 199{
200 int ports = 0;
201 struct netxen_board_info *board_info = &(adapter->ahw.boardcfg);
202
180 if (netxen_nic_get_board_info(adapter) != 0) 203 if (netxen_nic_get_board_info(adapter) != 0)
181 printk("%s: Error getting board config info.\n", 204 printk("%s: Error getting board config info.\n",
182 netxen_nic_driver_name); 205 netxen_nic_driver_name);
183 206 get_brd_port_by_type(board_info->board_type, &ports);
184 switch (adapter->ahw.board_type) { 207 if (ports == 0)
185 case NETXEN_NIC_GBE:
186 adapter->ahw.max_ports = 4;
187 break;
188
189 case NETXEN_NIC_XGBE:
190 adapter->ahw.max_ports = 1;
191 break;
192
193 default:
194 printk(KERN_ERR "%s: Unknown board type\n", 208 printk(KERN_ERR "%s: Unknown board type\n",
195 netxen_nic_driver_name); 209 netxen_nic_driver_name);
196 } 210 adapter->ahw.max_ports = ports;
197} 211}
198 212
199void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) 213void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
@@ -225,6 +239,7 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter)
225 ops->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr; 239 ops->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr;
226 ops->macaddr_set = netxen_niu_xg_macaddr_set; 240 ops->macaddr_set = netxen_niu_xg_macaddr_set;
227 ops->set_mtu = netxen_nic_set_mtu_xgb; 241 ops->set_mtu = netxen_nic_set_mtu_xgb;
242 ops->init_port = netxen_niu_xg_init_port;
228 ops->set_promisc = netxen_niu_xg_set_promiscuous_mode; 243 ops->set_promisc = netxen_niu_xg_set_promiscuous_mode;
229 ops->unset_promisc = netxen_niu_xg_set_promiscuous_mode; 244 ops->unset_promisc = netxen_niu_xg_set_promiscuous_mode;
230 ops->stop_port = netxen_niu_disable_xg_port; 245 ops->stop_port = netxen_niu_disable_xg_port;
@@ -295,15 +310,6 @@ static inline int rom_lock(struct netxen_adapter *adapter)
295 return 0; 310 return 0;
296} 311}
297 312
298static inline void rom_unlock(struct netxen_adapter *adapter)
299{
300 u32 val;
301
302 /* release semaphore2 */
303 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK), &val);
304
305}
306
307int netxen_wait_rom_done(struct netxen_adapter *adapter) 313int netxen_wait_rom_done(struct netxen_adapter *adapter)
308{ 314{
309 long timeout = 0; 315 long timeout = 0;
@@ -321,6 +327,81 @@ int netxen_wait_rom_done(struct netxen_adapter *adapter)
321 return 0; 327 return 0;
322} 328}
323 329
330static inline int netxen_rom_wren(struct netxen_adapter *adapter)
331{
332 /* Set write enable latch in ROM status register */
333 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
334 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
335 M25P_INSTR_WREN);
336 if (netxen_wait_rom_done(adapter)) {
337 return -1;
338 }
339 return 0;
340}
341
342static inline unsigned int netxen_rdcrbreg(struct netxen_adapter *adapter,
343 unsigned int addr)
344{
345 unsigned int data = 0xdeaddead;
346 data = netxen_nic_reg_read(adapter, addr);
347 return data;
348}
349
350static inline int netxen_do_rom_rdsr(struct netxen_adapter *adapter)
351{
352 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
353 M25P_INSTR_RDSR);
354 if (netxen_wait_rom_done(adapter)) {
355 return -1;
356 }
357 return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA);
358}
359
360static inline void netxen_rom_unlock(struct netxen_adapter *adapter)
361{
362 u32 val;
363
364 /* release semaphore2 */
365 netxen_nic_read_w0(adapter, NETXEN_PCIE_REG(PCIE_SEM2_UNLOCK), &val);
366
367}
368
369int netxen_rom_wip_poll(struct netxen_adapter *adapter)
370{
371 long timeout = 0;
372 long wip = 1;
373 int val;
374 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
375 while (wip != 0) {
376 val = netxen_do_rom_rdsr(adapter);
377 wip = val & 1;
378 timeout++;
379 if (timeout > rom_max_timeout) {
380 return -1;
381 }
382 }
383 return 0;
384}
385
386static inline int do_rom_fast_write(struct netxen_adapter *adapter,
387 int addr, int data)
388{
389 if (netxen_rom_wren(adapter)) {
390 return -1;
391 }
392 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_WDATA, data);
393 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
394 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
395 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
396 M25P_INSTR_PP);
397 if (netxen_wait_rom_done(adapter)) {
398 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
399 return -1;
400 }
401
402 return netxen_rom_wip_poll(adapter);
403}
404
324static inline int 405static inline int
325do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) 406do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
326{ 407{
@@ -350,7 +431,43 @@ int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp)
350 return -EIO; 431 return -EIO;
351 432
352 ret = do_rom_fast_read(adapter, addr, valp); 433 ret = do_rom_fast_read(adapter, addr, valp);
353 rom_unlock(adapter); 434 netxen_rom_unlock(adapter);
435 return ret;
436}
437
438int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data)
439{
440 int ret = 0;
441
442 if (rom_lock(adapter) != 0) {
443 return -1;
444 }
445 ret = do_rom_fast_write(adapter, addr, data);
446 netxen_rom_unlock(adapter);
447 return ret;
448}
449int netxen_do_rom_se(struct netxen_adapter *adapter, int addr)
450{
451 netxen_rom_wren(adapter);
452 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
453 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
454 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE,
455 M25P_INSTR_SE);
456 if (netxen_wait_rom_done(adapter)) {
457 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
458 return -1;
459 }
460 return netxen_rom_wip_poll(adapter);
461}
462
463int netxen_rom_se(struct netxen_adapter *adapter, int addr)
464{
465 int ret = 0;
466 if (rom_lock(adapter) != 0) {
467 return -1;
468 }
469 ret = netxen_do_rom_se(adapter, addr);
470 netxen_rom_unlock(adapter);
354 return ret; 471 return ret;
355} 472}
356 473
@@ -372,7 +489,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
372 /* resetall */ 489 /* resetall */
373 status = netxen_nic_get_board_info(adapter); 490 status = netxen_nic_get_board_info(adapter);
374 if (status) 491 if (status)
375 printk("%s: pinit_from_rom: Error getting board info\n", 492 printk("%s: netxen_pinit_from_rom: Error getting board info\n",
376 netxen_nic_driver_name); 493 netxen_nic_driver_name);
377 494
378 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 495 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
@@ -408,8 +525,8 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
408 } 525 }
409 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL); 526 buf = kcalloc(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
410 if (buf == NULL) { 527 if (buf == NULL) {
411 printk("%s: pinit_from_rom: Unable to calloc memory.\n", 528 printk("%s: netxen_pinit_from_rom: Unable to calloc "
412 netxen_nic_driver_name); 529 "memory.\n", netxen_nic_driver_name);
413 return -ENOMEM; 530 return -ENOMEM;
414 } 531 }
415 for (i = 0; i < n; i++) { 532 for (i = 0; i < n; i++) {
@@ -441,7 +558,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
441 if (off == NETXEN_ROMUSB_GLB_SW_RESET) { 558 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
442 init_delay = 1; 559 init_delay = 1;
443 /* hold xdma in reset also */ 560 /* hold xdma in reset also */
444 buf[i].data = 0x8000ff; 561 buf[i].data = NETXEN_NIC_XDMA_RESET;
445 } 562 }
446 563
447 if (ADDR_IN_WINDOW1(off)) { 564 if (ADDR_IN_WINDOW1(off)) {
@@ -450,7 +567,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
450 } else { 567 } else {
451 netxen_nic_pci_change_crbwindow(adapter, 0); 568 netxen_nic_pci_change_crbwindow(adapter, 0);
452 writel(buf[i].data, 569 writel(buf[i].data,
453 adapter->ahw.pci_base + off); 570 pci_base_offset(adapter, off));
454 571
455 netxen_nic_pci_change_crbwindow(adapter, 1); 572 netxen_nic_pci_change_crbwindow(adapter, 1);
456 } 573 }
@@ -505,18 +622,15 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
505 return 0; 622 return 0;
506} 623}
507 624
508void netxen_phantom_init(struct netxen_adapter *adapter) 625void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
509{ 626{
510 u32 val = 0; 627 u32 val = 0;
511 int loops = 0; 628 int loops = 0;
512 629
513 netxen_nic_hw_read_wx(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE, &val, 4); 630 if (!pegtune_val) {
514 writel(1,
515 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
516
517 if (0 == val) {
518 while (val != PHAN_INITIALIZE_COMPLETE && loops < 200000) { 631 while (val != PHAN_INITIALIZE_COMPLETE && loops < 200000) {
519 udelay(100); 632 udelay(100);
633 schedule();
520 val = 634 val =
521 readl(NETXEN_CRB_NORMALIZE 635 readl(NETXEN_CRB_NORMALIZE
522 (adapter, CRB_CMDPEG_STATE)); 636 (adapter, CRB_CMDPEG_STATE));
@@ -536,7 +650,7 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
536 &(adapter->recv_ctx[ctx]); 650 &(adapter->recv_ctx[ctx]);
537 u32 consumer; 651 u32 consumer;
538 struct status_desc *desc_head; 652 struct status_desc *desc_head;
539 struct status_desc *desc; /* used to read status desc here */ 653 struct status_desc *desc;
540 654
541 consumer = recv_ctx->status_rx_consumer; 655 consumer = recv_ctx->status_rx_consumer;
542 desc_head = recv_ctx->rcv_status_desc_head; 656 desc_head = recv_ctx->rcv_status_desc_head;
@@ -549,6 +663,53 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
549 return 0; 663 return 0;
550} 664}
551 665
666static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
667{
668 int port_num;
669 struct netxen_port *port;
670 struct net_device *netdev;
671 uint32_t temp, temp_state, temp_val;
672 int rv = 0;
673
674 temp = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_TEMP_STATE));
675
676 temp_state = nx_get_temp_state(temp);
677 temp_val = nx_get_temp_val(temp);
678
679 if (temp_state == NX_TEMP_PANIC) {
680 printk(KERN_ALERT
681 "%s: Device temperature %d degrees C exceeds"
682 " maximum allowed. Hardware has been shut down.\n",
683 netxen_nic_driver_name, temp_val);
684 for (port_num = 0; port_num < adapter->ahw.max_ports;
685 port_num++) {
686 port = adapter->port[port_num];
687 netdev = port->netdev;
688
689 netif_carrier_off(netdev);
690 netif_stop_queue(netdev);
691 }
692 rv = 1;
693 } else if (temp_state == NX_TEMP_WARN) {
694 if (adapter->temp == NX_TEMP_NORMAL) {
695 printk(KERN_ALERT
696 "%s: Device temperature %d degrees C "
697 "exceeds operating range."
698 " Immediate action needed.\n",
699 netxen_nic_driver_name, temp_val);
700 }
701 } else {
702 if (adapter->temp == NX_TEMP_WARN) {
703 printk(KERN_INFO
704 "%s: Device temperature is now %d degrees C"
705 " in normal range.\n", netxen_nic_driver_name,
706 temp_val);
707 }
708 }
709 adapter->temp = temp_state;
710 return rv;
711}
712
552void netxen_watchdog_task(unsigned long v) 713void netxen_watchdog_task(unsigned long v)
553{ 714{
554 int port_num; 715 int port_num;
@@ -556,6 +717,9 @@ void netxen_watchdog_task(unsigned long v)
556 struct net_device *netdev; 717 struct net_device *netdev;
557 struct netxen_adapter *adapter = (struct netxen_adapter *)v; 718 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
558 719
720 if (netxen_nic_check_temp(adapter))
721 return;
722
559 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { 723 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) {
560 port = adapter->port[port_num]; 724 port = adapter->port[port_num];
561 netdev = port->netdev; 725 netdev = port->netdev;
@@ -570,8 +734,6 @@ void netxen_watchdog_task(unsigned long v)
570 netif_wake_queue(netdev); 734 netif_wake_queue(netdev);
571 } 735 }
572 736
573 netxen_nic_pci_change_crbwindow(adapter, 1);
574
575 if (adapter->ops->handle_phy_intr) 737 if (adapter->ops->handle_phy_intr)
576 adapter->ops->handle_phy_intr(adapter); 738 adapter->ops->handle_phy_intr(adapter);
577 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 739 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
@@ -742,7 +904,6 @@ void netxen_process_cmd_ring(unsigned long data)
742 * number as part of the descriptor. This way we will be able to get 904 * number as part of the descriptor. This way we will be able to get
743 * the netdev which is associated with that device. 905 * the netdev which is associated with that device.
744 */ 906 */
745 /* Window = 1 */
746 consumer = 907 consumer =
747 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); 908 readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
748 909
@@ -861,7 +1022,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
861 * We need to schedule the posting of buffers to the pegs. 1022 * We need to schedule the posting of buffers to the pegs.
862 */ 1023 */
863 rcv_desc->begin_alloc = index; 1024 rcv_desc->begin_alloc = index;
864 DPRINTK(ERR, "unm_post_rx_buffers: " 1025 DPRINTK(ERR, "netxen_post_rx_buffers: "
865 " allocated only %d buffers\n", count); 1026 " allocated only %d buffers\n", count);
866 break; 1027 break;
867 } 1028 }
diff --git a/drivers/net/netxen/netxen_nic_ioctl.h b/drivers/net/netxen/netxen_nic_ioctl.h
index 806818eb9630..23e53adbf123 100644
--- a/drivers/net/netxen/netxen_nic_ioctl.h
+++ b/drivers/net/netxen/netxen_nic_ioctl.h
@@ -6,12 +6,12 @@
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -32,9 +32,11 @@
32 32
33#include <linux/sockios.h> 33#include <linux/sockios.h>
34 34
35#define NETXEN_CMD_START SIOCDEVPRIVATE 35#define NETXEN_CMD_START SIOCDEVPRIVATE
36#define NETXEN_NIC_CMD (NETXEN_CMD_START + 1) 36#define NETXEN_NIC_CMD (NETXEN_CMD_START + 1)
37#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2) 37#define NETXEN_NIC_NAME (NETXEN_CMD_START + 2)
38#define NETXEN_NIC_NAME_LEN 16
39#define NETXEN_NIC_NAME_RSP "NETXEN"
38 40
39typedef enum { 41typedef enum {
40 netxen_nic_cmd_none = 0, 42 netxen_nic_cmd_none = 0,
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c
index f1c3e5af03a9..ae180fee8008 100644
--- a/drivers/net/netxen/netxen_nic_isr.c
+++ b/drivers/net/netxen/netxen_nic_isr.c
@@ -149,47 +149,41 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
149 149
150void netxen_nic_isr_other(struct netxen_adapter *adapter) 150void netxen_nic_isr_other(struct netxen_adapter *adapter)
151{ 151{
152 u32 enable, portno; 152 u32 portno;
153 u32 i2qhi; 153 u32 val, linkup, qg_linksup;
154
155 /*
156 * bit 3 is for i2qInt, if high its enabled
157 * check for phy interrupts
158 * read vector and check for bit 45 for phy
159 * clear int by writing the same value into ISR_INT_VECTOR REG
160 */
161
162 DPRINTK(INFO, "I2Q is the source of INT \n");
163 154
164 /* verify the offset */ 155 /* verify the offset */
165 i2qhi = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_I2Q_CLR_PCI_HI)); 156 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
166 157 if (val == adapter->ahw.qg_linksup)
167 DPRINTK(INFO, "isr NETXEN_I2Q_CLR_PCI_HI = 0x%x \n", i2qhi); 158 return;
168 159
169 if (i2qhi & 0x4000) { 160 qg_linksup = adapter->ahw.qg_linksup;
170 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) { 161 adapter->ahw.qg_linksup = val;
171 DPRINTK(INFO, "External PHY interrupt ON PORT %d\n", 162 DPRINTK(1, INFO, "%s: link update 0x%08x\n", netxen_nic_driver_name,
172 portno); 163 val);
164 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
165 linkup = val & 1;
166 if (linkup != (qg_linksup & 1)) {
167 printk(KERN_INFO "%s: PORT %d link %s\n",
168 netxen_nic_driver_name, portno,
169 ((linkup == 0) ? "down" : "up"));
170 netxen_indicate_link_status(adapter, portno, linkup);
171 if (linkup)
172 netxen_nic_set_link_parameters(adapter->
173 port[portno]);
173 174
174 enable = 1;
175 netxen_handle_port_int(adapter, portno, enable);
176 } 175 }
176 val = val >> 1;
177 qg_linksup = qg_linksup >> 1;
178 }
177 179
178 /* Clear the interrupt on I2Q */ 180 adapter->stats.otherints++;
179 writel((u32) i2qhi,
180 NETXEN_CRB_NORMALIZE(adapter, NETXEN_I2Q_CLR_PCI_HI));
181 181
182 }
183} 182}
184 183
185void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter) 184void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter)
186{ 185{
187 u32 val; 186 netxen_nic_isr_other(adapter);
188 val = readl(NETXEN_CRB_NORMALIZE(adapter, ISR_INT_VECTOR));
189 if (val & 0x4) {
190 adapter->stats.otherints++;
191 netxen_nic_isr_other(adapter);
192 }
193} 187}
194 188
195void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter) 189void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index ffd272c93a6b..cd1336e899b1 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -31,6 +31,7 @@
31 * 31 *
32 */ 32 */
33 33
34#include <linux/vmalloc.h>
34#include "netxen_nic_hw.h" 35#include "netxen_nic_hw.h"
35 36
36#include "netxen_nic.h" 37#include "netxen_nic.h"
@@ -41,16 +42,19 @@
41#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
42#include <linux/vmalloc.h> 43#include <linux/vmalloc.h>
43 44
45#define PHAN_VENDOR_ID 0x4040
46
44MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); 47MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver");
45MODULE_LICENSE("GPL"); 48MODULE_LICENSE("GPL");
46MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); 49MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID);
47 50
48char netxen_nic_driver_name[] = "netxen"; 51char netxen_nic_driver_name[] = "netxen";
49static char netxen_nic_driver_string[] = "NetXen Network Driver version " 52static char netxen_nic_driver_string[] = "NetXen Network Driver version "
50 NETXEN_NIC_LINUX_VERSIONID "-" NETXEN_NIC_BUILD_NO; 53 NETXEN_NIC_LINUX_VERSIONID;
51 54
52#define NETXEN_NETDEV_WEIGHT 120 55#define NETXEN_NETDEV_WEIGHT 120
53#define NETXEN_ADAPTER_UP_MAGIC 777 56#define NETXEN_ADAPTER_UP_MAGIC 777
57#define NETXEN_NIC_PEG_TUNE 0
54 58
55/* Local functions to NetXen NIC driver */ 59/* Local functions to NetXen NIC driver */
56static int __devinit netxen_nic_probe(struct pci_dev *pdev, 60static int __devinit netxen_nic_probe(struct pci_dev *pdev,
@@ -101,7 +105,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
101 struct net_device *netdev = NULL; 105 struct net_device *netdev = NULL;
102 struct netxen_adapter *adapter = NULL; 106 struct netxen_adapter *adapter = NULL;
103 struct netxen_port *port = NULL; 107 struct netxen_port *port = NULL;
104 u8 __iomem *mem_ptr = NULL; 108 u8 *mem_ptr0 = NULL;
109 u8 *mem_ptr1 = NULL;
110 u8 *mem_ptr2 = NULL;
111
105 unsigned long mem_base, mem_len; 112 unsigned long mem_base, mem_len;
106 int pci_using_dac, i, err; 113 int pci_using_dac, i, err;
107 int ring; 114 int ring;
@@ -111,6 +118,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
111 u64 mac_addr[FLASH_NUM_PORTS + 1]; 118 u64 mac_addr[FLASH_NUM_PORTS + 1];
112 int valid_mac; 119 int valid_mac;
113 120
121 printk(KERN_INFO "%s \n", netxen_nic_driver_string);
114 if ((err = pci_enable_device(pdev))) 122 if ((err = pci_enable_device(pdev)))
115 return err; 123 return err;
116 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 124 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
@@ -138,11 +146,26 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
138 mem_len = pci_resource_len(pdev, 0); 146 mem_len = pci_resource_len(pdev, 0);
139 147
140 /* 128 Meg of memory */ 148 /* 128 Meg of memory */
141 mem_ptr = ioremap(mem_base, NETXEN_PCI_MAPSIZE_BYTES); 149 mem_ptr0 = ioremap(mem_base, FIRST_PAGE_GROUP_SIZE);
142 if (mem_ptr == 0UL) { 150 mem_ptr1 =
143 printk(KERN_ERR "%s: Cannot ioremap adapter memory aborting." 151 ioremap(mem_base + SECOND_PAGE_GROUP_START, SECOND_PAGE_GROUP_SIZE);
144 ":%p\n", netxen_nic_driver_name, mem_ptr); 152 mem_ptr2 =
153 ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE);
154
155 if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) {
156 DPRINTK(1, ERR,
157 "Cannot remap adapter memory aborting.:"
158 "0 -> %p, 1 -> %p, 2 -> %p\n",
159 mem_ptr0, mem_ptr1, mem_ptr2);
160
145 err = -EIO; 161 err = -EIO;
162 if (mem_ptr0)
163 iounmap(mem_ptr0);
164 if (mem_ptr1)
165 iounmap(mem_ptr1);
166 if (mem_ptr2)
167 iounmap(mem_ptr2);
168
146 goto err_out_free_res; 169 goto err_out_free_res;
147 } 170 }
148 171
@@ -221,9 +244,17 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
221 } 244 }
222 245
223 adapter->cmd_buf_arr = cmd_buf_arr; 246 adapter->cmd_buf_arr = cmd_buf_arr;
224 adapter->ahw.pci_base = mem_ptr; 247 adapter->ahw.pci_base0 = mem_ptr0;
248 adapter->ahw.pci_base1 = mem_ptr1;
249 adapter->ahw.pci_base2 = mem_ptr2;
225 spin_lock_init(&adapter->tx_lock); 250 spin_lock_init(&adapter->tx_lock);
226 spin_lock_init(&adapter->lock); 251 spin_lock_init(&adapter->lock);
252#ifdef CONFIG_IA64
253 netxen_pinit_from_rom(adapter, 0);
254 udelay(500);
255 netxen_load_firmware(adapter);
256#endif
257
227 /* initialize the buffers in adapter */ 258 /* initialize the buffers in adapter */
228 netxen_initialize_adapter_sw(adapter); 259 netxen_initialize_adapter_sw(adapter);
229 /* 260 /*
@@ -262,6 +293,20 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
262 else 293 else
263 valid_mac = 0; 294 valid_mac = 0;
264 295
296 /*
297 * Initialize all the CRB registers here.
298 */
299 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
300 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
301 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
302
303 /* Unlock the HW, prompting the boot sequence */
304 writel(1,
305 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
306
307 /* Handshake with the card before we register the devices. */
308 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
309
265 /* initialize the all the ports */ 310 /* initialize the all the ports */
266 311
267 for (i = 0; i < adapter->ahw.max_ports; i++) { 312 for (i = 0; i < adapter->ahw.max_ports; i++) {
@@ -352,15 +397,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
352 } 397 }
353 398
354 /* 399 /*
355 * Initialize all the CRB registers here.
356 */
357 /* Window = 1 */
358 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
359 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET));
360 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
361
362 netxen_phantom_init(adapter);
363 /*
364 * delay a while to ensure that the Pegs are up & running. 400 * delay a while to ensure that the Pegs are up & running.
365 * Otherwise, we might see some flaky behaviour. 401 * Otherwise, we might see some flaky behaviour.
366 */ 402 */
@@ -414,7 +450,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
414 kfree(adapter); 450 kfree(adapter);
415 451
416 err_out_iounmap: 452 err_out_iounmap:
417 iounmap(mem_ptr); 453 iounmap(mem_ptr0);
454 iounmap(mem_ptr1);
455 iounmap(mem_ptr2);
456
418 err_out_free_res: 457 err_out_free_res:
419 pci_release_regions(pdev); 458 pci_release_regions(pdev);
420 err_out_disable_pdev: 459 err_out_disable_pdev:
@@ -460,7 +499,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
460 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) 499 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
461 netxen_free_hw_resources(adapter); 500 netxen_free_hw_resources(adapter);
462 501
463 iounmap(adapter->ahw.pci_base); 502 iounmap(adapter->ahw.pci_base0);
503 iounmap(adapter->ahw.pci_base1);
504 iounmap(adapter->ahw.pci_base2);
464 505
465 pci_release_regions(pdev); 506 pci_release_regions(pdev);
466 pci_disable_device(pdev); 507 pci_disable_device(pdev);
@@ -496,7 +537,6 @@ static int netxen_nic_open(struct net_device *netdev)
496{ 537{
497 struct netxen_port *port = netdev_priv(netdev); 538 struct netxen_port *port = netdev_priv(netdev);
498 struct netxen_adapter *adapter = port->adapter; 539 struct netxen_adapter *adapter = port->adapter;
499 struct netxen_rcv_desc_ctx *rcv_desc;
500 int err = 0; 540 int err = 0;
501 int ctx, ring; 541 int ctx, ring;
502 542
@@ -527,11 +567,8 @@ static int netxen_nic_open(struct net_device *netdev)
527 if (adapter->ops->init_niu) 567 if (adapter->ops->init_niu)
528 adapter->ops->init_niu(adapter); 568 adapter->ops->init_niu(adapter);
529 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 569 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
530 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 570 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
531 rcv_desc =
532 &adapter->recv_ctx[ctx].rcv_desc[ring];
533 netxen_post_rx_buffers(adapter, ctx, ring); 571 netxen_post_rx_buffers(adapter, ctx, ring);
534 }
535 } 572 }
536 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; 573 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
537 } 574 }
@@ -579,10 +616,6 @@ static int netxen_nic_close(struct net_device *netdev)
579 netif_carrier_off(netdev); 616 netif_carrier_off(netdev);
580 netif_stop_queue(netdev); 617 netif_stop_queue(netdev);
581 618
582 /* disable phy_ints */
583 if (adapter->ops->disable_phy_interrupts)
584 adapter->ops->disable_phy_interrupts(adapter, port->portnum);
585
586 adapter->active_ports--; 619 adapter->active_ports--;
587 620
588 if (!adapter->active_ports) { 621 if (!adapter->active_ports) {
@@ -690,13 +723,16 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
690 local_producer = adapter->cmd_producer; 723 local_producer = adapter->cmd_producer;
691 /* There 4 fragments per descriptor */ 724 /* There 4 fragments per descriptor */
692 no_of_desc = (frag_count + 3) >> 2; 725 no_of_desc = (frag_count + 3) >> 2;
693 if (skb_shinfo(skb)->gso_size > 0) { 726 if (netdev->features & NETIF_F_TSO) {
694 no_of_desc++; 727 if (skb_shinfo(skb)->gso_size > 0) {
695 if (((skb->nh.iph)->ihl * sizeof(u32)) + 728
696 ((skb->h.th)->doff * sizeof(u32)) +
697 sizeof(struct ethhdr) >
698 (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
699 no_of_desc++; 729 no_of_desc++;
730 if (((skb->nh.iph)->ihl * sizeof(u32)) +
731 ((skb->h.th)->doff * sizeof(u32)) +
732 sizeof(struct ethhdr) >
733 (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) {
734 no_of_desc++;
735 }
700 } 736 }
701 } 737 }
702 k = adapter->cmd_producer; 738 k = adapter->cmd_producer;
@@ -740,7 +776,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
740 memset(hwdesc, 0, sizeof(struct cmd_desc_type0)); 776 memset(hwdesc, 0, sizeof(struct cmd_desc_type0));
741 /* Take skb->data itself */ 777 /* Take skb->data itself */
742 pbuf = &adapter->cmd_buf_arr[producer]; 778 pbuf = &adapter->cmd_buf_arr[producer];
743 if (skb_shinfo(skb)->gso_size > 0) { 779 if ((netdev->features & NETIF_F_TSO) && skb_shinfo(skb)->gso_size > 0) {
744 pbuf->mss = skb_shinfo(skb)->gso_size; 780 pbuf->mss = skb_shinfo(skb)->gso_size;
745 hwdesc->mss = skb_shinfo(skb)->gso_size; 781 hwdesc->mss = skb_shinfo(skb)->gso_size;
746 } else { 782 } else {
@@ -934,9 +970,10 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
934 /* Window = 0 or 1 */ 970 /* Window = 0 or 1 */
935 do { 971 do {
936 writel(0xffffffff, (void __iomem *) 972 writel(0xffffffff, (void __iomem *)
937 (adapter->ahw.pci_base + ISR_INT_TARGET_STATUS)); 973 (PCI_OFFSET_SECOND_RANGE
974 (adapter, ISR_INT_TARGET_STATUS)));
938 mask = readl((void __iomem *) 975 mask = readl((void __iomem *)
939 (adapter->ahw.pci_base + ISR_INT_VECTOR)); 976 pci_base_offset(adapter, ISR_INT_VECTOR));
940 } while (((mask & 0x80) != 0) && (++count < 32)); 977 } while (((mask & 0x80) != 0) && (++count < 32));
941 if ((mask & 0x80) != 0) 978 if ((mask & 0x80) != 0)
942 printk("Could not disable interrupt completely\n"); 979 printk("Could not disable interrupt completely\n");
@@ -1065,8 +1102,10 @@ static int
1065netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 1102netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1066{ 1103{
1067 int err = 0; 1104 int err = 0;
1105 unsigned long nr_bytes = 0;
1068 struct netxen_port *port = netdev_priv(netdev); 1106 struct netxen_port *port = netdev_priv(netdev);
1069 struct netxen_adapter *adapter = port->adapter; 1107 struct netxen_adapter *adapter = port->adapter;
1108 char dev_name[NETXEN_NIC_NAME_LEN];
1070 1109
1071 DPRINTK(INFO, "doing ioctl for %s\n", netdev->name); 1110 DPRINTK(INFO, "doing ioctl for %s\n", netdev->name);
1072 switch (cmd) { 1111 switch (cmd) {
@@ -1077,7 +1116,13 @@ netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1077 case NETXEN_NIC_NAME: 1116 case NETXEN_NIC_NAME:
1078 DPRINTK(INFO, "ioctl cmd for NetXen\n"); 1117 DPRINTK(INFO, "ioctl cmd for NetXen\n");
1079 if (ifr->ifr_data) { 1118 if (ifr->ifr_data) {
1080 put_user(port->portnum, (u16 __user *) ifr->ifr_data); 1119 sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP,
1120 port->portnum);
1121 nr_bytes = copy_to_user((char *)ifr->ifr_data, dev_name,
1122 NETXEN_NIC_NAME_LEN);
1123 if (nr_bytes)
1124 err = -EIO;
1125
1081 } 1126 }
1082 break; 1127 break;
1083 1128
@@ -1101,8 +1146,6 @@ static struct pci_driver netxen_driver = {
1101 1146
1102static int __init netxen_init_module(void) 1147static int __init netxen_init_module(void)
1103{ 1148{
1104 printk(KERN_INFO "%s \n", netxen_nic_driver_string);
1105
1106 return pci_module_init(&netxen_driver); 1149 return pci_module_init(&netxen_driver);
1107} 1150}
1108 1151
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index 6e421c876fe5..7950a04532e6 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -6,12 +6,12 @@
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -32,19 +32,56 @@
32 */ 32 */
33 33
34#include "netxen_nic.h" 34#include "netxen_nic.h"
35#include <linux/delay.h> 35
36#define NETXEN_GB_MAC_SOFT_RESET 0x80000000
37#define NETXEN_GB_MAC_RESET_PROT_BLK 0x000F0000
38#define NETXEN_GB_MAC_ENABLE_TX_RX 0x00000005
39#define NETXEN_GB_MAC_PAUSED_FRMS 0x00000020
40
41static long phy_lock_timeout = 100000000;
42
43static inline int phy_lock(void)
44{
45 int i;
46 int done = 0, timeout = 0;
47
48 while (!done) {
49 done = readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_LOCK));
50 if (done == 1)
51 break;
52 if (timeout >= phy_lock_timeout) {
53 return -1;
54 }
55 timeout++;
56 if (!in_atomic())
57 schedule();
58 else {
59 for (i = 0; i < 20; i++)
60 cpu_relax();
61 }
62 }
63
64 writel(NETXEN_PHY_LOCK_ID, (void __iomem *)PHY_LOCK_DRIVER);
65 return 0;
66}
67
68static inline int phy_unlock(void)
69{
70 readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK));
71 return 0;
72}
36 73
37/* 74/*
38 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via 75 * netxen_niu_gbe_phy_read - read a register from the GbE PHY via
39 * mii management interface. 76 * mii management interface.
40 * 77 *
41 * Note: The MII management interface goes through port 0. 78 * Note: The MII management interface goes through port 0.
42 * Individual phys are addressed as follows: 79 * Individual phys are addressed as follows:
43 * @param phy [15:8] phy id 80 * @param phy [15:8] phy id
44 * @param reg [7:0] register number 81 * @param reg [7:0] register number
45 * 82 *
46 * @returns 0 on success 83 * @returns 0 on success
47 * -1 on error 84 * -1 on error
48 * 85 *
49 */ 86 */
50int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, 87int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
@@ -56,10 +93,17 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
56 __le32 address; 93 __le32 address;
57 __le32 command; 94 __le32 command;
58 __le32 status; 95 __le32 status;
59 __le32 mii_cfg;
60 __le32 mac_cfg0; 96 __le32 mac_cfg0;
61 97
62 /* MII mgmt all goes through port 0 MAC interface, so it cannot be in reset */ 98 if (phy_lock() != 0) {
99 return -1;
100 }
101
102 /*
103 * MII mgmt all goes through port 0 MAC interface,
104 * so it cannot be in reset
105 */
106
63 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), 107 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
64 &mac_cfg0, 4)) 108 &mac_cfg0, 4))
65 return -EIO; 109 return -EIO;
@@ -77,18 +121,6 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
77 restore = 1; 121 restore = 1;
78 } 122 }
79 123
80 /* reset MII management interface */
81 mii_cfg = 0;
82 netxen_gb_set_mii_mgmt_clockselect(mii_cfg, 7);
83 netxen_gb_mii_mgmt_reset(mii_cfg);
84 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
85 &mii_cfg, 4))
86 return -EIO;
87 netxen_gb_mii_mgmt_unset(mii_cfg);
88 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_MII_MGMT_CONFIG(0),
89 &mii_cfg, 4))
90 return -EIO;
91
92 address = 0; 124 address = 0;
93 netxen_gb_mii_mgmt_reg_addr(address, reg); 125 netxen_gb_mii_mgmt_reg_addr(address, reg);
94 netxen_gb_mii_mgmt_phy_addr(address, phy); 126 netxen_gb_mii_mgmt_phy_addr(address, phy);
@@ -130,7 +162,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
130 NETXEN_NIU_GB_MAC_CONFIG_0(0), 162 NETXEN_NIU_GB_MAC_CONFIG_0(0),
131 &mac_cfg0, 4)) 163 &mac_cfg0, 4))
132 return -EIO; 164 return -EIO;
133 165 phy_unlock();
134 return result; 166 return result;
135} 167}
136 168
@@ -139,12 +171,12 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy,
139 * mii management interface. 171 * mii management interface.
140 * 172 *
141 * Note: The MII management interface goes through port 0. 173 * Note: The MII management interface goes through port 0.
142 * Individual phys are addressed as follows: 174 * Individual phys are addressed as follows:
143 * @param phy [15:8] phy id 175 * @param phy [15:8] phy id
144 * @param reg [7:0] register number 176 * @param reg [7:0] register number
145 * 177 *
146 * @returns 0 on success 178 * @returns 0 on success
147 * -1 on error 179 * -1 on error
148 * 180 *
149 */ 181 */
150int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, 182int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
@@ -158,7 +190,11 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter,
158 __le32 status; 190 __le32 status;
159 __le32 mac_cfg0; 191 __le32 mac_cfg0;
160 192
161 /* MII mgmt all goes through port 0 MAC interface, so it cannot be in reset */ 193 /*
194 * MII mgmt all goes through port 0 MAC interface, so it
195 * cannot be in reset
196 */
197
162 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0), 198 if (netxen_nic_hw_read_wx(adapter, NETXEN_NIU_GB_MAC_CONFIG_0(0),
163 &mac_cfg0, 4)) 199 &mac_cfg0, 4))
164 return -EIO; 200 return -EIO;
@@ -382,14 +418,23 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
382 } 418 }
383 419
384 } else { 420 } else {
385 /* We don't have link. Cable must be unconnected. */ 421 /*
386 /* Enable phy interrupts so we take action when plugged in */ 422 * We don't have link. Cable must be unconnected.
423 * Enable phy interrupts so we take action when
424 * plugged in.
425 */
426
387 netxen_crb_writelit_adapter(adapter, 427 netxen_crb_writelit_adapter(adapter,
388 NETXEN_NIU_GB_MAC_CONFIG_0 428 NETXEN_NIU_GB_MAC_CONFIG_0
389 (port), 0x80000000); 429 (port),
430 NETXEN_GB_MAC_SOFT_RESET);
390 netxen_crb_writelit_adapter(adapter, 431 netxen_crb_writelit_adapter(adapter,
391 NETXEN_NIU_GB_MAC_CONFIG_0 432 NETXEN_NIU_GB_MAC_CONFIG_0
392 (port), 0x0000f0025); 433 (port),
434 NETXEN_GB_MAC_RESET_PROT_BLK
435 | NETXEN_GB_MAC_ENABLE_TX_RX
436 |
437 NETXEN_GB_MAC_PAUSED_FRMS);
393 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port)) 438 if (netxen_niu_gbe_clear_phy_interrupts(adapter, port))
394 printk(KERN_ERR PFX 439 printk(KERN_ERR PFX
395 "ERROR clearing PHY interrupts\n"); 440 "ERROR clearing PHY interrupts\n");
@@ -407,10 +452,34 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port)
407 return result; 452 return result;
408} 453}
409 454
455int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port)
456{
457 long reg = 0, ret = 0;
458
459 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) {
460 netxen_crb_writelit_adapter(adapter,
461 NETXEN_NIU_XG1_CONFIG_0, 0x5);
462 /* XXX hack for Mez cards: both ports in promisc mode */
463 netxen_nic_hw_read_wx(adapter,
464 NETXEN_NIU_XGE_CONFIG_1, &reg, 4);
465 reg = (reg | 0x2000UL);
466 netxen_crb_writelit_adapter(adapter,
467 NETXEN_NIU_XGE_CONFIG_1, reg);
468 reg = 0;
469 netxen_nic_hw_read_wx(adapter,
470 NETXEN_NIU_XG1_CONFIG_1, &reg, 4);
471 reg = (reg | 0x2000UL);
472 netxen_crb_writelit_adapter(adapter,
473 NETXEN_NIU_XG1_CONFIG_1, reg);
474 }
475
476 return ret;
477}
478
410/* 479/*
411 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts 480 * netxen_niu_gbe_handle_phy_interrupt - Handles GbE PHY interrupts
412 * @param enable 0 means don't enable the port 481 * @param enable 0 means don't enable the port
413 * 1 means enable (or re-enable) the port 482 * 1 means enable (or re-enable) the port
414 */ 483 */
415int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter, 484int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter,
416 int port, long enable) 485 int port, long enable)
@@ -421,7 +490,10 @@ int netxen_niu_gbe_handle_phy_interrupt(struct netxen_adapter *adapter,
421 printk(KERN_INFO PFX "NETXEN: Handling PHY interrupt on port %d" 490 printk(KERN_INFO PFX "NETXEN: Handling PHY interrupt on port %d"
422 " (device enable = %d)\n", (int)port, (int)enable); 491 " (device enable = %d)\n", (int)port, (int)enable);
423 492
424 /* The read of the PHY INT status will clear the pending interrupt status */ 493 /*
494 * The read of the PHY INT status will clear the pending
495 * interrupt status
496 */
425 if (netxen_niu_gbe_phy_read(adapter, port, 497 if (netxen_niu_gbe_phy_read(adapter, port,
426 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, 498 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
427 &int_src) != 0) 499 &int_src) != 0)
@@ -540,20 +612,42 @@ int netxen_niu_macaddr_set(struct netxen_port *port,
540 __le32 temp = 0; 612 __le32 temp = 0;
541 struct netxen_adapter *adapter = port->adapter; 613 struct netxen_adapter *adapter = port->adapter;
542 int phy = port->portnum; 614 int phy = port->portnum;
615 unsigned char mac_addr[MAX_ADDR_LEN];
616 int i;
617
618 for (i = 0; i < 10; i++) {
619 memcpy(&temp, addr, 2);
620 temp <<= 16;
621 if (netxen_nic_hw_write_wx
622 (adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy), &temp, 4))
623 return -EIO;
543 624
544 memcpy(&temp, addr, 2); 625 temp = 0;
545 temp <<= 16;
546 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_1(phy),
547 &temp, 4))
548 return -EIO;
549 626
550 temp = 0; 627 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32));
628 if (netxen_nic_hw_write_wx
629 (adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), &temp, 4))
630 return -2;
551 631
552 memcpy(&temp, ((u8 *) addr) + 2, sizeof(__le32)); 632 netxen_niu_macaddr_get(adapter, phy,
553 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_GB_STATION_ADDR_0(phy), 633 (netxen_ethernet_macaddr_t *) mac_addr);
554 &temp, 4)) 634 if (memcmp(mac_addr, addr, MAX_ADDR_LEN == 0))
555 return -2; 635 break;
636 }
556 637
638 if (i == 10) {
639 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
640 netxen_nic_driver_name, port->netdev->name);
641 printk(KERN_ERR "MAC address set: "
642 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
643 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
644
645 printk(KERN_ERR "MAC address get: "
646 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
647 mac_addr[0],
648 mac_addr[1],
649 mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);
650 }
557 return 0; 651 return 0;
558} 652}
559 653
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index 863645ed1cd3..8181d436783f 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -6,12 +6,12 @@
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2 7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version. 8 * of the License, or (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, but 10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of 11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -58,6 +58,9 @@
58#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08) 58#define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08)
59#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c) 59#define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c)
60 60
61#define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10)
62#define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14)
63
61/* address of command descriptors in the host memory */ 64/* address of command descriptors in the host memory */
62#define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x30) 65#define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x30)
63#define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x34) 66#define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x34)
@@ -82,10 +85,18 @@
82#define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x94) 85#define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x94)
83#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98) 86#define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98)
84#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c) 87#define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c)
88#define CRB_INT_THRESH NETXEN_NIC_REG(0xa4)
85 89
86/* Register for communicating XG link status */ 90/* Register for communicating XG link status */
87#define CRB_XG_STATE NETXEN_NIC_REG(0xa0) 91#define CRB_XG_STATE NETXEN_NIC_REG(0xa0)
88 92
93/* Register for communicating card temperature */
94/* Upper 16 bits are temperature value. Lower 16 bits are the state */
95#define CRB_TEMP_STATE NETXEN_NIC_REG(0xa8)
96#define nx_get_temp_val(x) ((x) >> 16)
97#define nx_get_temp_state(x) ((x) & 0xffff)
98#define nx_encode_temp(val, state) (((val) << 16) | (state))
99
89/* Debug registers for controlling NIC pkt gen agent */ 100/* Debug registers for controlling NIC pkt gen agent */
90#define CRB_AGENT_GO NETXEN_NIC_REG(0xb0) 101#define CRB_AGENT_GO NETXEN_NIC_REG(0xb0)
91#define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0xb4) 102#define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0xb4)
@@ -192,4 +203,13 @@ struct netxen_recv_crb recv_crb_registers[] = {
192extern struct netxen_recv_crb recv_crb_registers[]; 203extern struct netxen_recv_crb recv_crb_registers[];
193#endif /* DEFINE_GLOBAL_RECEIVE_CRB */ 204#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
194 205
206/*
207 * Temperature control.
208 */
209enum {
210 NX_TEMP_NORMAL = 0x1, /* Normal operating range */
211 NX_TEMP_WARN, /* Sound alert, temperature getting high */
212 NX_TEMP_PANIC /* Fatal error, hardware has shut down. */
213};
214
195#endif /* __NIC_PHAN_REG_H_ */ 215#endif /* __NIC_PHAN_REG_H_ */