f055f98fa379b72b9ca4b90310319b797d523bcb
[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  * Version:     $Revision: 1.9.2.1 $
6  * Date:        $Date: 2001/03/12 16:50:59 $
7  * Purpose:     First header file for driver and all other modules
8  *
9  ******************************************************************************/
10
11 /******************************************************************************
12  *
13  *      (C)Copyright 1998-2001 SysKonnect,
14  *      a business unit of Schneider & Koch & Co. Datensysteme GmbH.
15  *
16  *      This program is free software; you can redistribute it and/or modify
17  *      it under the terms of the GNU General Public License as published by
18  *      the Free Software Foundation; either version 2 of the License, or
19  *      (at your option) any later version.
20  *
21  *      The information in this file is provided "AS IS" without warranty.
22  *
23  ******************************************************************************/
24
25 /******************************************************************************
26  *
27  * History:
28  *
29  *      $Log: skdrv1st.h,v $
30  *      Revision 1.9.2.1  2001/03/12 16:50:59  mlindner
31  *      chg: kernel 2.4 adaption
32  *      
33  *      Revision 1.9  2001/01/22 14:16:04  mlindner
34  *      added ProcFs functionality
35  *      Dual Net functionality integrated
36  *      Rlmt networks added
37  *      
38  *      Revision 1.8  2000/02/21 12:19:18  cgoos
39  *      Added default for SK_DEBUG_CHKMOD/_CHKCAT
40  *      
41  *      Revision 1.7  1999/11/22 13:50:00  cgoos
42  *      Changed license header to GPL.
43  *      Added overwrite for several functions.
44  *      Removed linux 2.0.x definitions.
45  *      Removed PCI vendor ID definition (now in kernel).
46  *      
47  *      Revision 1.6  1999/07/27 08:03:33  cgoos
48  *      Changed SK_IN/OUT macros to readX/writeX instead of memory
49  *      accesses (necessary for ALPHA).
50  *      
51  *      Revision 1.5  1999/07/23 12:10:21  cgoos
52  *      Removed SK_RLMT_SLOW_LOOKAHEAD define.
53  *      
54  *      Revision 1.4  1999/07/14 12:31:13  cgoos
55  *      Added SK_RLMT_SLOW_LOOKAHEAD define.
56  *      
57  *      Revision 1.3  1999/04/07 10:12:54  cgoos
58  *      Added check for KERNEL and OPTIMIZATION defines.
59  *      
60  *      Revision 1.2  1999/03/01 08:51:47  cgoos
61  *      Fixed pcibios_read/write definitions.
62  *      
63  *      Revision 1.1  1999/02/16 07:40:49  cgoos
64  *      First version.
65  *      
66  *      
67  *
68  ******************************************************************************/
69
70 /******************************************************************************
71  *
72  * Description:
73  *
74  * This is the first include file of the driver, which includes all
75  * necessary system header files and some of the GEnesis header files.
76  * It also defines some basic items.
77  *
78  * Include File Hierarchy:
79  *
80  *      see skge.c
81  *
82  ******************************************************************************/
83
84 #ifndef __INC_SKDRV1ST_H
85 #define __INC_SKDRV1ST_H
86
87
88 typedef struct s_AC     SK_AC;
89
90 /* override some default functions with optimized linux functions */
91
92 #define SK_PNMI_STORE_U16(p,v)          memcpy((char*)(p),(char*)&(v),2)
93 #define SK_PNMI_STORE_U32(p,v)          memcpy((char*)(p),(char*)&(v),4)
94 #define SK_PNMI_STORE_U64(p,v)          memcpy((char*)(p),(char*)&(v),8)
95 #define SK_PNMI_READ_U16(p,v)           memcpy((char*)&(v),(char*)(p),2)
96 #define SK_PNMI_READ_U32(p,v)           memcpy((char*)&(v),(char*)(p),2)
97 #define SK_PNMI_READ_U64(p,v)           memcpy((char*)&(v),(char*)(p),2)
98
99 #define SkCsCalculateChecksum(p,l)      ((~ip_compute_csum(p, l)) & 0xffff)
100
101 #define SK_ADDR_EQUAL(a1,a2)            (!memcmp(a1,a2,6))
102
103
104 #if !defined(__OPTIMIZE__)  ||  !defined(__KERNEL__)
105 #warning  You must compile this file with the correct options!
106 #warning  See the last lines of the source file.
107 #error You must compile this driver with "-O".
108 #endif
109
110 #include <linux/version.h>
111 #include <linux/types.h>
112 #include <linux/kernel.h>
113 #include <linux/string.h>
114 #include <linux/errno.h>
115 #include <linux/ioport.h>
116 #include <linux/slab.h>
117 #include <linux/interrupt.h>
118 #include <linux/pci.h>
119 #include <linux/crc32.h>
120 #include <asm/byteorder.h>
121 #include <asm/bitops.h>
122 #include <asm/io.h>
123 #include <linux/netdevice.h>
124 #include <linux/etherdevice.h>
125 #include <linux/skbuff.h>
126
127 #include <linux/init.h>
128 #include <asm/uaccess.h>
129 #include <net/checksum.h>
130
131 #include        "h/sktypes.h"
132 #include        "h/skerror.h"
133 #include        "h/skdebug.h"
134 #include        "h/lm80.h"
135 #include        "h/xmac_ii.h"
136
137 #ifdef __LITTLE_ENDIAN
138 #define SK_LITTLE_ENDIAN
139 #else
140 #define SK_BIG_ENDIAN
141 #endif
142
143
144 /* we use gethrtime(), return unit: nanoseconds */
145 #define SK_TICKS_PER_SEC        HZ
146
147 #define SK_MEM_MAPPED_IO
148
149 // #define SK_RLMT_SLOW_LOOKAHEAD
150
151 #define SK_MAX_MACS             2
152 #define SK_MAX_NETS             2
153
154 #define SK_IOC                  char*
155
156 typedef struct s_DrvRlmtMbuf SK_MBUF;
157
158 #define SK_CONST64      INT64_C
159 #define SK_CONSTU64     UINT64_C
160
161 #define SK_MEMCPY(dest,src,size)        memcpy(dest,src,size)
162 #define SK_MEMCMP(s1,s2,size)           memcmp(s1,s2,size)
163 #define SK_MEMSET(dest,val,size)        memset(dest,val,size)
164 #define SK_STRLEN(pStr)                 strlen((char*)pStr)
165 #define SK_STRNCPY(pDest,pSrc,size)     strncpy((char*)pDest,(char*)pSrc,size)
166 #define SK_STRCMP(pStr1,pStr2)          strcmp((char*)pStr1,(char*)pStr2)
167
168 /* macros to access the adapter */
169 #define SK_OUT8(b,a,v)          writeb(v, (b+a))        
170 #define SK_OUT16(b,a,v)         writew(v, (b+a))        
171 #define SK_OUT32(b,a,v)         writel(v, (b+a))        
172 #define SK_IN8(b,a,pv)          (*(pv) = readb(b+a))
173 #define SK_IN16(b,a,pv)         (*(pv) = readw(b+a))
174 #define SK_IN32(b,a,pv)         (*(pv) = readl(b+a))
175
176 #define int8_t          char
177 #define int16_t         short
178 #define int32_t         long
179 #define int64_t         long long
180 #define uint8_t         u_char
181 #define uint16_t        u_short
182 #define uint32_t        u_long
183 #define uint64_t        unsigned long long
184 #define t_scalar_t      int
185 #define t_uscalar_t     unsigned int
186 #define uintptr_t       unsigned long
187
188 #define __CONCAT__(A,B) A##B
189
190 #define INT32_C(a)              __CONCAT__(a,L)
191 #define INT64_C(a)              __CONCAT__(a,LL)
192 #define UINT32_C(a)             __CONCAT__(a,UL)
193 #define UINT64_C(a)             __CONCAT__(a,ULL)
194
195 #ifdef DEBUG
196 #define SK_DBG_PRINTF           printk
197 #ifndef SK_DEBUG_CHKMOD
198 #define SK_DEBUG_CHKMOD         0
199 #endif
200 #ifndef SK_DEBUG_CHKCAT
201 #define SK_DEBUG_CHKCAT         0
202 #endif
203 /* those come from the makefile */
204 #define SK_DBG_CHKMOD(pAC)      (SK_DEBUG_CHKMOD)
205 #define SK_DBG_CHKCAT(pAC)      (SK_DEBUG_CHKCAT)
206
207 extern void SkDbgPrintf(const char *format,...);
208
209 #define SK_DBGMOD_DRV                   0x00010000
210
211 /**** possible driver debug categories ********************************/
212 #define SK_DBGCAT_DRV_ENTRY             0x00010000
213 #define SK_DBGCAT_DRV_SAP               0x00020000
214 #define SK_DBGCAT_DRV_MCA               0x00040000
215 #define SK_DBGCAT_DRV_TX_PROGRESS       0x00080000
216 #define SK_DBGCAT_DRV_RX_PROGRESS       0x00100000
217 #define SK_DBGCAT_DRV_PROGRESS          0x00200000
218 #define SK_DBGCAT_DRV_MSG               0x00400000
219 #define SK_DBGCAT_DRV_PROM              0x00800000
220 #define SK_DBGCAT_DRV_TX_FRAME          0x01000000
221 #define SK_DBGCAT_DRV_ERROR             0x02000000
222 #define SK_DBGCAT_DRV_INT_SRC           0x04000000
223 #define SK_DBGCAT_DRV_EVENT             0x08000000
224
225 #endif /* DEBUG */
226
227 #define SK_ERR_LOG              SkErrorLog
228
229 extern void SkErrorLog(SK_AC*, int, int, char*);
230
231 #endif /* __INC_SKDRV1ST_H */
232