diff options
author | Dhananjay Phadke <dhananjay@netxen.com> | 2008-07-21 22:44:00 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-07-22 17:50:55 -0400 |
commit | 7830b22cbc5f5e804469b74a3fe0d3a8ed88ca31 (patch) | |
tree | e7779997b1a62f7a4e0003d51132ec710981c258 /drivers/net/netxen/netxen_nic_init.c | |
parent | f0084a36d4d799c024a5211555334d56c91d236d (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/netxen_nic_init.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 88 |
1 files changed, 23 insertions, 65 deletions
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 | ||
45 | unsigned long last_schedule_time; | ||
46 | |||
47 | #define NETXEN_MAX_CRB_XFORM 60 | 45 | #define NETXEN_MAX_CRB_XFORM 60 |
48 | static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; | 46 | static 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 | |||
160 | void *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 | |||
176 | void netxen_initialize_adapter_sw(struct netxen_adapter *adapter) | 156 | void 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 | ||
271 | static long rom_max_timeout = 100; | 251 | static long rom_max_timeout = 100; |
272 | static long rom_lock_timeout = 10000; | 252 | static long rom_lock_timeout = 10000; |
253 | #if 0 | ||
273 | static long rom_write_timeout = 700; | 254 | static long rom_write_timeout = 700; |
255 | #endif | ||
274 | 256 | ||
275 | static int rom_lock(struct netxen_adapter *adapter) | 257 | static 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 | ||
322 | static int netxen_rom_wren(struct netxen_adapter *adapter) | 305 | static 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 | ||
352 | static void netxen_rom_unlock(struct netxen_adapter *adapter) | 336 | static 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 | ||
361 | static int netxen_rom_wip_poll(struct netxen_adapter *adapter) | 346 | static 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 | ||
397 | static int do_rom_fast_read(struct netxen_adapter *adapter, | 383 | static 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 | ||
480 | static int do_rom_fast_write_words(struct netxen_adapter *adapter, | 465 | static 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 | ||
751 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) | 735 | int 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 | */ |
1232 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | 1201 | void 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) | |||
1325 | static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, | 1289 | static 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 | } |