aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netxen/netxen_nic_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r--drivers/net/netxen/netxen_nic_init.c105
1 files changed, 54 insertions, 51 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index d924468e506..ca7c8d8050c 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -308,7 +308,6 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
308 } 308 }
309 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE); 309 memset(rds_ring->rx_buf_arr, 0, RCV_BUFFSIZE);
310 INIT_LIST_HEAD(&rds_ring->free_list); 310 INIT_LIST_HEAD(&rds_ring->free_list);
311 rds_ring->begin_alloc = 0;
312 /* 311 /*
313 * Now go through all of them, set reference handles 312 * Now go through all of them, set reference handles
314 * and put them in the queues. 313 * and put them in the queues.
@@ -439,6 +438,8 @@ static int netxen_wait_rom_done(struct netxen_adapter *adapter)
439 long timeout = 0; 438 long timeout = 0;
440 long done = 0; 439 long done = 0;
441 440
441 cond_resched();
442
442 while (done == 0) { 443 while (done == 0) {
443 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS); 444 done = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_GLB_STATUS);
444 done &= 2; 445 done &= 2;
@@ -533,12 +534,9 @@ static int do_rom_fast_write(struct netxen_adapter *adapter, int addr,
533static int do_rom_fast_read(struct netxen_adapter *adapter, 534static int do_rom_fast_read(struct netxen_adapter *adapter,
534 int addr, int *valp) 535 int addr, int *valp)
535{ 536{
536 cond_resched();
537
538 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); 537 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr);
539 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
540 udelay(100); /* prevent bursting on CRB */
541 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); 538 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
539 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 3);
542 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb); 540 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0xb);
543 if (netxen_wait_rom_done(adapter)) { 541 if (netxen_wait_rom_done(adapter)) {
544 printk("Error waiting for rom done\n"); 542 printk("Error waiting for rom done\n");
@@ -546,7 +544,7 @@ static int do_rom_fast_read(struct netxen_adapter *adapter,
546 } 544 }
547 /* reset abyte_cnt and dummy_byte_cnt */ 545 /* reset abyte_cnt and dummy_byte_cnt */
548 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); 546 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0);
549 udelay(100); /* prevent bursting on CRB */ 547 udelay(10);
550 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0); 548 netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_DUMMY_BYTE_CNT, 0);
551 549
552 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA); 550 *valp = netxen_nic_reg_read(adapter, NETXEN_ROMUSB_ROM_RDATA);
@@ -884,14 +882,16 @@ int netxen_flash_unlock(struct netxen_adapter *adapter)
884int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) 882int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
885{ 883{
886 int addr, val; 884 int addr, val;
887 int i, init_delay = 0; 885 int i, n, init_delay = 0;
888 struct crb_addr_pair *buf; 886 struct crb_addr_pair *buf;
889 unsigned offset, n; 887 unsigned offset;
890 u32 off; 888 u32 off;
891 889
892 /* resetall */ 890 /* resetall */
891 rom_lock(adapter);
893 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET, 892 netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_GLB_SW_RESET,
894 0xffffffff); 893 0xffffffff);
894 netxen_rom_unlock(adapter);
895 895
896 if (verbose) { 896 if (verbose) {
897 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0) 897 if (netxen_rom_fast_read(adapter, NETXEN_BOARDTYPE, &val) == 0)
@@ -910,7 +910,7 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
910 910
911 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) { 911 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
912 if (netxen_rom_fast_read(adapter, 0, &n) != 0 || 912 if (netxen_rom_fast_read(adapter, 0, &n) != 0 ||
913 (n != 0xcafecafeUL) || 913 (n != 0xcafecafe) ||
914 netxen_rom_fast_read(adapter, 4, &n) != 0) { 914 netxen_rom_fast_read(adapter, 4, &n) != 0) {
915 printk(KERN_ERR "%s: ERROR Reading crb_init area: " 915 printk(KERN_ERR "%s: ERROR Reading crb_init area: "
916 "n: %08x\n", netxen_nic_driver_name, n); 916 "n: %08x\n", netxen_nic_driver_name, n);
@@ -975,6 +975,14 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
975 /* do not reset PCI */ 975 /* do not reset PCI */
976 if (off == (ROMUSB_GLB + 0xbc)) 976 if (off == (ROMUSB_GLB + 0xbc))
977 continue; 977 continue;
978 if (off == (ROMUSB_GLB + 0xa8))
979 continue;
980 if (off == (ROMUSB_GLB + 0xc8)) /* core clock */
981 continue;
982 if (off == (ROMUSB_GLB + 0x24)) /* MN clock */
983 continue;
984 if (off == (ROMUSB_GLB + 0x1c)) /* MS clock */
985 continue;
978 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18)) 986 if (off == (NETXEN_CRB_PEG_NET_1 + 0x18))
979 buf[i].data = 0x1020; 987 buf[i].data = 0x1020;
980 /* skip the function enable register */ 988 /* skip the function enable register */
@@ -992,23 +1000,21 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
992 continue; 1000 continue;
993 } 1001 }
994 1002
1003 init_delay = 1;
995 /* After writing this register, HW needs time for CRB */ 1004 /* After writing this register, HW needs time for CRB */
996 /* to quiet down (else crb_window returns 0xffffffff) */ 1005 /* to quiet down (else crb_window returns 0xffffffff) */
997 if (off == NETXEN_ROMUSB_GLB_SW_RESET) { 1006 if (off == NETXEN_ROMUSB_GLB_SW_RESET) {
998 init_delay = 1; 1007 init_delay = 1000;
999 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 1008 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
1000 /* hold xdma in reset also */ 1009 /* hold xdma in reset also */
1001 buf[i].data = NETXEN_NIC_XDMA_RESET; 1010 buf[i].data = NETXEN_NIC_XDMA_RESET;
1011 buf[i].data = 0x8000ff;
1002 } 1012 }
1003 } 1013 }
1004 1014
1005 adapter->hw_write_wx(adapter, off, &buf[i].data, 4); 1015 adapter->hw_write_wx(adapter, off, &buf[i].data, 4);
1006 1016
1007 if (init_delay == 1) { 1017 msleep(init_delay);
1008 msleep(1000);
1009 init_delay = 0;
1010 }
1011 msleep(1);
1012 } 1018 }
1013 kfree(buf); 1019 kfree(buf);
1014 1020
@@ -1277,7 +1283,7 @@ static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid,
1277 1283
1278 dev_kfree_skb_any(skb); 1284 dev_kfree_skb_any(skb);
1279 for (i = 0; i < nr_frags; i++) { 1285 for (i = 0; i < nr_frags; i++) {
1280 index = frag_desc->frag_handles[i]; 1286 index = le16_to_cpu(frag_desc->frag_handles[i]);
1281 skb = netxen_process_rxbuf(adapter, 1287 skb = netxen_process_rxbuf(adapter,
1282 rds_ring, index, cksum); 1288 rds_ring, index, cksum);
1283 if (skb) 1289 if (skb)
@@ -1428,7 +1434,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1428 struct rcv_desc *pdesc; 1434 struct rcv_desc *pdesc;
1429 struct netxen_rx_buffer *buffer; 1435 struct netxen_rx_buffer *buffer;
1430 int count = 0; 1436 int count = 0;
1431 int index = 0;
1432 netxen_ctx_msg msg = 0; 1437 netxen_ctx_msg msg = 0;
1433 dma_addr_t dma; 1438 dma_addr_t dma;
1434 struct list_head *head; 1439 struct list_head *head;
@@ -1436,7 +1441,6 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1436 rds_ring = &recv_ctx->rds_rings[ringid]; 1441 rds_ring = &recv_ctx->rds_rings[ringid];
1437 1442
1438 producer = rds_ring->producer; 1443 producer = rds_ring->producer;
1439 index = rds_ring->begin_alloc;
1440 head = &rds_ring->free_list; 1444 head = &rds_ring->free_list;
1441 1445
1442 /* We can start writing rx descriptors into the phantom memory. */ 1446 /* We can start writing rx descriptors into the phantom memory. */
@@ -1444,39 +1448,37 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid)
1444 1448
1445 skb = dev_alloc_skb(rds_ring->skb_size); 1449 skb = dev_alloc_skb(rds_ring->skb_size);
1446 if (unlikely(!skb)) { 1450 if (unlikely(!skb)) {
1447 rds_ring->begin_alloc = index;
1448 break; 1451 break;
1449 } 1452 }
1450 1453
1454 if (!adapter->ahw.cut_through)
1455 skb_reserve(skb, 2);
1456
1457 dma = pci_map_single(pdev, skb->data,
1458 rds_ring->dma_size, PCI_DMA_FROMDEVICE);
1459 if (pci_dma_mapping_error(pdev, dma)) {
1460 dev_kfree_skb_any(skb);
1461 break;
1462 }
1463
1464 count++;
1451 buffer = list_entry(head->next, struct netxen_rx_buffer, list); 1465 buffer = list_entry(head->next, struct netxen_rx_buffer, list);
1452 list_del(&buffer->list); 1466 list_del(&buffer->list);
1453 1467
1454 count++; /* now there should be no failure */
1455 pdesc = &rds_ring->desc_head[producer];
1456
1457 if (!adapter->ahw.cut_through)
1458 skb_reserve(skb, 2);
1459 /* This will be setup when we receive the
1460 * buffer after it has been filled FSL TBD TBD
1461 * skb->dev = netdev;
1462 */
1463 dma = pci_map_single(pdev, skb->data, rds_ring->dma_size,
1464 PCI_DMA_FROMDEVICE);
1465 pdesc->addr_buffer = cpu_to_le64(dma);
1466 buffer->skb = skb; 1468 buffer->skb = skb;
1467 buffer->state = NETXEN_BUFFER_BUSY; 1469 buffer->state = NETXEN_BUFFER_BUSY;
1468 buffer->dma = dma; 1470 buffer->dma = dma;
1471
1469 /* make a rcv descriptor */ 1472 /* make a rcv descriptor */
1473 pdesc = &rds_ring->desc_head[producer];
1474 pdesc->addr_buffer = cpu_to_le64(dma);
1470 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1475 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1471 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1476 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1472 DPRINTK(INFO, "done writing descripter\n"); 1477
1473 producer = 1478 producer = get_next_index(producer, rds_ring->max_rx_desc_count);
1474 get_next_index(producer, rds_ring->max_rx_desc_count);
1475 index = get_next_index(index, rds_ring->max_rx_desc_count);
1476 } 1479 }
1477 /* if we did allocate buffers, then write the count to Phantom */ 1480 /* if we did allocate buffers, then write the count to Phantom */
1478 if (count) { 1481 if (count) {
1479 rds_ring->begin_alloc = index;
1480 rds_ring->producer = producer; 1482 rds_ring->producer = producer;
1481 /* Window = 1 */ 1483 /* Window = 1 */
1482 adapter->pci_write_normalize(adapter, 1484 adapter->pci_write_normalize(adapter,
@@ -1515,49 +1517,50 @@ static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter,
1515 struct rcv_desc *pdesc; 1517 struct rcv_desc *pdesc;
1516 struct netxen_rx_buffer *buffer; 1518 struct netxen_rx_buffer *buffer;
1517 int count = 0; 1519 int count = 0;
1518 int index = 0;
1519 struct list_head *head; 1520 struct list_head *head;
1521 dma_addr_t dma;
1520 1522
1521 rds_ring = &recv_ctx->rds_rings[ringid]; 1523 rds_ring = &recv_ctx->rds_rings[ringid];
1522 1524
1523 producer = rds_ring->producer; 1525 producer = rds_ring->producer;
1524 index = rds_ring->begin_alloc;
1525 head = &rds_ring->free_list; 1526 head = &rds_ring->free_list;
1526 /* We can start writing rx descriptors into the phantom memory. */ 1527 /* We can start writing rx descriptors into the phantom memory. */
1527 while (!list_empty(head)) { 1528 while (!list_empty(head)) {
1528 1529
1529 skb = dev_alloc_skb(rds_ring->skb_size); 1530 skb = dev_alloc_skb(rds_ring->skb_size);
1530 if (unlikely(!skb)) { 1531 if (unlikely(!skb)) {
1531 rds_ring->begin_alloc = index;
1532 break; 1532 break;
1533 } 1533 }
1534 1534
1535 if (!adapter->ahw.cut_through)
1536 skb_reserve(skb, 2);
1537
1538 dma = pci_map_single(pdev, skb->data,
1539 rds_ring->dma_size, PCI_DMA_FROMDEVICE);
1540 if (pci_dma_mapping_error(pdev, dma)) {
1541 dev_kfree_skb_any(skb);
1542 break;
1543 }
1544
1545 count++;
1535 buffer = list_entry(head->next, struct netxen_rx_buffer, list); 1546 buffer = list_entry(head->next, struct netxen_rx_buffer, list);
1536 list_del(&buffer->list); 1547 list_del(&buffer->list);
1537 1548
1538 count++; /* now there should be no failure */
1539 pdesc = &rds_ring->desc_head[producer];
1540 if (!adapter->ahw.cut_through)
1541 skb_reserve(skb, 2);
1542 buffer->skb = skb; 1549 buffer->skb = skb;
1543 buffer->state = NETXEN_BUFFER_BUSY; 1550 buffer->state = NETXEN_BUFFER_BUSY;
1544 buffer->dma = pci_map_single(pdev, skb->data, 1551 buffer->dma = dma;
1545 rds_ring->dma_size,
1546 PCI_DMA_FROMDEVICE);
1547 1552
1548 /* make a rcv descriptor */ 1553 /* make a rcv descriptor */
1554 pdesc = &rds_ring->desc_head[producer];
1549 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle); 1555 pdesc->reference_handle = cpu_to_le16(buffer->ref_handle);
1550 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size); 1556 pdesc->buffer_length = cpu_to_le32(rds_ring->dma_size);
1551 pdesc->addr_buffer = cpu_to_le64(buffer->dma); 1557 pdesc->addr_buffer = cpu_to_le64(buffer->dma);
1552 producer = 1558
1553 get_next_index(producer, rds_ring->max_rx_desc_count); 1559 producer = get_next_index(producer, rds_ring->max_rx_desc_count);
1554 index = get_next_index(index, rds_ring->max_rx_desc_count);
1555 buffer = &rds_ring->rx_buf_arr[index];
1556 } 1560 }
1557 1561
1558 /* if we did allocate buffers, then write the count to Phantom */ 1562 /* if we did allocate buffers, then write the count to Phantom */
1559 if (count) { 1563 if (count) {
1560 rds_ring->begin_alloc = index;
1561 rds_ring->producer = producer; 1564 rds_ring->producer = producer;
1562 /* Window = 1 */ 1565 /* Window = 1 */
1563 adapter->pci_write_normalize(adapter, 1566 adapter->pci_write_normalize(adapter,