1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.11 $
6 * Date: $Date: 2003/02/25 14:16:40 $
7 * Purpose: First header file for driver and all other modules
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * The information in this file is provided "AS IS" without warranty.
22 ******************************************************************************/
24 /******************************************************************************
28 * $Log: skdrv1st.h,v $
29 * Revision 1.11 2003/02/25 14:16:40 mlindner
30 * Fix: Copyright statement
32 * Revision 1.10 2002/10/02 12:46:02 mlindner
33 * Add: Support for Yukon
35 * Revision 1.9.2.2 2001/12/07 12:06:42 mlindner
36 * Fix: malloc -> slab changes
38 * Revision 1.9.2.1 2001/03/12 16:50:59 mlindner
39 * chg: kernel 2.4 adaption
41 * Revision 1.9 2001/01/22 14:16:04 mlindner
42 * added ProcFs functionality
43 * Dual Net functionality integrated
46 * Revision 1.8 2000/02/21 12:19:18 cgoos
47 * Added default for SK_DEBUG_CHKMOD/_CHKCAT
49 * Revision 1.7 1999/11/22 13:50:00 cgoos
50 * Changed license header to GPL.
51 * Added overwrite for several functions.
52 * Removed linux 2.0.x definitions.
53 * Removed PCI vendor ID definition (now in kernel).
55 * Revision 1.6 1999/07/27 08:03:33 cgoos
56 * Changed SK_IN/OUT macros to readX/writeX instead of memory
57 * accesses (necessary for ALPHA).
59 * Revision 1.5 1999/07/23 12:10:21 cgoos
60 * Removed SK_RLMT_SLOW_LOOKAHEAD define.
62 * Revision 1.4 1999/07/14 12:31:13 cgoos
63 * Added SK_RLMT_SLOW_LOOKAHEAD define.
65 * Revision 1.3 1999/04/07 10:12:54 cgoos
66 * Added check for KERNEL and OPTIMIZATION defines.
68 * Revision 1.2 1999/03/01 08:51:47 cgoos
69 * Fixed pcibios_read/write definitions.
71 * Revision 1.1 1999/02/16 07:40:49 cgoos
76 ******************************************************************************/
78 /******************************************************************************
82 * This is the first include file of the driver, which includes all
83 * neccessary system header files and some of the GEnesis header files.
84 * It also defines some basic items.
86 * Include File Hierarchy:
90 ******************************************************************************/
92 #ifndef __INC_SKDRV1ST_H
93 #define __INC_SKDRV1ST_H
96 /* Check kernel version */
97 #include <linux/version.h>
98 #if (LINUX_VERSION_CODE > 0x020300)
102 typedef struct s_AC SK_AC;
104 /* override some default functions with optimized linux functions */
106 #define SK_PNMI_STORE_U16(p,v) memcpy((char*)(p),(char*)&(v),2)
107 #define SK_PNMI_STORE_U32(p,v) memcpy((char*)(p),(char*)&(v),4)
108 #define SK_PNMI_STORE_U64(p,v) memcpy((char*)(p),(char*)&(v),8)
109 #define SK_PNMI_READ_U16(p,v) memcpy((char*)&(v),(char*)(p),2)
110 #define SK_PNMI_READ_U32(p,v) memcpy((char*)&(v),(char*)(p),2)
111 #define SK_PNMI_READ_U64(p,v) memcpy((char*)&(v),(char*)(p),2)
113 #define SkCsCalculateChecksum(p,l) ((~ip_compute_csum(p, l)) & 0xffff)
115 #define SK_ADDR_EQUAL(a1,a2) (!memcmp(a1,a2,6))
118 #if !defined(__OPTIMIZE__) || !defined(__KERNEL__)
119 #warning You must compile this file with the correct options!
120 #warning See the last lines of the source file.
121 #error You must compile this driver with "-O".
125 #include <linux/version.h>
127 #include <linux/types.h>
129 #include <linux/kernel.h>
131 #include <linux/string.h>
133 #include <linux/errno.h>
134 #include <linux/ioport.h>
135 #include <linux/slab.h>
136 #include <linux/interrupt.h>
137 #include <linux/pci.h>
139 #include <asm/byteorder.h>
140 #include <asm/bitops.h>
143 #include <linux/netdevice.h>
144 #include <linux/etherdevice.h>
145 #include <linux/skbuff.h>
147 #include <linux/init.h>
148 #include <asm/uaccess.h>
149 #include <net/checksum.h>
152 #include "h/sktypes.h"
153 #include "h/skerror.h"
154 #include "h/skdebug.h"
156 #include "h/xmac_ii.h"
158 #include "u-boot_compat.h"
160 #ifdef __LITTLE_ENDIAN
161 #define SK_LITTLE_ENDIAN
163 #define SK_BIG_ENDIAN
167 #define SK_NET_DEVICE net_device
169 #define SK_NET_DEVICE eth_device
173 /* we use gethrtime(), return unit: nanoseconds */
175 #define SK_TICKS_PER_SEC HZ
177 #define SK_TICKS_PER_SEC CONFIG_SYS_HZ
180 #define SK_MEM_MAPPED_IO
182 /* #define SK_RLMT_SLOW_LOOKAHEAD */
184 #define SK_MAX_MACS 2
185 #define SK_MAX_NETS 2
189 typedef struct s_DrvRlmtMbuf SK_MBUF;
191 #define SK_CONST64 INT64_C
192 #define SK_CONSTU64 UINT64_C
194 #define SK_MEMCPY(dest,src,size) memcpy(dest,src,size)
195 #define SK_MEMCMP(s1,s2,size) memcmp(s1,s2,size)
196 #define SK_MEMSET(dest,val,size) memset(dest,val,size)
197 #define SK_STRLEN(pStr) strlen((char*)(pStr))
198 #define SK_STRNCPY(pDest,pSrc,size) strncpy((char*)(pDest),(char*)(pSrc),size)
199 #define SK_STRCMP(pStr1,pStr2) strcmp((char*)(pStr1),(char*)(pStr2))
201 /* macros to access the adapter */
202 #define SK_OUT8(b,a,v) writeb((v), ((b)+(a)))
203 #define SK_OUT16(b,a,v) writew((v), ((b)+(a)))
204 #define SK_OUT32(b,a,v) writel((v), ((b)+(a)))
205 #define SK_IN8(b,a,pv) (*(pv) = readb((b)+(a)))
206 #define SK_IN16(b,a,pv) (*(pv) = readw((b)+(a)))
207 #define SK_IN32(b,a,pv) (*(pv) = readl((b)+(a)))
210 #define int16_t short
212 #define int64_t long long
213 #define uint8_t u_char
214 #define uint16_t u_short
215 #define uint32_t u_long
216 #define uint64_t unsigned long long
217 #define t_scalar_t int
218 #define t_uscalar_t unsigned int
219 #define uintptr_t unsigned long
221 #define __CONCAT__(A,B) A##B
223 #define INT32_C(a) __CONCAT__(a,L)
224 #define INT64_C(a) __CONCAT__(a,LL)
225 #define UINT32_C(a) __CONCAT__(a,UL)
226 #define UINT64_C(a) __CONCAT__(a,ULL)
229 #define SK_DBG_PRINTF printk
230 #ifndef SK_DEBUG_CHKMOD
231 #define SK_DEBUG_CHKMOD 0
233 #ifndef SK_DEBUG_CHKCAT
234 #define SK_DEBUG_CHKCAT 0
236 /* those come from the makefile */
237 #define SK_DBG_CHKMOD(pAC) (SK_DEBUG_CHKMOD)
238 #define SK_DBG_CHKCAT(pAC) (SK_DEBUG_CHKCAT)
240 extern void SkDbgPrintf(const char *format,...);
242 #define SK_DBGMOD_DRV 0x00010000
244 /**** possible driver debug categories ********************************/
245 #define SK_DBGCAT_DRV_ENTRY 0x00010000
246 #define SK_DBGCAT_DRV_SAP 0x00020000
247 #define SK_DBGCAT_DRV_MCA 0x00040000
248 #define SK_DBGCAT_DRV_TX_PROGRESS 0x00080000
249 #define SK_DBGCAT_DRV_RX_PROGRESS 0x00100000
250 #define SK_DBGCAT_DRV_PROGRESS 0x00200000
251 #define SK_DBGCAT_DRV_MSG 0x00400000
252 #define SK_DBGCAT_DRV_PROM 0x00800000
253 #define SK_DBGCAT_DRV_TX_FRAME 0x01000000
254 #define SK_DBGCAT_DRV_ERROR 0x02000000
255 #define SK_DBGCAT_DRV_INT_SRC 0x04000000
256 #define SK_DBGCAT_DRV_EVENT 0x08000000
260 #define SK_ERR_LOG SkErrorLog
262 extern void SkErrorLog(SK_AC*, int, int, char*);