skdrv1st.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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. * (C)Copyright 1998-2002 SysKonnect GmbH.
  13. * (C)Copyright 2002-2003 Marvell.
  14. *
  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.
  19. *
  20. * The information in this file is provided "AS IS" without warranty.
  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. #ifndef __INC_SKDRV1ST_H
  37. #define __INC_SKDRV1ST_H
  38. typedef struct s_AC SK_AC;
  39. /* Set card versions */
  40. #define SK_FAR
  41. /* override some default functions with optimized linux functions */
  42. #define SK_PNMI_STORE_U16(p,v) memcpy((char*)(p),(char*)&(v),2)
  43. #define SK_PNMI_STORE_U32(p,v) memcpy((char*)(p),(char*)&(v),4)
  44. #define SK_PNMI_STORE_U64(p,v) memcpy((char*)(p),(char*)&(v),8)
  45. #define SK_PNMI_READ_U16(p,v) memcpy((char*)&(v),(char*)(p),2)
  46. #define SK_PNMI_READ_U32(p,v) memcpy((char*)&(v),(char*)(p),4)
  47. #define SK_PNMI_READ_U64(p,v) memcpy((char*)&(v),(char*)(p),8)
  48. #define SK_ADDR_EQUAL(a1,a2) (!memcmp(a1,a2,6))
  49. #include <linux/types.h>
  50. #include <linux/kernel.h>
  51. #include <linux/string.h>
  52. #include <linux/errno.h>
  53. #include <linux/ioport.h>
  54. #include <linux/slab.h>
  55. #include <linux/interrupt.h>
  56. #include <linux/pci.h>
  57. #include <linux/bitops.h>
  58. #include <asm/byteorder.h>
  59. #include <asm/io.h>
  60. #include <asm/irq.h>
  61. #include <linux/netdevice.h>
  62. #include <linux/etherdevice.h>
  63. #include <linux/skbuff.h>
  64. #include <linux/init.h>
  65. #include <asm/uaccess.h>
  66. #include <net/checksum.h>
  67. #define SK_CS_CALCULATE_CHECKSUM
  68. #ifndef CONFIG_X86_64
  69. #define SkCsCalculateChecksum(p,l) ((~ip_compute_csum(p, l)) & 0xffff)
  70. #else
  71. #define SkCsCalculateChecksum(p,l) ((~ip_fast_csum(p, l)) & 0xffff)
  72. #endif
  73. #include "h/sktypes.h"
  74. #include "h/skerror.h"
  75. #include "h/skdebug.h"
  76. #include "h/lm80.h"
  77. #include "h/xmac_ii.h"
  78. #ifdef __LITTLE_ENDIAN
  79. #define SK_LITTLE_ENDIAN
  80. #else
  81. #define SK_BIG_ENDIAN
  82. #endif
  83. #define SK_NET_DEVICE net_device
  84. /* we use gethrtime(), return unit: nanoseconds */
  85. #define SK_TICKS_PER_SEC 100
  86. #define SK_MEM_MAPPED_IO
  87. // #define SK_RLMT_SLOW_LOOKAHEAD
  88. #define SK_MAX_MACS 2
  89. #define SK_MAX_NETS 2
  90. #define SK_IOC char __iomem *
  91. typedef struct s_DrvRlmtMbuf SK_MBUF;
  92. #define SK_CONST64 INT64_C
  93. #define SK_CONSTU64 UINT64_C
  94. #define SK_MEMCPY(dest,src,size) memcpy(dest,src,size)
  95. #define SK_MEMCMP(s1,s2,size) memcmp(s1,s2,size)
  96. #define SK_MEMSET(dest,val,size) memset(dest,val,size)
  97. #define SK_STRLEN(pStr) strlen((char*)(pStr))
  98. #define SK_STRNCPY(pDest,pSrc,size) strncpy((char*)(pDest),(char*)(pSrc),size)
  99. #define SK_STRCMP(pStr1,pStr2) strcmp((char*)(pStr1),(char*)(pStr2))
  100. /* macros to access the adapter */
  101. #define SK_OUT8(b,a,v) writeb((v), ((b)+(a)))
  102. #define SK_OUT16(b,a,v) writew((v), ((b)+(a)))
  103. #define SK_OUT32(b,a,v) writel((v), ((b)+(a)))
  104. #define SK_IN8(b,a,pv) (*(pv) = readb((b)+(a)))
  105. #define SK_IN16(b,a,pv) (*(pv) = readw((b)+(a)))
  106. #define SK_IN32(b,a,pv) (*(pv) = readl((b)+(a)))
  107. #define int8_t char
  108. #define int16_t short
  109. #define int32_t long
  110. #define int64_t long long
  111. #define uint8_t u_char
  112. #define uint16_t u_short
  113. #define uint32_t u_long
  114. #define uint64_t unsigned long long
  115. #define t_scalar_t int
  116. #define t_uscalar_t unsigned int
  117. #define uintptr_t unsigned long
  118. #define __CONCAT__(A,B) A##B
  119. #define INT32_C(a) __CONCAT__(a,L)
  120. #define INT64_C(a) __CONCAT__(a,LL)
  121. #define UINT32_C(a) __CONCAT__(a,UL)
  122. #define UINT64_C(a) __CONCAT__(a,ULL)
  123. #ifdef DEBUG
  124. #define SK_DBG_PRINTF printk
  125. #ifndef SK_DEBUG_CHKMOD
  126. #define SK_DEBUG_CHKMOD 0
  127. #endif
  128. #ifndef SK_DEBUG_CHKCAT
  129. #define SK_DEBUG_CHKCAT 0
  130. #endif
  131. /* those come from the makefile */
  132. #define SK_DBG_CHKMOD(pAC) (SK_DEBUG_CHKMOD)
  133. #define SK_DBG_CHKCAT(pAC) (SK_DEBUG_CHKCAT)
  134. extern void SkDbgPrintf(const char *format,...);
  135. #define SK_DBGMOD_DRV 0x00010000
  136. /**** possible driver debug categories ********************************/
  137. #define SK_DBGCAT_DRV_ENTRY 0x00010000
  138. #define SK_DBGCAT_DRV_SAP 0x00020000
  139. #define SK_DBGCAT_DRV_MCA 0x00040000
  140. #define SK_DBGCAT_DRV_TX_PROGRESS 0x00080000
  141. #define SK_DBGCAT_DRV_RX_PROGRESS 0x00100000
  142. #define SK_DBGCAT_DRV_PROGRESS 0x00200000
  143. #define SK_DBGCAT_DRV_MSG 0x00400000
  144. #define SK_DBGCAT_DRV_PROM 0x00800000
  145. #define SK_DBGCAT_DRV_TX_FRAME 0x01000000
  146. #define SK_DBGCAT_DRV_ERROR 0x02000000
  147. #define SK_DBGCAT_DRV_INT_SRC 0x04000000
  148. #define SK_DBGCAT_DRV_EVENT 0x08000000
  149. #endif
  150. #define SK_ERR_LOG SkErrorLog
  151. extern void SkErrorLog(SK_AC*, int, int, char*);
  152. #endif