1 /******************************************************************************
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
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2001 SysKonnect,
14 * a business unit of Schneider & Koch & Co. Datensysteme GmbH.
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.
21 * The information in this file is provided "AS IS" without warranty.
23 ******************************************************************************/
25 /******************************************************************************
29 * $Log: skdrv1st.h,v $
30 * Revision 1.9.2.1 2001/03/12 16:50:59 mlindner
31 * chg: kernel 2.4 adaption
33 * Revision 1.9 2001/01/22 14:16:04 mlindner
34 * added ProcFs functionality
35 * Dual Net functionality integrated
38 * Revision 1.8 2000/02/21 12:19:18 cgoos
39 * Added default for SK_DEBUG_CHKMOD/_CHKCAT
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).
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).
51 * Revision 1.5 1999/07/23 12:10:21 cgoos
52 * Removed SK_RLMT_SLOW_LOOKAHEAD define.
54 * Revision 1.4 1999/07/14 12:31:13 cgoos
55 * Added SK_RLMT_SLOW_LOOKAHEAD define.
57 * Revision 1.3 1999/04/07 10:12:54 cgoos
58 * Added check for KERNEL and OPTIMIZATION defines.
60 * Revision 1.2 1999/03/01 08:51:47 cgoos
61 * Fixed pcibios_read/write definitions.
63 * Revision 1.1 1999/02/16 07:40:49 cgoos
68 ******************************************************************************/
70 /******************************************************************************
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.
78 * Include File Hierarchy:
82 ******************************************************************************/
84 #ifndef __INC_SKDRV1ST_H
85 #define __INC_SKDRV1ST_H
88 typedef struct s_AC SK_AC;
90 /* override some default functions with optimized linux functions */
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)
99 #define SkCsCalculateChecksum(p,l) ((~ip_compute_csum(p, l)) & 0xffff)
101 #define SK_ADDR_EQUAL(a1,a2) (!memcmp(a1,a2,6))
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".
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>
123 #include <linux/netdevice.h>
124 #include <linux/etherdevice.h>
125 #include <linux/skbuff.h>
127 #include <linux/init.h>
128 #include <asm/uaccess.h>
129 #include <net/checksum.h>
131 #include "h/sktypes.h"
132 #include "h/skerror.h"
133 #include "h/skdebug.h"
135 #include "h/xmac_ii.h"
137 #ifdef __LITTLE_ENDIAN
138 #define SK_LITTLE_ENDIAN
140 #define SK_BIG_ENDIAN
144 /* we use gethrtime(), return unit: nanoseconds */
145 #define SK_TICKS_PER_SEC HZ
147 #define SK_MEM_MAPPED_IO
149 // #define SK_RLMT_SLOW_LOOKAHEAD
151 #define SK_MAX_MACS 2
152 #define SK_MAX_NETS 2
156 typedef struct s_DrvRlmtMbuf SK_MBUF;
158 #define SK_CONST64 INT64_C
159 #define SK_CONSTU64 UINT64_C
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)
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))
177 #define int16_t short
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
188 #define __CONCAT__(A,B) A##B
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)
196 #define SK_DBG_PRINTF printk
197 #ifndef SK_DEBUG_CHKMOD
198 #define SK_DEBUG_CHKMOD 0
200 #ifndef SK_DEBUG_CHKCAT
201 #define SK_DEBUG_CHKCAT 0
203 /* those come from the makefile */
204 #define SK_DBG_CHKMOD(pAC) (SK_DEBUG_CHKMOD)
205 #define SK_DBG_CHKCAT(pAC) (SK_DEBUG_CHKCAT)
207 extern void SkDbgPrintf(const char *format,...);
209 #define SK_DBGMOD_DRV 0x00010000
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
227 #define SK_ERR_LOG SkErrorLog
229 extern void SkErrorLog(SK_AC*, int, int, char*);
231 #endif /* __INC_SKDRV1ST_H */