diff options
author | David Woodhouse <dwmw2@infradead.org> | 2008-02-03 18:29:41 +1100 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2008-02-03 18:30:32 +1100 |
commit | c1f3ee120bb61045b1c0a3ead620d1d65af47130 (patch) | |
tree | 908430bf2b47fe8e96ac623ae7ab6dd5698d0938 /drivers/net/netxen/netxen_nic_init.c | |
parent | e619a75ff6201b567a539e787aa9af9bc63a3187 (diff) | |
parent | 9135f1901ee6449dfe338adf6e40e9c2025b8150 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Diffstat (limited to 'drivers/net/netxen/netxen_nic_init.c')
-rw-r--r-- | drivers/net/netxen/netxen_nic_init.c | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index 37589265297..9e38bcb3fba 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c @@ -54,13 +54,17 @@ static unsigned int crb_addr_xform[NETXEN_MAX_CRB_XFORM]; #define NETXEN_NIC_XDMA_RESET 0x8000ff -static inline void -netxen_nic_locked_write_reg(struct netxen_adapter *adapter, - unsigned long off, int *data) +static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, + uint32_t ctx, uint32_t ringid); + +#if 0 +static void netxen_nic_locked_write_reg(struct netxen_adapter *adapter, + unsigned long off, int *data) { void __iomem *addr = pci_base_offset(adapter, off); writel(*data, addr); } +#endif /* 0 */ static void crb_addr_transform_setup(void) { @@ -255,7 +259,7 @@ void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) * netxen_decode_crb_addr(0 - utility to translate from internal Phantom CRB * address to external PCI CRB address. */ -u32 netxen_decode_crb_addr(u32 addr) +static u32 netxen_decode_crb_addr(u32 addr) { int i; u32 base_addr, offset, pci_base; @@ -282,7 +286,7 @@ static long rom_max_timeout = 100; static long rom_lock_timeout = 10000; static long rom_write_timeout = 700; -static inline int rom_lock(struct netxen_adapter *adapter) +static int rom_lock(struct netxen_adapter *adapter) { int iter; u32 done = 0; @@ -312,7 +316,7 @@ static inline int rom_lock(struct netxen_adapter *adapter) return 0; } -int netxen_wait_rom_done(struct netxen_adapter *adapter) +static int netxen_wait_rom_done(struct netxen_adapter *adapter) { long timeout = 0; long done = 0; @@ -329,7 +333,7 @@ int netxen_wait_rom_done(struct netxen_adapter *adapter) return 0; } -static inline int netxen_rom_wren(struct netxen_adapter *adapter) +static int netxen_rom_wren(struct netxen_adapter *adapter) { /* Set write enable latch in ROM status register */ netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ABYTE_CNT, 0); @@ -341,15 +345,15 @@ static inline int netxen_rom_wren(struct netxen_adapter *adapter) return 0; } -static inline unsigned int netxen_rdcrbreg(struct netxen_adapter *adapter, - unsigned int addr) +static unsigned int netxen_rdcrbreg(struct netxen_adapter *adapter, + unsigned int addr) { unsigned int data = 0xdeaddead; data = netxen_nic_reg_read(adapter, addr); return data; } -static inline int netxen_do_rom_rdsr(struct netxen_adapter *adapter) +static int netxen_do_rom_rdsr(struct netxen_adapter *adapter) { netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, M25P_INSTR_RDSR); @@ -359,7 +363,7 @@ static inline int netxen_do_rom_rdsr(struct netxen_adapter *adapter) return netxen_rdcrbreg(adapter, NETXEN_ROMUSB_ROM_RDATA); } -static inline void netxen_rom_unlock(struct netxen_adapter *adapter) +static void netxen_rom_unlock(struct netxen_adapter *adapter) { u32 val; @@ -368,7 +372,7 @@ static inline void netxen_rom_unlock(struct netxen_adapter *adapter) } -int netxen_rom_wip_poll(struct netxen_adapter *adapter) +static int netxen_rom_wip_poll(struct netxen_adapter *adapter) { long timeout = 0; long wip = 1; @@ -385,8 +389,8 @@ int netxen_rom_wip_poll(struct netxen_adapter *adapter) return 0; } -static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr, - int data) +static int do_rom_fast_write(struct netxen_adapter *adapter, int addr, + int data) { if (netxen_rom_wren(adapter)) { return -1; @@ -404,8 +408,8 @@ static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr, return netxen_rom_wip_poll(adapter); } -static inline int -do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) +static int do_rom_fast_read(struct netxen_adapter *adapter, + int addr, int *valp) { cond_resched(); @@ -427,18 +431,18 @@ do_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) return 0; } -static inline int -do_rom_fast_read_words(struct netxen_adapter *adapter, int addr, - u8 *bytes, size_t size) +static int do_rom_fast_read_words(struct netxen_adapter *adapter, int addr, + u8 *bytes, size_t size) { int addridx; int ret = 0; for (addridx = addr; addridx < (addr + size); addridx += 4) { - ret = do_rom_fast_read(adapter, addridx, (int *)bytes); + int v; + ret = do_rom_fast_read(adapter, addridx, &v); if (ret != 0) break; - *(int *)bytes = cpu_to_le32(*(int *)bytes); + *(__le32 *)bytes = cpu_to_le32(v); bytes += 4; } @@ -446,7 +450,7 @@ do_rom_fast_read_words(struct netxen_adapter *adapter, int addr, } int -netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, +netxen_rom_fast_read_words(struct netxen_adapter *adapter, int addr, u8 *bytes, size_t size) { int ret; @@ -473,6 +477,7 @@ int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, int *valp) return ret; } +#if 0 int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data) { int ret = 0; @@ -484,9 +489,10 @@ int netxen_rom_fast_write(struct netxen_adapter *adapter, int addr, int data) netxen_rom_unlock(adapter); return ret; } +#endif /* 0 */ -static inline int do_rom_fast_write_words(struct netxen_adapter *adapter, - int addr, u8 *bytes, size_t size) +static int do_rom_fast_write_words(struct netxen_adapter *adapter, + int addr, u8 *bytes, size_t size) { int addridx = addr; int ret = 0; @@ -496,11 +502,11 @@ static inline int do_rom_fast_write_words(struct netxen_adapter *adapter, int timeout = 0; int data; - data = le32_to_cpu((*(u32*)bytes)); + data = le32_to_cpu((*(__le32*)bytes)); ret = do_rom_fast_write(adapter, addridx, data); if (ret < 0) return ret; - + while(1) { int data1; @@ -513,7 +519,7 @@ static inline int do_rom_fast_write_words(struct netxen_adapter *adapter, if (timeout++ >= rom_write_timeout) { if (last_attempt++ < 4) { - ret = do_rom_fast_write(adapter, + ret = do_rom_fast_write(adapter, addridx, data); if (ret < 0) return ret; @@ -533,7 +539,7 @@ static inline int do_rom_fast_write_words(struct netxen_adapter *adapter, return ret; } -int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, +int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, u8 *bytes, size_t size) { int ret = 0; @@ -548,7 +554,7 @@ int netxen_rom_fast_write_words(struct netxen_adapter *adapter, int addr, return ret; } -int netxen_rom_wrsr(struct netxen_adapter *adapter, int data) +static int netxen_rom_wrsr(struct netxen_adapter *adapter, int data) { int ret; @@ -557,7 +563,7 @@ int netxen_rom_wrsr(struct netxen_adapter *adapter, int data) return ret; netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_ROM_WDATA, data); - netxen_crb_writelit_adapter(adapter, + netxen_crb_writelit_adapter(adapter, NETXEN_ROMUSB_ROM_INSTR_OPCODE, 0x1); ret = netxen_wait_rom_done(adapter); @@ -567,7 +573,7 @@ int netxen_rom_wrsr(struct netxen_adapter *adapter, int data) return netxen_rom_wip_poll(adapter); } -int netxen_rom_rdsr(struct netxen_adapter *adapter) +static int netxen_rom_rdsr(struct netxen_adapter *adapter) { int ret; @@ -587,7 +593,7 @@ int netxen_backup_crbinit(struct netxen_adapter *adapter) char *buffer = kmalloc(NETXEN_FLASH_SECTOR_SIZE, GFP_KERNEL); if (!buffer) - return -ENOMEM; + return -ENOMEM; /* unlock sector 63 */ val = netxen_rom_rdsr(adapter); val = val & 0xe3; @@ -600,12 +606,12 @@ int netxen_backup_crbinit(struct netxen_adapter *adapter) goto out_kfree; /* copy sector 0 to sector 63 */ - ret = netxen_rom_fast_read_words(adapter, NETXEN_CRBINIT_START, + ret = netxen_rom_fast_read_words(adapter, NETXEN_CRBINIT_START, buffer, NETXEN_FLASH_SECTOR_SIZE); if (ret != FLASH_SUCCESS) goto out_kfree; - ret = netxen_rom_fast_write_words(adapter, NETXEN_FIXED_START, + ret = netxen_rom_fast_write_words(adapter, NETXEN_FIXED_START, buffer, NETXEN_FLASH_SECTOR_SIZE); if (ret != FLASH_SUCCESS) goto out_kfree; @@ -632,7 +638,7 @@ out_kfree: return ret; } -int netxen_do_rom_se(struct netxen_adapter *adapter, int addr) +static int netxen_do_rom_se(struct netxen_adapter *adapter, int addr) { netxen_rom_wren(adapter); netxen_nic_reg_write(adapter, NETXEN_ROMUSB_ROM_ADDRESS, addr); @@ -646,16 +652,16 @@ int netxen_do_rom_se(struct netxen_adapter *adapter, int addr) return netxen_rom_wip_poll(adapter); } -void check_erased_flash(struct netxen_adapter *adapter, int addr) +static void check_erased_flash(struct netxen_adapter *adapter, int addr) { int i; int val; int count = 0, erased_errors = 0; int range; - range = (addr == NETXEN_USER_START) ? + range = (addr == NETXEN_USER_START) ? NETXEN_FIXED_START : addr + NETXEN_FLASH_SECTOR_SIZE; - + for (i = addr; i < range; i += 4) { netxen_rom_fast_read(adapter, i, &val); if (val != 0xffffffff) @@ -682,8 +688,8 @@ int netxen_rom_se(struct netxen_adapter *adapter, int addr) return ret; } -int -netxen_flash_erase_sections(struct netxen_adapter *adapter, int start, int end) +static int netxen_flash_erase_sections(struct netxen_adapter *adapter, + int start, int end) { int ret = FLASH_SUCCESS; int i; @@ -990,7 +996,7 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter) return 0; } -static inline int netxen_nic_check_temp(struct netxen_adapter *adapter) +static int netxen_nic_check_temp(struct netxen_adapter *adapter) { struct net_device *netdev = adapter->netdev; uint32_t temp, temp_state, temp_val; @@ -1064,22 +1070,22 @@ void netxen_watchdog_task(struct work_struct *work) * and if the number of receives exceeds RX_BUFFERS_REFILL, then we * invoke the routine to send more rx buffers to the Phantom... */ -void -netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, - struct status_desc *desc) +static void netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, + struct status_desc *desc) { struct pci_dev *pdev = adapter->pdev; struct net_device *netdev = adapter->netdev; - int index = netxen_get_sts_refhandle(desc); + u64 sts_data = le64_to_cpu(desc->status_desc_data); + int index = netxen_get_sts_refhandle(sts_data); struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); struct netxen_rx_buffer *buffer; struct sk_buff *skb; - u32 length = netxen_get_sts_totallength(desc); + u32 length = netxen_get_sts_totallength(sts_data); u32 desc_ctx; struct netxen_rcv_desc_ctx *rcv_desc; int ret; - desc_ctx = netxen_get_sts_type(desc); + desc_ctx = netxen_get_sts_type(sts_data); if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { printk("%s: %s Bad Rcv descriptor ring\n", netxen_nic_driver_name, netdev->name); @@ -1102,8 +1108,8 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, } if (buffer->lro_current_frags != buffer->lro_expected_frags) { if (buffer->lro_expected_frags != 0) { - printk("LRO: (refhandle:%x) recv frag." - "wait for last. flags: %x expected:%d" + printk("LRO: (refhandle:%x) recv frag. " + "wait for last. flags: %x expected:%d " "have:%d\n", index, netxen_get_sts_desc_lro_last_frag(desc), buffer->lro_expected_frags, @@ -1119,7 +1125,7 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, skb = (struct sk_buff *)buffer->skb; if (likely(adapter->rx_csum && - netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { + netxen_get_sts_status(sts_data) == STATUS_CKSUM_OK)) { adapter->stats.csummed++; skb->ip_summed = CHECKSUM_UNNECESSARY; } else @@ -1209,7 +1215,6 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) break; } netxen_process_rcv(adapter, ctxid, desc); - netxen_clear_sts_owner(desc); netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM); consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); count++; @@ -1248,7 +1253,6 @@ int netxen_process_cmd_ring(unsigned long data) struct pci_dev *pdev; struct netxen_skb_frag *frag; u32 i; - struct sk_buff *skb = NULL; int done; spin_lock(&adapter->tx_lock); @@ -1278,9 +1282,8 @@ int netxen_process_cmd_ring(unsigned long data) while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { buffer = &adapter->cmd_buf_arr[last_consumer]; pdev = adapter->pdev; - frag = &buffer->frag_array[0]; - skb = buffer->skb; - if (skb && (cmpxchg(&buffer->skb, skb, 0) == skb)) { + if (buffer->skb) { + frag = &buffer->frag_array[0]; pci_unmap_single(pdev, frag->dma, frag->length, PCI_DMA_TODEVICE); frag->dma = 0ULL; @@ -1293,8 +1296,8 @@ int netxen_process_cmd_ring(unsigned long data) } adapter->stats.skbfreed++; - dev_kfree_skb_any(skb); - skb = NULL; + dev_kfree_skb_any(buffer->skb); + buffer->skb = NULL; } else if (adapter->proc_cmd_buf_counter == 1) { adapter->stats.txnullskb++; } @@ -1460,8 +1463,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) } } -void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, - uint32_t ringid) +static void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, + uint32_t ctx, uint32_t ringid) { struct pci_dev *pdev = adapter->ahw.pdev; struct sk_buff *skb; @@ -1493,7 +1496,7 @@ void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, count++; /* now there should be no failure */ pdesc = &rcv_desc->desc_head[producer]; skb_reserve(skb, 2); - /* + /* * This will be setup when we receive the * buffer after it has been filled * skb->dev = netdev; |