1 /******************************************************************************
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
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
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 * This is the second include file of the driver, which includes all other
30 * neccessary files and defines all structures and constants used by the
31 * driver and the common modules.
33 * Include File Hierarchy:
37 ******************************************************************************/
39 #ifndef __INC_SKDRV2ND_H
40 #define __INC_SKDRV2ND_H
42 #include "h/skqueue.h"
43 #include "h/skgehwt.h"
44 #include "h/sktimer.h"
46 #include "h/skgepnmi.h"
49 #include "h/skgeinit.h"
51 #include "h/skgesirq.h"
54 #include "h/skgedrv.h"
56 #define SK_PCI_ISCOMPLIANT(result, pdev) { \
57 result = SK_FALSE; /* default */ \
59 if (pdev->vendor == 0x10b7) { \
60 /* Gigabit Ethernet Adapter (0x1700) */ \
61 if ((pdev->device == 0x1700) || \
62 (pdev->device == 0x80eb)) { \
65 /* SysKonnect (0x1148) */ \
66 } else if (pdev->vendor == 0x1148) { \
67 /* SK-98xx Gigabit Ethernet Server Adapter (0x4300) */ \
68 /* SK-98xx V2.0 Gigabit Ethernet Adapter (0x4320) */ \
69 if ((pdev->device == 0x4300) || \
70 (pdev->device == 0x4320)) { \
73 /* D-Link (0x1186) */ \
74 } else if (pdev->vendor == 0x1186) { \
75 /* Gigabit Ethernet Adapter (0x4c00) */ \
76 if ((pdev->device == 0x4c00)) { \
79 /* Marvell (0x11ab) */ \
80 } else if (pdev->vendor == 0x11ab) { \
81 /* Gigabit Ethernet Adapter (0x4320) */ \
82 /* Gigabit Ethernet Adapter (0x4360) */ \
83 /* Gigabit Ethernet Adapter (0x4361) */ \
84 /* Belkin (0x5005) */ \
85 if ((pdev->device == 0x4320) || \
86 (pdev->device == 0x4360) || \
87 (pdev->device == 0x4361) || \
88 (pdev->device == 0x5005)) { \
92 } else if (pdev->vendor == 0x1371) { \
93 /* GigaCard Network Adapter (0x434e) */ \
94 if ((pdev->device == 0x434e)) { \
97 /* Linksys (0x1737) */ \
98 } else if (pdev->vendor == 0x1737) { \
99 /* Gigabit Network Adapter (0x1032) */ \
100 /* Gigabit Network Adapter (0x1064) */ \
101 if ((pdev->device == 0x1032) || \
102 (pdev->device == 0x1064)) { \
111 extern SK_MBUF *SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
112 extern void SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
113 extern SK_U64 SkOsGetTime(SK_AC*);
114 extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
115 extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*);
116 extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*);
117 extern int SkPciWriteCfgDWord(SK_AC*, int, SK_U32);
118 extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16);
119 extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8);
120 extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
122 #ifdef SK_DIAG_SUPPORT
123 extern int SkDrvEnterDiagMode(SK_AC *pAc);
124 extern int SkDrvLeaveDiagMode(SK_AC *pAc);
127 struct s_DrvRlmtMbuf {
128 SK_MBUF *pNext; /* Pointer to next RLMT Mbuf. */
129 SK_U8 *pData; /* Data buffer (virtually contig.). */
130 unsigned Size; /* Data buffer size. */
131 unsigned Length; /* Length of packet (<= Size). */
132 SK_U32 PortIdx; /* Receiving/transmitting port. */
133 #ifdef SK_RLMT_MBUF_PRIVATE
134 SK_RLMT_MBUF Rlmt; /* Private part for RLMT. */
135 #endif /* SK_RLMT_MBUF_PRIVATE */
136 struct sk_buff *pOs; /* Pointer to message block */
143 #if SK_TICKS_PER_SEC == 100
144 #define SK_PNMI_HUNDREDS_SEC(t) (t)
146 #define SK_PNMI_HUNDREDS_SEC(t) ((((unsigned long)t) * 100) / \
153 #define SkOsGetTimeCurrent(pAC, pUsec) {\
155 do_gettimeofday(&t);\
156 *pUsec = ((((t.tv_sec) * 1000000L)+t.tv_usec)/10000);\
163 #define SK_IOCTL_BASE (SIOCDEVPRIVATE)
164 #define SK_IOCTL_GETMIB (SK_IOCTL_BASE + 0)
165 #define SK_IOCTL_SETMIB (SK_IOCTL_BASE + 1)
166 #define SK_IOCTL_PRESETMIB (SK_IOCTL_BASE + 2)
167 #define SK_IOCTL_GEN (SK_IOCTL_BASE + 3)
168 #define SK_IOCTL_DIAG (SK_IOCTL_BASE + 4)
170 typedef struct s_IOCTL SK_GE_IOCTL;
179 * define sizes of descriptor rings in bytes
182 #define TX_RING_SIZE (8*1024)
183 #define RX_RING_SIZE (24*1024)
186 * Buffer size for ethernet packets
188 #define ETH_BUF_SIZE 1540
189 #define ETH_MAX_MTU 1514
190 #define ETH_MIN_MTU 60
191 #define ETH_MULTICAST_BIT 0x01
192 #define SK_JUMBO_MTU 9000
195 * transmit priority selects the queue: LOW=asynchron, HIGH=synchron
197 #define TX_PRIO_LOW 0
198 #define TX_PRIO_HIGH 1
201 * alignment of rx/tx descriptors
203 #define DESCR_ALIGN 64
206 * definitions for pnmi. TODO
208 #define SK_DRIVER_RESET(pAC, IoC) 0
209 #define SK_DRIVER_SENDEVENT(pAC, IoC) 0
210 #define SK_DRIVER_SELFTEST(pAC, IoC) 0
211 /* For get mtu you must add an own function */
212 #define SK_DRIVER_GET_MTU(pAc,IoC,i) 0
213 #define SK_DRIVER_SET_MTU(pAc,IoC,i,v) 0
214 #define SK_DRIVER_PRESET_MTU(pAc,IoC,i,v) 0
217 ** Interim definition of SK_DRV_TIMER placed in this file until
218 ** common modules have boon finallized
220 #define SK_DRV_TIMER 11
221 #define SK_DRV_MODERATION_TIMER 1
222 #define SK_DRV_MODERATION_TIMER_LENGTH 1000000 /* 1 second */
223 #define SK_DRV_RX_CLEANUP_TIMER 2
224 #define SK_DRV_RX_CLEANUP_TIMER_LENGTH 1000000 /* 100 millisecs */
227 ** Definitions regarding transmitting frames
228 ** any calculating any checksum.
230 #define C_LEN_ETHERMAC_HEADER_DEST_ADDR 6
231 #define C_LEN_ETHERMAC_HEADER_SRC_ADDR 6
232 #define C_LEN_ETHERMAC_HEADER_LENTYPE 2
233 #define C_LEN_ETHERMAC_HEADER ( (C_LEN_ETHERMAC_HEADER_DEST_ADDR) + \
234 (C_LEN_ETHERMAC_HEADER_SRC_ADDR) + \
235 (C_LEN_ETHERMAC_HEADER_LENTYPE) )
237 #define C_LEN_ETHERMTU_MINSIZE 46
238 #define C_LEN_ETHERMTU_MAXSIZE_STD 1500
239 #define C_LEN_ETHERMTU_MAXSIZE_JUMBO 9000
241 #define C_LEN_ETHERNET_MINSIZE ( (C_LEN_ETHERMAC_HEADER) + \
242 (C_LEN_ETHERMTU_MINSIZE) )
244 #define C_OFFSET_IPHEADER C_LEN_ETHERMAC_HEADER
245 #define C_OFFSET_IPHEADER_IPPROTO 9
246 #define C_OFFSET_TCPHEADER_TCPCS 16
247 #define C_OFFSET_UDPHEADER_UDPCS 6
249 #define C_OFFSET_IPPROTO ( (C_LEN_ETHERMAC_HEADER) + \
250 (C_OFFSET_IPHEADER_IPPROTO) )
252 #define C_PROTO_ID_UDP 17 /* refer to RFC 790 or Stevens' */
253 #define C_PROTO_ID_TCP 6 /* TCP/IP illustrated for details */
255 /* TX and RX descriptors *****************************************************/
257 typedef struct s_RxD RXD; /* the receive descriptor */
260 volatile SK_U32 RBControl; /* Receive Buffer Control */
261 SK_U32 VNextRxd; /* Next receive descriptor,low dword */
262 SK_U32 VDataLow; /* Receive buffer Addr, low dword */
263 SK_U32 VDataHigh; /* Receive buffer Addr, high dword */
264 SK_U32 FrameStat; /* Receive Frame Status word */
265 SK_U32 TimeStamp; /* Time stamp from XMAC */
266 SK_U32 TcpSums; /* TCP Sum 2 / TCP Sum 1 */
267 SK_U32 TcpSumStarts; /* TCP Sum Start 2 / TCP Sum Start 1 */
268 RXD *pNextRxd; /* Pointer to next Rxd */
269 struct sk_buff *pMBuf; /* Pointer to Linux' socket buffer */
272 typedef struct s_TxD TXD; /* the transmit descriptor */
275 volatile SK_U32 TBControl; /* Transmit Buffer Control */
276 SK_U32 VNextTxd; /* Next transmit descriptor,low dword */
277 SK_U32 VDataLow; /* Transmit Buffer Addr, low dword */
278 SK_U32 VDataHigh; /* Transmit Buffer Addr, high dword */
279 SK_U32 FrameStat; /* Transmit Frame Status Word */
280 SK_U32 TcpSumOfs; /* Reserved / TCP Sum Offset */
281 SK_U16 TcpSumSt; /* TCP Sum Start */
282 SK_U16 TcpSumWr; /* TCP Sum Write */
283 SK_U32 TcpReserved; /* not used */
284 TXD *pNextTxd; /* Pointer to next Txd */
285 struct sk_buff *pMBuf; /* Pointer to Linux' socket buffer */
288 /* Used interrupt bits in the interrupts source register *********************/
290 #define DRIVER_IRQS ((IS_IRQ_SW) | \
291 (IS_R1_F) |(IS_R2_F) | \
292 (IS_XS1_F) |(IS_XA1_F) | \
293 (IS_XS2_F) |(IS_XA2_F))
295 #define SPECIAL_IRQS ((IS_HW_ERR) |(IS_I2C_READY) | \
296 (IS_EXT_REG) |(IS_TIMINT) | \
297 (IS_PA_TO_RX1) |(IS_PA_TO_RX2) | \
298 (IS_PA_TO_TX1) |(IS_PA_TO_TX2) | \
299 (IS_MAC1) |(IS_LNK_SYNC_M1)| \
300 (IS_MAC2) |(IS_LNK_SYNC_M2)| \
301 (IS_R1_C) |(IS_R2_C) | \
302 (IS_XS1_C) |(IS_XA1_C) | \
303 (IS_XS2_C) |(IS_XA2_C))
305 #define IRQ_MASK ((IS_IRQ_SW) | \
306 (IS_R1_B) |(IS_R1_F) |(IS_R2_B) |(IS_R2_F) | \
307 (IS_XS1_B) |(IS_XS1_F) |(IS_XA1_B)|(IS_XA1_F)| \
308 (IS_XS2_B) |(IS_XS2_F) |(IS_XA2_B)|(IS_XA2_F)| \
309 (IS_HW_ERR) |(IS_I2C_READY)| \
310 (IS_EXT_REG) |(IS_TIMINT) | \
311 (IS_PA_TO_RX1) |(IS_PA_TO_RX2)| \
312 (IS_PA_TO_TX1) |(IS_PA_TO_TX2)| \
313 (IS_MAC1) |(IS_MAC2) | \
314 (IS_R1_C) |(IS_R2_C) | \
315 (IS_XS1_C) |(IS_XA1_C) | \
316 (IS_XS2_C) |(IS_XA2_C))
318 #define IRQ_HWE_MASK (IS_ERR_MSK) /* enable all HW irqs */
320 typedef struct s_DevNet DEV_NET;
323 struct proc_dir_entry *proc;
331 typedef struct s_TxPort TX_PORT;
334 /* the transmit descriptor rings */
335 caddr_t pTxDescrRing; /* descriptor area memory */
336 SK_U64 VTxDescrRing; /* descr. area bus virt. addr. */
337 TXD *pTxdRingHead; /* Head of Tx rings */
338 TXD *pTxdRingTail; /* Tail of Tx rings */
339 TXD *pTxdRingPrev; /* descriptor sent previously */
340 int TxdRingFree; /* # of free entrys */
341 spinlock_t TxDesRingLock; /* serialize descriptor accesses */
342 caddr_t HwAddr; /* bmu registers address */
343 int PortIndex; /* index number of port (0 or 1) */
346 typedef struct s_RxPort RX_PORT;
349 /* the receive descriptor rings */
350 caddr_t pRxDescrRing; /* descriptor area memory */
351 SK_U64 VRxDescrRing; /* descr. area bus virt. addr. */
352 RXD *pRxdRingHead; /* Head of Rx rings */
353 RXD *pRxdRingTail; /* Tail of Rx rings */
354 RXD *pRxdRingPrev; /* descriptor given to BMU previously */
355 int RxdRingFree; /* # of free entrys */
356 spinlock_t RxDesRingLock; /* serialize descriptor accesses */
357 int RxFillLimit; /* limit for buffers in ring */
358 caddr_t HwAddr; /* bmu registers address */
359 int PortIndex; /* index number of port (0 or 1) */
362 /* Definitions needed for interrupt moderation *******************************/
364 #define IRQ_EOF_AS_TX ((IS_XA1_F) | (IS_XA2_F))
365 #define IRQ_EOF_SY_TX ((IS_XS1_F) | (IS_XS2_F))
366 #define IRQ_MASK_TX_ONLY ((IRQ_EOF_AS_TX)| (IRQ_EOF_SY_TX))
367 #define IRQ_MASK_RX_ONLY ((IS_R1_F) | (IS_R2_F))
368 #define IRQ_MASK_SP_ONLY (SPECIAL_IRQS)
369 #define IRQ_MASK_TX_RX ((IRQ_MASK_TX_ONLY)| (IRQ_MASK_RX_ONLY))
370 #define IRQ_MASK_SP_RX ((SPECIAL_IRQS) | (IRQ_MASK_RX_ONLY))
371 #define IRQ_MASK_SP_TX ((SPECIAL_IRQS) | (IRQ_MASK_TX_ONLY))
372 #define IRQ_MASK_RX_TX_SP ((SPECIAL_IRQS) | (IRQ_MASK_TX_RX))
374 #define C_INT_MOD_NONE 1
375 #define C_INT_MOD_STATIC 2
376 #define C_INT_MOD_DYNAMIC 4
378 #define C_CLK_FREQ_GENESIS 53215000 /* shorter: 53.125 MHz */
379 #define C_CLK_FREQ_YUKON 78215000 /* shorter: 78.125 MHz */
381 #define C_INTS_PER_SEC_DEFAULT 2000
382 #define C_INT_MOD_ENABLE_PERCENTAGE 50 /* if higher 50% enable */
383 #define C_INT_MOD_DISABLE_PERCENTAGE 50 /* if lower 50% disable */
384 #define C_INT_MOD_IPS_LOWER_RANGE 30
385 #define C_INT_MOD_IPS_UPPER_RANGE 40000
388 typedef struct s_DynIrqModInfo DIM_INFO;
389 struct s_DynIrqModInfo {
390 unsigned long PrevTimeVal;
391 unsigned int PrevSysLoad;
392 unsigned int PrevUsedTime;
393 unsigned int PrevTotalTime;
394 int PrevUsedDescrRatio;
395 int NbrProcessedDescr;
396 SK_U64 PrevPort0RxIntrCts;
397 SK_U64 PrevPort1RxIntrCts;
398 SK_U64 PrevPort0TxIntrCts;
399 SK_U64 PrevPort1TxIntrCts;
400 SK_BOOL ModJustEnabled; /* Moderation just enabled yes/no */
402 int MaxModIntsPerSec; /* Moderation Threshold */
403 int MaxModIntsPerSecUpperLimit; /* Upper limit for DIM */
404 int MaxModIntsPerSecLowerLimit; /* Lower limit for DIM */
406 long MaskIrqModeration; /* ModIrqType (eg. 'TxRx') */
407 SK_BOOL DisplayStats; /* Stats yes/no */
408 SK_BOOL AutoSizing; /* Resize DIM-timer on/off */
409 int IntModTypeSelect; /* EnableIntMod (eg. 'dynamic') */
411 SK_TIMER ModTimer; /* just some timer */
414 typedef struct s_PerStrm PER_STRM;
416 #define SK_ALLOC_IRQ 0x00000001
418 #ifdef SK_DIAG_SUPPORT
419 #define DIAG_ACTIVE 1
420 #define DIAG_NOTACTIVE 0
423 /****************************************************************************
424 * Per board structure / Adapter Context structure:
425 * Allocated within attach(9e) and freed within detach(9e).
426 * Contains all 'per device' necessary handles, flags, locks etc.:
429 SK_GEINIT GIni; /* GE init struct */
430 SK_PNMI Pnmi; /* PNMI data struct */
431 SK_VPD vpd; /* vpd data struct */
432 SK_QUEUE Event; /* Event queue */
433 SK_HWT Hwt; /* Hardware Timer control struct */
434 SK_TIMCTRL Tim; /* Software Timer control struct */
435 SK_I2C I2c; /* I2C relevant data structure */
436 SK_ADDR Addr; /* for Address module */
437 SK_CSUM Csum; /* for checksum module */
438 SK_RLMT Rlmt; /* for rlmt module */
439 spinlock_t SlowPathLock; /* Normal IRQ lock */
440 SK_PNMI_STRUCT_DATA PnmiStruct; /* structure to get all Pnmi-Data */
441 int RlmtMode; /* link check mode to set */
442 int RlmtNets; /* Number of nets */
444 SK_IOC IoBase; /* register set of adapter */
445 int BoardLevel; /* level of active hw init (0-2) */
446 char DeviceStr[80]; /* adapter string from vpd */
447 SK_U32 AllocFlag; /* flag allocation of resources */
448 struct pci_dev *PciDev; /* for access to pci config space */
449 SK_U32 PciDevId; /* pci device id */
450 struct SK_NET_DEVICE *dev[2]; /* pointer to device struct */
451 char Name[30]; /* driver name */
452 struct SK_NET_DEVICE *Next; /* link all devices (for clearing) */
453 int RxBufSize; /* length of receive buffers */
454 struct net_device_stats stats; /* linux 'netstat -i' statistics */
455 int Index; /* internal board index number */
457 /* adapter RAM sizes for queues of active port */
458 int RxQueueSize; /* memory used for receive queue */
459 int TxSQueueSize; /* memory used for sync. tx queue */
460 int TxAQueueSize; /* memory used for async. tx queue */
462 int PromiscCount; /* promiscuous mode counter */
463 int AllMultiCount; /* allmulticast mode counter */
464 int MulticCount; /* number of different MC */
465 /* addresses for this board */
466 /* (may be more than HW can)*/
468 int HWRevision; /* Hardware revision */
469 int ActivePort; /* the active XMAC port */
470 int MaxPorts; /* number of activated ports */
471 int TxDescrPerRing; /* # of descriptors per tx ring */
472 int RxDescrPerRing; /* # of descriptors per rx ring */
474 caddr_t pDescrMem; /* Pointer to the descriptor area */
475 dma_addr_t pDescrMemDMA; /* PCI DMA address of area */
477 /* the port structures with descriptor rings */
478 TX_PORT TxPort[SK_MAX_MACS][2];
479 RX_PORT RxPort[SK_MAX_MACS];
481 unsigned int CsOfs1; /* for checksum calculation */
482 unsigned int CsOfs2; /* for checksum calculation */
483 SK_U32 CsOfs; /* for checksum calculation */
485 SK_BOOL CheckQueue; /* check event queue soon */
486 SK_TIMER DrvCleanupTimer;/* to check for pending descriptors */
487 DIM_INFO DynIrqModInfo; /* all data related to DIM */
492 int ChipsetType; /* Chipset family type
493 * 0 == Genesis family support
494 * 1 == Yukon family support
496 #ifdef SK_DIAG_SUPPORT
497 SK_U32 DiagModeActive; /* is diag active? */
498 SK_BOOL DiagFlowCtrl; /* for control purposes */
499 SK_PNMI_STRUCT_DATA PnmiBackup; /* backup structure for all Pnmi-Data */
500 SK_BOOL WasIfUp[SK_MAX_MACS]; /* for OpenClose while
501 * DIAG is busy with NIC
508 #endif /* __INC_SKDRV2ND_H */