8e9a77f8e9ca1d871853d72a1e9328fc72c29693
[linux-flexiantxendom0-3.2.10.git] / drivers / net / sk98lin / h / skdrv1st.h
1 /******************************************************************************
2  *
3  * Name:        skdrv1st.h
4  * Project:     GEnesis, PCI Gigabit Ethernet Adapter
5  * Purpose:     First header file for driver and all other modules
6  *
7  ******************************************************************************/
8
9 /******************************************************************************
10  *
11  *      (C)Copyright 1998-2002 SysKonnect GmbH.
12  *      (C)Copyright 2002-2003 Marvell.
13  *
14  *      This program is free software; you can redistribute it and/or modify
15  *      it under the terms of the GNU General Public License as published by
16  *      the Free Software Foundation; either version 2 of the License, or
17  *      (at your option) any later version.
18  *
19  *      The information in this file is provided "AS IS" without warranty.
20  *
21  ******************************************************************************/
22
23 /******************************************************************************
24  *
25  * Description:
26  *
27  * This is the first include file of the driver, which includes all
28  * neccessary system header files and some of the GEnesis header files.
29  * It also defines some basic items.
30  *
31  * Include File Hierarchy:
32  *
33  *      see skge.c
34  *
35  ******************************************************************************/
36
37 #ifndef __INC_SKDRV1ST_H
38 #define __INC_SKDRV1ST_H
39
40 /* Check kernel version */
41 #include <linux/version.h>
42
43 typedef struct s_AC     SK_AC;
44
45 /* Set card versions */
46 #define SK_FAR
47
48 /* override some default functions with optimized linux functions */
49
50 #define SK_PNMI_STORE_U16(p,v)          memcpy((char*)(p),(char*)&(v),2)
51 #define SK_PNMI_STORE_U32(p,v)          memcpy((char*)(p),(char*)&(v),4)
52 #define SK_PNMI_STORE_U64(p,v)          memcpy((char*)(p),(char*)&(v),8)
53 #define SK_PNMI_READ_U16(p,v)           memcpy((char*)&(v),(char*)(p),2)
54 #define SK_PNMI_READ_U32(p,v)           memcpy((char*)&(v),(char*)(p),4)
55 #define SK_PNMI_READ_U64(p,v)           memcpy((char*)&(v),(char*)(p),8)
56
57 #define SK_ADDR_EQUAL(a1,a2)            (!memcmp(a1,a2,6))
58
59 #if !defined(__OPTIMIZE__)  ||  !defined(__KERNEL__)
60 #warning  You must compile this file with the correct options!
61 #warning  See the last lines of the source file.
62 #error You must compile this driver with "-O".
63 #endif
64
65 #include <linux/version.h>
66 #include <linux/types.h>
67 #include <linux/kernel.h>
68 #include <linux/string.h>
69 #include <linux/errno.h>
70 #include <linux/ioport.h>
71 #include <linux/slab.h>
72 #include <linux/interrupt.h>
73 #include <linux/pci.h>
74 #include <asm/byteorder.h>
75 #include <asm/bitops.h>
76 #include <asm/io.h>
77 #include <linux/netdevice.h>
78 #include <linux/etherdevice.h>
79 #include <linux/skbuff.h>
80
81 #include <linux/init.h>
82 #include <asm/uaccess.h>
83 #include <net/checksum.h>
84
85 #define SK_CS_CALCULATE_CHECKSUM
86 #ifndef CONFIG_X86_64
87 #define SkCsCalculateChecksum(p,l)      ((~ip_compute_csum(p, l)) & 0xffff)
88 #else
89 #define SkCsCalculateChecksum(p,l)      ((~ip_fast_csum(p, l)) & 0xffff)
90 #endif
91
92 #include        "h/sktypes.h"
93 #include        "h/skerror.h"
94 #include        "h/skdebug.h"
95 #include        "h/lm80.h"
96 #include        "h/xmac_ii.h"
97
98 #ifdef __LITTLE_ENDIAN
99 #define SK_LITTLE_ENDIAN
100 #else
101 #define SK_BIG_ENDIAN
102 #endif
103
104 #define SK_NET_DEVICE   net_device
105
106
107 /* we use gethrtime(), return unit: nanoseconds */
108 #define SK_TICKS_PER_SEC        100
109
110 #define SK_MEM_MAPPED_IO
111
112 // #define SK_RLMT_SLOW_LOOKAHEAD
113
114 #define SK_MAX_MACS             2
115 #define SK_MAX_NETS             2
116
117 #define SK_IOC                  char*
118
119 typedef struct s_DrvRlmtMbuf SK_MBUF;
120
121 #define SK_CONST64      INT64_C
122 #define SK_CONSTU64     UINT64_C
123
124 #define SK_MEMCPY(dest,src,size)        memcpy(dest,src,size)
125 #define SK_MEMCMP(s1,s2,size)           memcmp(s1,s2,size)
126 #define SK_MEMSET(dest,val,size)        memset(dest,val,size)
127 #define SK_STRLEN(pStr)                 strlen((char*)(pStr))
128 #define SK_STRNCPY(pDest,pSrc,size)     strncpy((char*)(pDest),(char*)(pSrc),size)
129 #define SK_STRCMP(pStr1,pStr2)          strcmp((char*)(pStr1),(char*)(pStr2))
130
131 /* macros to access the adapter */
132 #define SK_OUT8(b,a,v)          writeb((v), ((b)+(a)))  
133 #define SK_OUT16(b,a,v)         writew((v), ((b)+(a)))  
134 #define SK_OUT32(b,a,v)         writel((v), ((b)+(a)))  
135 #define SK_IN8(b,a,pv)          (*(pv) = readb((b)+(a)))
136 #define SK_IN16(b,a,pv)         (*(pv) = readw((b)+(a)))
137 #define SK_IN32(b,a,pv)         (*(pv) = readl((b)+(a)))
138
139 #define int8_t          char
140 #define int16_t         short
141 #define int32_t         long
142 #define int64_t         long long
143 #define uint8_t         u_char
144 #define uint16_t        u_short
145 #define uint32_t        u_long
146 #define uint64_t        unsigned long long
147 #define t_scalar_t      int
148 #define t_uscalar_t     unsigned int
149 #define uintptr_t       unsigned long
150
151 #define __CONCAT__(A,B) A##B
152
153 #define INT32_C(a)              __CONCAT__(a,L)
154 #define INT64_C(a)              __CONCAT__(a,LL)
155 #define UINT32_C(a)             __CONCAT__(a,UL)
156 #define UINT64_C(a)             __CONCAT__(a,ULL)
157
158 #ifdef DEBUG
159 #define SK_DBG_PRINTF           printk
160 #ifndef SK_DEBUG_CHKMOD
161 #define SK_DEBUG_CHKMOD         0
162 #endif
163 #ifndef SK_DEBUG_CHKCAT
164 #define SK_DEBUG_CHKCAT         0
165 #endif
166 /* those come from the makefile */
167 #define SK_DBG_CHKMOD(pAC)      (SK_DEBUG_CHKMOD)
168 #define SK_DBG_CHKCAT(pAC)      (SK_DEBUG_CHKCAT)
169
170 extern void SkDbgPrintf(const char *format,...);
171
172 #define SK_DBGMOD_DRV                   0x00010000
173
174 /**** possible driver debug categories ********************************/
175 #define SK_DBGCAT_DRV_ENTRY             0x00010000
176 #define SK_DBGCAT_DRV_SAP               0x00020000
177 #define SK_DBGCAT_DRV_MCA               0x00040000
178 #define SK_DBGCAT_DRV_TX_PROGRESS       0x00080000
179 #define SK_DBGCAT_DRV_RX_PROGRESS       0x00100000
180 #define SK_DBGCAT_DRV_PROGRESS          0x00200000
181 #define SK_DBGCAT_DRV_MSG               0x00400000
182 #define SK_DBGCAT_DRV_PROM              0x00800000
183 #define SK_DBGCAT_DRV_TX_FRAME          0x01000000
184 #define SK_DBGCAT_DRV_ERROR             0x02000000
185 #define SK_DBGCAT_DRV_INT_SRC           0x04000000
186 #define SK_DBGCAT_DRV_EVENT             0x08000000
187
188 #endif
189
190 #define SK_ERR_LOG              SkErrorLog
191
192 extern void SkErrorLog(SK_AC*, int, int, char*);
193
194 #endif
195