skdrv2nd.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /******************************************************************************
  2. *
  3. * Name: skdrv2nd.h
  4. * Project: GEnesis, PCI Gigabit Ethernet Adapter
  5. * Version: $Revision: 1.10 $
  6. * Date: $Date: 2003/12/11 16:04:45 $
  7. * Purpose: Second 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 second include file of the driver, which includes all other
  28. * neccessary files and defines all structures and constants used by the
  29. * driver and the common modules.
  30. *
  31. * Include File Hierarchy:
  32. *
  33. * see skge.c
  34. *
  35. ******************************************************************************/
  36. #ifndef __INC_SKDRV2ND_H
  37. #define __INC_SKDRV2ND_H
  38. #include "h/skqueue.h"
  39. #include "h/skgehwt.h"
  40. #include "h/sktimer.h"
  41. #include "h/ski2c.h"
  42. #include "h/skgepnmi.h"
  43. #include "h/skvpd.h"
  44. #include "h/skgehw.h"
  45. #include "h/skgeinit.h"
  46. #include "h/skaddr.h"
  47. #include "h/skgesirq.h"
  48. #include "h/skcsum.h"
  49. #include "h/skrlmt.h"
  50. #include "h/skgedrv.h"
  51. extern SK_MBUF *SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
  52. extern void SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
  53. extern SK_U64 SkOsGetTime(SK_AC*);
  54. extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
  55. extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*);
  56. extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*);
  57. extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16);
  58. extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8);
  59. extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
  60. #ifdef SK_DIAG_SUPPORT
  61. extern int SkDrvEnterDiagMode(SK_AC *pAc);
  62. extern int SkDrvLeaveDiagMode(SK_AC *pAc);
  63. #endif
  64. struct s_DrvRlmtMbuf {
  65. SK_MBUF *pNext; /* Pointer to next RLMT Mbuf. */
  66. SK_U8 *pData; /* Data buffer (virtually contig.). */
  67. unsigned Size; /* Data buffer size. */
  68. unsigned Length; /* Length of packet (<= Size). */
  69. SK_U32 PortIdx; /* Receiving/transmitting port. */
  70. #ifdef SK_RLMT_MBUF_PRIVATE
  71. SK_RLMT_MBUF Rlmt; /* Private part for RLMT. */
  72. #endif /* SK_RLMT_MBUF_PRIVATE */
  73. struct sk_buff *pOs; /* Pointer to message block */
  74. };
  75. /*
  76. * Time macros
  77. */
  78. #if SK_TICKS_PER_SEC == 100
  79. #define SK_PNMI_HUNDREDS_SEC(t) (t)
  80. #else
  81. #define SK_PNMI_HUNDREDS_SEC(t) ((((unsigned long)t) * 100) / \
  82. (SK_TICKS_PER_SEC))
  83. #endif
  84. /*
  85. * New SkOsGetTime
  86. */
  87. #define SkOsGetTimeCurrent(pAC, pUsec) {\
  88. struct timeval t;\
  89. do_gettimeofday(&t);\
  90. *pUsec = ((((t.tv_sec) * 1000000L)+t.tv_usec)/10000);\
  91. }
  92. /*
  93. * ioctl definitions
  94. */
  95. #define SK_IOCTL_BASE (SIOCDEVPRIVATE)
  96. #define SK_IOCTL_GETMIB (SK_IOCTL_BASE + 0)
  97. #define SK_IOCTL_SETMIB (SK_IOCTL_BASE + 1)
  98. #define SK_IOCTL_PRESETMIB (SK_IOCTL_BASE + 2)
  99. #define SK_IOCTL_GEN (SK_IOCTL_BASE + 3)
  100. #define SK_IOCTL_DIAG (SK_IOCTL_BASE + 4)
  101. typedef struct s_IOCTL SK_GE_IOCTL;
  102. struct s_IOCTL {
  103. char __user * pData;
  104. unsigned int Len;
  105. };
  106. /*
  107. * define sizes of descriptor rings in bytes
  108. */
  109. #define TX_RING_SIZE (8*1024)
  110. #define RX_RING_SIZE (24*1024)
  111. /*
  112. * Buffer size for ethernet packets
  113. */
  114. #define ETH_BUF_SIZE 1540
  115. #define ETH_MAX_MTU 1514
  116. #define ETH_MIN_MTU 60
  117. #define ETH_MULTICAST_BIT 0x01
  118. #define SK_JUMBO_MTU 9000
  119. /*
  120. * transmit priority selects the queue: LOW=asynchron, HIGH=synchron
  121. */
  122. #define TX_PRIO_LOW 0
  123. #define TX_PRIO_HIGH 1
  124. /*
  125. * alignment of rx/tx descriptors
  126. */
  127. #define DESCR_ALIGN 64
  128. /*
  129. * definitions for pnmi. TODO
  130. */
  131. #define SK_DRIVER_RESET(pAC, IoC) 0
  132. #define SK_DRIVER_SENDEVENT(pAC, IoC) 0
  133. #define SK_DRIVER_SELFTEST(pAC, IoC) 0
  134. /* For get mtu you must add an own function */
  135. #define SK_DRIVER_GET_MTU(pAc,IoC,i) 0
  136. #define SK_DRIVER_SET_MTU(pAc,IoC,i,v) 0
  137. #define SK_DRIVER_PRESET_MTU(pAc,IoC,i,v) 0
  138. /*
  139. ** Interim definition of SK_DRV_TIMER placed in this file until
  140. ** common modules have boon finallized
  141. */
  142. #define SK_DRV_TIMER 11
  143. #define SK_DRV_MODERATION_TIMER 1
  144. #define SK_DRV_MODERATION_TIMER_LENGTH 1000000 /* 1 second */
  145. #define SK_DRV_RX_CLEANUP_TIMER 2
  146. #define SK_DRV_RX_CLEANUP_TIMER_LENGTH 1000000 /* 100 millisecs */
  147. /*
  148. ** Definitions regarding transmitting frames
  149. ** any calculating any checksum.
  150. */
  151. #define C_LEN_ETHERMAC_HEADER_DEST_ADDR 6
  152. #define C_LEN_ETHERMAC_HEADER_SRC_ADDR 6
  153. #define C_LEN_ETHERMAC_HEADER_LENTYPE 2
  154. #define C_LEN_ETHERMAC_HEADER ( (C_LEN_ETHERMAC_HEADER_DEST_ADDR) + \
  155. (C_LEN_ETHERMAC_HEADER_SRC_ADDR) + \
  156. (C_LEN_ETHERMAC_HEADER_LENTYPE) )
  157. #define C_LEN_ETHERMTU_MINSIZE 46
  158. #define C_LEN_ETHERMTU_MAXSIZE_STD 1500
  159. #define C_LEN_ETHERMTU_MAXSIZE_JUMBO 9000
  160. #define C_LEN_ETHERNET_MINSIZE ( (C_LEN_ETHERMAC_HEADER) + \
  161. (C_LEN_ETHERMTU_MINSIZE) )
  162. #define C_OFFSET_IPHEADER C_LEN_ETHERMAC_HEADER
  163. #define C_OFFSET_IPHEADER_IPPROTO 9
  164. #define C_OFFSET_TCPHEADER_TCPCS 16
  165. #define C_OFFSET_UDPHEADER_UDPCS 6
  166. #define C_OFFSET_IPPROTO ( (C_LEN_ETHERMAC_HEADER) + \
  167. (C_OFFSET_IPHEADER_IPPROTO) )
  168. #define C_PROTO_ID_UDP 17 /* refer to RFC 790 or Stevens' */
  169. #define C_PROTO_ID_TCP 6 /* TCP/IP illustrated for details */
  170. /* TX and RX descriptors *****************************************************/
  171. typedef struct s_RxD RXD; /* the receive descriptor */
  172. struct s_RxD {
  173. volatile SK_U32 RBControl; /* Receive Buffer Control */
  174. SK_U32 VNextRxd; /* Next receive descriptor,low dword */
  175. SK_U32 VDataLow; /* Receive buffer Addr, low dword */
  176. SK_U32 VDataHigh; /* Receive buffer Addr, high dword */
  177. SK_U32 FrameStat; /* Receive Frame Status word */
  178. SK_U32 TimeStamp; /* Time stamp from XMAC */
  179. SK_U32 TcpSums; /* TCP Sum 2 / TCP Sum 1 */
  180. SK_U32 TcpSumStarts; /* TCP Sum Start 2 / TCP Sum Start 1 */
  181. RXD *pNextRxd; /* Pointer to next Rxd */
  182. struct sk_buff *pMBuf; /* Pointer to Linux' socket buffer */
  183. };
  184. typedef struct s_TxD TXD; /* the transmit descriptor */
  185. struct s_TxD {
  186. volatile SK_U32 TBControl; /* Transmit Buffer Control */
  187. SK_U32 VNextTxd; /* Next transmit descriptor,low dword */
  188. SK_U32 VDataLow; /* Transmit Buffer Addr, low dword */
  189. SK_U32 VDataHigh; /* Transmit Buffer Addr, high dword */
  190. SK_U32 FrameStat; /* Transmit Frame Status Word */
  191. SK_U32 TcpSumOfs; /* Reserved / TCP Sum Offset */
  192. SK_U16 TcpSumSt; /* TCP Sum Start */
  193. SK_U16 TcpSumWr; /* TCP Sum Write */
  194. SK_U32 TcpReserved; /* not used */
  195. TXD *pNextTxd; /* Pointer to next Txd */
  196. struct sk_buff *pMBuf; /* Pointer to Linux' socket buffer */
  197. };
  198. /* Used interrupt bits in the interrupts source register *********************/
  199. #define DRIVER_IRQS ((IS_IRQ_SW) | \
  200. (IS_R1_F) |(IS_R2_F) | \
  201. (IS_XS1_F) |(IS_XA1_F) | \
  202. (IS_XS2_F) |(IS_XA2_F))
  203. #define SPECIAL_IRQS ((IS_HW_ERR) |(IS_I2C_READY) | \
  204. (IS_EXT_REG) |(IS_TIMINT) | \
  205. (IS_PA_TO_RX1) |(IS_PA_TO_RX2) | \
  206. (IS_PA_TO_TX1) |(IS_PA_TO_TX2) | \
  207. (IS_MAC1) |(IS_LNK_SYNC_M1)| \
  208. (IS_MAC2) |(IS_LNK_SYNC_M2)| \
  209. (IS_R1_C) |(IS_R2_C) | \
  210. (IS_XS1_C) |(IS_XA1_C) | \
  211. (IS_XS2_C) |(IS_XA2_C))
  212. #define IRQ_MASK ((IS_IRQ_SW) | \
  213. (IS_R1_B) |(IS_R1_F) |(IS_R2_B) |(IS_R2_F) | \
  214. (IS_XS1_B) |(IS_XS1_F) |(IS_XA1_B)|(IS_XA1_F)| \
  215. (IS_XS2_B) |(IS_XS2_F) |(IS_XA2_B)|(IS_XA2_F)| \
  216. (IS_HW_ERR) |(IS_I2C_READY)| \
  217. (IS_EXT_REG) |(IS_TIMINT) | \
  218. (IS_PA_TO_RX1) |(IS_PA_TO_RX2)| \
  219. (IS_PA_TO_TX1) |(IS_PA_TO_TX2)| \
  220. (IS_MAC1) |(IS_MAC2) | \
  221. (IS_R1_C) |(IS_R2_C) | \
  222. (IS_XS1_C) |(IS_XA1_C) | \
  223. (IS_XS2_C) |(IS_XA2_C))
  224. #define IRQ_HWE_MASK (IS_ERR_MSK) /* enable all HW irqs */
  225. typedef struct s_DevNet DEV_NET;
  226. struct s_DevNet {
  227. int PortNr;
  228. int NetNr;
  229. SK_AC *pAC;
  230. };
  231. typedef struct s_TxPort TX_PORT;
  232. struct s_TxPort {
  233. /* the transmit descriptor rings */
  234. caddr_t pTxDescrRing; /* descriptor area memory */
  235. SK_U64 VTxDescrRing; /* descr. area bus virt. addr. */
  236. TXD *pTxdRingHead; /* Head of Tx rings */
  237. TXD *pTxdRingTail; /* Tail of Tx rings */
  238. TXD *pTxdRingPrev; /* descriptor sent previously */
  239. int TxdRingFree; /* # of free entrys */
  240. spinlock_t TxDesRingLock; /* serialize descriptor accesses */
  241. SK_IOC HwAddr; /* bmu registers address */
  242. int PortIndex; /* index number of port (0 or 1) */
  243. };
  244. typedef struct s_RxPort RX_PORT;
  245. struct s_RxPort {
  246. /* the receive descriptor rings */
  247. caddr_t pRxDescrRing; /* descriptor area memory */
  248. SK_U64 VRxDescrRing; /* descr. area bus virt. addr. */
  249. RXD *pRxdRingHead; /* Head of Rx rings */
  250. RXD *pRxdRingTail; /* Tail of Rx rings */
  251. RXD *pRxdRingPrev; /* descriptor given to BMU previously */
  252. int RxdRingFree; /* # of free entrys */
  253. int RxCsum; /* use receive checksum hardware */
  254. spinlock_t RxDesRingLock; /* serialize descriptor accesses */
  255. int RxFillLimit; /* limit for buffers in ring */
  256. SK_IOC HwAddr; /* bmu registers address */
  257. int PortIndex; /* index number of port (0 or 1) */
  258. };
  259. /* Definitions needed for interrupt moderation *******************************/
  260. #define IRQ_EOF_AS_TX ((IS_XA1_F) | (IS_XA2_F))
  261. #define IRQ_EOF_SY_TX ((IS_XS1_F) | (IS_XS2_F))
  262. #define IRQ_MASK_TX_ONLY ((IRQ_EOF_AS_TX)| (IRQ_EOF_SY_TX))
  263. #define IRQ_MASK_RX_ONLY ((IS_R1_F) | (IS_R2_F))
  264. #define IRQ_MASK_SP_ONLY (SPECIAL_IRQS)
  265. #define IRQ_MASK_TX_RX ((IRQ_MASK_TX_ONLY)| (IRQ_MASK_RX_ONLY))
  266. #define IRQ_MASK_SP_RX ((SPECIAL_IRQS) | (IRQ_MASK_RX_ONLY))
  267. #define IRQ_MASK_SP_TX ((SPECIAL_IRQS) | (IRQ_MASK_TX_ONLY))
  268. #define IRQ_MASK_RX_TX_SP ((SPECIAL_IRQS) | (IRQ_MASK_TX_RX))
  269. #define C_INT_MOD_NONE 1
  270. #define C_INT_MOD_STATIC 2
  271. #define C_INT_MOD_DYNAMIC 4
  272. #define C_CLK_FREQ_GENESIS 53215000 /* shorter: 53.125 MHz */
  273. #define C_CLK_FREQ_YUKON 78215000 /* shorter: 78.125 MHz */
  274. #define C_INTS_PER_SEC_DEFAULT 2000
  275. #define C_INT_MOD_ENABLE_PERCENTAGE 50 /* if higher 50% enable */
  276. #define C_INT_MOD_DISABLE_PERCENTAGE 50 /* if lower 50% disable */
  277. #define C_INT_MOD_IPS_LOWER_RANGE 30
  278. #define C_INT_MOD_IPS_UPPER_RANGE 40000
  279. typedef struct s_DynIrqModInfo DIM_INFO;
  280. struct s_DynIrqModInfo {
  281. unsigned long PrevTimeVal;
  282. unsigned int PrevSysLoad;
  283. unsigned int PrevUsedTime;
  284. unsigned int PrevTotalTime;
  285. int PrevUsedDescrRatio;
  286. int NbrProcessedDescr;
  287. SK_U64 PrevPort0RxIntrCts;
  288. SK_U64 PrevPort1RxIntrCts;
  289. SK_U64 PrevPort0TxIntrCts;
  290. SK_U64 PrevPort1TxIntrCts;
  291. SK_BOOL ModJustEnabled; /* Moderation just enabled yes/no */
  292. int MaxModIntsPerSec; /* Moderation Threshold */
  293. int MaxModIntsPerSecUpperLimit; /* Upper limit for DIM */
  294. int MaxModIntsPerSecLowerLimit; /* Lower limit for DIM */
  295. long MaskIrqModeration; /* ModIrqType (eg. 'TxRx') */
  296. SK_BOOL DisplayStats; /* Stats yes/no */
  297. SK_BOOL AutoSizing; /* Resize DIM-timer on/off */
  298. int IntModTypeSelect; /* EnableIntMod (eg. 'dynamic') */
  299. SK_TIMER ModTimer; /* just some timer */
  300. };
  301. typedef struct s_PerStrm PER_STRM;
  302. #define SK_ALLOC_IRQ 0x00000001
  303. #ifdef SK_DIAG_SUPPORT
  304. #define DIAG_ACTIVE 1
  305. #define DIAG_NOTACTIVE 0
  306. #endif
  307. /****************************************************************************
  308. * Per board structure / Adapter Context structure:
  309. * Allocated within attach(9e) and freed within detach(9e).
  310. * Contains all 'per device' necessary handles, flags, locks etc.:
  311. */
  312. struct s_AC {
  313. SK_GEINIT GIni; /* GE init struct */
  314. SK_PNMI Pnmi; /* PNMI data struct */
  315. SK_VPD vpd; /* vpd data struct */
  316. SK_QUEUE Event; /* Event queue */
  317. SK_HWT Hwt; /* Hardware Timer control struct */
  318. SK_TIMCTRL Tim; /* Software Timer control struct */
  319. SK_I2C I2c; /* I2C relevant data structure */
  320. SK_ADDR Addr; /* for Address module */
  321. SK_CSUM Csum; /* for checksum module */
  322. SK_RLMT Rlmt; /* for rlmt module */
  323. spinlock_t SlowPathLock; /* Normal IRQ lock */
  324. struct timer_list BlinkTimer; /* for LED blinking */
  325. int LedsOn;
  326. SK_PNMI_STRUCT_DATA PnmiStruct; /* structure to get all Pnmi-Data */
  327. int RlmtMode; /* link check mode to set */
  328. int RlmtNets; /* Number of nets */
  329. SK_IOC IoBase; /* register set of adapter */
  330. int BoardLevel; /* level of active hw init (0-2) */
  331. SK_U32 AllocFlag; /* flag allocation of resources */
  332. struct pci_dev *PciDev; /* for access to pci config space */
  333. struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
  334. int RxBufSize; /* length of receive buffers */
  335. struct net_device_stats stats; /* linux 'netstat -i' statistics */
  336. int Index; /* internal board index number */
  337. /* adapter RAM sizes for queues of active port */
  338. int RxQueueSize; /* memory used for receive queue */
  339. int TxSQueueSize; /* memory used for sync. tx queue */
  340. int TxAQueueSize; /* memory used for async. tx queue */
  341. int PromiscCount; /* promiscuous mode counter */
  342. int AllMultiCount; /* allmulticast mode counter */
  343. int MulticCount; /* number of different MC */
  344. /* addresses for this board */
  345. /* (may be more than HW can)*/
  346. int HWRevision; /* Hardware revision */
  347. int ActivePort; /* the active XMAC port */
  348. int MaxPorts; /* number of activated ports */
  349. int TxDescrPerRing; /* # of descriptors per tx ring */
  350. int RxDescrPerRing; /* # of descriptors per rx ring */
  351. caddr_t pDescrMem; /* Pointer to the descriptor area */
  352. dma_addr_t pDescrMemDMA; /* PCI DMA address of area */
  353. /* the port structures with descriptor rings */
  354. TX_PORT TxPort[SK_MAX_MACS][2];
  355. RX_PORT RxPort[SK_MAX_MACS];
  356. SK_BOOL CheckQueue; /* check event queue soon */
  357. SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */
  358. DIM_INFO DynIrqModInfo; /* all data related to DIM */
  359. /* Only for tests */
  360. int PortDown;
  361. int ChipsetType; /* Chipset family type
  362. * 0 == Genesis family support
  363. * 1 == Yukon family support
  364. */
  365. #ifdef SK_DIAG_SUPPORT
  366. SK_U32 DiagModeActive; /* is diag active? */
  367. SK_BOOL DiagFlowCtrl; /* for control purposes */
  368. SK_PNMI_STRUCT_DATA PnmiBackup; /* backup structure for all Pnmi-Data */
  369. SK_BOOL WasIfUp[SK_MAX_MACS]; /* for OpenClose while
  370. * DIAG is busy with NIC
  371. */
  372. #endif
  373. };
  374. #endif /* __INC_SKDRV2ND_H */