aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/net/netxen/netxen_nic.h125
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c83
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h8
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c221
-rw-r--r--drivers/net/netxen/netxen_nic_hw.h18
-rw-r--r--drivers/net/netxen/netxen_nic_init.c117
-rw-r--r--drivers/net/netxen/netxen_nic_isr.c87
-rw-r--r--drivers/net/netxen/netxen_nic_main.c526
-rw-r--r--drivers/net/netxen/netxen_nic_niu.c27
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h125
10 files changed, 646 insertions, 691 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index dd8ce35332f..b996cb38ecb 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -230,7 +230,9 @@ enum {
230 (((index) + (count)) & ((length) - 1)) 230 (((index) + (count)) & ((length) - 1))
231 231
232#define MPORT_SINGLE_FUNCTION_MODE 0x1111 232#define MPORT_SINGLE_FUNCTION_MODE 0x1111
233#define MPORT_MULTI_FUNCTION_MODE 0x2222
233 234
235#include "netxen_nic_phan_reg.h"
234extern unsigned long long netxen_dma_mask; 236extern unsigned long long netxen_dma_mask;
235extern unsigned long last_schedule_time; 237extern unsigned long last_schedule_time;
236 238
@@ -703,10 +705,8 @@ extern char netxen_nic_driver_name[];
703#else 705#else
704#define DPRINTK(klevel, fmt, args...) do { \ 706#define DPRINTK(klevel, fmt, args...) do { \
705 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ 707 printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\
706 (adapter != NULL && \ 708 (adapter != NULL && adapter->netdev != NULL) ? \
707 adapter->port[0] != NULL && \ 709 adapter->netdev->name : NULL, \
708 adapter->port[0]->netdev != NULL) ? \
709 adapter->port[0]->netdev->name : NULL, \
710 ## args); } while(0) 710 ## args); } while(0)
711#endif 711#endif
712 712
@@ -788,17 +788,27 @@ struct netxen_hardware_context {
788#define ETHERNET_FCS_SIZE 4 788#define ETHERNET_FCS_SIZE 4
789 789
790struct netxen_adapter_stats { 790struct netxen_adapter_stats {
791 u64 ints; 791 u64 rcvdbadskb;
792 u64 hostints; 792 u64 xmitcalled;
793 u64 otherints; 793 u64 xmitedframes;
794 u64 process_rcv; 794 u64 xmitfinished;
795 u64 process_xmit; 795 u64 badskblen;
796 u64 noxmitdone; 796 u64 nocmddescriptor;
797 u64 xmitcsummed; 797 u64 polled;
798 u64 post_called; 798 u64 uphappy;
799 u64 posted; 799 u64 updropped;
800 u64 lastposted; 800 u64 uplcong;
801 u64 goodskbposts; 801 u64 uphcong;
802 u64 upmcong;
803 u64 updunno;
804 u64 skbfreed;
805 u64 txdropped;
806 u64 txnullskb;
807 u64 csummed;
808 u64 no_rcv;
809 u64 rxbytes;
810 u64 txbytes;
811 u64 ints;
802}; 812};
803 813
804/* 814/*
@@ -846,13 +856,19 @@ struct netxen_dummy_dma {
846 856
847struct netxen_adapter { 857struct netxen_adapter {
848 struct netxen_hardware_context ahw; 858 struct netxen_hardware_context ahw;
849 int port_count; /* Number of configured ports */ 859
850 int active_ports; /* Number of open ports */ 860 struct netxen_adapter *master;
851 struct netxen_port *port[NETXEN_MAX_PORTS]; /* ptr to each port */ 861 struct net_device *netdev;
862 struct pci_dev *pdev;
863 unsigned char mac_addr[ETH_ALEN];
864 int mtu;
865 int portnum;
866
852 spinlock_t tx_lock; 867 spinlock_t tx_lock;
853 spinlock_t lock; 868 spinlock_t lock;
854 struct work_struct watchdog_task; 869 struct work_struct watchdog_task;
855 struct timer_list watchdog_timer; 870 struct timer_list watchdog_timer;
871 struct work_struct tx_timeout_task;
856 872
857 u32 curr_window; 873 u32 curr_window;
858 874
@@ -875,6 +891,15 @@ struct netxen_adapter {
875 u32 temp; 891 u32 temp;
876 892
877 struct netxen_adapter_stats stats; 893 struct netxen_adapter_stats stats;
894
895 u16 portno;
896 u16 link_speed;
897 u16 link_duplex;
898 u16 state;
899 u16 link_autoneg;
900 int rcsum;
901 int status;
902 spinlock_t stats_lock;
878 903
879 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */ 904 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */
880 905
@@ -894,62 +919,20 @@ struct netxen_adapter {
894 int (*enable_phy_interrupts) (struct netxen_adapter *, int); 919 int (*enable_phy_interrupts) (struct netxen_adapter *, int);
895 int (*disable_phy_interrupts) (struct netxen_adapter *, int); 920 int (*disable_phy_interrupts) (struct netxen_adapter *, int);
896 void (*handle_phy_intr) (struct netxen_adapter *); 921 void (*handle_phy_intr) (struct netxen_adapter *);
897 int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t); 922 int (*macaddr_set) (struct netxen_adapter *, netxen_ethernet_macaddr_t);
898 int (*set_mtu) (struct netxen_port *, int); 923 int (*set_mtu) (struct netxen_adapter *, int);
899 int (*set_promisc) (struct netxen_adapter *, int, 924 int (*set_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t);
900 netxen_niu_prom_mode_t); 925 int (*unset_promisc) (struct netxen_adapter *, netxen_niu_prom_mode_t);
901 int (*unset_promisc) (struct netxen_adapter *, int,
902 netxen_niu_prom_mode_t);
903 int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *); 926 int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *);
904 int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val); 927 int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val);
905 int (*init_port) (struct netxen_adapter *, int); 928 int (*init_port) (struct netxen_adapter *, int);
906 void (*init_niu) (struct netxen_adapter *); 929 void (*init_niu) (struct netxen_adapter *);
907 int (*stop_port) (struct netxen_adapter *, int); 930 int (*stop_port) (struct netxen_adapter *);
908}; /* netxen_adapter structure */ 931}; /* netxen_adapter structure */
909 932
910/* Max number of xmit producer threads that can run simultaneously */ 933/* Max number of xmit producer threads that can run simultaneously */
911#define MAX_XMIT_PRODUCERS 16 934#define MAX_XMIT_PRODUCERS 16
912 935
913struct netxen_port_stats {
914 u64 rcvdbadskb;
915 u64 xmitcalled;
916 u64 xmitedframes;
917 u64 xmitfinished;
918 u64 badskblen;
919 u64 nocmddescriptor;
920 u64 polled;
921 u64 uphappy;
922 u64 updropped;
923 u64 uplcong;
924 u64 uphcong;
925 u64 upmcong;
926 u64 updunno;
927 u64 skbfreed;
928 u64 txdropped;
929 u64 txnullskb;
930 u64 csummed;
931 u64 no_rcv;
932 u64 rxbytes;
933 u64 txbytes;
934};
935
936struct netxen_port {
937 struct netxen_adapter *adapter;
938
939 u16 portnum; /* GBE port number */
940 u16 link_speed;
941 u16 link_duplex;
942 u16 link_autoneg;
943
944 int flags;
945
946 struct net_device *netdev;
947 struct pci_dev *pdev;
948 struct net_device_stats net_stats;
949 struct netxen_port_stats stats;
950 struct work_struct tx_timeout_task;
951};
952
953#define PCI_OFFSET_FIRST_RANGE(adapter, off) \ 936#define PCI_OFFSET_FIRST_RANGE(adapter, off) \
954 ((adapter)->ahw.pci_base0 + (off)) 937 ((adapter)->ahw.pci_base0 + (off))
955#define PCI_OFFSET_SECOND_RANGE(adapter, off) \ 938#define PCI_OFFSET_SECOND_RANGE(adapter, off) \
@@ -1011,8 +994,8 @@ int netxen_niu_gbe_phy_write(struct netxen_adapter *adapter, long phy,
1011 long reg, __u32 val); 994 long reg, __u32 val);
1012 995
1013/* Functions available from netxen_nic_hw.c */ 996/* Functions available from netxen_nic_hw.c */
1014int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu); 997int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu);
1015int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu); 998int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu);
1016void netxen_nic_init_niu_gb(struct netxen_adapter *adapter); 999void netxen_nic_init_niu_gb(struct netxen_adapter *adapter);
1017void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw); 1000void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw);
1018void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val); 1001void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val);
@@ -1051,11 +1034,8 @@ int netxen_do_rom_se(struct netxen_adapter *adapter, int addr);
1051 1034
1052/* Functions from netxen_nic_isr.c */ 1035/* Functions from netxen_nic_isr.c */
1053void netxen_nic_isr_other(struct netxen_adapter *adapter); 1036void netxen_nic_isr_other(struct netxen_adapter *adapter);
1054void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 port, 1037void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 link);
1055 u32 link); 1038void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable);
1056void netxen_handle_port_int(struct netxen_adapter *adapter, u32 port,
1057 u32 enable);
1058void netxen_nic_stop_all_ports(struct netxen_adapter *adapter);
1059void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); 1039void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
1060void netxen_initialize_adapter_hw(struct netxen_adapter *adapter); 1040void netxen_initialize_adapter_hw(struct netxen_adapter *adapter);
1061void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr, 1041void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
@@ -1110,6 +1090,7 @@ static inline void netxen_nic_enable_int(struct netxen_adapter *adapter)
1110 1090
1111 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 1091 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
1112 mask = 0xbff; 1092 mask = 0xbff;
1093 writel(0X0, NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1113 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter, 1094 writel(mask, PCI_OFFSET_SECOND_RANGE(adapter,
1114 ISR_INT_TARGET_MASK)); 1095 ISR_INT_TARGET_MASK));
1115 } 1096 }
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index ee1b5a24cbe..c400f264ea4 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -50,8 +50,8 @@ struct netxen_nic_stats {
50 int stat_offset; 50 int stat_offset;
51}; 51};
52 52
53#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_port *)0)->m), \ 53#define NETXEN_NIC_STAT(m) sizeof(((struct netxen_adapter *)0)->m), \
54 offsetof(struct netxen_port, m) 54 offsetof(struct netxen_adapter, m)
55 55
56#define NETXEN_NIC_PORT_WINDOW 0x10000 56#define NETXEN_NIC_PORT_WINDOW 0x10000
57#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF 57#define NETXEN_NIC_INVALID_DATA 0xDEADBEEF
@@ -100,8 +100,7 @@ static int netxen_nic_get_eeprom_len(struct net_device *dev)
100static void 100static void
101netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) 101netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
102{ 102{
103 struct netxen_port *port = netdev_priv(dev); 103 struct netxen_adapter *adapter = netdev_priv(dev);
104 struct netxen_adapter *adapter = port->adapter;
105 u32 fw_major = 0; 104 u32 fw_major = 0;
106 u32 fw_minor = 0; 105 u32 fw_minor = 0;
107 u32 fw_build = 0; 106 u32 fw_build = 0;
@@ -115,7 +114,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
115 fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB)); 114 fw_build = readl(NETXEN_CRB_NORMALIZE(adapter, NETXEN_FW_VERSION_SUB));
116 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build); 115 sprintf(drvinfo->fw_version, "%d.%d.%d", fw_major, fw_minor, fw_build);
117 116
118 strncpy(drvinfo->bus_info, pci_name(port->pdev), 32); 117 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 32);
119 drvinfo->n_stats = NETXEN_NIC_STATS_LEN; 118 drvinfo->n_stats = NETXEN_NIC_STATS_LEN;
120 drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN; 119 drvinfo->testinfo_len = NETXEN_NIC_TEST_LEN;
121 drvinfo->regdump_len = NETXEN_NIC_REGS_LEN; 120 drvinfo->regdump_len = NETXEN_NIC_REGS_LEN;
@@ -125,8 +124,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo)
125static int 124static int
126netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 125netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
127{ 126{
128 struct netxen_port *port = netdev_priv(dev); 127 struct netxen_adapter *adapter = netdev_priv(dev);
129 struct netxen_adapter *adapter = port->adapter;
130 struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg; 128 struct netxen_board_info *boardinfo = &adapter->ahw.boardcfg;
131 129
132 /* read which mode */ 130 /* read which mode */
@@ -146,8 +144,8 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
146 ecmd->port = PORT_TP; 144 ecmd->port = PORT_TP;
147 145
148 if (netif_running(dev)) { 146 if (netif_running(dev)) {
149 ecmd->speed = port->link_speed; 147 ecmd->speed = adapter->link_speed;
150 ecmd->duplex = port->link_duplex; 148 ecmd->duplex = adapter->link_duplex;
151 } else 149 } else
152 return -EIO; /* link absent */ 150 return -EIO; /* link absent */
153 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { 151 } else if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
@@ -165,7 +163,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
165 } else 163 } else
166 return -EIO; 164 return -EIO;
167 165
168 ecmd->phy_address = port->portnum; 166 ecmd->phy_address = adapter->portnum;
169 ecmd->transceiver = XCVR_EXTERNAL; 167 ecmd->transceiver = XCVR_EXTERNAL;
170 168
171 switch ((netxen_brdtype_t) boardinfo->board_type) { 169 switch ((netxen_brdtype_t) boardinfo->board_type) {
@@ -179,7 +177,7 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
179 ecmd->port = PORT_TP; 177 ecmd->port = PORT_TP;
180 ecmd->autoneg = (boardinfo->board_type == 178 ecmd->autoneg = (boardinfo->board_type ==
181 NETXEN_BRDTYPE_P2_SB31_10G_CX4) ? 179 NETXEN_BRDTYPE_P2_SB31_10G_CX4) ?
182 (AUTONEG_DISABLE) : (port->link_autoneg); 180 (AUTONEG_DISABLE) : (adapter->link_autoneg);
183 break; 181 break;
184 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ: 182 case NETXEN_BRDTYPE_P2_SB31_10G_HMEZ:
185 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ: 183 case NETXEN_BRDTYPE_P2_SB31_10G_IMEZ:
@@ -206,23 +204,22 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
206static int 204static int
207netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) 205netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
208{ 206{
209 struct netxen_port *port = netdev_priv(dev); 207 struct netxen_adapter *adapter = netdev_priv(dev);
210 struct netxen_adapter *adapter = port->adapter;
211 __u32 status; 208 __u32 status;
212 209
213 /* read which mode */ 210 /* read which mode */
214 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 211 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
215 /* autonegotiation */ 212 /* autonegotiation */
216 if (adapter->phy_write 213 if (adapter->phy_write
217 && adapter->phy_write(adapter, port->portnum, 214 && adapter->phy_write(adapter, adapter->portnum,
218 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 215 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
219 ecmd->autoneg) != 0) 216 ecmd->autoneg) != 0)
220 return -EIO; 217 return -EIO;
221 else 218 else
222 port->link_autoneg = ecmd->autoneg; 219 adapter->link_autoneg = ecmd->autoneg;
223 220
224 if (adapter->phy_read 221 if (adapter->phy_read
225 && adapter->phy_read(adapter, port->portnum, 222 && adapter->phy_read(adapter, adapter->portnum,
226 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 223 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
227 &status) != 0) 224 &status) != 0)
228 return -EIO; 225 return -EIO;
@@ -245,13 +242,13 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd)
245 if (ecmd->duplex == DUPLEX_FULL) 242 if (ecmd->duplex == DUPLEX_FULL)
246 netxen_set_phy_duplex(status); 243 netxen_set_phy_duplex(status);
247 if (adapter->phy_write 244 if (adapter->phy_write
248 && adapter->phy_write(adapter, port->portnum, 245 && adapter->phy_write(adapter, adapter->portnum,
249 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 246 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
250 *((int *)&status)) != 0) 247 *((int *)&status)) != 0)
251 return -EIO; 248 return -EIO;
252 else { 249 else {
253 port->link_speed = ecmd->speed; 250 adapter->link_speed = ecmd->speed;
254 port->link_duplex = ecmd->duplex; 251 adapter->link_duplex = ecmd->duplex;
255 } 252 }
256 } else 253 } else
257 return -EOPNOTSUPP; 254 return -EOPNOTSUPP;
@@ -360,15 +357,14 @@ static struct netxen_niu_regs niu_registers[] = {
360static void 357static void
361netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p) 358netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
362{ 359{
363 struct netxen_port *port = netdev_priv(dev); 360 struct netxen_adapter *adapter = netdev_priv(dev);
364 struct netxen_adapter *adapter = port->adapter;
365 __u32 mode, *regs_buff = p; 361 __u32 mode, *regs_buff = p;
366 void __iomem *addr; 362 void __iomem *addr;
367 int i, window; 363 int i, window;
368 364
369 memset(p, 0, NETXEN_NIC_REGS_LEN); 365 memset(p, 0, NETXEN_NIC_REGS_LEN);
370 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) | 366 regs->version = (1 << 24) | (adapter->ahw.revision_id << 16) |
371 (port->pdev)->device; 367 (adapter->pdev)->device;
372 /* which mode */ 368 /* which mode */
373 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, &regs_buff[0]); 369 NETXEN_NIC_LOCKED_READ_REG(NETXEN_NIU_MODE, &regs_buff[0]);
374 mode = regs_buff[0]; 370 mode = regs_buff[0];
@@ -383,7 +379,8 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
383 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) { 379 for (i = 3; niu_registers[mode].reg[i - 3] != -1; i++) {
384 /* GB: port specific registers */ 380 /* GB: port specific registers */
385 if (mode == 0 && i >= 19) 381 if (mode == 0 && i >= 19)
386 window = port->portnum * NETXEN_NIC_PORT_WINDOW; 382 window = adapter->portnum *
383 NETXEN_NIC_PORT_WINDOW;
387 384
388 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode]. 385 NETXEN_NIC_LOCKED_READ_REG(niu_registers[mode].
389 reg[i - 3] + window, 386 reg[i - 3] + window,
@@ -395,15 +392,14 @@ netxen_nic_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *p)
395 392
396static u32 netxen_nic_test_link(struct net_device *dev) 393static u32 netxen_nic_test_link(struct net_device *dev)
397{ 394{
398 struct netxen_port *port = netdev_priv(dev); 395 struct netxen_adapter *adapter = netdev_priv(dev);
399 struct netxen_adapter *adapter = port->adapter;
400 __u32 status; 396 __u32 status;
401 int val; 397 int val;
402 398
403 /* read which mode */ 399 /* read which mode */
404 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 400 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
405 if (adapter->phy_read 401 if (adapter->phy_read
406 && adapter->phy_read(adapter, port->portnum, 402 && adapter->phy_read(adapter, adapter->portnum,
407 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 403 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
408 &status) != 0) 404 &status) != 0)
409 return -EIO; 405 return -EIO;
@@ -422,15 +418,15 @@ static int
422netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, 418netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
423 u8 * bytes) 419 u8 * bytes)
424{ 420{
425 struct netxen_port *port = netdev_priv(dev); 421 struct netxen_adapter *adapter = netdev_priv(dev);
426 struct netxen_adapter *adapter = port->adapter;
427 int offset; 422 int offset;
428 int ret; 423 int ret;
429 424
430 if (eeprom->len == 0) 425 if (eeprom->len == 0)
431 return -EINVAL; 426 return -EINVAL;
432 427
433 eeprom->magic = (port->pdev)->vendor | ((port->pdev)->device << 16); 428 eeprom->magic = (adapter->pdev)->vendor |
429 ((adapter->pdev)->device << 16);
434 offset = eeprom->offset; 430 offset = eeprom->offset;
435 431
436 ret = netxen_rom_fast_read_words(adapter, offset, bytes, 432 ret = netxen_rom_fast_read_words(adapter, offset, bytes,
@@ -445,8 +441,7 @@ static int
445netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, 441netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
446 u8 * bytes) 442 u8 * bytes)
447{ 443{
448 struct netxen_port *port = netdev_priv(dev); 444 struct netxen_adapter *adapter = netdev_priv(dev);
449 struct netxen_adapter *adapter = port->adapter;
450 int offset = eeprom->offset; 445 int offset = eeprom->offset;
451 static int flash_start; 446 static int flash_start;
452 static int ready_to_flash; 447 static int ready_to_flash;
@@ -516,8 +511,7 @@ netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
516static void 511static void
517netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) 512netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
518{ 513{
519 struct netxen_port *port = netdev_priv(dev); 514 struct netxen_adapter *adapter = netdev_priv(dev);
520 struct netxen_adapter *adapter = port->adapter;
521 int i; 515 int i;
522 516
523 ring->rx_pending = 0; 517 ring->rx_pending = 0;
@@ -541,19 +535,18 @@ static void
541netxen_nic_get_pauseparam(struct net_device *dev, 535netxen_nic_get_pauseparam(struct net_device *dev,
542 struct ethtool_pauseparam *pause) 536 struct ethtool_pauseparam *pause)
543{ 537{
544 struct netxen_port *port = netdev_priv(dev); 538 struct netxen_adapter *adapter = netdev_priv(dev);
545 struct netxen_adapter *adapter = port->adapter;
546 __u32 val; 539 __u32 val;
547 540
548 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 541 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
549 /* get flow control settings */ 542 /* get flow control settings */
550 netxen_nic_read_w0(adapter, 543 netxen_nic_read_w0(adapter,
551 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), 544 NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum),
552 &val); 545 &val);
553 pause->rx_pause = netxen_gb_get_rx_flowctl(val); 546 pause->rx_pause = netxen_gb_get_rx_flowctl(val);
554 pause->tx_pause = netxen_gb_get_tx_flowctl(val); 547 pause->tx_pause = netxen_gb_get_tx_flowctl(val);
555 /* get autoneg settings */ 548 /* get autoneg settings */
556 pause->autoneg = port->link_autoneg; 549 pause->autoneg = adapter->link_autoneg;
557 } 550 }
558} 551}
559 552
@@ -561,8 +554,7 @@ static int
561netxen_nic_set_pauseparam(struct net_device *dev, 554netxen_nic_set_pauseparam(struct net_device *dev,
562 struct ethtool_pauseparam *pause) 555 struct ethtool_pauseparam *pause)
563{ 556{
564 struct netxen_port *port = netdev_priv(dev); 557 struct netxen_adapter *adapter = netdev_priv(dev);
565 struct netxen_adapter *adapter = port->adapter;
566 __u32 val; 558 __u32 val;
567 unsigned int autoneg; 559 unsigned int autoneg;
568 560
@@ -570,7 +562,7 @@ netxen_nic_set_pauseparam(struct net_device *dev,
570 if (adapter->ahw.board_type == NETXEN_NIC_GBE) { 562 if (adapter->ahw.board_type == NETXEN_NIC_GBE) {
571 /* set flow control */ 563 /* set flow control */
572 netxen_nic_read_w0(adapter, 564 netxen_nic_read_w0(adapter,
573 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), 565 NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum),
574 (u32 *) & val); 566 (u32 *) & val);
575 if (pause->tx_pause) 567 if (pause->tx_pause)
576 netxen_gb_tx_flowctl(val); 568 netxen_gb_tx_flowctl(val);
@@ -582,17 +574,17 @@ netxen_nic_set_pauseparam(struct net_device *dev,
582 netxen_gb_unset_rx_flowctl(val); 574 netxen_gb_unset_rx_flowctl(val);
583 575
584 netxen_nic_write_w0(adapter, 576 netxen_nic_write_w0(adapter,
585 NETXEN_NIU_GB_MAC_CONFIG_0(port->portnum), 577 NETXEN_NIU_GB_MAC_CONFIG_0(adapter->portnum),
586 *&val); 578 *&val);
587 /* set autoneg */ 579 /* set autoneg */
588 autoneg = pause->autoneg; 580 autoneg = pause->autoneg;
589 if (adapter->phy_write 581 if (adapter->phy_write
590 && adapter->phy_write(adapter, port->portnum, 582 && adapter->phy_write(adapter, adapter->portnum,
591 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 583 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
592 autoneg) != 0) 584 autoneg) != 0)
593 return -EIO; 585 return -EIO;
594 else { 586 else {
595 port->link_autoneg = pause->autoneg; 587 adapter->link_autoneg = pause->autoneg;
596 return 0; 588 return 0;
597 } 589 }
598 } else 590 } else
@@ -675,12 +667,13 @@ static void
675netxen_nic_get_ethtool_stats(struct net_device *dev, 667netxen_nic_get_ethtool_stats(struct net_device *dev,
676 struct ethtool_stats *stats, u64 * data) 668 struct ethtool_stats *stats, u64 * data)
677{ 669{
678 struct netxen_port *port = netdev_priv(dev); 670 struct netxen_adapter *adapter = netdev_priv(dev);
679 int index; 671 int index;
680 672
681 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) { 673 for (index = 0; index < NETXEN_NIC_STATS_LEN; index++) {
682 char *p = 674 char *p =
683 (char *)port + netxen_nic_gstrings_stats[index].stat_offset; 675 (char *)adapter +
676 netxen_nic_gstrings_stats[index].stat_offset;
684 data[index] = 677 data[index] =
685 (netxen_nic_gstrings_stats[index].sizeof_stat == 678 (netxen_nic_gstrings_stats[index].sizeof_stat ==
686 sizeof(u64)) ? *(u64 *) p : *(u32 *) p; 679 sizeof(u64)) ? *(u64 *) p : *(u32 *) p;
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index fe8b675f9e7..b67a5c3ca99 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -649,11 +649,19 @@ enum {
649#define PCIX_MS_WINDOW (0x10204) 649#define PCIX_MS_WINDOW (0x10204)
650#define PCIX_SN_WINDOW (0x10208) 650#define PCIX_SN_WINDOW (0x10208)
651#define PCIX_CRB_WINDOW (0x10210) 651#define PCIX_CRB_WINDOW (0x10210)
652#define PCIX_CRB_WINDOW_F0 (0x10210)
653#define PCIX_CRB_WINDOW_F1 (0x10230)
654#define PCIX_CRB_WINDOW_F2 (0x10250)
655#define PCIX_CRB_WINDOW_F3 (0x10270)
652 656
653#define PCIX_TARGET_STATUS (0x10118) 657#define PCIX_TARGET_STATUS (0x10118)
654#define PCIX_TARGET_MASK (0x10128) 658#define PCIX_TARGET_MASK (0x10128)
655 659
656#define PCIX_MSI_F0 (0x13000) 660#define PCIX_MSI_F0 (0x13000)
661#define PCIX_MSI_F1 (0x13004)
662#define PCIX_MSI_F2 (0x13008)
663#define PCIX_MSI_F3 (0x1300c)
664#define PCIX_MSI_F(i) (0x13000+((i)*4))
657 665
658#define PCIX_PS_MEM_SPACE (0x90000) 666#define PCIX_PS_MEM_SPACE (0x90000)
659 667
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 0fba8f19076..50430911c80 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -33,10 +33,128 @@
33 33
34#include "netxen_nic.h" 34#include "netxen_nic.h"
35#include "netxen_nic_hw.h" 35#include "netxen_nic_hw.h"
36#define DEFINE_GLOBAL_RECV_CRB
36#include "netxen_nic_phan_reg.h" 37#include "netxen_nic_phan_reg.h"
37 38
39
38#include <net/ip.h> 40#include <net/ip.h>
39 41
42struct netxen_recv_crb recv_crb_registers[] = {
43 /*
44 * Instance 0.
45 */
46 {
47 /* rcv_desc_crb: */
48 {
49 {
50 /* crb_rcv_producer_offset: */
51 NETXEN_NIC_REG(0x100),
52 /* crb_rcv_consumer_offset: */
53 NETXEN_NIC_REG(0x104),
54 /* crb_gloablrcv_ring: */
55 NETXEN_NIC_REG(0x108),
56 /* crb_rcv_ring_size */
57 NETXEN_NIC_REG(0x10c),
58
59 },
60 /* Jumbo frames */
61 {
62 /* crb_rcv_producer_offset: */
63 NETXEN_NIC_REG(0x110),
64 /* crb_rcv_consumer_offset: */
65 NETXEN_NIC_REG(0x114),
66 /* crb_gloablrcv_ring: */
67 NETXEN_NIC_REG(0x118),
68 /* crb_rcv_ring_size */
69 NETXEN_NIC_REG(0x11c),
70 },
71 /* LRO */
72 {
73 /* crb_rcv_producer_offset: */
74 NETXEN_NIC_REG(0x120),
75 /* crb_rcv_consumer_offset: */
76 NETXEN_NIC_REG(0x124),
77 /* crb_gloablrcv_ring: */
78 NETXEN_NIC_REG(0x128),
79 /* crb_rcv_ring_size */
80 NETXEN_NIC_REG(0x12c),
81 }
82 },
83 /* crb_rcvstatus_ring: */
84 NETXEN_NIC_REG(0x130),
85 /* crb_rcv_status_producer: */
86 NETXEN_NIC_REG(0x134),
87 /* crb_rcv_status_consumer: */
88 NETXEN_NIC_REG(0x138),
89 /* crb_rcvpeg_state: */
90 NETXEN_NIC_REG(0x13c),
91 /* crb_status_ring_size */
92 NETXEN_NIC_REG(0x140),
93
94 },
95 /*
96 * Instance 1,
97 */
98 {
99 /* rcv_desc_crb: */
100 {
101 {
102 /* crb_rcv_producer_offset: */
103 NETXEN_NIC_REG(0x144),
104 /* crb_rcv_consumer_offset: */
105 NETXEN_NIC_REG(0x148),
106 /* crb_globalrcv_ring: */
107 NETXEN_NIC_REG(0x14c),
108 /* crb_rcv_ring_size */
109 NETXEN_NIC_REG(0x150),
110
111 },
112 /* Jumbo frames */
113 {
114 /* crb_rcv_producer_offset: */
115 NETXEN_NIC_REG(0x154),
116 /* crb_rcv_consumer_offset: */
117 NETXEN_NIC_REG(0x158),
118 /* crb_globalrcv_ring: */
119 NETXEN_NIC_REG(0x15c),
120 /* crb_rcv_ring_size */
121 NETXEN_NIC_REG(0x160),
122 },
123 /* LRO */
124 {
125 /* crb_rcv_producer_offset: */
126 NETXEN_NIC_REG(0x164),
127 /* crb_rcv_consumer_offset: */
128 NETXEN_NIC_REG(0x168),
129 /* crb_globalrcv_ring: */
130 NETXEN_NIC_REG(0x16c),
131 /* crb_rcv_ring_size */
132 NETXEN_NIC_REG(0x170),
133 }
134
135 },
136 /* crb_rcvstatus_ring: */
137 NETXEN_NIC_REG(0x174),
138 /* crb_rcv_status_producer: */
139 NETXEN_NIC_REG(0x178),
140 /* crb_rcv_status_consumer: */
141 NETXEN_NIC_REG(0x17c),
142 /* crb_rcvpeg_state: */
143 NETXEN_NIC_REG(0x180),
144 /* crb_status_ring_size */
145 NETXEN_NIC_REG(0x184),
146
147 },
148};
149
150u64 ctx_addr_sig_regs[][3] = {
151 {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)},
152 {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)},
153 {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)},
154 {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)}
155};
156
157
40/* PCI Windowing for DDR regions. */ 158/* PCI Windowing for DDR regions. */
41 159
42#define ADDR_IN_RANGE(addr, low, high) \ 160#define ADDR_IN_RANGE(addr, low, high) \
@@ -70,8 +188,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter);
70 188
71int netxen_nic_set_mac(struct net_device *netdev, void *p) 189int netxen_nic_set_mac(struct net_device *netdev, void *p)
72{ 190{
73 struct netxen_port *port = netdev_priv(netdev); 191 struct netxen_adapter *adapter = netdev_priv(netdev);
74 struct netxen_adapter *adapter = port->adapter;
75 struct sockaddr *addr = p; 192 struct sockaddr *addr = p;
76 193
77 if (netif_running(netdev)) 194 if (netif_running(netdev))
@@ -84,7 +201,7 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p)
84 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 201 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
85 202
86 if (adapter->macaddr_set) 203 if (adapter->macaddr_set)
87 adapter->macaddr_set(port, addr->sa_data); 204 adapter->macaddr_set(adapter, addr->sa_data);
88 205
89 return 0; 206 return 0;
90} 207}
@@ -94,8 +211,7 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p)
94 */ 211 */
95void netxen_nic_set_multi(struct net_device *netdev) 212void netxen_nic_set_multi(struct net_device *netdev)
96{ 213{
97 struct netxen_port *port = netdev_priv(netdev); 214 struct netxen_adapter *adapter = netdev_priv(netdev);
98 struct netxen_adapter *adapter = port->adapter;
99 struct dev_mc_list *mc_ptr; 215 struct dev_mc_list *mc_ptr;
100 __u32 netxen_mac_addr_cntl_data = 0; 216 __u32 netxen_mac_addr_cntl_data = 0;
101 217
@@ -103,14 +219,12 @@ void netxen_nic_set_multi(struct net_device *netdev)
103 if (netdev->flags & IFF_PROMISC) { 219 if (netdev->flags & IFF_PROMISC) {
104 if (adapter->set_promisc) 220 if (adapter->set_promisc)
105 adapter->set_promisc(adapter, 221 adapter->set_promisc(adapter,
106 port->portnum,
107 NETXEN_NIU_PROMISC_MODE); 222 NETXEN_NIU_PROMISC_MODE);
108 } else { 223 } else {
109 if (adapter->unset_promisc && 224 if (adapter->unset_promisc &&
110 adapter->ahw.boardcfg.board_type 225 adapter->ahw.boardcfg.board_type
111 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) 226 != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
112 adapter->unset_promisc(adapter, 227 adapter->unset_promisc(adapter,
113 port->portnum,
114 NETXEN_NIU_NON_PROMISC_MODE); 228 NETXEN_NIU_NON_PROMISC_MODE);
115 } 229 }
116 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { 230 if (adapter->ahw.board_type == NETXEN_NIC_XGBE) {
@@ -152,8 +266,7 @@ void netxen_nic_set_multi(struct net_device *netdev)
152 */ 266 */
153int netxen_nic_change_mtu(struct net_device *netdev, int mtu) 267int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
154{ 268{
155 struct netxen_port *port = netdev_priv(netdev); 269 struct netxen_adapter *adapter = netdev_priv(netdev);
156 struct netxen_adapter *adapter = port->adapter;
157 int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE; 270 int eff_mtu = mtu + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE;
158 271
159 if ((eff_mtu > NETXEN_MAX_MTU) || (eff_mtu < NETXEN_MIN_MTU)) { 272 if ((eff_mtu > NETXEN_MAX_MTU) || (eff_mtu < NETXEN_MIN_MTU)) {
@@ -163,7 +276,7 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu)
163 } 276 }
164 277
165 if (adapter->set_mtu) 278 if (adapter->set_mtu)
166 adapter->set_mtu(port, mtu); 279 adapter->set_mtu(adapter, mtu);
167 netdev->mtu = mtu; 280 netdev->mtu = mtu;
168 281
169 return 0; 282 return 0;
@@ -229,7 +342,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
229 (dma_addr_t *) & adapter->ctx_desc_phys_addr, 342 (dma_addr_t *) & adapter->ctx_desc_phys_addr,
230 &adapter->ctx_desc_pdev); 343 &adapter->ctx_desc_pdev);
231 344
232 printk("ctx_desc_phys_addr: 0x%llx\n", 345 printk(KERN_INFO "ctx_desc_phys_addr: 0x%llx\n",
233 (unsigned long long) adapter->ctx_desc_phys_addr); 346 (unsigned long long) adapter->ctx_desc_phys_addr);
234 if (addr == NULL) { 347 if (addr == NULL) {
235 DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); 348 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
@@ -249,7 +362,7 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
249 adapter->max_tx_desc_count, 362 adapter->max_tx_desc_count,
250 (dma_addr_t *) & hw->cmd_desc_phys_addr, 363 (dma_addr_t *) & hw->cmd_desc_phys_addr,
251 &adapter->ahw.cmd_desc_pdev); 364 &adapter->ahw.cmd_desc_pdev);
252 printk("cmd_desc_phys_addr: 0x%llx\n", 365 printk(KERN_INFO "cmd_desc_phys_addr: 0x%llx\n",
253 (unsigned long long) hw->cmd_desc_phys_addr); 366 (unsigned long long) hw->cmd_desc_phys_addr);
254 367
255 if (addr == NULL) { 368 if (addr == NULL) {
@@ -385,7 +498,6 @@ void netxen_tso_check(struct netxen_adapter *adapter,
385 return; 498 return;
386 } 499 }
387 } 500 }
388 adapter->stats.xmitcsummed++;
389 desc->tcp_hdr_offset = skb_transport_offset(skb); 501 desc->tcp_hdr_offset = skb_transport_offset(skb);
390 desc->ip_hdr_offset = skb_network_offset(skb); 502 desc->ip_hdr_offset = skb_network_offset(skb);
391} 503}
@@ -475,7 +587,30 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw)
475 587
476 if (adapter->curr_window == wndw) 588 if (adapter->curr_window == wndw)
477 return; 589 return;
478 590 switch(adapter->portnum) {
591 case 0:
592 offset = PCI_OFFSET_SECOND_RANGE(adapter,
593 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW));
594 break;
595 case 1:
596 offset = PCI_OFFSET_SECOND_RANGE(adapter,
597 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW_F1));
598 break;
599 case 2:
600 offset = PCI_OFFSET_SECOND_RANGE(adapter,
601 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW_F2));
602 break;
603 case 3:
604 offset = PCI_OFFSET_SECOND_RANGE(adapter,
605 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW_F3));
606 break;
607 default:
608 printk(KERN_INFO "Changing the window for PCI function"
609 "%d\n", adapter->portnum);
610 offset = PCI_OFFSET_SECOND_RANGE(adapter,
611 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW));
612 break;
613 }
479 /* 614 /*
480 * Move the CRB window. 615 * Move the CRB window.
481 * We need to write to the "direct access" region of PCI 616 * We need to write to the "direct access" region of PCI
@@ -484,9 +619,6 @@ void netxen_nic_pci_change_crbwindow(struct netxen_adapter *adapter, u32 wndw)
484 * register address is received by PCI. The direct region bypasses 619 * register address is received by PCI. The direct region bypasses
485 * the CRB bus. 620 * the CRB bus.
486 */ 621 */
487 offset =
488 PCI_OFFSET_SECOND_RANGE(adapter,
489 NETXEN_PCIX_PH_REG(PCIX_CRB_WINDOW));
490 622
491 if (wndw & 0x1) 623 if (wndw & 0x1)
492 wndw = NETXEN_WINDOW_ONE; 624 wndw = NETXEN_WINDOW_ONE;
@@ -810,43 +942,27 @@ int netxen_nic_get_board_info(struct netxen_adapter *adapter)
810 942
811/* NIU access sections */ 943/* NIU access sections */
812 944
813int netxen_nic_set_mtu_gb(struct netxen_port *port, int new_mtu) 945int netxen_nic_set_mtu_gb(struct netxen_adapter *adapter, int new_mtu)
814{ 946{
815 struct netxen_adapter *adapter = port->adapter;
816 netxen_nic_write_w0(adapter, 947 netxen_nic_write_w0(adapter,
817 NETXEN_NIU_GB_MAX_FRAME_SIZE(port->portnum), 948 NETXEN_NIU_GB_MAX_FRAME_SIZE(adapter->portnum),
818 new_mtu); 949 new_mtu);
819 return 0; 950 return 0;
820} 951}
821 952
822int netxen_nic_set_mtu_xgb(struct netxen_port *port, int new_mtu) 953int netxen_nic_set_mtu_xgb(struct netxen_adapter *adapter, int new_mtu)
823{ 954{
824 struct netxen_adapter *adapter = port->adapter;
825 new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE; 955 new_mtu += NETXEN_NIU_HDRSIZE + NETXEN_NIU_TLRSIZE;
826 if (port->portnum == 0) 956 if (adapter->portnum == 0)
827 netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu); 957 netxen_nic_write_w0(adapter, NETXEN_NIU_XGE_MAX_FRAME_SIZE, new_mtu);
828 else if (port->portnum == 1) 958 else if (adapter->portnum == 1)
829 netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu); 959 netxen_nic_write_w0(adapter, NETXEN_NIU_XG1_MAX_FRAME_SIZE, new_mtu);
830 return 0; 960 return 0;
831} 961}
832 962
833void netxen_nic_init_niu_gb(struct netxen_adapter *adapter) 963void netxen_nic_init_niu_gb(struct netxen_adapter *adapter)
834{ 964{
835 int portno; 965 netxen_niu_gbe_init_port(adapter, adapter->portnum);
836 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++)
837 netxen_niu_gbe_init_port(adapter, portno);
838}
839
840void netxen_nic_stop_all_ports(struct netxen_adapter *adapter)
841{
842 int port_nr;
843 struct netxen_port *port;
844
845 for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) {
846 port = adapter->port[port_nr];
847 if (adapter->stop_port)
848 adapter->stop_port(adapter, port->portnum);
849 }
850} 966}
851 967
852void 968void
@@ -865,9 +981,8 @@ netxen_crb_writelit_adapter(struct netxen_adapter *adapter, unsigned long off,
865 } 981 }
866} 982}
867 983
868void netxen_nic_set_link_parameters(struct netxen_port *port) 984void netxen_nic_set_link_parameters(struct netxen_adapter *adapter)
869{ 985{
870 struct netxen_adapter *adapter = port->adapter;
871 __u32 status; 986 __u32 status;
872 __u32 autoneg; 987 __u32 autoneg;
873 __u32 mode; 988 __u32 mode;
@@ -876,47 +991,47 @@ void netxen_nic_set_link_parameters(struct netxen_port *port)
876 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ 991 if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */
877 if (adapter->phy_read 992 if (adapter->phy_read
878 && adapter-> 993 && adapter->
879 phy_read(adapter, port->portnum, 994 phy_read(adapter, adapter->portnum,
880 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 995 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
881 &status) == 0) { 996 &status) == 0) {
882 if (netxen_get_phy_link(status)) { 997 if (netxen_get_phy_link(status)) {
883 switch (netxen_get_phy_speed(status)) { 998 switch (netxen_get_phy_speed(status)) {
884 case 0: 999 case 0:
885 port->link_speed = SPEED_10; 1000 adapter->link_speed = SPEED_10;
886 break; 1001 break;
887 case 1: 1002 case 1:
888 port->link_speed = SPEED_100; 1003 adapter->link_speed = SPEED_100;
889 break; 1004 break;
890 case 2: 1005 case 2:
891 port->link_speed = SPEED_1000; 1006 adapter->link_speed = SPEED_1000;
892 break; 1007 break;
893 default: 1008 default:
894 port->link_speed = -1; 1009 adapter->link_speed = -1;
895 break; 1010 break;
896 } 1011 }
897 switch (netxen_get_phy_duplex(status)) { 1012 switch (netxen_get_phy_duplex(status)) {
898 case 0: 1013 case 0:
899 port->link_duplex = DUPLEX_HALF; 1014 adapter->link_duplex = DUPLEX_HALF;
900 break; 1015 break;
901 case 1: 1016 case 1:
902 port->link_duplex = DUPLEX_FULL; 1017 adapter->link_duplex = DUPLEX_FULL;
903 break; 1018 break;
904 default: 1019 default:
905 port->link_duplex = -1; 1020 adapter->link_duplex = -1;
906 break; 1021 break;
907 } 1022 }
908 if (adapter->phy_read 1023 if (adapter->phy_read
909 && adapter-> 1024 && adapter->
910 phy_read(adapter, port->portnum, 1025 phy_read(adapter, adapter->portnum,
911 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, 1026 NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG,
912 &autoneg) != 0) 1027 &autoneg) != 0)
913 port->link_autoneg = autoneg; 1028 adapter->link_autoneg = autoneg;
914 } else 1029 } else
915 goto link_down; 1030 goto link_down;
916 } else { 1031 } else {
917 link_down: 1032 link_down:
918 port->link_speed = -1; 1033 adapter->link_speed = -1;
919 port->link_duplex = -1; 1034 adapter->link_duplex = -1;
920 } 1035 }
921 } 1036 }
922} 1037}
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h
index ab1112eb1b0..841341d52dc 100644
--- a/drivers/net/netxen/netxen_nic_hw.h
+++ b/drivers/net/netxen/netxen_nic_hw.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,
@@ -87,7 +87,7 @@ struct netxen_adapter;
87 *(u32 *)Y = readl((void __iomem*) addr); 87 *(u32 *)Y = readl((void __iomem*) 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_adapter *adapter);
91void netxen_nic_flash_print(struct netxen_adapter *adapter); 91void netxen_nic_flash_print(struct netxen_adapter *adapter);
92int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, 92int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off,
93 void *data, int len); 93 void *data, int len);
@@ -452,21 +452,21 @@ typedef enum {
452 ((config) |= (((val) & 0x0f) << 28)) 452 ((config) |= (((val) & 0x0f) << 28))
453 453
454/* Set promiscuous mode for a GbE interface */ 454/* Set promiscuous mode for a GbE interface */
455int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, 455int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
456 netxen_niu_prom_mode_t mode); 456 netxen_niu_prom_mode_t mode);
457int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, 457int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
458 int port, netxen_niu_prom_mode_t mode); 458 netxen_niu_prom_mode_t mode);
459 459
460/* get/set the MAC address for a given MAC */ 460/* get/set the MAC address for a given MAC */
461int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int port, 461int netxen_niu_macaddr_get(struct netxen_adapter *adapter, int port,
462 netxen_ethernet_macaddr_t * addr); 462 netxen_ethernet_macaddr_t * addr);
463int netxen_niu_macaddr_set(struct netxen_port *port, 463int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
464 netxen_ethernet_macaddr_t addr); 464 netxen_ethernet_macaddr_t addr);
465 465
466/* XG versons */ 466/* XG versons */
467int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int port, 467int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int port,
468 netxen_ethernet_macaddr_t * addr); 468 netxen_ethernet_macaddr_t * addr);
469int netxen_niu_xg_macaddr_set(struct netxen_port *port, 469int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
470 netxen_ethernet_macaddr_t addr); 470 netxen_ethernet_macaddr_t addr);
471 471
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. */
@@ -475,8 +475,8 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port);
475int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port); 475int netxen_niu_xg_init_port(struct netxen_adapter *adapter, int port);
476 476
477/* Disable a GbE interface */ 477/* Disable a GbE interface */
478int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port); 478int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter);
479 479
480int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port); 480int netxen_niu_disable_xg_port(struct netxen_adapter *adapter);
481 481
482#endif /* __NETXEN_NIC_HW_H_ */ 482#endif /* __NETXEN_NIC_HW_H_ */
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 5cd40562da7..4df38c7e71a 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -139,7 +139,7 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
139 return err; 139 return err;
140 } 140 }
141 /* Window 1 call */ 141 /* Window 1 call */
142 writel(MPORT_SINGLE_FUNCTION_MODE, 142 writel(MPORT_MULTI_FUNCTION_MODE,
143 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); 143 NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE));
144 writel(PHAN_INITIALIZE_ACK, 144 writel(PHAN_INITIALIZE_ACK,
145 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 145 NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
@@ -990,9 +990,7 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter)
990 990
991static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) 991static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
992{ 992{
993 int port_num; 993 struct net_device *netdev = adapter->netdev;
994 struct netxen_port *port;
995 struct net_device *netdev;
996 uint32_t temp, temp_state, temp_val; 994 uint32_t temp, temp_state, temp_val;
997 int rv = 0; 995 int rv = 0;
998 996
@@ -1006,14 +1004,9 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
1006 "%s: Device temperature %d degrees C exceeds" 1004 "%s: Device temperature %d degrees C exceeds"
1007 " maximum allowed. Hardware has been shut down.\n", 1005 " maximum allowed. Hardware has been shut down.\n",
1008 netxen_nic_driver_name, temp_val); 1006 netxen_nic_driver_name, temp_val);
1009 for (port_num = 0; port_num < adapter->ahw.max_ports;
1010 port_num++) {
1011 port = adapter->port[port_num];
1012 netdev = port->netdev;
1013 1007
1014 netif_carrier_off(netdev); 1008 netif_carrier_off(netdev);
1015 netif_stop_queue(netdev); 1009 netif_stop_queue(netdev);
1016 }
1017 rv = 1; 1010 rv = 1;
1018 } else if (temp_state == NX_TEMP_WARN) { 1011 } else if (temp_state == NX_TEMP_WARN) {
1019 if (adapter->temp == NX_TEMP_NORMAL) { 1012 if (adapter->temp == NX_TEMP_NORMAL) {
@@ -1037,8 +1030,6 @@ static inline int netxen_nic_check_temp(struct netxen_adapter *adapter)
1037 1030
1038void netxen_watchdog_task(struct work_struct *work) 1031void netxen_watchdog_task(struct work_struct *work)
1039{ 1032{
1040 int port_num;
1041 struct netxen_port *port;
1042 struct net_device *netdev; 1033 struct net_device *netdev;
1043 struct netxen_adapter *adapter = 1034 struct netxen_adapter *adapter =
1044 container_of(work, struct netxen_adapter, watchdog_task); 1035 container_of(work, struct netxen_adapter, watchdog_task);
@@ -1046,20 +1037,16 @@ void netxen_watchdog_task(struct work_struct *work)
1046 if (netxen_nic_check_temp(adapter)) 1037 if (netxen_nic_check_temp(adapter))
1047 return; 1038 return;
1048 1039
1049 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { 1040 netdev = adapter->netdev;
1050 port = adapter->port[port_num]; 1041 if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) {
1051 netdev = port->netdev; 1042 printk(KERN_INFO "%s port %d, %s carrier is now ok\n",
1052 1043 netxen_nic_driver_name, adapter->portnum, netdev->name);
1053 if ((netif_running(netdev)) && !netif_carrier_ok(netdev)) { 1044 netif_carrier_on(netdev);
1054 printk(KERN_INFO "%s port %d, %s carrier is now ok\n",
1055 netxen_nic_driver_name, port_num, netdev->name);
1056 netif_carrier_on(netdev);
1057 }
1058
1059 if (netif_queue_stopped(netdev))
1060 netif_wake_queue(netdev);
1061 } 1045 }
1062 1046
1047 if (netif_queue_stopped(netdev))
1048 netif_wake_queue(netdev);
1049
1063 if (adapter->handle_phy_intr) 1050 if (adapter->handle_phy_intr)
1064 adapter->handle_phy_intr(adapter); 1051 adapter->handle_phy_intr(adapter);
1065 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 1052 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
@@ -1074,9 +1061,8 @@ void
1074netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, 1061netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1075 struct status_desc *desc) 1062 struct status_desc *desc)
1076{ 1063{
1077 struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)]; 1064 struct pci_dev *pdev = adapter->pdev;
1078 struct pci_dev *pdev = port->pdev; 1065 struct net_device *netdev = adapter->netdev;
1079 struct net_device *netdev = port->netdev;
1080 int index = netxen_get_sts_refhandle(desc); 1066 int index = netxen_get_sts_refhandle(desc);
1081 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); 1067 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]);
1082 struct netxen_rx_buffer *buffer; 1068 struct netxen_rx_buffer *buffer;
@@ -1126,7 +1112,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1126 skb = (struct sk_buff *)buffer->skb; 1112 skb = (struct sk_buff *)buffer->skb;
1127 1113
1128 if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { 1114 if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) {
1129 port->stats.csummed++; 1115 adapter->stats.csummed++;
1130 skb->ip_summed = CHECKSUM_UNNECESSARY; 1116 skb->ip_summed = CHECKSUM_UNNECESSARY;
1131 } 1117 }
1132 if (desc_ctx == RCV_DESC_LRO_CTXID) { 1118 if (desc_ctx == RCV_DESC_LRO_CTXID) {
@@ -1146,27 +1132,27 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1146 */ 1132 */
1147 switch (ret) { 1133 switch (ret) {
1148 case NET_RX_SUCCESS: 1134 case NET_RX_SUCCESS:
1149 port->stats.uphappy++; 1135 adapter->stats.uphappy++;
1150 break; 1136 break;
1151 1137
1152 case NET_RX_CN_LOW: 1138 case NET_RX_CN_LOW:
1153 port->stats.uplcong++; 1139 adapter->stats.uplcong++;
1154 break; 1140 break;
1155 1141
1156 case NET_RX_CN_MOD: 1142 case NET_RX_CN_MOD:
1157 port->stats.upmcong++; 1143 adapter->stats.upmcong++;
1158 break; 1144 break;
1159 1145
1160 case NET_RX_CN_HIGH: 1146 case NET_RX_CN_HIGH:
1161 port->stats.uphcong++; 1147 adapter->stats.uphcong++;
1162 break; 1148 break;
1163 1149
1164 case NET_RX_DROP: 1150 case NET_RX_DROP:
1165 port->stats.updropped++; 1151 adapter->stats.updropped++;
1166 break; 1152 break;
1167 1153
1168 default: 1154 default:
1169 port->stats.updunno++; 1155 adapter->stats.updunno++;
1170 break; 1156 break;
1171 } 1157 }
1172 1158
@@ -1178,14 +1164,13 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1178 /* 1164 /*
1179 * We just consumed one buffer so post a buffer. 1165 * We just consumed one buffer so post a buffer.
1180 */ 1166 */
1181 adapter->stats.post_called++;
1182 buffer->skb = NULL; 1167 buffer->skb = NULL;
1183 buffer->state = NETXEN_BUFFER_FREE; 1168 buffer->state = NETXEN_BUFFER_FREE;
1184 buffer->lro_current_frags = 0; 1169 buffer->lro_current_frags = 0;
1185 buffer->lro_expected_frags = 0; 1170 buffer->lro_expected_frags = 0;
1186 1171
1187 port->stats.no_rcv++; 1172 adapter->stats.no_rcv++;
1188 port->stats.rxbytes += length; 1173 adapter->stats.rxbytes += length;
1189} 1174}
1190 1175
1191/* Process Receive status ring */ 1176/* Process Receive status ring */
@@ -1226,7 +1211,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1226 1211
1227 /* update the consumer index in phantom */ 1212 /* update the consumer index in phantom */
1228 if (count) { 1213 if (count) {
1229 adapter->stats.process_rcv++;
1230 recv_ctx->status_rx_consumer = consumer; 1214 recv_ctx->status_rx_consumer = consumer;
1231 recv_ctx->status_rx_producer = producer; 1215 recv_ctx->status_rx_producer = producer;
1232 1216
@@ -1249,13 +1233,10 @@ int netxen_process_cmd_ring(unsigned long data)
1249 int count1 = 0; 1233 int count1 = 0;
1250 int count2 = 0; 1234 int count2 = 0;
1251 struct netxen_cmd_buffer *buffer; 1235 struct netxen_cmd_buffer *buffer;
1252 struct netxen_port *port; /* port #1 */
1253 struct netxen_port *nport;
1254 struct pci_dev *pdev; 1236 struct pci_dev *pdev;
1255 struct netxen_skb_frag *frag; 1237 struct netxen_skb_frag *frag;
1256 u32 i; 1238 u32 i;
1257 struct sk_buff *skb = NULL; 1239 struct sk_buff *skb = NULL;
1258 int p;
1259 int done; 1240 int done;
1260 1241
1261 spin_lock(&adapter->tx_lock); 1242 spin_lock(&adapter->tx_lock);
@@ -1276,7 +1257,6 @@ int netxen_process_cmd_ring(unsigned long data)
1276 } 1257 }
1277 1258
1278 adapter->proc_cmd_buf_counter++; 1259 adapter->proc_cmd_buf_counter++;
1279 adapter->stats.process_xmit++;
1280 /* 1260 /*
1281 * Not needed - does not seem to be used anywhere. 1261 * Not needed - does not seem to be used anywhere.
1282 * adapter->cmd_consumer = consumer; 1262 * adapter->cmd_consumer = consumer;
@@ -1285,8 +1265,7 @@ int netxen_process_cmd_ring(unsigned long data)
1285 1265
1286 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { 1266 while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) {
1287 buffer = &adapter->cmd_buf_arr[last_consumer]; 1267 buffer = &adapter->cmd_buf_arr[last_consumer];
1288 port = adapter->port[buffer->port]; 1268 pdev = adapter->pdev;
1289 pdev = port->pdev;
1290 frag = &buffer->frag_array[0]; 1269 frag = &buffer->frag_array[0];
1291 skb = buffer->skb; 1270 skb = buffer->skb;
1292 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) { 1271 if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) {
@@ -1299,24 +1278,23 @@ int netxen_process_cmd_ring(unsigned long data)
1299 PCI_DMA_TODEVICE); 1278 PCI_DMA_TODEVICE);
1300 } 1279 }
1301 1280
1302 port->stats.skbfreed++; 1281 adapter->stats.skbfreed++;
1303 dev_kfree_skb_any(skb); 1282 dev_kfree_skb_any(skb);
1304 skb = NULL; 1283 skb = NULL;
1305 } else if (adapter->proc_cmd_buf_counter == 1) { 1284 } else if (adapter->proc_cmd_buf_counter == 1) {
1306 port->stats.txnullskb++; 1285 adapter->stats.txnullskb++;
1307 } 1286 }
1308 if (unlikely(netif_queue_stopped(port->netdev) 1287 if (unlikely(netif_queue_stopped(adapter->netdev)
1309 && netif_carrier_ok(port->netdev)) 1288 && netif_carrier_ok(adapter->netdev))
1310 && ((jiffies - port->netdev->trans_start) > 1289 && ((jiffies - adapter->netdev->trans_start) >
1311 port->netdev->watchdog_timeo)) { 1290 adapter->netdev->watchdog_timeo)) {
1312 SCHEDULE_WORK(&port->tx_timeout_task); 1291 SCHEDULE_WORK(&adapter->tx_timeout_task);
1313 } 1292 }
1314 1293
1315 last_consumer = get_next_index(last_consumer, 1294 last_consumer = get_next_index(last_consumer,
1316 adapter->max_tx_desc_count); 1295 adapter->max_tx_desc_count);
1317 count1++; 1296 count1++;
1318 } 1297 }
1319 adapter->stats.noxmitdone += count1;
1320 1298
1321 count2 = 0; 1299 count2 = 0;
1322 spin_lock(&adapter->tx_lock); 1300 spin_lock(&adapter->tx_lock);
@@ -1336,13 +1314,10 @@ int netxen_process_cmd_ring(unsigned long data)
1336 } 1314 }
1337 } 1315 }
1338 if (count1 || count2) { 1316 if (count1 || count2) {
1339 for (p = 0; p < adapter->ahw.max_ports; p++) { 1317 if (netif_queue_stopped(adapter->netdev)
1340 nport = adapter->port[p]; 1318 && (adapter->flags & NETXEN_NETDEV_STATUS)) {
1341 if (netif_queue_stopped(nport->netdev) 1319 netif_wake_queue(adapter->netdev);
1342 && (nport->flags & NETXEN_NETDEV_STATUS)) { 1320 adapter->flags &= ~NETXEN_NETDEV_STATUS;
1343 netif_wake_queue(nport->netdev);
1344 nport->flags &= ~NETXEN_NETDEV_STATUS;
1345 }
1346 } 1321 }
1347 } 1322 }
1348 /* 1323 /*
@@ -1388,7 +1363,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1388 netxen_ctx_msg msg = 0; 1363 netxen_ctx_msg msg = 0;
1389 dma_addr_t dma; 1364 dma_addr_t dma;
1390 1365
1391 adapter->stats.post_called++;
1392 rcv_desc = &recv_ctx->rcv_desc[ringid]; 1366 rcv_desc = &recv_ctx->rcv_desc[ringid];
1393 1367
1394 producer = rcv_desc->producer; 1368 producer = rcv_desc->producer;
@@ -1441,8 +1415,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1441 if (count) { 1415 if (count) {
1442 rcv_desc->begin_alloc = index; 1416 rcv_desc->begin_alloc = index;
1443 rcv_desc->rcv_pending += count; 1417 rcv_desc->rcv_pending += count;
1444 adapter->stats.lastposted = count;
1445 adapter->stats.posted += count;
1446 rcv_desc->producer = producer; 1418 rcv_desc->producer = producer;
1447 if (rcv_desc->rcv_free >= 32) { 1419 if (rcv_desc->rcv_free >= 32) {
1448 rcv_desc->rcv_free = 0; 1420 rcv_desc->rcv_free = 0;
@@ -1450,7 +1422,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1450 writel((producer - 1) & 1422 writel((producer - 1) &
1451 (rcv_desc->max_rx_desc_count - 1), 1423 (rcv_desc->max_rx_desc_count - 1),
1452 NETXEN_CRB_NORMALIZE(adapter, 1424 NETXEN_CRB_NORMALIZE(adapter,
1453 recv_crb_registers[0]. 1425 recv_crb_registers[
1426 adapter->portnum].
1454 rcv_desc_crb[ringid]. 1427 rcv_desc_crb[ringid].
1455 crb_rcv_producer_offset)); 1428 crb_rcv_producer_offset));
1456 /* 1429 /*
@@ -1463,7 +1436,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1463 ((producer - 1436 ((producer -
1464 1) & (rcv_desc-> 1437 1) & (rcv_desc->
1465 max_rx_desc_count - 1))); 1438 max_rx_desc_count - 1)));
1466 netxen_set_msg_ctxid(msg, 0); 1439 netxen_set_msg_ctxid(msg, adapter->portnum);
1467 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); 1440 netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid));
1468 writel(msg, 1441 writel(msg,
1469 DB_NORMALIZE(adapter, 1442 DB_NORMALIZE(adapter,
@@ -1485,7 +1458,6 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1485 int count = 0; 1458 int count = 0;
1486 int index = 0; 1459 int index = 0;
1487 1460
1488 adapter->stats.post_called++;
1489 rcv_desc = &recv_ctx->rcv_desc[ringid]; 1461 rcv_desc = &recv_ctx->rcv_desc[ringid];
1490 1462
1491 producer = rcv_desc->producer; 1463 producer = rcv_desc->producer;
@@ -1532,8 +1504,6 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1532 if (count) { 1504 if (count) {
1533 rcv_desc->begin_alloc = index; 1505 rcv_desc->begin_alloc = index;
1534 rcv_desc->rcv_pending += count; 1506 rcv_desc->rcv_pending += count;
1535 adapter->stats.lastposted = count;
1536 adapter->stats.posted += count;
1537 rcv_desc->producer = producer; 1507 rcv_desc->producer = producer;
1538 if (rcv_desc->rcv_free >= 32) { 1508 if (rcv_desc->rcv_free >= 32) {
1539 rcv_desc->rcv_free = 0; 1509 rcv_desc->rcv_free = 0;
@@ -1541,7 +1511,8 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx,
1541 writel((producer - 1) & 1511 writel((producer - 1) &
1542 (rcv_desc->max_rx_desc_count - 1), 1512 (rcv_desc->max_rx_desc_count - 1),
1543 NETXEN_CRB_NORMALIZE(adapter, 1513 NETXEN_CRB_NORMALIZE(adapter,
1544 recv_crb_registers[0]. 1514 recv_crb_registers[
1515 adapter->portnum].
1545 rcv_desc_crb[ringid]. 1516 rcv_desc_crb[ringid].
1546 crb_rcv_producer_offset)); 1517 crb_rcv_producer_offset));
1547 wmb(); 1518 wmb();
@@ -1562,13 +1533,7 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter)
1562 1533
1563void netxen_nic_clear_stats(struct netxen_adapter *adapter) 1534void netxen_nic_clear_stats(struct netxen_adapter *adapter)
1564{ 1535{
1565 struct netxen_port *port;
1566 int port_num;
1567
1568 memset(&adapter->stats, 0, sizeof(adapter->stats)); 1536 memset(&adapter->stats, 0, sizeof(adapter->stats));
1569 for (port_num = 0; port_num < adapter->ahw.max_ports; port_num++) { 1537 return;
1570 port = adapter->port[port_num];
1571 memset(&port->stats, 0, sizeof(port->stats));
1572 }
1573} 1538}
1574 1539
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c
index be366e48007..f60c9699191 100644
--- a/drivers/net/netxen/netxen_nic_isr.c
+++ b/drivers/net/netxen/netxen_nic_isr.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,
@@ -34,6 +34,7 @@
34#include "netxen_nic_hw.h" 34#include "netxen_nic_hw.h"
35#include "netxen_nic_phan_reg.h" 35#include "netxen_nic_phan_reg.h"
36 36
37#if 0
37/* 38/*
38 * netxen_nic_get_stats - Get System Network Statistics 39 * netxen_nic_get_stats - Get System Network Statistics
39 * @netdev: network interface device structure 40 * @netdev: network interface device structure
@@ -41,7 +42,7 @@
41struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) 42struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
42{ 43{
43 struct netxen_port *port = netdev_priv(netdev); 44 struct netxen_port *port = netdev_priv(netdev);
44 struct net_device_stats *stats = &port->net_stats; 45 struct net_device_stats *stats = &adapter->net_stats;
45 46
46 memset(stats, 0, sizeof(*stats)); 47 memset(stats, 0, sizeof(*stats));
47 48
@@ -64,11 +65,10 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev)
64 65
65 return stats; 66 return stats;
66} 67}
67 68#endif
68void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, 69void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 link)
69 u32 link)
70{ 70{
71 struct net_device *netdev = (adapter->port[portno])->netdev; 71 struct net_device *netdev = adapter->netdev;
72 72
73 if (link) 73 if (link)
74 netif_carrier_on(netdev); 74 netif_carrier_on(netdev);
@@ -76,15 +76,13 @@ void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno,
76 netif_carrier_off(netdev); 76 netif_carrier_off(netdev);
77} 77}
78 78
79void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, 79void netxen_handle_port_int(struct netxen_adapter *adapter, u32 enable)
80 u32 enable)
81{ 80{
82 __u32 int_src; 81 __u32 int_src;
83 struct netxen_port *port;
84 82
85 /* This should clear the interrupt source */ 83 /* This should clear the interrupt source */
86 if (adapter->phy_read) 84 if (adapter->phy_read)
87 adapter->phy_read(adapter, portno, 85 adapter->phy_read(adapter, adapter->portnum,
88 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, 86 NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS,
89 &int_src); 87 &int_src);
90 if (int_src == 0) { 88 if (int_src == 0) {
@@ -92,9 +90,7 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
92 return; 90 return;
93 } 91 }
94 if (adapter->disable_phy_interrupts) 92 if (adapter->disable_phy_interrupts)
95 adapter->disable_phy_interrupts(adapter, portno); 93 adapter->disable_phy_interrupts(adapter, adapter->portnum);
96
97 port = adapter->port[portno];
98 94
99 if (netxen_get_phy_int_jabber(int_src)) 95 if (netxen_get_phy_int_jabber(int_src))
100 DPRINTK(INFO, "Jabber interrupt \n"); 96 DPRINTK(INFO, "Jabber interrupt \n");
@@ -115,64 +111,60 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno,
115 DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n"); 111 DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n");
116 112
117 if (adapter->phy_read 113 if (adapter->phy_read
118 && adapter->phy_read(adapter, portno, 114 && adapter->phy_read(adapter, adapter->portnum,
119 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, 115 NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS,
120 &status) == 0) { 116 &status) == 0) {
121 if (netxen_get_phy_int_link_status_changed(int_src)) { 117 if (netxen_get_phy_int_link_status_changed(int_src)) {
122 if (netxen_get_phy_link(status)) { 118 if (netxen_get_phy_link(status)) {
123 netxen_niu_gbe_init_port(adapter, 119 netxen_niu_gbe_init_port(
124 portno); 120 adapter,
125 printk("%s: %s Link UP\n", 121 adapter->portnum);
122 printk(KERN_INFO "%s: %s Link UP\n",
126 netxen_nic_driver_name, 123 netxen_nic_driver_name,
127 port->netdev->name); 124 adapter->netdev->name);
128 125
129 } else { 126 } else {
130 printk("%s: %s Link DOWN\n", 127 printk(KERN_INFO "%s: %s Link DOWN\n",
131 netxen_nic_driver_name, 128 netxen_nic_driver_name,
132 port->netdev->name); 129 adapter->netdev->name);
133 } 130 }
134 netxen_indicate_link_status(adapter, portno, 131 netxen_indicate_link_status(adapter,
135 netxen_get_phy_link 132 netxen_get_phy_link
136 (status)); 133 (status));
137 } 134 }
138 } 135 }
139 } 136 }
140 if (adapter->enable_phy_interrupts) 137 if (adapter->enable_phy_interrupts)
141 adapter->enable_phy_interrupts(adapter, portno); 138 adapter->enable_phy_interrupts(adapter, adapter->portnum);
142} 139}
143 140
144void netxen_nic_isr_other(struct netxen_adapter *adapter) 141void netxen_nic_isr_other(struct netxen_adapter *adapter)
145{ 142{
146 u32 portno; 143 int portno = adapter->portnum;
147 u32 val, linkup, qg_linksup; 144 u32 val, linkup, qg_linksup;
148 145
149 /* verify the offset */ 146 /* verify the offset */
150 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); 147 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
148 val = val >> adapter->portnum;
151 if (val == adapter->ahw.qg_linksup) 149 if (val == adapter->ahw.qg_linksup)
152 return; 150 return;
153 151
154 qg_linksup = adapter->ahw.qg_linksup; 152 qg_linksup = adapter->ahw.qg_linksup;
155 adapter->ahw.qg_linksup = val; 153 adapter->ahw.qg_linksup = val;
156 DPRINTK(INFO, "link update 0x%08x\n", val); 154 DPRINTK(INFO, "link update 0x%08x\n", val);
157 for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) {
158 linkup = val & 1;
159 if (linkup != (qg_linksup & 1)) {
160 printk(KERN_INFO "%s: %s PORT %d link %s\n",
161 adapter->port[portno]->netdev->name,
162 netxen_nic_driver_name, portno,
163 ((linkup == 0) ? "down" : "up"));
164 netxen_indicate_link_status(adapter, portno, linkup);
165 if (linkup)
166 netxen_nic_set_link_parameters(adapter->
167 port[portno]);
168 155
169 } 156 linkup = val & 1;
170 val = val >> 1;
171 qg_linksup = qg_linksup >> 1;
172 }
173 157
174 adapter->stats.otherints++; 158 if (linkup != (qg_linksup & 1)) {
159 printk(KERN_INFO "%s: %s PORT %d link %s\n",
160 adapter->netdev->name,
161 netxen_nic_driver_name, portno,
162 ((linkup == 0) ? "down" : "up"));
163 netxen_indicate_link_status(adapter, linkup);
164 if (linkup)
165 netxen_nic_set_link_parameters(adapter);
175 166
167 }
176} 168}
177 169
178void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter) 170void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter)
@@ -182,26 +174,27 @@ void netxen_nic_gbe_handle_phy_intr(struct netxen_adapter *adapter)
182 174
183void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter) 175void netxen_nic_xgbe_handle_phy_intr(struct netxen_adapter *adapter)
184{ 176{
185 struct net_device *netdev = adapter->port[0]->netdev; 177 struct net_device *netdev = adapter->netdev;
186 u32 val; 178 u32 val, val1;
187 179
188 /* WINDOW = 1 */ 180 /* WINDOW = 1 */
189 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE)); 181 val = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_XG_STATE));
182 val1 = val & 0xff;
190 183
191 if (adapter->ahw.xg_linkup == 1 && val != XG_LINK_UP) { 184 if (adapter->ahw.xg_linkup == 1 && val1 != XG_LINK_UP) {
192 printk(KERN_INFO "%s: %s NIC Link is down\n", 185 printk(KERN_INFO "%s: %s NIC Link is down\n",
193 netxen_nic_driver_name, netdev->name); 186 netxen_nic_driver_name, netdev->name);
194 adapter->ahw.xg_linkup = 0; 187 adapter->ahw.xg_linkup = 0;
195 /* read twice to clear sticky bits */ 188 /* read twice to clear sticky bits */
196 /* WINDOW = 0 */ 189 /* WINDOW = 0 */
197 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val); 190 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1);
198 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val); 191 netxen_nic_read_w0(adapter, NETXEN_NIU_XG_STATUS, &val1);
199 192
200 if ((val & 0xffb) != 0xffb) { 193 if ((val & 0xffb) != 0xffb) {
201 printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n", 194 printk(KERN_INFO "%s ISR: Sync/Align BAD: 0x%08x\n",
202 netxen_nic_driver_name, val); 195 netxen_nic_driver_name, val1);
203 } 196 }
204 } else if (adapter->ahw.xg_linkup == 0 && val == XG_LINK_UP) { 197 } else if (adapter->ahw.xg_linkup == 0 && val1 == XG_LINK_UP) {
205 printk(KERN_INFO "%s: %s NIC Link is up\n", 198 printk(KERN_INFO "%s: %s NIC Link is up\n",
206 netxen_nic_driver_name, netdev->name); 199 netxen_nic_driver_name, netdev->name);
207 adapter->ahw.xg_linkup = 1; 200 adapter->ahw.xg_linkup = 1;
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index ab25c225a07..514cb393f48 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -36,7 +36,6 @@
36#include "netxen_nic_hw.h" 36#include "netxen_nic_hw.h"
37 37
38#include "netxen_nic.h" 38#include "netxen_nic.h"
39#define DEFINE_GLOBAL_RECV_CRB
40#include "netxen_nic_phan_reg.h" 39#include "netxen_nic_phan_reg.h"
41 40
42#include <linux/dma-mapping.h> 41#include <linux/dma-mapping.h>
@@ -94,6 +93,67 @@ MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
94struct workqueue_struct *netxen_workq; 93struct workqueue_struct *netxen_workq;
95static void netxen_watchdog(unsigned long); 94static void netxen_watchdog(unsigned long);
96 95
96static inline void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
97 uint32_t crb_producer)
98{
99 switch (adapter->portnum) {
100 case 0:
101 writel(crb_producer, NETXEN_CRB_NORMALIZE
102 (adapter, CRB_CMD_PRODUCER_OFFSET));
103 return;
104 case 1:
105 writel(crb_producer, NETXEN_CRB_NORMALIZE
106 (adapter, CRB_CMD_PRODUCER_OFFSET_1));
107 return;
108 case 2:
109 writel(crb_producer, NETXEN_CRB_NORMALIZE
110 (adapter, CRB_CMD_PRODUCER_OFFSET_2));
111 return;
112 case 3:
113 writel(crb_producer, NETXEN_CRB_NORMALIZE
114 (adapter, CRB_CMD_PRODUCER_OFFSET_3));
115 return;
116 default:
117 printk(KERN_WARNING "We tried to update "
118 "CRB_CMD_PRODUCER_OFFSET for invalid "
119 "PCI function id %d\n",
120 adapter->portnum);
121 return;
122 }
123}
124
125static inline void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
126 u32 crb_consumer)
127{
128 switch (adapter->portnum) {
129 case 0:
130 writel(crb_consumer, NETXEN_CRB_NORMALIZE
131 (adapter, CRB_CMD_CONSUMER_OFFSET));
132 return;
133 case 1:
134 writel(crb_consumer, NETXEN_CRB_NORMALIZE
135 (adapter, CRB_CMD_CONSUMER_OFFSET_1));
136 return;
137 case 2:
138 writel(crb_consumer, NETXEN_CRB_NORMALIZE
139 (adapter, CRB_CMD_CONSUMER_OFFSET_2));
140 return;
141 case 3:
142 writel(crb_consumer, NETXEN_CRB_NORMALIZE
143 (adapter, CRB_CMD_CONSUMER_OFFSET_3));
144 return;
145 default:
146 printk(KERN_WARNING "We tried to update "
147 "CRB_CMD_PRODUCER_OFFSET for invalid "
148 "PCI function id %d\n",
149 adapter->portnum);
150 return;
151 }
152}
153
154#define ADAPTER_LIST_SIZE 12
155int netxen_cards_found;
156
97/* 157/*
98 * netxen_nic_probe() 158 * netxen_nic_probe()
99 * 159 *
@@ -111,26 +171,26 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
111{ 171{
112 struct net_device *netdev = NULL; 172 struct net_device *netdev = NULL;
113 struct netxen_adapter *adapter = NULL; 173 struct netxen_adapter *adapter = NULL;
114 struct netxen_port *port = NULL;
115 void __iomem *mem_ptr0 = NULL; 174 void __iomem *mem_ptr0 = NULL;
116 void __iomem *mem_ptr1 = NULL; 175 void __iomem *mem_ptr1 = NULL;
117 void __iomem *mem_ptr2 = NULL; 176 void __iomem *mem_ptr2 = NULL;
118 177
119 u8 __iomem *db_ptr = NULL; 178 u8 __iomem *db_ptr = NULL;
120 unsigned long mem_base, mem_len, db_base, db_len; 179 unsigned long mem_base, mem_len, db_base, db_len;
121 int pci_using_dac, i, err; 180 int pci_using_dac, i = 0, err;
122 int ring; 181 int ring;
123 struct netxen_recv_context *recv_ctx = NULL; 182 struct netxen_recv_context *recv_ctx = NULL;
124 struct netxen_rcv_desc_ctx *rcv_desc = NULL; 183 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
125 struct netxen_cmd_buffer *cmd_buf_arr = NULL; 184 struct netxen_cmd_buffer *cmd_buf_arr = NULL;
126 u64 mac_addr[FLASH_NUM_PORTS + 1]; 185 u64 mac_addr[FLASH_NUM_PORTS + 1];
127 int valid_mac = 0; 186 static int valid_mac = 0;
187 static int netxen_probe_flag;
188 int pci_func_id = PCI_FUNC(pdev->devfn);
128 189
129 printk(KERN_INFO "%s \n", netxen_nic_driver_string); 190 printk(KERN_INFO "%s \n", netxen_nic_driver_string);
130 /* In current scheme, we use only PCI function 0 */ 191 if (pdev->class != 0x020000) {
131 if (PCI_FUNC(pdev->devfn) != 0) { 192 printk(KERN_ERR"NetXen function %d, class %x will not"
132 DPRINTK(ERR, "NetXen function %d will not be enabled.\n", 193 "be enabled.\n",pci_func_id, pdev->class);
133 PCI_FUNC(pdev->devfn));
134 return -ENODEV; 194 return -ENODEV;
135 } 195 }
136 if ((err = pci_enable_device(pdev))) 196 if ((err = pci_enable_device(pdev)))
@@ -157,6 +217,22 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
157 pci_using_dac = 0; 217 pci_using_dac = 0;
158 } 218 }
159 219
220
221 netdev = alloc_etherdev(sizeof(struct netxen_adapter));
222 if(!netdev) {
223 printk(KERN_ERR"%s: Failed to allocate memory for the "
224 "device block.Check system memory resource"
225 " usage.\n", netxen_nic_driver_name);
226 goto err_out_free_res;
227 }
228
229 SET_MODULE_OWNER(netdev);
230 SET_NETDEV_DEV(netdev, &pdev->dev);
231
232 adapter = netdev->priv;
233 memset(adapter, 0 , sizeof(struct netxen_adapter));
234
235 adapter->ahw.pdev = pdev;
160 /* remap phys address */ 236 /* remap phys address */
161 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */ 237 mem_base = pci_resource_start(pdev, 0); /* 0 is for BAR 0 */
162 mem_len = pci_resource_len(pdev, 0); 238 mem_len = pci_resource_len(pdev, 0);
@@ -198,23 +274,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
198 } 274 }
199 DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); 275 DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr);
200 276
201/*
202 * Allocate a adapter structure which will manage all the initialization
203 * as well as the common resources for all ports...
204 * all the ports will have pointer to this adapter as well as Adapter
205 * will have pointers of all the ports structures.
206 */
207
208 /* One adapter structure for all 4 ports.... */
209 adapter = kzalloc(sizeof(struct netxen_adapter), GFP_KERNEL);
210 if (adapter == NULL) {
211 printk(KERN_ERR "%s: Could not allocate adapter memory:%d\n",
212 netxen_nic_driver_name,
213 (int)sizeof(struct netxen_adapter));
214 err = -ENOMEM;
215 goto err_out_dbunmap;
216 }
217
218 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS; 277 adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS;
219 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; 278 adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS;
220 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; 279 adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS;
@@ -222,6 +281,42 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
222 281
223 pci_set_drvdata(pdev, adapter); 282 pci_set_drvdata(pdev, adapter);
224 283
284 adapter->netdev = netdev;
285 adapter->pdev = pdev;
286 adapter->portnum = pci_func_id;
287
288 netdev->open = netxen_nic_open;
289 netdev->stop = netxen_nic_close;
290 netdev->hard_start_xmit = netxen_nic_xmit_frame;
291 netdev->set_multicast_list = netxen_nic_set_multi;
292 netdev->set_mac_address = netxen_nic_set_mac;
293 netdev->change_mtu = netxen_nic_change_mtu;
294 netdev->tx_timeout = netxen_tx_timeout;
295 netdev->watchdog_timeo = HZ;
296
297 netxen_nic_change_mtu(netdev, netdev->mtu);
298
299 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
300 netdev->poll = netxen_nic_poll;
301 netdev->weight = NETXEN_NETDEV_WEIGHT;
302#ifdef CONFIG_NET_POLL_CONTROLLER
303 netdev->poll_controller = netxen_nic_poll_controller;
304#endif
305 /* ScatterGather support */
306 netdev->features = NETIF_F_SG;
307 netdev->features |= NETIF_F_IP_CSUM;
308 netdev->features |= NETIF_F_TSO;
309
310 if (pci_using_dac)
311 netdev->features |= NETIF_F_HIGHDMA;
312
313 if (pci_enable_msi(pdev)) {
314 adapter->flags &= ~NETXEN_NIC_MSI_ENABLED;
315 printk(KERN_WARNING "%s: unable to allocate MSI interrupt"
316 " error\n", netxen_nic_driver_name);
317 } else
318 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
319
225 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); 320 cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE);
226 if (cmd_buf_arr == NULL) { 321 if (cmd_buf_arr == NULL) {
227 printk(KERN_ERR 322 printk(KERN_ERR
@@ -288,9 +383,11 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
288 spin_lock_init(&adapter->lock); 383 spin_lock_init(&adapter->lock);
289 netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */ 384 netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */
290#ifdef CONFIG_IA64 385#ifdef CONFIG_IA64
291 netxen_pinit_from_rom(adapter, 0); 386 if(netxen_probe_flag == 0) {
292 udelay(500); 387 netxen_pinit_from_rom(adapter, 0);
293 netxen_load_firmware(adapter); 388 udelay(500);
389 netxen_load_firmware(adapter);
390 }
294#endif 391#endif
295 392
296 /* 393 /*
@@ -304,6 +401,10 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
304 */ 401 */
305 netxen_initialize_adapter_hw(adapter); /* initialize the adapter */ 402 netxen_initialize_adapter_hw(adapter); /* initialize the adapter */
306 403
404 if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ)
405 if (pci_func_id >= 2)
406 adapter->portnum = pci_func_id - 2;
407
307 netxen_initialize_adapter_ops(adapter); 408 netxen_initialize_adapter_ops(adapter);
308 409
309 init_timer(&adapter->watchdog_timer); 410 init_timer(&adapter->watchdog_timer);
@@ -315,12 +416,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
315 adapter->proc_cmd_buf_counter = 0; 416 adapter->proc_cmd_buf_counter = 0;
316 adapter->ahw.revision_id = nx_p2_id; 417 adapter->ahw.revision_id = nx_p2_id;
317 418
318 if (pci_enable_msi(pdev)) { 419 netxen_nic_update_cmd_producer(adapter, 0);
319 adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; 420 netxen_nic_update_cmd_consumer(adapter, 0);
320 printk(KERN_WARNING "%s: unable to allocate MSI interrupt"
321 " error\n", netxen_nic_driver_name);
322 } else
323 adapter->flags |= NETXEN_NIC_MSI_ENABLED;
324 421
325 if (netxen_is_flash_supported(adapter) == 0 && 422 if (netxen_is_flash_supported(adapter) == 0 &&
326 netxen_get_flash_mac_addr(adapter, mac_addr) == 0) 423 netxen_get_flash_mac_addr(adapter, mac_addr) == 0)
@@ -328,6 +425,34 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
328 else 425 else
329 valid_mac = 0; 426 valid_mac = 0;
330 427
428 if (valid_mac) {
429 unsigned char *p = (unsigned char *)&mac_addr[i];
430 netdev->dev_addr[0] = *(p + 5);
431 netdev->dev_addr[1] = *(p + 4);
432 netdev->dev_addr[2] = *(p + 3);
433 netdev->dev_addr[3] = *(p + 2);
434 netdev->dev_addr[4] = *(p + 1);
435 netdev->dev_addr[5] = *(p + 0);
436
437 memcpy(netdev->perm_addr, netdev->dev_addr,
438 netdev->addr_len);
439 if (!is_valid_ether_addr(netdev->perm_addr)) {
440 printk(KERN_ERR "%s: Bad MAC address "
441 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
442 netxen_nic_driver_name,
443 netdev->dev_addr[0],
444 netdev->dev_addr[1],
445 netdev->dev_addr[2],
446 netdev->dev_addr[3],
447 netdev->dev_addr[4],
448 netdev->dev_addr[5]);
449 } else {
450 if (adapter->macaddr_set)
451 adapter->macaddr_set(adapter,
452 netdev->dev_addr);
453 }
454 }
455
331 /* 456 /*
332 * Initialize all the CRB registers here. 457 * Initialize all the CRB registers here.
333 */ 458 */
@@ -337,140 +462,62 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
337 462
338 /* do this before waking up pegs so that we have valid dummy dma addr */ 463 /* do this before waking up pegs so that we have valid dummy dma addr */
339 err = netxen_initialize_adapter_offload(adapter); 464 err = netxen_initialize_adapter_offload(adapter);
340 if (err) { 465 if (err)
341 goto err_out_free_dev; 466 goto err_out_free_dev;
342 }
343
344 /* Unlock the HW, prompting the boot sequence */
345 writel(1,
346 NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
347
348 /* Handshake with the card before we register the devices. */
349 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
350
351 /* initialize the all the ports */
352 adapter->active_ports = 0;
353
354 for (i = 0; i < adapter->ahw.max_ports; i++) {
355 netdev = alloc_etherdev(sizeof(struct netxen_port));
356 if (!netdev) {
357 printk(KERN_ERR "%s: could not allocate netdev for port"
358 " %d\n", netxen_nic_driver_name, i + 1);
359 goto err_out_free_dev;
360 }
361 467
362 SET_MODULE_OWNER(netdev); 468 if (netxen_probe_flag == 0) {
363 SET_NETDEV_DEV(netdev, &pdev->dev); 469 /* Unlock the HW, prompting the boot sequence */
364 470 writel(1,
365 port = netdev_priv(netdev); 471 NETXEN_CRB_NORMALIZE(adapter,
366 port->netdev = netdev; 472 NETXEN_ROMUSB_GLB_PEGTUNE_DONE));
367 port->pdev = pdev; 473 /* Handshake with the card before we register the devices. */
368 port->adapter = adapter; 474 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
369 port->portnum = i; /* Gigabit port number from 0-3 */ 475 }
370
371 netdev->open = netxen_nic_open;
372 netdev->stop = netxen_nic_close;
373 netdev->hard_start_xmit = netxen_nic_xmit_frame;
374 netdev->get_stats = netxen_nic_get_stats;
375 netdev->set_multicast_list = netxen_nic_set_multi;
376 netdev->set_mac_address = netxen_nic_set_mac;
377 netdev->change_mtu = netxen_nic_change_mtu;
378 netdev->tx_timeout = netxen_tx_timeout;
379 netdev->watchdog_timeo = HZ;
380
381 netxen_nic_change_mtu(netdev, netdev->mtu);
382
383 SET_ETHTOOL_OPS(netdev, &netxen_nic_ethtool_ops);
384 netdev->poll = netxen_nic_poll;
385 netdev->weight = NETXEN_NETDEV_WEIGHT;
386#ifdef CONFIG_NET_POLL_CONTROLLER
387 netdev->poll_controller = netxen_nic_poll_controller;
388#endif
389 /* ScatterGather support */
390 netdev->features = NETIF_F_SG;
391 netdev->features |= NETIF_F_IP_CSUM;
392 netdev->features |= NETIF_F_TSO;
393
394 if (pci_using_dac)
395 netdev->features |= NETIF_F_HIGHDMA;
396
397 if (valid_mac) {
398 unsigned char *p = (unsigned char *)&mac_addr[i];
399 netdev->dev_addr[0] = *(p + 5);
400 netdev->dev_addr[1] = *(p + 4);
401 netdev->dev_addr[2] = *(p + 3);
402 netdev->dev_addr[3] = *(p + 2);
403 netdev->dev_addr[4] = *(p + 1);
404 netdev->dev_addr[5] = *(p + 0);
405
406 memcpy(netdev->perm_addr, netdev->dev_addr,
407 netdev->addr_len);
408 if (!is_valid_ether_addr(netdev->perm_addr)) {
409 printk(KERN_ERR "%s: Bad MAC address "
410 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
411 netxen_nic_driver_name,
412 netdev->dev_addr[0],
413 netdev->dev_addr[1],
414 netdev->dev_addr[2],
415 netdev->dev_addr[3],
416 netdev->dev_addr[4],
417 netdev->dev_addr[5]);
418 } else {
419 if (adapter->macaddr_set)
420 adapter->macaddr_set(port,
421 netdev->dev_addr);
422 }
423 }
424 INIT_WORK(&port->tx_timeout_task, netxen_tx_timeout_task);
425 netif_carrier_off(netdev);
426 netif_stop_queue(netdev);
427 476
428 if ((err = register_netdev(netdev))) { 477 if(netxen_probe_flag == 0) {
429 printk(KERN_ERR "%s: register_netdev failed port #%d" 478 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
430 " aborting\n", netxen_nic_driver_name, i + 1); 479 netxen_pinit_from_rom(adapter, 0);
431 err = -EIO; 480 udelay(500);
432 free_netdev(netdev); 481 netxen_load_firmware(adapter);
433 goto err_out_free_dev; 482 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
434 }
435 adapter->port_count++;
436 adapter->port[i] = port;
437 } 483 }
438 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
439 netxen_pinit_from_rom(adapter, 0);
440 udelay(500);
441 netxen_load_firmware(adapter);
442 netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
443 /* 484 /*
444 * delay a while to ensure that the Pegs are up & running. 485 * delay a while to ensure that the Pegs are up & running.
445 * Otherwise, we might see some flaky behaviour. 486 * Otherwise, we might see some flaky behaviour.
446 */ 487 */
447 udelay(100); 488 udelay(100);
489 INIT_WORK(&adapter->tx_timeout_task, netxen_tx_timeout_task);
490 netif_carrier_off(netdev);
491 netif_stop_queue(netdev);
492
493 if((err = register_netdev(netdev)))
494 DPRINTK(1, ERR, "register_netdev failed port #%d"
495 " aborting\n", i+1);
448 496
449 switch (adapter->ahw.board_type) { 497 switch (adapter->ahw.board_type) {
450 case NETXEN_NIC_GBE: 498 case NETXEN_NIC_GBE:
451 printk("%s: QUAD GbE board initialized\n", 499 printk(KERN_INFO "%s: QUAD GbE board initialized\n",
452 netxen_nic_driver_name); 500 netxen_nic_driver_name);
453 break; 501 break;
454 502
455 case NETXEN_NIC_XGBE: 503 case NETXEN_NIC_XGBE:
456 printk("%s: XGbE board initialized\n", netxen_nic_driver_name); 504 printk(KERN_INFO "%s: XGbE board initialized\n",
457 break; 505 netxen_nic_driver_name);
506 break;
458 } 507 }
459 508
460 adapter->driver_mismatch = 0; 509 adapter->driver_mismatch = 0;
510 if(netxen_probe_flag == 0)
511 netxen_probe_flag ++;
461 512
462 return 0; 513 return 0;
463 514
464 err_out_free_dev: 515 err_out_free_dev:
465 if (adapter->flags & NETXEN_NIC_MSI_ENABLED) 516 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
466 pci_disable_msi(pdev); 517 pci_disable_msi(pdev);
467 for (i = 0; i < adapter->port_count; i++) { 518
468 port = adapter->port[i]; 519 unregister_netdev(adapter->netdev);
469 if ((port) && (port->netdev)) { 520 free_netdev(adapter->netdev);
470 unregister_netdev(port->netdev);
471 free_netdev(port->netdev);
472 }
473 }
474 521
475 netxen_free_adapter_offload(adapter); 522 netxen_free_adapter_offload(adapter);
476 523
@@ -491,7 +538,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
491 pci_set_drvdata(pdev, NULL); 538 pci_set_drvdata(pdev, NULL);
492 kfree(adapter); 539 kfree(adapter);
493 540
494 err_out_dbunmap:
495 if (db_ptr) 541 if (db_ptr)
496 iounmap(db_ptr); 542 iounmap(db_ptr);
497 543
@@ -513,35 +559,32 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
513static void __devexit netxen_nic_remove(struct pci_dev *pdev) 559static void __devexit netxen_nic_remove(struct pci_dev *pdev)
514{ 560{
515 struct netxen_adapter *adapter; 561 struct netxen_adapter *adapter;
516 struct netxen_port *port; 562 struct net_device *netdev;
517 struct netxen_rx_buffer *buffer; 563 struct netxen_rx_buffer *buffer;
518 struct netxen_recv_context *recv_ctx; 564 struct netxen_recv_context *recv_ctx;
519 struct netxen_rcv_desc_ctx *rcv_desc; 565 struct netxen_rcv_desc_ctx *rcv_desc;
520 int i; 566 int i;
521 int ctxid, ring; 567 int ctxid, ring;
522 568
523 adapter = pci_get_drvdata(pdev); 569 netdev = pci_get_drvdata(pdev);
570 adapter = netdev_priv(netdev);
524 if (adapter == NULL) 571 if (adapter == NULL)
525 return; 572 return;
526 573
574 if (adapter->stop_port)
575 adapter->stop_port(adapter);
576
527 if (adapter->irq) 577 if (adapter->irq)
528 free_irq(adapter->irq, adapter); 578 free_irq(adapter->irq, adapter);
529 netxen_nic_stop_all_ports(adapter);
530 /* leave the hw in the same state as reboot */ 579 /* leave the hw in the same state as reboot */
531 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); 580 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE));
532 netxen_pinit_from_rom(adapter, 0); 581 netxen_pinit_from_rom(adapter, 0);
533 udelay(500);
534 netxen_load_firmware(adapter); 582 netxen_load_firmware(adapter);
535 netxen_free_adapter_offload(adapter); 583 netxen_free_adapter_offload(adapter);
536 584
537 mdelay(1000); /* Delay for a while to drain the DMA engines */ 585 udelay(500);
538 for (i = 0; i < adapter->port_count; i++) { 586 unregister_netdev(netdev);
539 port = adapter->port[i]; 587 free_netdev(netdev);
540 if ((port) && (port->netdev)) {
541 unregister_netdev(port->netdev);
542 free_netdev(port->netdev);
543 }
544 }
545 588
546 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED)) 589 if ((adapter->flags & NETXEN_NIC_MSI_ENABLED))
547 pci_disable_msi(pdev); 590 pci_disable_msi(pdev);
@@ -585,8 +628,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
585 */ 628 */
586static int netxen_nic_open(struct net_device *netdev) 629static int netxen_nic_open(struct net_device *netdev)
587{ 630{
588 struct netxen_port *port = netdev_priv(netdev); 631 struct netxen_adapter *adapter = (struct netxen_adapter *)netdev->priv;
589 struct netxen_adapter *adapter = port->adapter;
590 int err = 0; 632 int err = 0;
591 int ctx, ring; 633 int ctx, ring;
592 634
@@ -610,9 +652,9 @@ static int netxen_nic_open(struct net_device *netdev)
610 return err; 652 return err;
611 } 653 }
612 if (adapter->init_port 654 if (adapter->init_port
613 && adapter->init_port(adapter, port->portnum) != 0) { 655 && adapter->init_port(adapter, adapter->portnum) != 0) {
614 printk(KERN_ERR "%s: Failed to initialize port %d\n", 656 printk(KERN_ERR "%s: Failed to initialize port %d\n",
615 netxen_nic_driver_name, port->portnum); 657 netxen_nic_driver_name, adapter->portnum);
616 netxen_free_hw_resources(adapter); 658 netxen_free_hw_resources(adapter);
617 return -EIO; 659 return -EIO;
618 } 660 }
@@ -632,23 +674,20 @@ static int netxen_nic_open(struct net_device *netdev)
632 674
633 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; 675 adapter->is_up = NETXEN_ADAPTER_UP_MAGIC;
634 } 676 }
635 adapter->active_ports++; 677 if (!adapter->driver_mismatch)
636 if (adapter->active_ports == 1) { 678 mod_timer(&adapter->watchdog_timer, jiffies);
637 if (!adapter->driver_mismatch)
638 mod_timer(&adapter->watchdog_timer, jiffies);
639 679
640 netxen_nic_enable_int(adapter); 680 netxen_nic_enable_int(adapter);
641 }
642 681
643 /* Done here again so that even if phantom sw overwrote it, 682 /* Done here again so that even if phantom sw overwrote it,
644 * we set it */ 683 * we set it */
645 if (adapter->macaddr_set) 684 if (adapter->macaddr_set)
646 adapter->macaddr_set(port, netdev->dev_addr); 685 adapter->macaddr_set(adapter, netdev->dev_addr);
647 netxen_nic_set_link_parameters(port); 686 netxen_nic_set_link_parameters(adapter);
648 687
649 netxen_nic_set_multi(netdev); 688 netxen_nic_set_multi(netdev);
650 if (adapter->set_mtu) 689 if (adapter->set_mtu)
651 adapter->set_mtu(port, netdev->mtu); 690 adapter->set_mtu(adapter, netdev->mtu);
652 691
653 if (!adapter->driver_mismatch) 692 if (!adapter->driver_mismatch)
654 netif_start_queue(netdev); 693 netif_start_queue(netdev);
@@ -661,8 +700,7 @@ static int netxen_nic_open(struct net_device *netdev)
661 */ 700 */
662static int netxen_nic_close(struct net_device *netdev) 701static int netxen_nic_close(struct net_device *netdev)
663{ 702{
664 struct netxen_port *port = netdev_priv(netdev); 703 struct netxen_adapter *adapter = netdev_priv(netdev);
665 struct netxen_adapter *adapter = port->adapter;
666 int i, j; 704 int i, j;
667 struct netxen_cmd_buffer *cmd_buff; 705 struct netxen_cmd_buffer *cmd_buff;
668 struct netxen_skb_frag *buffrag; 706 struct netxen_skb_frag *buffrag;
@@ -670,47 +708,43 @@ static int netxen_nic_close(struct net_device *netdev)
670 netif_carrier_off(netdev); 708 netif_carrier_off(netdev);
671 netif_stop_queue(netdev); 709 netif_stop_queue(netdev);
672 710
673 adapter->active_ports--; 711 netxen_nic_disable_int(adapter);
674 712 if (adapter->irq)
675 if (!adapter->active_ports) { 713 free_irq(adapter->irq, adapter);
676 netxen_nic_disable_int(adapter); 714
677 cmd_buff = adapter->cmd_buf_arr; 715 cmd_buff = adapter->cmd_buf_arr;
678 for (i = 0; i < adapter->max_tx_desc_count; i++) { 716 for (i = 0; i < adapter->max_tx_desc_count; i++) {
679 buffrag = cmd_buff->frag_array; 717 buffrag = cmd_buff->frag_array;
718 if (buffrag->dma) {
719 pci_unmap_single(adapter->pdev, buffrag->dma,
720 buffrag->length, PCI_DMA_TODEVICE);
721 buffrag->dma = (u64) NULL;
722 }
723 for (j = 0; j < cmd_buff->frag_count; j++) {
724 buffrag++;
680 if (buffrag->dma) { 725 if (buffrag->dma) {
681 pci_unmap_single(port->pdev, buffrag->dma, 726 pci_unmap_page(adapter->pdev, buffrag->dma,
682 buffrag->length, 727 buffrag->length,
683 PCI_DMA_TODEVICE); 728 PCI_DMA_TODEVICE);
684 buffrag->dma = (u64) NULL; 729 buffrag->dma = (u64) NULL;
685 } 730 }
686 for (j = 0; j < cmd_buff->frag_count; j++) {
687 buffrag++;
688 if (buffrag->dma) {
689 pci_unmap_page(port->pdev,
690 buffrag->dma,
691 buffrag->length,
692 PCI_DMA_TODEVICE);
693 buffrag->dma = (u64) NULL;
694 }
695 }
696 /* Free the skb we received in netxen_nic_xmit_frame */
697 if (cmd_buff->skb) {
698 dev_kfree_skb_any(cmd_buff->skb);
699 cmd_buff->skb = NULL;
700 }
701 cmd_buff++;
702 } 731 }
703 FLUSH_SCHEDULED_WORK(); 732 /* Free the skb we received in netxen_nic_xmit_frame */
704 del_timer_sync(&adapter->watchdog_timer); 733 if (cmd_buff->skb) {
734 dev_kfree_skb_any(cmd_buff->skb);
735 cmd_buff->skb = NULL;
736 }
737 cmd_buff++;
705 } 738 }
739 FLUSH_SCHEDULED_WORK();
740 del_timer_sync(&adapter->watchdog_timer);
706 741
707 return 0; 742 return 0;
708} 743}
709 744
710static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) 745static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
711{ 746{
712 struct netxen_port *port = netdev_priv(netdev); 747 struct netxen_adapter *adapter = netdev_priv(netdev);
713 struct netxen_adapter *adapter = port->adapter;
714 struct netxen_hardware_context *hw = &adapter->ahw; 748 struct netxen_hardware_context *hw = &adapter->ahw;
715 unsigned int first_seg_len = skb->len - skb->data_len; 749 unsigned int first_seg_len = skb->len - skb->data_len;
716 struct netxen_skb_frag *buffrag; 750 struct netxen_skb_frag *buffrag;
@@ -728,12 +762,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
728 u32 last_cmd_consumer = 0; 762 u32 last_cmd_consumer = 0;
729 int no_of_desc; 763 int no_of_desc;
730 764
731 port->stats.xmitcalled++; 765 adapter->stats.xmitcalled++;
732 frag_count = skb_shinfo(skb)->nr_frags + 1; 766 frag_count = skb_shinfo(skb)->nr_frags + 1;
733 767
734 if (unlikely(skb->len <= 0)) { 768 if (unlikely(skb->len <= 0)) {
735 dev_kfree_skb_any(skb); 769 dev_kfree_skb_any(skb);
736 port->stats.badskblen++; 770 adapter->stats.badskblen++;
737 return NETDEV_TX_OK; 771 return NETDEV_TX_OK;
738 } 772 }
739 773
@@ -742,7 +776,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
742 "too large, can handle only %d frags\n", 776 "too large, can handle only %d frags\n",
743 netxen_nic_driver_name, netdev->name, 777 netxen_nic_driver_name, netdev->name,
744 frag_count, MAX_BUFFERS_PER_CMD); 778 frag_count, MAX_BUFFERS_PER_CMD);
745 port->stats.txdropped++; 779 adapter->stats.txdropped++;
746 if ((++dropped_packet & 0xff) == 0xff) 780 if ((++dropped_packet & 0xff) == 0xff)
747 printk("%s: %s droppped packets = %d\n", 781 printk("%s: %s droppped packets = %d\n",
748 netxen_nic_driver_name, netdev->name, 782 netxen_nic_driver_name, netdev->name,
@@ -759,7 +793,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
759 */ 793 */
760 retry_getting_window: 794 retry_getting_window:
761 spin_lock_bh(&adapter->tx_lock); 795 spin_lock_bh(&adapter->tx_lock);
762 if (adapter->total_threads == MAX_XMIT_PRODUCERS) { 796 if (adapter->total_threads >= MAX_XMIT_PRODUCERS) {
763 spin_unlock_bh(&adapter->tx_lock); 797 spin_unlock_bh(&adapter->tx_lock);
764 /* 798 /*
765 * Yield CPU 799 * Yield CPU
@@ -792,15 +826,8 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
792 if ((k + no_of_desc) >= 826 if ((k + no_of_desc) >=
793 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : 827 ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count :
794 last_cmd_consumer)) { 828 last_cmd_consumer)) {
795 port->stats.nocmddescriptor++;
796 DPRINTK(ERR, "No command descriptors available,"
797 " producer = %d, consumer = %d count=%llu,"
798 " dropping packet\n", producer,
799 adapter->last_cmd_consumer,
800 port->stats.nocmddescriptor);
801
802 netif_stop_queue(netdev); 829 netif_stop_queue(netdev);
803 port->flags |= NETXEN_NETDEV_STATUS; 830 adapter->flags |= NETXEN_NETDEV_STATUS;
804 spin_unlock_bh(&adapter->tx_lock); 831 spin_unlock_bh(&adapter->tx_lock);
805 return NETDEV_TX_BUSY; 832 return NETDEV_TX_BUSY;
806 } 833 }
@@ -828,16 +855,16 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
828 pbuf->skb = skb; 855 pbuf->skb = skb;
829 pbuf->cmd = TX_ETHER_PKT; 856 pbuf->cmd = TX_ETHER_PKT;
830 pbuf->frag_count = frag_count; 857 pbuf->frag_count = frag_count;
831 pbuf->port = port->portnum; 858 pbuf->port = adapter->portnum;
832 buffrag = &pbuf->frag_array[0]; 859 buffrag = &pbuf->frag_array[0];
833 buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len, 860 buffrag->dma = pci_map_single(adapter->pdev, skb->data, first_seg_len,
834 PCI_DMA_TODEVICE); 861 PCI_DMA_TODEVICE);
835 buffrag->length = first_seg_len; 862 buffrag->length = first_seg_len;
836 netxen_set_cmd_desc_totallength(hwdesc, skb->len); 863 netxen_set_cmd_desc_totallength(hwdesc, skb->len);
837 netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); 864 netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count);
838 netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT); 865 netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT);
839 866
840 netxen_set_cmd_desc_port(hwdesc, port->portnum); 867 netxen_set_cmd_desc_port(hwdesc, adapter->portnum);
841 hwdesc->buffer1_length = cpu_to_le16(first_seg_len); 868 hwdesc->buffer1_length = cpu_to_le16(first_seg_len);
842 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); 869 hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma);
843 870
@@ -860,7 +887,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
860 offset = frag->page_offset; 887 offset = frag->page_offset;
861 888
862 temp_len = len; 889 temp_len = len;
863 temp_dma = pci_map_page(port->pdev, frag->page, offset, 890 temp_dma = pci_map_page(adapter->pdev, frag->page, offset,
864 len, PCI_DMA_TODEVICE); 891 len, PCI_DMA_TODEVICE);
865 892
866 buffrag++; 893 buffrag++;
@@ -928,20 +955,19 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
928 } 955 }
929 } 956 }
930 spin_lock_bh(&adapter->tx_lock); 957 spin_lock_bh(&adapter->tx_lock);
931 port->stats.txbytes += 958 adapter->stats.txbytes +=
932 netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]); 959 netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]);
933 /* Code to update the adapter considering how many producer threads 960 /* Code to update the adapter considering how many producer threads
934 are currently working */ 961 are currently working */
935 if ((--adapter->num_threads) == 0) { 962 if ((--adapter->num_threads) == 0) {
936 /* This is the last thread */ 963 /* This is the last thread */
937 u32 crb_producer = adapter->cmd_producer; 964 u32 crb_producer = adapter->cmd_producer;
938 writel(crb_producer, 965 netxen_nic_update_cmd_producer(adapter, crb_producer);
939 NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET));
940 wmb(); 966 wmb();
941 adapter->total_threads = 0; 967 adapter->total_threads = 0;
942 } 968 }
943 969
944 port->stats.xmitfinished++; 970 adapter->stats.xmitfinished++;
945 spin_unlock_bh(&adapter->tx_lock); 971 spin_unlock_bh(&adapter->tx_lock);
946 972
947 netdev->trans_start = jiffies; 973 netdev->trans_start = jiffies;
@@ -961,25 +987,25 @@ static void netxen_watchdog(unsigned long v)
961 987
962static void netxen_tx_timeout(struct net_device *netdev) 988static void netxen_tx_timeout(struct net_device *netdev)
963{ 989{
964 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); 990 struct netxen_adapter *adapter = (struct netxen_adapter *)
965 991 netdev_priv(netdev);
966 SCHEDULE_WORK(&port->tx_timeout_task); 992 SCHEDULE_WORK(&adapter->tx_timeout_task);
967} 993}
968 994
969static void netxen_tx_timeout_task(struct work_struct *work) 995static void netxen_tx_timeout_task(struct work_struct *work)
970{ 996{
971 struct netxen_port *port = 997 struct netxen_adapter *adapter =
972 container_of(work, struct netxen_port, tx_timeout_task); 998 container_of(work, struct netxen_adapter, tx_timeout_task);
973 struct net_device *netdev = port->netdev; 999 struct net_device *netdev = adapter->netdev;
974 unsigned long flags; 1000 unsigned long flags;
975 1001
976 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n", 1002 printk(KERN_ERR "%s %s: transmit timeout, resetting.\n",
977 netxen_nic_driver_name, netdev->name); 1003 netxen_nic_driver_name, netdev->name);
978 1004
979 spin_lock_irqsave(&port->adapter->lock, flags); 1005 spin_lock_irqsave(&adapter->lock, flags);
980 netxen_nic_close(netdev); 1006 netxen_nic_close(netdev);
981 netxen_nic_open(netdev); 1007 netxen_nic_open(netdev);
982 spin_unlock_irqrestore(&port->adapter->lock, flags); 1008 spin_unlock_irqrestore(&adapter->lock, flags);
983 netdev->trans_start = jiffies; 1009 netdev->trans_start = jiffies;
984 netif_wake_queue(netdev); 1010 netif_wake_queue(netdev);
985} 1011}
@@ -991,16 +1017,14 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
991 1017
992 DPRINTK(INFO, "Entered handle ISR\n"); 1018 DPRINTK(INFO, "Entered handle ISR\n");
993 1019
994 adapter->stats.ints++;
995
996 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { 1020 if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) {
997 int count = 0; 1021 int count = 0;
998 u32 mask; 1022 u32 mask;
999 mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR)); 1023 u32 our_int = 0;
1000 if ((mask & 0x80) == 0) { 1024 our_int = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_INT_VECTOR));
1001 /* not our interrupt */ 1025 /* not our interrupt */
1026 if ((our_int & (0x80 << adapter->portnum)) == 0)
1002 return ret; 1027 return ret;
1003 }
1004 netxen_nic_disable_int(adapter); 1028 netxen_nic_disable_int(adapter);
1005 /* Window = 0 or 1 */ 1029 /* Window = 0 or 1 */
1006 do { 1030 do {
@@ -1012,7 +1036,6 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
1012 printk("Could not disable interrupt completely\n"); 1036 printk("Could not disable interrupt completely\n");
1013 1037
1014 } 1038 }
1015 adapter->stats.hostints++;
1016 1039
1017 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) { 1040 if (netxen_nic_rx_has_work(adapter) || netxen_nic_tx_has_work(adapter)) {
1018 if (netif_rx_schedule_prep(netdev)) { 1041 if (netif_rx_schedule_prep(netdev)) {
@@ -1046,33 +1069,24 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev)
1046irqreturn_t netxen_intr(int irq, void *data) 1069irqreturn_t netxen_intr(int irq, void *data)
1047{ 1070{
1048 struct netxen_adapter *adapter; 1071 struct netxen_adapter *adapter;
1049 struct netxen_port *port;
1050 struct net_device *netdev; 1072 struct net_device *netdev;
1051 int i;
1052 1073
1053 if (unlikely(!irq)) { 1074 if (unlikely(!irq)) {
1054 return IRQ_NONE; /* Not our interrupt */ 1075 return IRQ_NONE; /* Not our interrupt */
1055 } 1076 }
1056 1077
1057 adapter = (struct netxen_adapter *)data; 1078 adapter = (struct netxen_adapter *)data;
1058 for (i = 0; i < adapter->ahw.max_ports; i++) { 1079 netdev = adapter->netdev;
1059 port = adapter->port[i]; 1080 /* process our status queue (for all 4 ports) */
1060 netdev = port->netdev; 1081 if (netif_running(netdev))
1061 1082 netxen_handle_int(adapter, netdev);
1062 /* process our status queue (for all 4 ports) */
1063 if (netif_running(netdev)) {
1064 netxen_handle_int(adapter, netdev);
1065 break;
1066 }
1067 }
1068 1083
1069 return IRQ_HANDLED; 1084 return IRQ_HANDLED;
1070} 1085}
1071 1086
1072static int netxen_nic_poll(struct net_device *netdev, int *budget) 1087static int netxen_nic_poll(struct net_device *netdev, int *budget)
1073{ 1088{
1074 struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); 1089 struct netxen_adapter *adapter = netdev_priv(netdev);
1075 struct netxen_adapter *adapter = port->adapter;
1076 int work_to_do = min(*budget, netdev->quota); 1090 int work_to_do = min(*budget, netdev->quota);
1077 int done = 1; 1091 int done = 1;
1078 int ctx; 1092 int ctx;
@@ -1080,7 +1094,6 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
1080 int work_done = 0; 1094 int work_done = 0;
1081 1095
1082 DPRINTK(INFO, "polling for %d descriptors\n", *budget); 1096 DPRINTK(INFO, "polling for %d descriptors\n", *budget);
1083 port->stats.polled++;
1084 1097
1085 work_done = 0; 1098 work_done = 0;
1086 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { 1099 for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) {
@@ -1124,8 +1137,7 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget)
1124#ifdef CONFIG_NET_POLL_CONTROLLER 1137#ifdef CONFIG_NET_POLL_CONTROLLER
1125static void netxen_nic_poll_controller(struct net_device *netdev) 1138static void netxen_nic_poll_controller(struct net_device *netdev)
1126{ 1139{
1127 struct netxen_port *port = netdev_priv(netdev); 1140 struct netxen_adapter *adapter = netdev_priv(netdev);
1128 struct netxen_adapter *adapter = port->adapter;
1129 disable_irq(adapter->irq); 1141 disable_irq(adapter->irq);
1130 netxen_intr(adapter->irq, adapter); 1142 netxen_intr(adapter->irq, adapter);
1131 enable_irq(adapter->irq); 1143 enable_irq(adapter->irq);
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c
index d5d95074e56..f6befc32aa5 100644
--- a/drivers/net/netxen/netxen_nic_niu.c
+++ b/drivers/net/netxen/netxen_nic_niu.c
@@ -610,13 +610,12 @@ int netxen_niu_macaddr_get(struct netxen_adapter *adapter,
610 * Set the station MAC address. 610 * Set the station MAC address.
611 * Note that the passed-in value must already be in network byte order. 611 * Note that the passed-in value must already be in network byte order.
612 */ 612 */
613int netxen_niu_macaddr_set(struct netxen_port *port, 613int netxen_niu_macaddr_set(struct netxen_adapter *adapter,
614 netxen_ethernet_macaddr_t addr) 614 netxen_ethernet_macaddr_t addr)
615{ 615{
616 u8 temp[4]; 616 u8 temp[4];
617 u32 val; 617 u32 val;
618 struct netxen_adapter *adapter = port->adapter; 618 int phy = adapter->portnum;
619 int phy = port->portnum;
620 unsigned char mac_addr[6]; 619 unsigned char mac_addr[6];
621 int i; 620 int i;
622 621
@@ -642,7 +641,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port,
642 641
643 if (i == 10) { 642 if (i == 10) {
644 printk(KERN_ERR "%s: cannot set Mac addr for %s\n", 643 printk(KERN_ERR "%s: cannot set Mac addr for %s\n",
645 netxen_nic_driver_name, port->netdev->name); 644 netxen_nic_driver_name, adapter->netdev->name);
646 printk(KERN_ERR "MAC address set: " 645 printk(KERN_ERR "MAC address set: "
647 "%02x:%02x:%02x:%02x:%02x:%02x.\n", 646 "%02x:%02x:%02x:%02x:%02x:%02x.\n",
648 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); 647 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
@@ -735,12 +734,10 @@ int netxen_niu_enable_gbe_port(struct netxen_adapter *adapter,
735} 734}
736 735
737/* Disable a GbE interface */ 736/* Disable a GbE interface */
738int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port) 737int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter)
739{ 738{
740 __u32 mac_cfg0; 739 __u32 mac_cfg0;
741 740 int port = adapter->portnum;
742 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
743 return -EINVAL;
744 741
745 mac_cfg0 = 0; 742 mac_cfg0 = 0;
746 netxen_gb_soft_reset(mac_cfg0); 743 netxen_gb_soft_reset(mac_cfg0);
@@ -751,13 +748,10 @@ int netxen_niu_disable_gbe_port(struct netxen_adapter *adapter, int port)
751} 748}
752 749
753/* Disable an XG interface */ 750/* Disable an XG interface */
754int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port) 751int netxen_niu_disable_xg_port(struct netxen_adapter *adapter)
755{ 752{
756 __u32 mac_cfg; 753 __u32 mac_cfg;
757 754
758 if (port != 0)
759 return -EINVAL;
760
761 mac_cfg = 0; 755 mac_cfg = 0;
762 netxen_xg_soft_reset(mac_cfg); 756 netxen_xg_soft_reset(mac_cfg);
763 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0, 757 if (netxen_nic_hw_write_wx(adapter, NETXEN_NIU_XGE_CONFIG_0,
@@ -767,10 +761,11 @@ int netxen_niu_disable_xg_port(struct netxen_adapter *adapter, int port)
767} 761}
768 762
769/* Set promiscuous mode for a GbE interface */ 763/* Set promiscuous mode for a GbE interface */
770int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port, 764int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter,
771 netxen_niu_prom_mode_t mode) 765 netxen_niu_prom_mode_t mode)
772{ 766{
773 __u32 reg; 767 __u32 reg;
768 int port = adapter->portnum;
774 769
775 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) 770 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
776 return -EINVAL; 771 return -EINVAL;
@@ -824,12 +819,11 @@ int netxen_niu_set_promiscuous_mode(struct netxen_adapter *adapter, int port,
824 * Set the MAC address for an XG port 819 * Set the MAC address for an XG port
825 * Note that the passed-in value must already be in network byte order. 820 * Note that the passed-in value must already be in network byte order.
826 */ 821 */
827int netxen_niu_xg_macaddr_set(struct netxen_port *port, 822int netxen_niu_xg_macaddr_set(struct netxen_adapter *adapter,
828 netxen_ethernet_macaddr_t addr) 823 netxen_ethernet_macaddr_t addr)
829{ 824{
830 u8 temp[4]; 825 u8 temp[4];
831 u32 val; 826 u32 val;
832 struct netxen_adapter *adapter = port->adapter;
833 827
834 temp[0] = temp[1] = 0; 828 temp[0] = temp[1] = 0;
835 memcpy(temp + 2, addr, 2); 829 memcpy(temp + 2, addr, 2);
@@ -878,9 +872,10 @@ int netxen_niu_xg_macaddr_get(struct netxen_adapter *adapter, int phy,
878} 872}
879 873
880int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter, 874int netxen_niu_xg_set_promiscuous_mode(struct netxen_adapter *adapter,
881 int port, netxen_niu_prom_mode_t mode) 875 netxen_niu_prom_mode_t mode)
882{ 876{
883 __u32 reg; 877 __u32 reg;
878 int port = adapter->portnum;
884 879
885 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS)) 880 if ((port < 0) || (port > NETXEN_NIU_MAX_GBE_PORTS))
886 return -EINVAL; 881 return -EINVAL;
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index 0c7c94328b7..f7eb627f81c 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -100,6 +100,14 @@
100 100
101#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac) 101#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac)
102#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0) 102#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0)
103#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac)
104#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0)
105#define CRB_CMD_PRODUCER_OFFSET_2 NETXEN_NIC_REG(0x1b8)
106#define CRB_CMD_CONSUMER_OFFSET_2 NETXEN_NIC_REG(0x1bc)
107
108// 1c0 to 1cc used for signature reg
109#define CRB_CMD_PRODUCER_OFFSET_3 NETXEN_NIC_REG(0x1d0)
110#define CRB_CMD_CONSUMER_OFFSET_3 NETXEN_NIC_REG(0x1d4)
103#define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4) 111#define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4)
104 112
105/* used for ethtool tests */ 113/* used for ethtool tests */
@@ -139,128 +147,13 @@ struct netxen_recv_crb {
139}; 147};
140 148
141#if defined(DEFINE_GLOBAL_RECV_CRB) 149#if defined(DEFINE_GLOBAL_RECV_CRB)
142struct netxen_recv_crb recv_crb_registers[] = {
143 /*
144 * Instance 0.
145 */
146 {
147 /* rcv_desc_crb: */
148 {
149 {
150 /* crb_rcv_producer_offset: */
151 NETXEN_NIC_REG(0x100),
152 /* crb_rcv_consumer_offset: */
153 NETXEN_NIC_REG(0x104),
154 /* crb_gloablrcv_ring: */
155 NETXEN_NIC_REG(0x108),
156 /* crb_rcv_ring_size */
157 NETXEN_NIC_REG(0x10c),
158
159 },
160 /* Jumbo frames */
161 {
162 /* crb_rcv_producer_offset: */
163 NETXEN_NIC_REG(0x110),
164 /* crb_rcv_consumer_offset: */
165 NETXEN_NIC_REG(0x114),
166 /* crb_gloablrcv_ring: */
167 NETXEN_NIC_REG(0x118),
168 /* crb_rcv_ring_size */
169 NETXEN_NIC_REG(0x11c),
170 },
171 /* LRO */
172 {
173 /* crb_rcv_producer_offset: */
174 NETXEN_NIC_REG(0x120),
175 /* crb_rcv_consumer_offset: */
176 NETXEN_NIC_REG(0x124),
177 /* crb_gloablrcv_ring: */
178 NETXEN_NIC_REG(0x128),
179 /* crb_rcv_ring_size */
180 NETXEN_NIC_REG(0x12c),
181 }
182 },
183 /* crb_rcvstatus_ring: */
184 NETXEN_NIC_REG(0x130),
185 /* crb_rcv_status_producer: */
186 NETXEN_NIC_REG(0x134),
187 /* crb_rcv_status_consumer: */
188 NETXEN_NIC_REG(0x138),
189 /* crb_rcvpeg_state: */
190 NETXEN_NIC_REG(0x13c),
191 /* crb_status_ring_size */
192 NETXEN_NIC_REG(0x140),
193
194 },
195 /*
196 * Instance 1,
197 */
198 {
199 /* rcv_desc_crb: */
200 {
201 {
202 /* crb_rcv_producer_offset: */
203 NETXEN_NIC_REG(0x144),
204 /* crb_rcv_consumer_offset: */
205 NETXEN_NIC_REG(0x148),
206 /* crb_globalrcv_ring: */
207 NETXEN_NIC_REG(0x14c),
208 /* crb_rcv_ring_size */
209 NETXEN_NIC_REG(0x150),
210
211 },
212 /* Jumbo frames */
213 {
214 /* crb_rcv_producer_offset: */
215 NETXEN_NIC_REG(0x154),
216 /* crb_rcv_consumer_offset: */
217 NETXEN_NIC_REG(0x158),
218 /* crb_globalrcv_ring: */
219 NETXEN_NIC_REG(0x15c),
220 /* crb_rcv_ring_size */
221 NETXEN_NIC_REG(0x160),
222 },
223 /* LRO */
224 {
225 /* crb_rcv_producer_offset: */
226 NETXEN_NIC_REG(0x164),
227 /* crb_rcv_consumer_offset: */
228 NETXEN_NIC_REG(0x168),
229 /* crb_globalrcv_ring: */
230 NETXEN_NIC_REG(0x16c),
231 /* crb_rcv_ring_size */
232 NETXEN_NIC_REG(0x170),
233 }
234
235 },
236 /* crb_rcvstatus_ring: */
237 NETXEN_NIC_REG(0x174),
238 /* crb_rcv_status_producer: */
239 NETXEN_NIC_REG(0x178),
240 /* crb_rcv_status_consumer: */
241 NETXEN_NIC_REG(0x17c),
242 /* crb_rcvpeg_state: */
243 NETXEN_NIC_REG(0x180),
244 /* crb_status_ring_size */
245 NETXEN_NIC_REG(0x184),
246
247 },
248};
249
250u64 ctx_addr_sig_regs[][3] = {
251 {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)},
252 {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)},
253 {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)},
254 {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)}
255};
256
257#else 150#else
258extern struct netxen_recv_crb recv_crb_registers[]; 151extern struct netxen_recv_crb recv_crb_registers[];
259extern u64 ctx_addr_sig_regs[][3]; 152extern u64 ctx_addr_sig_regs[][3];
153#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
260#define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0]) 154#define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0])
261#define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2]) 155#define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2])
262#define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1]) 156#define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1])
263#endif /* DEFINE_GLOBAL_RECEIVE_CRB */
264 157
265/* 158/*
266 * Temperature control. 159 * Temperature control.