1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108#ifndef __INC_SKDRV2ND_H
109#define __INC_SKDRV2ND_H
110
111#include "h/skqueue.h"
112#include "h/skgehwt.h"
113#include "h/sktimer.h"
114#include "h/ski2c.h"
115#include "h/skgepnmi.h"
116#include "h/skvpd.h"
117#include "h/skgehw.h"
118#include "h/skgeinit.h"
119#include "h/skaddr.h"
120#include "h/skgesirq.h"
121#include "h/skcsum.h"
122#include "h/skrlmt.h"
123#include "h/skgedrv.h"
124
125#define SK_PCI_ISCOMPLIANT(result, pdev) { \
126 result = SK_FALSE; \
127 \
128 if (pdev->vendor == 0x10b7) { \
129 \
130 if ((pdev->device == 0x1700)) { \
131 result = SK_TRUE; \
132 } \
133 \
134 } else if (pdev->vendor == 0x1148) { \
135 \
136 \
137 if ((pdev->device == 0x4300) || \
138 (pdev->device == 0x4320)) { \
139 result = SK_TRUE; \
140 } \
141 \
142 } else if (pdev->vendor == 0x1186) { \
143 \
144 if ((pdev->device == 0x4c00)) { \
145 result = SK_TRUE; \
146 } \
147 \
148 } else if (pdev->vendor == 0x1371) { \
149 \
150 if ((pdev->device == 0x434e)) { \
151 result = SK_TRUE; \
152 } \
153 \
154 } else if (pdev->vendor == 0x1737) { \
155 \
156 \
157 if ((pdev->device == 0x1032) || \
158 (pdev->device == 0x1064)) { \
159 result = SK_TRUE; \
160 } \
161 } else { \
162 result = SK_FALSE; \
163 } \
164}
165
166
167extern SK_MBUF *SkDrvAllocRlmtMbuf(SK_AC*, SK_IOC, unsigned);
168extern void SkDrvFreeRlmtMbuf(SK_AC*, SK_IOC, SK_MBUF*);
169extern SK_U64 SkOsGetTime(SK_AC*);
170extern int SkPciReadCfgDWord(SK_AC*, int, SK_U32*);
171extern int SkPciReadCfgWord(SK_AC*, int, SK_U16*);
172extern int SkPciReadCfgByte(SK_AC*, int, SK_U8*);
173extern int SkPciWriteCfgDWord(SK_AC*, int, SK_U32);
174extern int SkPciWriteCfgWord(SK_AC*, int, SK_U16);
175extern int SkPciWriteCfgByte(SK_AC*, int, SK_U8);
176extern int SkDrvEvent(SK_AC*, SK_IOC IoC, SK_U32, SK_EVPARA);
177
178struct s_DrvRlmtMbuf {
179 SK_MBUF *pNext;
180 SK_U8 *pData;
181 unsigned Size;
182 unsigned Length;
183 SK_U32 PortIdx;
184#ifdef SK_RLMT_MBUF_PRIVATE
185 SK_RLMT_MBUF Rlmt;
186#endif
187 struct sk_buff *pOs;
188};
189
190
191
192
193
194#define SK_IOCTL_BASE (SIOCDEVPRIVATE)
195#define SK_IOCTL_GETMIB (SK_IOCTL_BASE + 0)
196#define SK_IOCTL_SETMIB (SK_IOCTL_BASE + 1)
197#define SK_IOCTL_PRESETMIB (SK_IOCTL_BASE + 2)
198
199typedef struct s_IOCTL SK_GE_IOCTL;
200
201struct s_IOCTL {
202 char* pData;
203 unsigned int Len;
204};
205
206
207
208
209
210
211#if 0
212#define TX_RING_SIZE (8*1024)
213#define RX_RING_SIZE (24*1024)
214#else
215#define TX_RING_SIZE (10 * 40)
216#define RX_RING_SIZE (10 * 40)
217#endif
218
219
220
221
222#define ETH_BUF_SIZE 1540
223#define ETH_MAX_MTU 1514
224#define ETH_MIN_MTU 60
225#define ETH_MULTICAST_BIT 0x01
226#define SK_JUMBO_MTU 9000
227
228
229
230
231#define TX_PRIO_LOW 0
232#define TX_PRIO_HIGH 1
233
234
235
236
237#define DESCR_ALIGN 8
238
239
240
241
242#define SK_DRIVER_RESET(pAC, IoC) 0
243#define SK_DRIVER_SENDEVENT(pAC, IoC) 0
244#define SK_DRIVER_SELFTEST(pAC, IoC) 0
245
246#define SK_DRIVER_GET_MTU(pAc,IoC,i) 0
247#define SK_DRIVER_SET_MTU(pAc,IoC,i,v) 0
248#define SK_DRIVER_PRESET_MTU(pAc,IoC,i,v) 0
249
250
251
252
253typedef struct s_RxD RXD;
254
255struct s_RxD {
256 volatile SK_U32 RBControl;
257 SK_U32 VNextRxd;
258 SK_U32 VDataLow;
259 SK_U32 VDataHigh;
260 SK_U32 FrameStat;
261 SK_U32 TimeStamp;
262 SK_U32 TcpSums;
263 SK_U32 TcpSumStarts;
264 RXD *pNextRxd;
265 struct sk_buff *pMBuf;
266};
267
268typedef struct s_TxD TXD;
269
270struct s_TxD {
271 volatile SK_U32 TBControl;
272 SK_U32 VNextTxd;
273 SK_U32 VDataLow;
274 SK_U32 VDataHigh;
275 SK_U32 FrameStat;
276 SK_U32 TcpSumOfs;
277 SK_U16 TcpSumSt;
278 SK_U16 TcpSumWr;
279 SK_U32 TcpReserved;
280 TXD *pNextTxd;
281 struct sk_buff *pMBuf;
282};
283
284
285
286#define RX_CTRL_OWN_BMU UINT32_C(0x80000000)
287#define RX_CTRL_STF UINT32_C(0x40000000)
288#define RX_CTRL_EOF UINT32_C(0x20000000)
289#define RX_CTRL_EOB_IRQ UINT32_C(0x10000000)
290#define RX_CTRL_EOF_IRQ UINT32_C(0x08000000)
291#define RX_CTRL_DEV_NULL UINT32_C(0x04000000)
292#define RX_CTRL_STAT_VALID UINT32_C(0x02000000)
293#define RX_CTRL_TIME_VALID UINT32_C(0x01000000)
294#define RX_CTRL_CHECK_DEFAULT UINT32_C(0x00550000)
295#define RX_CTRL_CHECK_CSUM UINT32_C(0x00560000)
296#define RX_CTRL_LEN_MASK UINT32_C(0x0000FFFF)
297
298#define TX_CTRL_OWN_BMU UINT32_C(0x80000000)
299#define TX_CTRL_STF UINT32_C(0x40000000)
300#define TX_CTRL_EOF UINT32_C(0x20000000)
301#define TX_CTRL_EOB_IRQ UINT32_C(0x10000000)
302#define TX_CTRL_EOF_IRQ UINT32_C(0x08000000)
303#define TX_CTRL_ST_FWD UINT32_C(0x04000000)
304#define TX_CTRL_DISAB_CRC UINT32_C(0x02000000)
305#define TX_CTRL_SOFTWARE UINT32_C(0x01000000)
306#define TX_CTRL_CHECK_DEFAULT UINT32_C(0x00550000)
307#define TX_CTRL_CHECK_CSUM UINT32_C(0x00560000)
308#define TX_CTRL_LEN_MASK UINT32_C(0x0000FFFF)
309
310
311
312
313#define RX_Q_BUF_CTRL_CNT 0x00
314#define RX_Q_NEXT_DESCR_LOW 0x04
315#define RX_Q_BUF_ADDR_LOW 0x08
316#define RX_Q_BUF_ADDR_HIGH 0x0c
317#define RX_Q_FRAME_STAT 0x10
318#define RX_Q_TIME_STAMP 0x14
319#define RX_Q_CSUM_1_2 0x18
320#define RX_Q_CSUM_START_1_2 0x1c
321#define RX_Q_CUR_DESCR_LOW 0x20
322#define RX_Q_DESCR_HIGH 0x24
323#define RX_Q_CUR_ADDR_LOW 0x28
324#define RX_Q_CUR_ADDR_HIGH 0x2c
325#define RX_Q_CUR_BYTE_CNT 0x30
326#define RX_Q_CTRL 0x34
327#define RX_Q_FLAG 0x38
328#define RX_Q_TEST1 0x3c
329#define RX_Q_TEST2 0x40
330#define RX_Q_TEST3 0x44
331
332#define TX_Q_BUF_CTRL_CNT 0x00
333#define TX_Q_NEXT_DESCR_LOW 0x04
334#define TX_Q_BUF_ADDR_LOW 0x08
335#define TX_Q_BUF_ADDR_HIGH 0x0c
336#define TX_Q_FRAME_STAT 0x10
337#define TX_Q_CSUM_START 0x14
338#define TX_Q_CSUM_START_POS 0x18
339#define TX_Q_RESERVED 0x1c
340#define TX_Q_CUR_DESCR_LOW 0x20
341#define TX_Q_DESCR_HIGH 0x24
342#define TX_Q_CUR_ADDR_LOW 0x28
343#define TX_Q_CUR_ADDR_HIGH 0x2c
344#define TX_Q_CUR_BYTE_CNT 0x30
345#define TX_Q_CTRL 0x34
346#define TX_Q_FLAG 0x38
347#define TX_Q_TEST1 0x3c
348#define TX_Q_TEST2 0x40
349#define TX_Q_TEST3 0x44
350
351
352#define RX_Q_CTRL_POLL_ON 0x00000080
353#define RX_Q_CTRL_POLL_OFF 0x00000040
354#define RX_Q_CTRL_STOP 0x00000020
355#define RX_Q_CTRL_START 0x00000010
356#define RX_Q_CTRL_CLR_I_PAR 0x00000008
357#define RX_Q_CTRL_CLR_I_EOB 0x00000004
358#define RX_Q_CTRL_CLR_I_EOF 0x00000002
359#define RX_Q_CTRL_CLR_I_ERR 0x00000001
360
361#define TX_Q_CTRL_POLL_ON 0x00000080
362#define TX_Q_CTRL_POLL_OFF 0x00000040
363#define TX_Q_CTRL_STOP 0x00000020
364#define TX_Q_CTRL_START 0x00000010
365#define TX_Q_CTRL_CLR_I_EOB 0x00000004
366#define TX_Q_CTRL_CLR_I_EOF 0x00000002
367#define TX_Q_CTRL_CLR_I_ERR 0x00000001
368
369
370
371#define IRQ_HW_ERROR 0x80000000
372#define IRQ_RESERVED 0x40000000
373#define IRQ_PKT_TOUT_RX1 0x20000000
374#define IRQ_PKT_TOUT_RX2 0x10000000
375#define IRQ_PKT_TOUT_TX1 0x08000000
376#define IRQ_PKT_TOUT_TX2 0x04000000
377#define IRQ_I2C_READY 0x02000000
378#define IRQ_SW 0x01000000
379#define IRQ_EXTERNAL_REG 0x00800000
380#define IRQ_TIMER 0x00400000
381#define IRQ_MAC1 0x00200000
382#define IRQ_LINK_SYNC_C_M1 0x00100000
383#define IRQ_MAC2 0x00080000
384#define IRQ_LINK_SYNC_C_M2 0x00040000
385#define IRQ_EOB_RX1 0x00020000
386#define IRQ_EOF_RX1 0x00010000
387#define IRQ_CHK_RX1 0x00008000
388#define IRQ_EOB_RX2 0x00004000
389#define IRQ_EOF_RX2 0x00002000
390#define IRQ_CHK_RX2 0x00001000
391#define IRQ_EOB_SY_TX1 0x00000800
392#define IRQ_EOF_SY_TX1 0x00000400
393#define IRQ_CHK_SY_TX1 0x00000200
394#define IRQ_EOB_AS_TX1 0x00000100
395#define IRQ_EOF_AS_TX1 0x00000080
396#define IRQ_CHK_AS_TX1 0x00000040
397#define IRQ_EOB_SY_TX2 0x00000020
398#define IRQ_EOF_SY_TX2 0x00000010
399#define IRQ_CHK_SY_TX2 0x00000008
400#define IRQ_EOB_AS_TX2 0x00000004
401#define IRQ_EOF_AS_TX2 0x00000002
402#define IRQ_CHK_AS_TX2 0x00000001
403
404#define DRIVER_IRQS (IRQ_SW | IRQ_EOF_RX1 | IRQ_EOF_RX2 | \
405 IRQ_EOF_SY_TX1 | IRQ_EOF_AS_TX1 | \
406 IRQ_EOF_SY_TX2 | IRQ_EOF_AS_TX2)
407
408#define SPECIAL_IRQS (IRQ_HW_ERROR | IRQ_PKT_TOUT_RX1 | IRQ_PKT_TOUT_RX2 | \
409 IRQ_PKT_TOUT_TX1 | IRQ_PKT_TOUT_TX2 | \
410 IRQ_I2C_READY | IRQ_EXTERNAL_REG | IRQ_TIMER | \
411 IRQ_MAC1 | IRQ_LINK_SYNC_C_M1 | \
412 IRQ_MAC2 | IRQ_LINK_SYNC_C_M2 | \
413 IRQ_CHK_RX1 | IRQ_CHK_RX2 | \
414 IRQ_CHK_SY_TX1 | IRQ_CHK_AS_TX1 | \
415 IRQ_CHK_SY_TX2 | IRQ_CHK_AS_TX2)
416
417#define IRQ_MASK (IRQ_SW | IRQ_EOB_RX1 | IRQ_EOF_RX1 | \
418 IRQ_EOB_RX2 | IRQ_EOF_RX2 | \
419 IRQ_EOB_SY_TX1 | IRQ_EOF_SY_TX1 | \
420 IRQ_EOB_AS_TX1 | IRQ_EOF_AS_TX1 | \
421 IRQ_EOB_SY_TX2 | IRQ_EOF_SY_TX2 | \
422 IRQ_EOB_AS_TX2 | IRQ_EOF_AS_TX2 | \
423 IRQ_HW_ERROR | IRQ_PKT_TOUT_RX1 | IRQ_PKT_TOUT_RX2 | \
424 IRQ_PKT_TOUT_TX1 | IRQ_PKT_TOUT_TX2 | \
425 IRQ_I2C_READY | IRQ_EXTERNAL_REG | IRQ_TIMER | \
426 IRQ_MAC1 | \
427 IRQ_MAC2 | \
428 IRQ_CHK_RX1 | IRQ_CHK_RX2 | \
429 IRQ_CHK_SY_TX1 | IRQ_CHK_AS_TX1 | \
430 IRQ_CHK_SY_TX2 | IRQ_CHK_AS_TX2)
431
432#define IRQ_HWE_MASK 0x00000FFF
433
434typedef struct s_DevNet DEV_NET;
435
436struct s_DevNet {
437 int PortNr;
438 int NetNr;
439 int Mtu;
440 int Up;
441 SK_AC *pAC;
442};
443
444typedef struct s_TxPort TX_PORT;
445
446struct s_TxPort {
447
448 caddr_t pTxDescrRing;
449 SK_U64 VTxDescrRing;
450 TXD *pTxdRingHead;
451 TXD *pTxdRingTail;
452 TXD *pTxdRingPrev;
453 int TxdRingFree;
454#if 0
455 spinlock_t TxDesRingLock;
456#endif
457 caddr_t HwAddr;
458 int PortIndex;
459};
460
461typedef struct s_RxPort RX_PORT;
462
463struct s_RxPort {
464
465 caddr_t pRxDescrRing;
466 SK_U64 VRxDescrRing;
467 RXD *pRxdRingHead;
468 RXD *pRxdRingTail;
469 RXD *pRxdRingPrev;
470 int RxdRingFree;
471#if 0
472 spinlock_t RxDesRingLock;
473#endif
474 int RxFillLimit;
475 caddr_t HwAddr;
476 int PortIndex;
477};
478
479typedef struct s_PerStrm PER_STRM;
480
481#define SK_ALLOC_IRQ 0x00000001
482
483
484
485
486
487
488struct s_AC {
489 SK_GEINIT GIni;
490 SK_PNMI Pnmi;
491 SK_VPD vpd;
492 SK_QUEUE Event;
493 SK_HWT Hwt;
494 SK_TIMCTRL Tim;
495 SK_I2C I2c;
496 SK_ADDR Addr;
497 SK_CSUM Csum;
498 SK_RLMT Rlmt;
499#if 0
500 spinlock_t SlowPathLock;
501#endif
502 SK_PNMI_STRUCT_DATA PnmiStruct;
503 int RlmtMode;
504 int RlmtNets;
505
506 SK_IOC IoBase;
507 int BoardLevel;
508 char DeviceStr[80];
509 SK_U32 AllocFlag;
510#if 0
511 struct pci_dev *PciDev;
512 SK_U32 PciDevId;
513#else
514 int PciDev;
515#endif
516 struct SK_NET_DEVICE *dev[2];
517 char Name[30];
518 struct SK_NET_DEVICE *Next;
519 int RxBufSize;
520#if 0
521 struct net_device_stats stats;
522#endif
523 int Index;
524
525
526 int RxQueueSize;
527 int TxSQueueSize;
528 int TxAQueueSize;
529
530 int PromiscCount;
531 int AllMultiCount;
532 int MulticCount;
533
534
535
536 int HWRevision;
537 int ActivePort;
538 int MaxPorts;
539 int TxDescrPerRing;
540 int RxDescrPerRing;
541
542 caddr_t pDescrMem;
543 dma_addr_t pDescrMemDMA;
544
545
546 TX_PORT TxPort[SK_MAX_MACS][2];
547 RX_PORT RxPort[SK_MAX_MACS];
548
549 unsigned int CsOfs1;
550 unsigned int CsOfs2;
551 SK_U32 CsOfs;
552
553 SK_BOOL CheckQueue;
554
555
556 int PortUp;
557 int PortDown;
558
559};
560
561#endif
562