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