aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2008-07-21 22:44:00 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-07-22 17:50:55 -0400
commit7830b22cbc5f5e804469b74a3fe0d3a8ed88ca31 (patch)
treee7779997b1a62f7a4e0003d51132ec710981c258 /drivers/net/netxen
parentf0084a36d4d799c024a5211555334d56c91d236d (diff)
netxen: cleanup unused variables/functions
o Reduce access to global arrays in data path. o Remove duplicate/unused variables, unecessary alignment constraints. o Use correct pci_dev instead of fallback device for consistent allocations. o Disable ethtool set_eeprom functionality for now, it was only used for flashing firmware. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/netxen')
-rw-r--r--drivers/net/netxen/netxen_nic.h19
-rw-r--r--drivers/net/netxen/netxen_nic_ethtool.c5
-rw-r--r--drivers/net/netxen/netxen_nic_hw.c270
-rw-r--r--drivers/net/netxen/netxen_nic_init.c88
-rw-r--r--drivers/net/netxen/netxen_nic_main.c74
-rw-r--r--drivers/net/netxen/netxen_nic_phan_reg.h17
6 files changed, 113 insertions, 360 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index da4c4fb97064..149bb60b0c46 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -132,7 +132,6 @@
132#define RX_JUMBO_DMA_MAP_LEN \ 132#define RX_JUMBO_DMA_MAP_LEN \
133 (MAX_RX_JUMBO_BUFFER_LENGTH - 2) 133 (MAX_RX_JUMBO_BUFFER_LENGTH - 2)
134#define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2) 134#define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2)
135#define NETXEN_ROM_ROUNDUP 0x80000000ULL
136 135
137/* 136/*
138 * Maximum number of ring contexts 137 * Maximum number of ring contexts
@@ -219,8 +218,6 @@ enum {
219#define MPORT_MULTI_FUNCTION_MODE 0x2222 218#define MPORT_MULTI_FUNCTION_MODE 0x2222
220 219
221#include "netxen_nic_phan_reg.h" 220#include "netxen_nic_phan_reg.h"
222extern unsigned long long netxen_dma_mask;
223extern unsigned long last_schedule_time;
224 221
225/* 222/*
226 * NetXen host-peg signal message structure 223 * NetXen host-peg signal message structure
@@ -765,7 +762,6 @@ struct netxen_rx_buffer {
765 * contains interrupt info as well shared hardware info. 762 * contains interrupt info as well shared hardware info.
766 */ 763 */
767struct netxen_hardware_context { 764struct netxen_hardware_context {
768 struct pci_dev *pdev;
769 void __iomem *pci_base0; 765 void __iomem *pci_base0;
770 void __iomem *pci_base1; 766 void __iomem *pci_base1;
771 void __iomem *pci_base2; 767 void __iomem *pci_base2;
@@ -781,7 +777,6 @@ struct netxen_hardware_context {
781 u32 qg_linksup; 777 u32 qg_linksup;
782 /* Address of cmd ring in Phantom */ 778 /* Address of cmd ring in Phantom */
783 struct cmd_desc_type0 *cmd_desc_head; 779 struct cmd_desc_type0 *cmd_desc_head;
784 struct pci_dev *cmd_desc_pdev;
785 dma_addr_t cmd_desc_phys_addr; 780 dma_addr_t cmd_desc_phys_addr;
786 struct netxen_adapter *adapter; 781 struct netxen_adapter *adapter;
787 int pci_func; 782 int pci_func;
@@ -816,9 +811,8 @@ struct netxen_adapter_stats {
816struct netxen_rcv_desc_ctx { 811struct netxen_rcv_desc_ctx {
817 u32 flags; 812 u32 flags;
818 u32 producer; 813 u32 producer;
819 u32 rcv_pending; /* Num of bufs posted in phantom */
820 dma_addr_t phys_addr; 814 dma_addr_t phys_addr;
821 struct pci_dev *phys_pdev; 815 u32 crb_rcv_producer; /* reg offset */
822 struct rcv_desc *desc_head; /* address of rx ring in Phantom */ 816 struct rcv_desc *desc_head; /* address of rx ring in Phantom */
823 u32 max_rx_desc_count; 817 u32 max_rx_desc_count;
824 u32 dma_size; 818 u32 dma_size;
@@ -835,10 +829,9 @@ struct netxen_rcv_desc_ctx {
835 */ 829 */
836struct netxen_recv_context { 830struct netxen_recv_context {
837 struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS]; 831 struct netxen_rcv_desc_ctx rcv_desc[NUM_RCV_DESC_RINGS];
838 u32 status_rx_producer;
839 u32 status_rx_consumer; 832 u32 status_rx_consumer;
833 u32 crb_sts_consumer; /* reg offset */
840 dma_addr_t rcv_status_desc_phys_addr; 834 dma_addr_t rcv_status_desc_phys_addr;
841 struct pci_dev *rcv_status_desc_pdev;
842 struct status_desc *rcv_status_desc_head; 835 struct status_desc *rcv_status_desc_head;
843}; 836};
844 837
@@ -854,7 +847,6 @@ struct netxen_dummy_dma {
854struct netxen_adapter { 847struct netxen_adapter {
855 struct netxen_hardware_context ahw; 848 struct netxen_hardware_context ahw;
856 849
857 struct netxen_adapter *master;
858 struct net_device *netdev; 850 struct net_device *netdev;
859 struct pci_dev *pdev; 851 struct pci_dev *pdev;
860 struct napi_struct napi; 852 struct napi_struct napi;
@@ -873,6 +865,8 @@ struct netxen_adapter {
873 u32 cmd_producer; 865 u32 cmd_producer;
874 __le32 *cmd_consumer; 866 __le32 *cmd_consumer;
875 u32 last_cmd_consumer; 867 u32 last_cmd_consumer;
868 u32 crb_addr_cmd_producer;
869 u32 crb_addr_cmd_consumer;
876 870
877 u32 max_tx_desc_count; 871 u32 max_tx_desc_count;
878 u32 max_rx_desc_count; 872 u32 max_rx_desc_count;
@@ -886,14 +880,12 @@ struct netxen_adapter {
886 880
887 struct netxen_adapter_stats stats; 881 struct netxen_adapter_stats stats;
888 882
889 u16 portno;
890 u16 link_speed; 883 u16 link_speed;
891 u16 link_duplex; 884 u16 link_duplex;
892 u16 state; 885 u16 state;
893 u16 link_autoneg; 886 u16 link_autoneg;
894 int rx_csum; 887 int rx_csum;
895 int status; 888 int status;
896 spinlock_t stats_lock;
897 889
898 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */ 890 struct netxen_cmd_buffer *cmd_buf_arr; /* Command buffers for xmit */
899 891
@@ -908,7 +900,6 @@ struct netxen_adapter {
908 900
909 /* Context interface shared between card and host */ 901 /* Context interface shared between card and host */
910 struct netxen_ring_ctx *ctx_desc; 902 struct netxen_ring_ctx *ctx_desc;
911 struct pci_dev *ctx_desc_pdev;
912 dma_addr_t ctx_desc_phys_addr; 903 dma_addr_t ctx_desc_phys_addr;
913 int intr_scheme; 904 int intr_scheme;
914 int msi_mode; 905 int msi_mode;
@@ -1034,8 +1025,6 @@ int netxen_rom_se(struct netxen_adapter *adapter, int addr);
1034 1025
1035/* Functions from netxen_nic_isr.c */ 1026/* Functions from netxen_nic_isr.c */
1036void netxen_initialize_adapter_sw(struct netxen_adapter *adapter); 1027void netxen_initialize_adapter_sw(struct netxen_adapter *adapter);
1037void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
1038 struct pci_dev **used_dev);
1039void netxen_initialize_adapter_ops(struct netxen_adapter *adapter); 1028void netxen_initialize_adapter_ops(struct netxen_adapter *adapter);
1040int netxen_init_firmware(struct netxen_adapter *adapter); 1029int netxen_init_firmware(struct netxen_adapter *adapter);
1041void netxen_free_hw_resources(struct netxen_adapter *adapter); 1030void netxen_free_hw_resources(struct netxen_adapter *adapter);
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c
index 723487bf200c..99071c253766 100644
--- a/drivers/net/netxen/netxen_nic_ethtool.c
+++ b/drivers/net/netxen/netxen_nic_ethtool.c
@@ -427,6 +427,7 @@ netxen_nic_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
427 return 0; 427 return 0;
428} 428}
429 429
430#if 0
430static int 431static int
431netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, 432netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
432 u8 * bytes) 433 u8 * bytes)
@@ -447,7 +448,6 @@ netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
447 } 448 }
448 printk(KERN_INFO "%s: flash unlocked. \n", 449 printk(KERN_INFO "%s: flash unlocked. \n",
449 netxen_nic_driver_name); 450 netxen_nic_driver_name);
450 last_schedule_time = jiffies;
451 ret = netxen_flash_erase_secondary(adapter); 451 ret = netxen_flash_erase_secondary(adapter);
452 if (ret != FLASH_SUCCESS) { 452 if (ret != FLASH_SUCCESS) {
453 printk(KERN_ERR "%s: Flash erase failed.\n", 453 printk(KERN_ERR "%s: Flash erase failed.\n",
@@ -497,6 +497,7 @@ netxen_nic_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
497 497
498 return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len); 498 return netxen_rom_fast_write_words(adapter, offset, bytes, eeprom->len);
499} 499}
500#endif /* 0 */
500 501
501static void 502static void
502netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) 503netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
@@ -745,7 +746,9 @@ struct ethtool_ops netxen_nic_ethtool_ops = {
745 .get_link = ethtool_op_get_link, 746 .get_link = ethtool_op_get_link,
746 .get_eeprom_len = netxen_nic_get_eeprom_len, 747 .get_eeprom_len = netxen_nic_get_eeprom_len,
747 .get_eeprom = netxen_nic_get_eeprom, 748 .get_eeprom = netxen_nic_get_eeprom,
749#if 0
748 .set_eeprom = netxen_nic_set_eeprom, 750 .set_eeprom = netxen_nic_set_eeprom,
751#endif
749 .get_ringparam = netxen_nic_get_ringparam, 752 .get_ringparam = netxen_nic_get_ringparam,
750 .get_pauseparam = netxen_nic_get_pauseparam, 753 .get_pauseparam = netxen_nic_get_pauseparam,
751 .set_pauseparam = netxen_nic_set_pauseparam, 754 .set_pauseparam = netxen_nic_set_pauseparam,
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index c43d06b8de9b..fa6d034c242c 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -43,203 +43,61 @@ struct netxen_recv_crb recv_crb_registers[] = {
43 * Instance 0. 43 * Instance 0.
44 */ 44 */
45 { 45 {
46 /* rcv_desc_crb: */ 46 /* crb_rcv_producer: */
47 { 47 {
48 { 48 NETXEN_NIC_REG(0x100),
49 /* crb_rcv_producer_offset: */ 49 /* Jumbo frames */
50 NETXEN_NIC_REG(0x100), 50 NETXEN_NIC_REG(0x110),
51 /* crb_rcv_consumer_offset: */ 51 /* LRO */
52 NETXEN_NIC_REG(0x104), 52 NETXEN_NIC_REG(0x120)
53 /* crb_gloablrcv_ring: */ 53 },
54 NETXEN_NIC_REG(0x108), 54 /* crb_sts_consumer: */
55 /* crb_rcv_ring_size */ 55 NETXEN_NIC_REG(0x138),
56 NETXEN_NIC_REG(0x10c), 56 },
57
58 },
59 /* Jumbo frames */
60 {
61 /* crb_rcv_producer_offset: */
62 NETXEN_NIC_REG(0x110),
63 /* crb_rcv_consumer_offset: */
64 NETXEN_NIC_REG(0x114),
65 /* crb_gloablrcv_ring: */
66 NETXEN_NIC_REG(0x118),
67 /* crb_rcv_ring_size */
68 NETXEN_NIC_REG(0x11c),
69 },
70 /* LRO */
71 {
72 /* crb_rcv_producer_offset: */
73 NETXEN_NIC_REG(0x120),
74 /* crb_rcv_consumer_offset: */
75 NETXEN_NIC_REG(0x124),
76 /* crb_gloablrcv_ring: */
77 NETXEN_NIC_REG(0x128),
78 /* crb_rcv_ring_size */
79 NETXEN_NIC_REG(0x12c),
80 }
81 },
82 /* crb_rcvstatus_ring: */
83 NETXEN_NIC_REG(0x130),
84 /* crb_rcv_status_producer: */
85 NETXEN_NIC_REG(0x134),
86 /* crb_rcv_status_consumer: */
87 NETXEN_NIC_REG(0x138),
88 /* crb_rcvpeg_state: */
89 NETXEN_NIC_REG(0x13c),
90 /* crb_status_ring_size */
91 NETXEN_NIC_REG(0x140),
92
93 },
94 /* 57 /*
95 * Instance 1, 58 * Instance 1,
96 */ 59 */
97 { 60 {
98 /* rcv_desc_crb: */ 61 /* crb_rcv_producer: */
99 { 62 {
100 { 63 NETXEN_NIC_REG(0x144),
101 /* crb_rcv_producer_offset: */ 64 /* Jumbo frames */
102 NETXEN_NIC_REG(0x144), 65 NETXEN_NIC_REG(0x154),
103 /* crb_rcv_consumer_offset: */ 66 /* LRO */
104 NETXEN_NIC_REG(0x148), 67 NETXEN_NIC_REG(0x164)
105 /* crb_globalrcv_ring: */ 68 },
106 NETXEN_NIC_REG(0x14c), 69 /* crb_sts_consumer: */
107 /* crb_rcv_ring_size */ 70 NETXEN_NIC_REG(0x17c),
108 NETXEN_NIC_REG(0x150), 71 },
109
110 },
111 /* Jumbo frames */
112 {
113 /* crb_rcv_producer_offset: */
114 NETXEN_NIC_REG(0x154),
115 /* crb_rcv_consumer_offset: */
116 NETXEN_NIC_REG(0x158),
117 /* crb_globalrcv_ring: */
118 NETXEN_NIC_REG(0x15c),
119 /* crb_rcv_ring_size */
120 NETXEN_NIC_REG(0x160),
121 },
122 /* LRO */
123 {
124 /* crb_rcv_producer_offset: */
125 NETXEN_NIC_REG(0x164),
126 /* crb_rcv_consumer_offset: */
127 NETXEN_NIC_REG(0x168),
128 /* crb_globalrcv_ring: */
129 NETXEN_NIC_REG(0x16c),
130 /* crb_rcv_ring_size */
131 NETXEN_NIC_REG(0x170),
132 }
133
134 },
135 /* crb_rcvstatus_ring: */
136 NETXEN_NIC_REG(0x174),
137 /* crb_rcv_status_producer: */
138 NETXEN_NIC_REG(0x178),
139 /* crb_rcv_status_consumer: */
140 NETXEN_NIC_REG(0x17c),
141 /* crb_rcvpeg_state: */
142 NETXEN_NIC_REG(0x180),
143 /* crb_status_ring_size */
144 NETXEN_NIC_REG(0x184),
145 },
146 /* 72 /*
147 * Instance 2, 73 * Instance 2,
148 */ 74 */
149 { 75 {
150 { 76 /* crb_rcv_producer: */
151 { 77 {
152 /* crb_rcv_producer_offset: */ 78 NETXEN_NIC_REG(0x1d8),
153 NETXEN_NIC_REG(0x1d8), 79 /* Jumbo frames */
154 /* crb_rcv_consumer_offset: */ 80 NETXEN_NIC_REG(0x1f8),
155 NETXEN_NIC_REG(0x1dc), 81 /* LRO */
156 /* crb_gloablrcv_ring: */ 82 NETXEN_NIC_REG(0x208)
157 NETXEN_NIC_REG(0x1f0), 83 },
158 /* crb_rcv_ring_size */ 84 /* crb_sts_consumer: */
159 NETXEN_NIC_REG(0x1f4), 85 NETXEN_NIC_REG(0x220),
160 },
161 /* Jumbo frames */
162 {
163 /* crb_rcv_producer_offset: */
164 NETXEN_NIC_REG(0x1f8),
165 /* crb_rcv_consumer_offset: */
166 NETXEN_NIC_REG(0x1fc),
167 /* crb_gloablrcv_ring: */
168 NETXEN_NIC_REG(0x200),
169 /* crb_rcv_ring_size */
170 NETXEN_NIC_REG(0x204),
171 },
172 /* LRO */
173 {
174 /* crb_rcv_producer_offset: */
175 NETXEN_NIC_REG(0x208),
176 /* crb_rcv_consumer_offset: */
177 NETXEN_NIC_REG(0x20c),
178 /* crb_gloablrcv_ring: */
179 NETXEN_NIC_REG(0x210),
180 /* crb_rcv_ring_size */
181 NETXEN_NIC_REG(0x214),
182 }
183 },
184 /* crb_rcvstatus_ring: */
185 NETXEN_NIC_REG(0x218),
186 /* crb_rcv_status_producer: */
187 NETXEN_NIC_REG(0x21c),
188 /* crb_rcv_status_consumer: */
189 NETXEN_NIC_REG(0x220),
190 /* crb_rcvpeg_state: */
191 NETXEN_NIC_REG(0x224),
192 /* crb_status_ring_size */
193 NETXEN_NIC_REG(0x228),
194 }, 86 },
195 /* 87 /*
196 * Instance 3, 88 * Instance 3,
197 */ 89 */
198 { 90 {
199 { 91 /* crb_rcv_producer: */
200 { 92 {
201 /* crb_rcv_producer_offset: */ 93 NETXEN_NIC_REG(0x22c),
202 NETXEN_NIC_REG(0x22c), 94 /* Jumbo frames */
203 /* crb_rcv_consumer_offset: */ 95 NETXEN_NIC_REG(0x23c),
204 NETXEN_NIC_REG(0x230), 96 /* LRO */
205 /* crb_gloablrcv_ring: */ 97 NETXEN_NIC_REG(0x24c)
206 NETXEN_NIC_REG(0x234), 98 },
207 /* crb_rcv_ring_size */ 99 /* crb_sts_consumer: */
208 NETXEN_NIC_REG(0x238), 100 NETXEN_NIC_REG(0x264),
209 },
210 /* Jumbo frames */
211 {
212 /* crb_rcv_producer_offset: */
213 NETXEN_NIC_REG(0x23c),
214 /* crb_rcv_consumer_offset: */
215 NETXEN_NIC_REG(0x240),
216 /* crb_gloablrcv_ring: */
217 NETXEN_NIC_REG(0x244),
218 /* crb_rcv_ring_size */
219 NETXEN_NIC_REG(0x248),
220 },
221 /* LRO */
222 {
223 /* crb_rcv_producer_offset: */
224 NETXEN_NIC_REG(0x24c),
225 /* crb_rcv_consumer_offset: */
226 NETXEN_NIC_REG(0x250),
227 /* crb_gloablrcv_ring: */
228 NETXEN_NIC_REG(0x254),
229 /* crb_rcv_ring_size */
230 NETXEN_NIC_REG(0x258),
231 }
232 },
233 /* crb_rcvstatus_ring: */
234 NETXEN_NIC_REG(0x25c),
235 /* crb_rcv_status_producer: */
236 NETXEN_NIC_REG(0x260),
237 /* crb_rcv_status_consumer: */
238 NETXEN_NIC_REG(0x264),
239 /* crb_rcvpeg_state: */
240 NETXEN_NIC_REG(0x268),
241 /* crb_status_ring_size */
242 NETXEN_NIC_REG(0x26c),
243 }, 101 },
244}; 102};
245 103
@@ -375,16 +233,12 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
375 loops = 0; 233 loops = 0;
376 state = 0; 234 state = 0;
377 /* Window 1 call */ 235 /* Window 1 call */
378 state = readl(NETXEN_CRB_NORMALIZE(adapter, 236 state = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_RCVPEG_STATE));
379 recv_crb_registers[ctx].
380 crb_rcvpeg_state));
381 while (state != PHAN_PEG_RCV_INITIALIZED && loops < 20) { 237 while (state != PHAN_PEG_RCV_INITIALIZED && loops < 20) {
382 msleep(1); 238 msleep(1);
383 /* Window 1 call */ 239 /* Window 1 call */
384 state = readl(NETXEN_CRB_NORMALIZE(adapter, 240 state = readl(NETXEN_CRB_NORMALIZE(adapter,
385 recv_crb_registers 241 CRB_RCVPEG_STATE));
386 [ctx].
387 crb_rcvpeg_state));
388 loops++; 242 loops++;
389 } 243 }
390 if (loops >= 20) { 244 if (loops >= 20) {
@@ -399,11 +253,9 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
399 adapter->msi_mode = readl( 253 adapter->msi_mode = readl(
400 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_MSI_MODE_FW)); 254 NETXEN_CRB_NORMALIZE(adapter, CRB_NIC_MSI_MODE_FW));
401 255
402 addr = netxen_alloc(adapter->ahw.pdev, 256 addr = pci_alloc_consistent(adapter->pdev,
403 sizeof(struct netxen_ring_ctx) + 257 sizeof(struct netxen_ring_ctx) + sizeof(uint32_t),
404 sizeof(uint32_t), 258 &adapter->ctx_desc_phys_addr);
405 (dma_addr_t *) & adapter->ctx_desc_phys_addr,
406 &adapter->ctx_desc_pdev);
407 259
408 if (addr == NULL) { 260 if (addr == NULL) {
409 DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); 261 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
@@ -419,11 +271,10 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
419 adapter->cmd_consumer = (__le32 *) (((char *)addr) + 271 adapter->cmd_consumer = (__le32 *) (((char *)addr) +
420 sizeof(struct netxen_ring_ctx)); 272 sizeof(struct netxen_ring_ctx));
421 273
422 addr = netxen_alloc(adapter->ahw.pdev, 274 addr = pci_alloc_consistent(adapter->pdev,
423 sizeof(struct cmd_desc_type0) * 275 sizeof(struct cmd_desc_type0) *
424 adapter->max_tx_desc_count, 276 adapter->max_tx_desc_count,
425 (dma_addr_t *) & hw->cmd_desc_phys_addr, 277 &hw->cmd_desc_phys_addr);
426 &adapter->ahw.cmd_desc_pdev);
427 278
428 if (addr == NULL) { 279 if (addr == NULL) {
429 DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); 280 DPRINTK(ERR, "bad return from pci_alloc_consistent\n");
@@ -443,10 +294,9 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
443 294
444 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { 295 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) {
445 rcv_desc = &recv_ctx->rcv_desc[ring]; 296 rcv_desc = &recv_ctx->rcv_desc[ring];
446 addr = netxen_alloc(adapter->ahw.pdev, 297 addr = pci_alloc_consistent(adapter->pdev,
447 RCV_DESC_RINGSIZE, 298 RCV_DESC_RINGSIZE,
448 &rcv_desc->phys_addr, 299 &rcv_desc->phys_addr);
449 &rcv_desc->phys_pdev);
450 if (addr == NULL) { 300 if (addr == NULL) {
451 DPRINTK(ERR, "bad return from " 301 DPRINTK(ERR, "bad return from "
452 "pci_alloc_consistent\n"); 302 "pci_alloc_consistent\n");
@@ -459,11 +309,13 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
459 cpu_to_le64(rcv_desc->phys_addr); 309 cpu_to_le64(rcv_desc->phys_addr);
460 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = 310 adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size =
461 cpu_to_le32(rcv_desc->max_rx_desc_count); 311 cpu_to_le32(rcv_desc->max_rx_desc_count);
312 rcv_desc->crb_rcv_producer =
313 recv_crb_registers[adapter->portnum].
314 crb_rcv_producer[ring];
462 } 315 }
463 316
464 addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE, 317 addr = pci_alloc_consistent(adapter->pdev, STATUS_DESC_RINGSIZE,
465 &recv_ctx->rcv_status_desc_phys_addr, 318 &recv_ctx->rcv_status_desc_phys_addr);
466 &recv_ctx->rcv_status_desc_pdev);
467 if (addr == NULL) { 319 if (addr == NULL) {
468 DPRINTK(ERR, "bad return from" 320 DPRINTK(ERR, "bad return from"
469 " pci_alloc_consistent\n"); 321 " pci_alloc_consistent\n");
@@ -476,6 +328,8 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter)
476 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr); 328 cpu_to_le64(recv_ctx->rcv_status_desc_phys_addr);
477 adapter->ctx_desc->sts_ring_size = 329 adapter->ctx_desc->sts_ring_size =
478 cpu_to_le32(adapter->max_rx_desc_count); 330 cpu_to_le32(adapter->max_rx_desc_count);
331 recv_ctx->crb_sts_consumer =
332 recv_crb_registers[adapter->portnum].crb_sts_consumer;
479 333
480 } 334 }
481 /* Window = 1 */ 335 /* Window = 1 */
@@ -496,7 +350,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
496 int ctx, ring; 350 int ctx, ring;
497 351
498 if (adapter->ctx_desc != NULL) { 352 if (adapter->ctx_desc != NULL) {
499 pci_free_consistent(adapter->ctx_desc_pdev, 353 pci_free_consistent(adapter->pdev,
500 sizeof(struct netxen_ring_ctx) + 354 sizeof(struct netxen_ring_ctx) +
501 sizeof(uint32_t), 355 sizeof(uint32_t),
502 adapter->ctx_desc, 356 adapter->ctx_desc,
@@ -505,7 +359,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
505 } 359 }
506 360
507 if (adapter->ahw.cmd_desc_head != NULL) { 361 if (adapter->ahw.cmd_desc_head != NULL) {
508 pci_free_consistent(adapter->ahw.cmd_desc_pdev, 362 pci_free_consistent(adapter->pdev,
509 sizeof(struct cmd_desc_type0) * 363 sizeof(struct cmd_desc_type0) *
510 adapter->max_tx_desc_count, 364 adapter->max_tx_desc_count,
511 adapter->ahw.cmd_desc_head, 365 adapter->ahw.cmd_desc_head,
@@ -519,7 +373,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
519 rcv_desc = &recv_ctx->rcv_desc[ring]; 373 rcv_desc = &recv_ctx->rcv_desc[ring];
520 374
521 if (rcv_desc->desc_head != NULL) { 375 if (rcv_desc->desc_head != NULL) {
522 pci_free_consistent(rcv_desc->phys_pdev, 376 pci_free_consistent(adapter->pdev,
523 RCV_DESC_RINGSIZE, 377 RCV_DESC_RINGSIZE,
524 rcv_desc->desc_head, 378 rcv_desc->desc_head,
525 rcv_desc->phys_addr); 379 rcv_desc->phys_addr);
@@ -528,7 +382,7 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter)
528 } 382 }
529 383
530 if (recv_ctx->rcv_status_desc_head != NULL) { 384 if (recv_ctx->rcv_status_desc_head != NULL) {
531 pci_free_consistent(recv_ctx->rcv_status_desc_pdev, 385 pci_free_consistent(adapter->pdev,
532 STATUS_DESC_RINGSIZE, 386 STATUS_DESC_RINGSIZE,
533 recv_ctx->rcv_status_desc_head, 387 recv_ctx->rcv_status_desc_head,
534 recv_ctx-> 388 recv_ctx->
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 70d1b22ced22..37fd6bc93eb9 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -42,8 +42,6 @@ struct crb_addr_pair {
42 u32 data; 42 u32 data;
43}; 43};
44 44
45unsigned long last_schedule_time;
46
47#define NETXEN_MAX_CRB_XFORM 60 45#define NETXEN_MAX_CRB_XFORM 60
48static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; 46static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM];
49#define NETXEN_ADDR_ERROR (0xffffffff) 47#define NETXEN_ADDR_ERROR (0xffffffff)
@@ -155,24 +153,6 @@ int netxen_init_firmware(struct netxen_adapter *adapter)
155 return err; 153 return err;
156} 154}
157 155
158#define NETXEN_ADDR_LIMIT 0xffffffffULL
159
160void *netxen_alloc(struct pci_dev *pdev, size_t sz, dma_addr_t * ptr,
161 struct pci_dev **used_dev)
162{
163 void *addr;
164
165 addr = pci_alloc_consistent(pdev, sz, ptr);
166 if ((unsigned long long)(*ptr) < NETXEN_ADDR_LIMIT) {
167 *used_dev = pdev;
168 return addr;
169 }
170 pci_free_consistent(pdev, sz, addr, *ptr);
171 addr = pci_alloc_consistent(NULL, sz, ptr);
172 *used_dev = NULL;
173 return addr;
174}
175
176void netxen_initialize_adapter_sw(struct netxen_adapter *adapter) 156void netxen_initialize_adapter_sw(struct netxen_adapter *adapter)
177{ 157{
178 int ctxid, ring; 158 int ctxid, ring;
@@ -270,7 +250,9 @@ static u32 netxen_decode_crb_addr(u32 addr)
270 250
271static long rom_max_timeout = 100; 251static long rom_max_timeout = 100;
272static long rom_lock_timeout = 10000; 252static long rom_lock_timeout = 10000;
253#if 0
273static long rom_write_timeout = 700; 254static long rom_write_timeout = 700;
255#endif
274 256
275static int rom_lock(struct netxen_adapter *adapter) 257static int rom_lock(struct netxen_adapter *adapter)
276{ 258{
@@ -319,6 +301,7 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
319 return 0; 301 return 0;
320} 302}
321 303
304#if 0
322static int netxen_rom_wren(struct netxen_adapter *adapter) 305static int netxen_rom_wren(struct netxen_adapter *adapter)
323{ 306{
324 /* Set write enable latch in ROM status register */ 307 /* Set write enable latch in ROM status register */
@@ -348,6 +331,7 @@ static int netxen_do_rom_rdsr(struct netxen_adapter *adapter)
348 } 331 }
349 return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA); 332 return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA);
350} 333}
334#endif
351 335
352static void netxen_rom_unlock(struct netxen_adapter *adapter) 336static void netxen_rom_unlock(struct netxen_adapter *adapter)
353{ 337{
@@ -358,6 +342,7 @@ static void netxen_rom_unlock(struct netxen_adapter *adapter)
358 342
359} 343}
360 344
345#if 0
361static int netxen_rom_wip_poll(struct netxen_adapter *adapter) 346static int netxen_rom_wip_poll(struct netxen_adapter *adapter)
362{ 347{
363 long timeout = 0; 348 long timeout = 0;
@@ -393,6 +378,7 @@ static int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
393 378
394 return netxen_rom_wip_poll(adapter); 379 return netxen_rom_wip_poll(adapter);
395} 380}
381#endif
396 382
397static int do_rom_fast_read(struct netxen_adapter *adapter, 383static int do_rom_fast_read(struct netxen_adapter *adapter,
398 int addr, int *valp) 384 int addr, int *valp)
@@ -475,7 +461,6 @@ int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data)
475 netxen_rom_unlock(adapter); 461 netxen_rom_unlock(adapter);
476 return ret; 462 return ret;
477} 463}
478#endif /* 0 */
479 464
480static int do_rom_fast_write_words(struct netxen_adapter *adapter, 465static int do_rom_fast_write_words(struct netxen_adapter *adapter,
481 int addr, u8 *bytes, size_t size) 466 int addr, u8 *bytes, size_t size)
@@ -740,13 +725,12 @@ int netxen_flash_unlock(struct netxen_adapter *adapter)
740 725
741 return ret; 726 return ret;
742} 727}
728#endif /* 0 */
743 729
744#define NETXEN_BOARDTYPE 0x4008 730#define NETXEN_BOARDTYPE 0x4008
745#define NETXEN_BOARDNUM 0x400c 731#define NETXEN_BOARDNUM 0x400c
746#define NETXEN_CHIPNUM 0x4010 732#define NETXEN_CHIPNUM 0x4010
747#define NETXEN_ROMBUS_RESET 0xFFFFFFFF 733#define NETXEN_ROMBUS_RESET 0xFFFFFFFF
748#define NETXEN_ROM_FIRST_BARRIER 0x800000000ULL
749#define NETXEN_ROM_FOUND_INIT 0x400
750 734
751int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) 735int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
752{ 736{
@@ -776,10 +760,9 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
776 printk("Could not read chip number\n"); 760 printk("Could not read chip number\n");
777 } 761 }
778 762
779 if (netxen_rom_fast_read(adapter, 0, &n) == 0 763 if (netxen_rom_fast_read(adapter, 0, &n) == 0 && (n & 0x80000000)) {
780 && (n & NETXEN_ROM_FIRST_BARRIER)) { 764 n &= ~0x80000000;
781 n &= ~NETXEN_ROM_ROUNDUP; 765 if (n < 0x400) {
782 if (n < NETXEN_ROM_FOUND_INIT) {
783 if (verbose) 766 if (verbose)
784 printk("%s: %d CRB init values found" 767 printk("%s: %d CRB init values found"
785 " in ROM.\n", netxen_nic_driver_name, n); 768 " in ROM.\n", netxen_nic_driver_name, n);
@@ -829,16 +812,8 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
829 buf[i].data = NETXEN_NIC_XDMA_RESET; 812 buf[i].data = NETXEN_NIC_XDMA_RESET;
830 } 813 }
831 814
832 if (ADDR_IN_WINDOW1(off)) { 815 netxen_nic_hw_write_wx(adapter, off, &buf[i].data, 4);
833 writel(buf[i].data,
834 NETXEN_CRB_NORMALIZE(adapter, off));
835 } else {
836 netxen_nic_pci_change_crbwindow(adapter, 0);
837 writel(buf[i].data,
838 pci_base_offset(adapter, off));
839 816
840 netxen_nic_pci_change_crbwindow(adapter, 1);
841 }
842 if (init_delay == 1) { 817 if (init_delay == 1) {
843 msleep(1000); 818 msleep(1000);
844 init_delay = 0; 819 init_delay = 0;
@@ -897,7 +872,7 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
897 uint32_t lo; 872 uint32_t lo;
898 873
899 adapter->dummy_dma.addr = 874 adapter->dummy_dma.addr =
900 pci_alloc_consistent(adapter->ahw.pdev, 875 pci_alloc_consistent(adapter->pdev,
901 NETXEN_HOST_DUMMY_DMA_SIZE, 876 NETXEN_HOST_DUMMY_DMA_SIZE,
902 &adapter->dummy_dma.phys_addr); 877 &adapter->dummy_dma.phys_addr);
903 if (adapter->dummy_dma.addr == NULL) { 878 if (adapter->dummy_dma.addr == NULL) {
@@ -931,7 +906,7 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter)
931 } while (--i); 906 } while (--i);
932 907
933 if (i) { 908 if (i) {
934 pci_free_consistent(adapter->ahw.pdev, 909 pci_free_consistent(adapter->pdev,
935 NETXEN_HOST_DUMMY_DMA_SIZE, 910 NETXEN_HOST_DUMMY_DMA_SIZE,
936 adapter->dummy_dma.addr, 911 adapter->dummy_dma.addr,
937 adapter->dummy_dma.phys_addr); 912 adapter->dummy_dma.phys_addr);
@@ -1104,8 +1079,6 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1104 ret = netif_receive_skb(skb); 1079 ret = netif_receive_skb(skb);
1105 netdev->last_rx = jiffies; 1080 netdev->last_rx = jiffies;
1106 1081
1107 rcv_desc->rcv_pending--;
1108
1109 /* 1082 /*
1110 * We just consumed one buffer so post a buffer. 1083 * We just consumed one buffer so post a buffer.
1111 */ 1084 */
@@ -1125,7 +1098,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1125 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; 1098 struct status_desc *desc_head = recv_ctx->rcv_status_desc_head;
1126 struct status_desc *desc; /* used to read status desc here */ 1099 struct status_desc *desc; /* used to read status desc here */
1127 u32 consumer = recv_ctx->status_rx_consumer; 1100 u32 consumer = recv_ctx->status_rx_consumer;
1128 u32 producer = 0;
1129 int count = 0, ring; 1101 int count = 0, ring;
1130 1102
1131 while (count < max) { 1103 while (count < max) {
@@ -1146,13 +1118,10 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max)
1146 /* update the consumer index in phantom */ 1118 /* update the consumer index in phantom */
1147 if (count) { 1119 if (count) {
1148 recv_ctx->status_rx_consumer = consumer; 1120 recv_ctx->status_rx_consumer = consumer;
1149 recv_ctx->status_rx_producer = producer;
1150 1121
1151 /* Window = 1 */ 1122 /* Window = 1 */
1152 writel(consumer, 1123 writel(consumer, NETXEN_CRB_NORMALIZE(adapter,
1153 NETXEN_CRB_NORMALIZE(adapter, 1124 recv_ctx->crb_sts_consumer));
1154 recv_crb_registers[adapter->portnum].
1155 crb_rcv_status_consumer));
1156 } 1125 }
1157 1126
1158 return count; 1127 return count;
@@ -1231,7 +1200,7 @@ int netxen_process_cmd_ring(struct netxen_adapter *adapter)
1231 */ 1200 */
1232void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) 1201void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1233{ 1202{
1234 struct pci_dev *pdev = adapter->ahw.pdev; 1203 struct pci_dev *pdev = adapter->pdev;
1235 struct sk_buff *skb; 1204 struct sk_buff *skb;
1236 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); 1205 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1237 struct netxen_rcv_desc_ctx *rcv_desc = NULL; 1206 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
@@ -1294,16 +1263,11 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1294 /* if we did allocate buffers, then write the count to Phantom */ 1263 /* if we did allocate buffers, then write the count to Phantom */
1295 if (count) { 1264 if (count) {
1296 rcv_desc->begin_alloc = index; 1265 rcv_desc->begin_alloc = index;
1297 rcv_desc->rcv_pending += count;
1298 rcv_desc->producer = producer; 1266 rcv_desc->producer = producer;
1299 /* Window = 1 */ 1267 /* Window = 1 */
1300 writel((producer - 1) & 1268 writel((producer - 1) & (rcv_desc->max_rx_desc_count - 1),
1301 (rcv_desc->max_rx_desc_count - 1), 1269 NETXEN_CRB_NORMALIZE(adapter,
1302 NETXEN_CRB_NORMALIZE(adapter, 1270 rcv_desc->crb_rcv_producer));
1303 recv_crb_registers[
1304 adapter->portnum].
1305 rcv_desc_crb[ringid].
1306 crb_rcv_producer_offset));
1307 /* 1271 /*
1308 * Write a doorbell msg to tell phanmon of change in 1272 * Write a doorbell msg to tell phanmon of change in
1309 * receive ring producer 1273 * receive ring producer
@@ -1325,7 +1289,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1325static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, 1289static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1326 uint32_t ctx, uint32_t ringid) 1290 uint32_t ctx, uint32_t ringid)
1327{ 1291{
1328 struct pci_dev *pdev = adapter->ahw.pdev; 1292 struct pci_dev *pdev = adapter->pdev;
1329 struct sk_buff *skb; 1293 struct sk_buff *skb;
1330 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); 1294 struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]);
1331 struct netxen_rcv_desc_ctx *rcv_desc = NULL; 1295 struct netxen_rcv_desc_ctx *rcv_desc = NULL;
@@ -1370,7 +1334,6 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1370 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1334 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1371 pdesc->buffer_length = cpu_to_le32(rcv_desc->dma_size); 1335 pdesc->buffer_length = cpu_to_le32(rcv_desc->dma_size);
1372 pdesc->addr_buffer = cpu_to_le64(buffer->dma); 1336 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1373 DPRINTK(INFO, "done writing descripter\n");
1374 producer = 1337 producer =
1375 get_next_index(producer, rcv_desc->max_rx_desc_count); 1338 get_next_index(producer, rcv_desc->max_rx_desc_count);
1376 index = get_next_index(index, rcv_desc->max_rx_desc_count); 1339 index = get_next_index(index, rcv_desc->max_rx_desc_count);
@@ -1380,16 +1343,11 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1380 /* if we did allocate buffers, then write the count to Phantom */ 1343 /* if we did allocate buffers, then write the count to Phantom */
1381 if (count) { 1344 if (count) {
1382 rcv_desc->begin_alloc = index; 1345 rcv_desc->begin_alloc = index;
1383 rcv_desc->rcv_pending += count;
1384 rcv_desc->producer = producer; 1346 rcv_desc->producer = producer;
1385 /* Window = 1 */ 1347 /* Window = 1 */
1386 writel((producer - 1) & 1348 writel((producer - 1) & (rcv_desc->max_rx_desc_count - 1),
1387 (rcv_desc->max_rx_desc_count - 1), 1349 NETXEN_CRB_NORMALIZE(adapter,
1388 NETXEN_CRB_NORMALIZE(adapter, 1350 rcv_desc->crb_rcv_producer));
1389 recv_crb_registers[
1390 adapter->portnum].
1391 rcv_desc_crb[ringid].
1392 crb_rcv_producer_offset));
1393 wmb(); 1351 wmb();
1394 } 1352 }
1395} 1353}
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 63cd67b931e7..91b02ebc9a10 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -108,66 +108,30 @@ static struct workqueue_struct *netxen_workq;
108 108
109static void netxen_watchdog(unsigned long); 109static void netxen_watchdog(unsigned long);
110 110
111static uint32_t crb_cmd_producer[4] = {
112 CRB_CMD_PRODUCER_OFFSET, CRB_CMD_PRODUCER_OFFSET_1,
113 CRB_CMD_PRODUCER_OFFSET_2, CRB_CMD_PRODUCER_OFFSET_3
114};
115
111static void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter, 116static void netxen_nic_update_cmd_producer(struct netxen_adapter *adapter,
112 uint32_t crb_producer) 117 uint32_t crb_producer)
113{ 118{
114 switch (adapter->portnum) { 119 writel(crb_producer, NETXEN_CRB_NORMALIZE(adapter,
115 case 0: 120 adapter->crb_addr_cmd_producer));
116 writel(crb_producer, NETXEN_CRB_NORMALIZE
117 (adapter, CRB_CMD_PRODUCER_OFFSET));
118 return;
119 case 1:
120 writel(crb_producer, NETXEN_CRB_NORMALIZE
121 (adapter, CRB_CMD_PRODUCER_OFFSET_1));
122 return;
123 case 2:
124 writel(crb_producer, NETXEN_CRB_NORMALIZE
125 (adapter, CRB_CMD_PRODUCER_OFFSET_2));
126 return;
127 case 3:
128 writel(crb_producer, NETXEN_CRB_NORMALIZE
129 (adapter, CRB_CMD_PRODUCER_OFFSET_3));
130 return;
131 default:
132 printk(KERN_WARNING "We tried to update "
133 "CRB_CMD_PRODUCER_OFFSET for invalid "
134 "PCI function id %d\n",
135 adapter->portnum);
136 return;
137 }
138} 121}
139 122
123static uint32_t crb_cmd_consumer[4] = {
124 CRB_CMD_CONSUMER_OFFSET, CRB_CMD_CONSUMER_OFFSET_1,
125 CRB_CMD_CONSUMER_OFFSET_2, CRB_CMD_CONSUMER_OFFSET_3
126};
127
140static void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter, 128static void netxen_nic_update_cmd_consumer(struct netxen_adapter *adapter,
141 u32 crb_consumer) 129 u32 crb_consumer)
142{ 130{
143 switch (adapter->portnum) { 131 writel(crb_consumer, NETXEN_CRB_NORMALIZE(adapter,
144 case 0: 132 adapter->crb_addr_cmd_consumer));
145 writel(crb_consumer, NETXEN_CRB_NORMALIZE
146 (adapter, CRB_CMD_CONSUMER_OFFSET));
147 return;
148 case 1:
149 writel(crb_consumer, NETXEN_CRB_NORMALIZE
150 (adapter, CRB_CMD_CONSUMER_OFFSET_1));
151 return;
152 case 2:
153 writel(crb_consumer, NETXEN_CRB_NORMALIZE
154 (adapter, CRB_CMD_CONSUMER_OFFSET_2));
155 return;
156 case 3:
157 writel(crb_consumer, NETXEN_CRB_NORMALIZE
158 (adapter, CRB_CMD_CONSUMER_OFFSET_3));
159 return;
160 default:
161 printk(KERN_WARNING "We tried to update "
162 "CRB_CMD_PRODUCER_OFFSET for invalid "
163 "PCI function id %d\n",
164 adapter->portnum);
165 return;
166 }
167} 133}
168 134
169#define ADAPTER_LIST_SIZE 12
170
171static uint32_t msi_tgt_status[4] = { 135static uint32_t msi_tgt_status[4] = {
172 ISR_INT_TARGET_STATUS, ISR_INT_TARGET_STATUS_F1, 136 ISR_INT_TARGET_STATUS, ISR_INT_TARGET_STATUS_F1,
173 ISR_INT_TARGET_STATUS_F2, ISR_INT_TARGET_STATUS_F3 137 ISR_INT_TARGET_STATUS_F2, ISR_INT_TARGET_STATUS_F3
@@ -334,7 +298,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
334 298
335 adapter = netdev->priv; 299 adapter = netdev->priv;
336 300
337 adapter->ahw.pdev = pdev;
338 adapter->ahw.pci_func = pci_func_id; 301 adapter->ahw.pci_func = pci_func_id;
339 302
340 /* remap phys address */ 303 /* remap phys address */
@@ -552,12 +515,13 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
552 adapter->watchdog_timer.function = &netxen_watchdog; 515 adapter->watchdog_timer.function = &netxen_watchdog;
553 adapter->watchdog_timer.data = (unsigned long)adapter; 516 adapter->watchdog_timer.data = (unsigned long)adapter;
554 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); 517 INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task);
555 adapter->ahw.pdev = pdev;
556 adapter->ahw.revision_id = pdev->revision; 518 adapter->ahw.revision_id = pdev->revision;
557 519
558 /* make sure Window == 1 */ 520 /* make sure Window == 1 */
559 netxen_nic_pci_change_crbwindow(adapter, 1); 521 netxen_nic_pci_change_crbwindow(adapter, 1);
560 522
523 adapter->crb_addr_cmd_producer = crb_cmd_producer[adapter->portnum];
524 adapter->crb_addr_cmd_consumer = crb_cmd_consumer[adapter->portnum];
561 netxen_nic_update_cmd_producer(adapter, 0); 525 netxen_nic_update_cmd_producer(adapter, 0);
562 netxen_nic_update_cmd_consumer(adapter, 0); 526 netxen_nic_update_cmd_consumer(adapter, 0);
563 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); 527 writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO));
@@ -816,7 +780,7 @@ static int netxen_nic_open(struct net_device *netdev)
816 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) 780 for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++)
817 netxen_post_rx_buffers(adapter, ctx, ring); 781 netxen_post_rx_buffers(adapter, ctx, ring);
818 } 782 }
819 adapter->irq = adapter->ahw.pdev->irq; 783 adapter->irq = adapter->pdev->irq;
820 if (adapter->flags & NETXEN_NIC_MSI_ENABLED) 784 if (adapter->flags & NETXEN_NIC_MSI_ENABLED)
821 handler = netxen_msi_intr; 785 handler = netxen_msi_intr;
822 else { 786 else {
@@ -1220,10 +1184,6 @@ module_init(netxen_init_module);
1220 1184
1221static void __exit netxen_exit_module(void) 1185static void __exit netxen_exit_module(void)
1222{ 1186{
1223 /*
1224 * Wait for some time to allow the dma to drain, if any.
1225 */
1226 msleep(100);
1227 pci_unregister_driver(&netxen_driver); 1187 pci_unregister_driver(&netxen_driver);
1228 destroy_workqueue(netxen_workq); 1188 destroy_workqueue(netxen_workq);
1229} 1189}
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h
index a566b50f36f5..db2202aeb0d7 100644
--- a/drivers/net/netxen/netxen_nic_phan_reg.h
+++ b/drivers/net/netxen/netxen_nic_phan_reg.h
@@ -98,6 +98,7 @@
98#define CRB_JUMBO_BUFFER_PROD NETXEN_NIC_REG(0xf4) 98#define CRB_JUMBO_BUFFER_PROD NETXEN_NIC_REG(0xf4)
99#define CRB_JUMBO_BUFFER_CONS NETXEN_NIC_REG(0xf8) 99#define CRB_JUMBO_BUFFER_CONS NETXEN_NIC_REG(0xf8)
100 100
101#define CRB_RCVPEG_STATE NETXEN_NIC_REG(0x13c)
101#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac) 102#define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac)
102#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0) 103#define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0)
103#define CRB_CMD_PRODUCER_OFFSET_2 NETXEN_NIC_REG(0x1b8) 104#define CRB_CMD_PRODUCER_OFFSET_2 NETXEN_NIC_REG(0x1b8)
@@ -147,25 +148,13 @@
147#define nx_get_temp_state(x) ((x) & 0xffff) 148#define nx_get_temp_state(x) ((x) & 0xffff)
148#define nx_encode_temp(val, state) (((val) << 16) | (state)) 149#define nx_encode_temp(val, state) (((val) << 16) | (state))
149 150
150/* CRB registers per Rcv Descriptor ring */
151struct netxen_rcv_desc_crb {
152 u32 crb_rcv_producer_offset __attribute__ ((aligned(512)));
153 u32 crb_rcv_consumer_offset;
154 u32 crb_globalrcv_ring;
155 u32 crb_rcv_ring_size;
156};
157
158/* 151/*
159 * CRB registers used by the receive peg logic. 152 * CRB registers used by the receive peg logic.
160 */ 153 */
161 154
162struct netxen_recv_crb { 155struct netxen_recv_crb {
163 struct netxen_rcv_desc_crb rcv_desc_crb[NUM_RCV_DESC_RINGS]; 156 u32 crb_rcv_producer[NUM_RCV_DESC_RINGS];
164 u32 crb_rcvstatus_ring; 157 u32 crb_sts_consumer;
165 u32 crb_rcv_status_producer;
166 u32 crb_rcv_status_consumer;
167 u32 crb_rcvpeg_state;
168 u32 crb_status_ring_size;
169}; 158};
170 159
171extern struct netxen_recv_crb recv_crb_registers[]; 160extern struct netxen_recv_crb recv_crb_registers[];