wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | |
| 2 | /******************************************************************************/ |
| 3 | /* */ |
| 4 | /* Broadcom BCM5700 Linux Network Driver, Copyright (c) 2000 Broadcom */ |
| 5 | /* Corporation. */ |
| 6 | /* All rights reserved. */ |
| 7 | /* */ |
| 8 | /* This program is free software; you can redistribute it and/or modify */ |
| 9 | /* it under the terms of the GNU General Public License as published by */ |
| 10 | /* the Free Software Foundation, located in the file LICENSE. */ |
| 11 | /* */ |
| 12 | /******************************************************************************/ |
| 13 | |
| 14 | #ifndef MM_H |
| 15 | #define MM_H |
| 16 | |
| 17 | #define __raw_readl readl |
| 18 | #define __raw_writel writel |
| 19 | |
| 20 | #define BIG_ENDIAN_HOST 1 |
| 21 | #define readl(addr) (*(volatile unsigned int*)(addr)) |
| 22 | #define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b)) |
| 23 | |
| 24 | /* Define memory barrier function here if needed */ |
| 25 | #define wmb() |
| 26 | #define membar() |
| 27 | #include <common.h> |
| 28 | #include <asm/types.h> |
| 29 | #include "bcm570x_lm.h" |
| 30 | #include "bcm570x_queue.h" |
| 31 | #include "tigon3.h" |
| 32 | #include <pci.h> |
| 33 | |
| 34 | #define FALSE 0 |
| 35 | #define TRUE 1 |
| 36 | #define ERROR -1 |
| 37 | |
| 38 | #if DBG |
| 39 | #define STATIC |
| 40 | #else |
| 41 | #define STATIC static |
| 42 | #endif |
| 43 | |
| 44 | extern int MM_Packet_Desc_Size; |
| 45 | |
| 46 | #define MM_PACKET_DESC_SIZE MM_Packet_Desc_Size |
| 47 | |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 48 | DECLARE_QUEUE_TYPE (UM_RX_PACKET_Q, MAX_RX_PACKET_DESC_COUNT + 1); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 49 | |
| 50 | #define MAX_MEM 16 |
| 51 | |
| 52 | /* Synch */ |
| 53 | typedef int mutex_t; |
| 54 | typedef int spinlock_t; |
| 55 | |
| 56 | /* Embedded device control */ |
| 57 | typedef struct _UM_DEVICE_BLOCK { |
| 58 | LM_DEVICE_BLOCK lm_dev; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 59 | pci_dev_t pdev; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 60 | char *name; |
| 61 | void *mem_list[MAX_MEM]; |
| 62 | dma_addr_t dma_list[MAX_MEM]; |
| 63 | int mem_size_list[MAX_MEM]; |
| 64 | int mem_list_num; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 65 | int mtu; |
| 66 | int index; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 67 | int opened; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 68 | int delayed_link_ind; /* Delay link status during initial load */ |
| 69 | int adapter_just_inited; /* the first few seconds after init. */ |
| 70 | int spurious_int; /* new -- unsupported */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 71 | int timer_interval; |
| 72 | int adaptive_expiry; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 73 | int crc_counter_expiry; /* new -- unsupported */ |
| 74 | int poll_tib_expiry; /* new -- unsupported */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 75 | int tx_full; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 76 | int tx_queued; |
| 77 | int line_speed; /* in Mbps, 0 if link is down */ |
| 78 | UM_RX_PACKET_Q rx_out_of_buf_q; |
| 79 | int rx_out_of_buf; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 80 | int rx_low_buf_thresh; /* changed to rx_buf_repl_thresh */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 81 | int rx_buf_repl_panic_thresh; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 82 | int rx_buf_align; /* new -- unsupported */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 83 | int do_global_lock; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 84 | mutex_t global_lock; |
| 85 | mutex_t undi_lock; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 86 | long undi_flags; |
| 87 | volatile int interrupt; |
| 88 | int tasklet_pending; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 89 | int tasklet_busy; /* new -- unsupported */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 90 | int rx_pkt; |
| 91 | int tx_pkt; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 92 | #ifdef NICE_SUPPORT /* unsupported, this is a linux ioctl */ |
| 93 | void (*nice_rx) (void *, void *); |
| 94 | void *nice_ctx; |
| 95 | #endif /* NICE_SUPPORT */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 96 | int rx_adaptive_coalesce; |
| 97 | unsigned int rx_last_cnt; |
| 98 | unsigned int tx_last_cnt; |
| 99 | unsigned int rx_curr_coalesce_frames; |
| 100 | unsigned int rx_curr_coalesce_ticks; |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 101 | unsigned int tx_curr_coalesce_frames; /* new -- unsupported */ |
| 102 | #if TIGON3_DEBUG /* new -- unsupported */ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 103 | uint tx_zc_count; |
| 104 | uint tx_chksum_count; |
| 105 | uint tx_himem_count; |
| 106 | uint rx_good_chksum_count; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 107 | #endif |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 108 | unsigned int rx_bad_chksum_count; /* new -- unsupported */ |
| 109 | unsigned int rx_misc_errors; /* new -- unsupported */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 110 | } UM_DEVICE_BLOCK, *PUM_DEVICE_BLOCK; |
| 111 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 112 | /* Physical/PCI DMA address */ |
| 113 | typedef union { |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 114 | dma_addr_t dma_map; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 115 | } dma_map_t; |
| 116 | |
| 117 | /* Packet */ |
| 118 | typedef struct |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 119 | _UM_PACKET { |
| 120 | LM_PACKET lm_packet; |
| 121 | void *skbuff; /* Address of packet buffer */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 122 | } UM_PACKET, *PUM_PACKET; |
| 123 | |
| 124 | #define MM_ACQUIRE_UNDI_LOCK(_pDevice) |
| 125 | #define MM_RELEASE_UNDI_LOCK(_pDevice) |
| 126 | #define MM_ACQUIRE_INT_LOCK(_pDevice) |
| 127 | #define MM_RELEASE_INT_LOCK(_pDevice) |
| 128 | #define MM_UINT_PTR(_ptr) ((unsigned long) (_ptr)) |
| 129 | |
| 130 | /* Macro for setting 64bit address struct */ |
| 131 | #define set_64bit_addr(paddr, low, high) \ |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 132 | (paddr)->Low = low; \ |
| 133 | (paddr)->High = high; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 134 | |
| 135 | /* Assume that PCI controller's view of host memory is same as host */ |
| 136 | |
| 137 | #define MEM_TO_PCI_PHYS(addr) (addr) |
| 138 | |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 139 | extern void MM_SetAddr (LM_PHYSICAL_ADDRESS * paddr, dma_addr_t addr); |
| 140 | extern void MM_SetT3Addr (T3_64BIT_HOST_ADDR * paddr, dma_addr_t addr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 141 | extern void MM_MapTxDma (PLM_DEVICE_BLOCK pDevice, |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 142 | struct _LM_PACKET *pPacket, T3_64BIT_HOST_ADDR * paddr, |
| 143 | LM_UINT32 * len, int frag); |
| 144 | extern void MM_MapRxDma (PLM_DEVICE_BLOCK pDevice, |
| 145 | struct _LM_PACKET *pPacket, |
| 146 | T3_64BIT_HOST_ADDR * paddr); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 147 | |
| 148 | /* BSP needs to provide sysUsecDelay and sysSerialPrintString */ |
| 149 | extern void sysSerialPrintString (char *s); |
| 150 | #define MM_Wait(usec) udelay(usec) |
| 151 | |
| 152 | /* Define memory barrier function here if needed */ |
| 153 | #define wmb() |
| 154 | |
| 155 | #if 0 |
| 156 | #define cpu_to_le32(val) LONGSWAP(val) |
| 157 | #endif |
Vadim Bendebury | 6ddfee5 | 2007-05-24 15:52:25 -0700 | [diff] [blame^] | 158 | #endif /* MM_H */ |