1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.45 $
6 * Date: $Date: 2004/02/12 14:41:02 $
7 * Purpose: The main driver source module
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
16 * Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet
19 * Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and
20 * SysKonnects GEnesis Solaris driver
21 * Author: Christoph Goos (cgoos@syskonnect.de)
22 * Mirko Lindner (mlindner@syskonnect.de)
24 * Address all question to: linux@syskonnect.de
26 * The technical manual for the adapters is available from SysKonnect's
27 * web pages: www.syskonnect.com
28 * Goto "Support" and search Knowledge Base for "manual".
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
35 * The information in this file is provided "AS IS" without warranty.
37 ******************************************************************************/
39 /******************************************************************************
41 * Possible compiler options (#define xxx / -Dxxx):
43 * debugging can be enable by changing SK_DEBUG_CHKMOD and
44 * SK_DEBUG_CHKCAT in makefile (described there).
46 ******************************************************************************/
48 /******************************************************************************
52 * This is the main module of the Linux GE driver.
54 * All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h
55 * are part of SysKonnect's COMMON MODULES for the SK-98xx adapters.
56 * Those are used for drivers on multiple OS', so some thing may seem
57 * unnecessary complicated on Linux. Please do not try to 'clean up'
58 * them without VERY good reasons, because this will make it more
59 * difficult to keep the Linux driver in synchronisation with the
62 * Include file hierarchy:
79 * <linux/etherdevice.h>
81 * those three depending on kernel version used:
106 ******************************************************************************/
108 #include "h/skversion.h"
110 #include <linux/in.h>
111 #include <linux/module.h>
112 #include <linux/moduleparam.h>
113 #include <linux/init.h>
114 #include <linux/dma-mapping.h>
115 #include <linux/ip.h>
116 #include <linux/mii.h>
117 #include <linux/mm.h>
119 #include "h/skdrv1st.h"
120 #include "h/skdrv2nd.h"
122 /*******************************************************************************
126 ******************************************************************************/
128 /* for debuging on x86 only */
129 /* #define BREAKPOINT() asm(" int $3"); */
131 /* use the transmit hw checksum driver functionality */
132 #define USE_SK_TX_CHECKSUM
134 /* use the receive hw checksum driver functionality */
135 #define USE_SK_RX_CHECKSUM
137 /* use the scatter-gather functionality with sendfile() */
140 /* use of a transmit complete interrupt */
141 #define USE_TX_COMPLETE
144 * threshold for copying small receive frames
145 * set to 0 to avoid copying, set to 9001 to copy all frames
147 #define SK_COPY_THRESHOLD 50
149 /* number of adapters that can be configured via command line params */
150 #define SK_MAX_CARD_PARAM 16
155 * use those defines for a compile-in version of the driver instead
156 * of command line parameters
158 // #define LINK_SPEED_A {"Auto", }
159 // #define LINK_SPEED_B {"Auto", }
160 // #define AUTO_NEG_A {"Sense", }
161 // #define AUTO_NEG_B {"Sense", }
162 // #define DUP_CAP_A {"Both", }
163 // #define DUP_CAP_B {"Both", }
164 // #define FLOW_CTRL_A {"SymOrRem", }
165 // #define FLOW_CTRL_B {"SymOrRem", }
166 // #define ROLE_A {"Auto", }
167 // #define ROLE_B {"Auto", }
168 // #define PREF_PORT {"A", }
169 // #define CON_TYPE {"Auto", }
170 // #define RLMT_MODE {"CheckLinkState", }
172 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
173 #define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
174 #define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
178 #define OEM_CONFIG_VALUE ( SK_ACT_LED_BLINK | \
179 SK_DUP_LED_NORMAL | \
183 /* Isr return value */
184 #define SkIsrRetVar irqreturn_t
185 #define SkIsrRetNone IRQ_NONE
186 #define SkIsrRetHandled IRQ_HANDLED
189 /*******************************************************************************
191 * Local Function Prototypes
193 ******************************************************************************/
195 static void FreeResources(struct SK_NET_DEVICE
*dev
);
196 static int SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
);
197 static SK_BOOL
BoardAllocMem(SK_AC
*pAC
);
198 static void BoardFreeMem(SK_AC
*pAC
);
199 static void BoardInitMem(SK_AC
*pAC
);
200 static void SetupRing(SK_AC
*, void*, uintptr_t, RXD
**, RXD
**, RXD
**, int*, SK_BOOL
);
201 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
);
202 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
);
203 static int SkGeOpen(struct SK_NET_DEVICE
*dev
);
204 static int SkGeClose(struct SK_NET_DEVICE
*dev
);
205 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
);
206 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
);
207 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
);
208 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
);
209 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
);
210 static void GetConfiguration(SK_AC
*);
211 static int XmitFrame(SK_AC
*, TX_PORT
*, struct sk_buff
*);
212 static void FreeTxDescriptors(SK_AC
*pAC
, TX_PORT
*);
213 static void FillRxRing(SK_AC
*, RX_PORT
*);
214 static SK_BOOL
FillRxDescriptor(SK_AC
*, RX_PORT
*);
215 static void ReceiveIrq(SK_AC
*, RX_PORT
*, SK_BOOL
);
216 static void ClearAndStartRx(SK_AC
*, int);
217 static void ClearTxIrq(SK_AC
*, int, int);
218 static void ClearRxRing(SK_AC
*, RX_PORT
*);
219 static void ClearTxRing(SK_AC
*, TX_PORT
*);
220 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int new_mtu
);
221 static void PortReInitBmu(SK_AC
*, int);
222 static int SkGeIocMib(DEV_NET
*, unsigned int, int);
223 static int SkGeInitPCI(SK_AC
*pAC
);
224 static void StartDrvCleanupTimer(SK_AC
*pAC
);
225 static void StopDrvCleanupTimer(SK_AC
*pAC
);
226 static int XmitFrameSG(SK_AC
*, TX_PORT
*, struct sk_buff
*);
228 #ifdef SK_DIAG_SUPPORT
229 static SK_U32
ParseDeviceNbrFromSlotName(const char *SlotName
);
230 static int SkDrvInitAdapter(SK_AC
*pAC
, int devNbr
);
231 static int SkDrvDeInitAdapter(SK_AC
*pAC
, int devNbr
);
234 /*******************************************************************************
236 * Extern Function Prototypes
238 ******************************************************************************/
239 extern void SkDimEnableModerationIfNeeded(SK_AC
*pAC
);
240 extern void SkDimDisplayModerationSettings(SK_AC
*pAC
);
241 extern void SkDimStartModerationTimer(SK_AC
*pAC
);
242 extern void SkDimModerate(SK_AC
*pAC
);
243 extern void SkGeBlinkTimer(unsigned long data
);
246 static void DumpMsg(struct sk_buff
*, char*);
247 static void DumpData(char*, int);
248 static void DumpLong(char*, int);
251 /* global variables *********************************************************/
252 static SK_BOOL DoPrintInterfaceChange
= SK_TRUE
;
253 extern const struct ethtool_ops SkGeEthtoolOps
;
255 /* local variables **********************************************************/
256 static uintptr_t TxQueueAddr
[SK_MAX_MACS
][2] = {{0x680, 0x600},{0x780, 0x700}};
257 static uintptr_t RxQueueAddr
[SK_MAX_MACS
] = {0x400, 0x480};
259 /*****************************************************************************
261 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
264 * This routine writes a 32 bit value to the pci configuration
268 * 0 - indicate everything worked ok.
269 * != 0 - error indication
271 static inline int SkPciWriteCfgDWord(
272 SK_AC
*pAC
, /* Adapter Control structure pointer */
273 int PciAddr
, /* PCI register address */
274 SK_U32 Val
) /* pointer to store the read value */
276 pci_write_config_dword(pAC
->PciDev
, PciAddr
, Val
);
278 } /* SkPciWriteCfgDWord */
280 /*****************************************************************************
282 * SkGeInitPCI - Init the PCI resources
285 * This function initialize the PCI resources and IO
288 * 0 - indicate everything worked ok.
289 * != 0 - error indication
291 static __devinit
int SkGeInitPCI(SK_AC
*pAC
)
293 struct SK_NET_DEVICE
*dev
= pAC
->dev
[0];
294 struct pci_dev
*pdev
= pAC
->PciDev
;
297 dev
->mem_start
= pci_resource_start (pdev
, 0);
298 pci_set_master(pdev
);
300 retval
= pci_request_regions(pdev
, "sk98lin");
306 * On big endian machines, we use the adapter's aibility of
307 * reading the descriptors as big endian.
311 SkPciReadCfgDWord(pAC
, PCI_OUR_REG_2
, &our2
);
312 our2
|= PCI_REV_DESC
;
313 SkPciWriteCfgDWord(pAC
, PCI_OUR_REG_2
, our2
);
318 * Remap the regs into kernel space.
320 pAC
->IoBase
= ioremap_nocache(dev
->mem_start
, 0x4000);
329 pci_release_regions(pdev
);
335 /*****************************************************************************
337 * FreeResources - release resources allocated for adapter
340 * This function releases the IRQ, unmaps the IO and
341 * frees the desriptor ring.
346 static void FreeResources(struct SK_NET_DEVICE
*dev
)
352 pNet
= netdev_priv(dev
);
354 AllocFlag
= pAC
->AllocFlag
;
356 pci_release_regions(pAC
->PciDev
);
358 if (AllocFlag
& SK_ALLOC_IRQ
) {
359 free_irq(dev
->irq
, dev
);
362 iounmap(pAC
->IoBase
);
364 if (pAC
->pDescrMem
) {
368 } /* FreeResources */
370 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
371 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
372 MODULE_LICENSE("GPL");
375 static char *Speed_A
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
377 static char *Speed_A
[SK_MAX_CARD_PARAM
] = {"", };
381 static char *Speed_B
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
383 static char *Speed_B
[SK_MAX_CARD_PARAM
] = {"", };
387 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = AUTO_NEG_A
;
389 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = {"", };
393 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = DUP_CAP_A
;
395 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = {"", };
399 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_A
;
401 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = {"", };
405 static char *Role_A
[SK_MAX_CARD_PARAM
] = ROLE_A
;
407 static char *Role_A
[SK_MAX_CARD_PARAM
] = {"", };
411 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = AUTO_NEG_B
;
413 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = {"", };
417 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = DUP_CAP_B
;
419 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = {"", };
423 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_B
;
425 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = {"", };
429 static char *Role_B
[SK_MAX_CARD_PARAM
] = ROLE_B
;
431 static char *Role_B
[SK_MAX_CARD_PARAM
] = {"", };
435 static char *ConType
[SK_MAX_CARD_PARAM
] = CON_TYPE
;
437 static char *ConType
[SK_MAX_CARD_PARAM
] = {"", };
441 static char *PrefPort
[SK_MAX_CARD_PARAM
] = PREF_PORT
;
443 static char *PrefPort
[SK_MAX_CARD_PARAM
] = {"", };
447 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = RLMT_MODE
;
449 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = {"", };
452 static int IntsPerSec
[SK_MAX_CARD_PARAM
];
453 static char *Moderation
[SK_MAX_CARD_PARAM
];
454 static char *ModerationMask
[SK_MAX_CARD_PARAM
];
455 static char *AutoSizing
[SK_MAX_CARD_PARAM
];
456 static char *Stats
[SK_MAX_CARD_PARAM
];
458 module_param_array(Speed_A
, charp
, NULL
, 0);
459 module_param_array(Speed_B
, charp
, NULL
, 0);
460 module_param_array(AutoNeg_A
, charp
, NULL
, 0);
461 module_param_array(AutoNeg_B
, charp
, NULL
, 0);
462 module_param_array(DupCap_A
, charp
, NULL
, 0);
463 module_param_array(DupCap_B
, charp
, NULL
, 0);
464 module_param_array(FlowCtrl_A
, charp
, NULL
, 0);
465 module_param_array(FlowCtrl_B
, charp
, NULL
, 0);
466 module_param_array(Role_A
, charp
, NULL
, 0);
467 module_param_array(Role_B
, charp
, NULL
, 0);
468 module_param_array(ConType
, charp
, NULL
, 0);
469 module_param_array(PrefPort
, charp
, NULL
, 0);
470 module_param_array(RlmtMode
, charp
, NULL
, 0);
471 /* used for interrupt moderation */
472 module_param_array(IntsPerSec
, int, NULL
, 0);
473 module_param_array(Moderation
, charp
, NULL
, 0);
474 module_param_array(Stats
, charp
, NULL
, 0);
475 module_param_array(ModerationMask
, charp
, NULL
, 0);
476 module_param_array(AutoSizing
, charp
, NULL
, 0);
478 /*****************************************************************************
480 * SkGeBoardInit - do level 0 and 1 initialization
483 * This function prepares the board hardware for running. The desriptor
484 * ring is set up, the IRQ is allocated and the configuration settings
488 * 0, if everything is ok
491 static int __devinit
SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
)
495 char *DescrString
= "sk98lin: Driver for Linux"; /* this is given to PNMI */
496 char *VerStr
= VER_STRING
;
497 int Ret
; /* return code of request_irq */
500 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
501 ("IoBase: %08lX\n", (unsigned long)pAC
->IoBase
));
502 for (i
=0; i
<SK_MAX_MACS
; i
++) {
503 pAC
->TxPort
[i
][0].HwAddr
= pAC
->IoBase
+ TxQueueAddr
[i
][0];
504 pAC
->TxPort
[i
][0].PortIndex
= i
;
505 pAC
->RxPort
[i
].HwAddr
= pAC
->IoBase
+ RxQueueAddr
[i
];
506 pAC
->RxPort
[i
].PortIndex
= i
;
509 /* Initialize the mutexes */
510 for (i
=0; i
<SK_MAX_MACS
; i
++) {
511 spin_lock_init(&pAC
->TxPort
[i
][0].TxDesRingLock
);
512 spin_lock_init(&pAC
->RxPort
[i
].RxDesRingLock
);
514 spin_lock_init(&pAC
->SlowPathLock
);
516 /* setup phy_id blink timer */
517 pAC
->BlinkTimer
.function
= SkGeBlinkTimer
;
518 pAC
->BlinkTimer
.data
= (unsigned long) dev
;
519 init_timer(&pAC
->BlinkTimer
);
521 /* level 0 init common modules here */
523 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
524 /* Does a RESET on board ...*/
525 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
) != 0) {
526 printk("HWInit (0) failed.\n");
527 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
530 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
531 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
532 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
533 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
534 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
535 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
537 pAC
->BoardLevel
= SK_INIT_DATA
;
538 pAC
->RxBufSize
= ETH_BUF_SIZE
;
540 SK_PNMI_SET_DRIVER_DESCR(pAC
, DescrString
);
541 SK_PNMI_SET_DRIVER_VER(pAC
, VerStr
);
543 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
545 /* level 1 init common modules here (HW init) */
546 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
547 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
548 printk("sk98lin: HWInit (1) failed.\n");
549 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
552 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
553 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
554 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
555 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
556 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
557 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
559 /* Set chipset type support */
560 pAC
->ChipsetType
= 0;
561 if ((pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
) ||
562 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON_LITE
)) {
563 pAC
->ChipsetType
= 1;
566 GetConfiguration(pAC
);
567 if (pAC
->RlmtNets
== 2) {
568 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
571 pAC
->BoardLevel
= SK_INIT_IO
;
572 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
574 if (pAC
->GIni
.GIMacsFound
== 2) {
575 Ret
= request_irq(dev
->irq
, SkGeIsr
, IRQF_SHARED
, "sk98lin", dev
);
576 } else if (pAC
->GIni
.GIMacsFound
== 1) {
577 Ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, IRQF_SHARED
,
580 printk(KERN_WARNING
"sk98lin: Illegal number of ports: %d\n",
581 pAC
->GIni
.GIMacsFound
);
586 printk(KERN_WARNING
"sk98lin: Requested IRQ %d is busy.\n",
590 pAC
->AllocFlag
|= SK_ALLOC_IRQ
;
592 /* Alloc memory for this board (Mem for RxD/TxD) : */
593 if(!BoardAllocMem(pAC
)) {
594 printk("No memory for descriptor rings.\n");
599 /* tschilling: New common function with minimum size check. */
601 if (pAC
->RlmtNets
== 2) {
605 if (SkGeInitAssignRamToQueues(
610 printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
615 } /* SkGeBoardInit */
618 /*****************************************************************************
620 * BoardAllocMem - allocate the memory for the descriptor rings
623 * This function allocates the memory for all descriptor rings.
624 * Each ring is aligned for the desriptor alignment and no ring
625 * has a 4 GByte boundary in it (because the upper 32 bit must
626 * be constant for all descriptiors in one rings).
629 * SK_TRUE, if all memory could be allocated
632 static __devinit SK_BOOL
BoardAllocMem(SK_AC
*pAC
)
634 caddr_t pDescrMem
; /* pointer to descriptor memory area */
635 size_t AllocLength
; /* length of complete descriptor area */
636 int i
; /* loop counter */
637 unsigned long BusAddr
;
640 /* rings plus one for alignment (do not cross 4 GB boundary) */
641 /* RX_RING_SIZE is assumed bigger than TX_RING_SIZE */
642 #if (BITS_PER_LONG == 32)
643 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
645 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
649 pDescrMem
= pci_alloc_consistent(pAC
->PciDev
, AllocLength
,
652 if (pDescrMem
== NULL
) {
655 pAC
->pDescrMem
= pDescrMem
;
656 BusAddr
= (unsigned long) pAC
->pDescrMemDMA
;
658 /* Descriptors need 8 byte alignment, and this is ensured
659 * by pci_alloc_consistent.
661 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
662 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
663 ("TX%d/A: pDescrMem: %lX, PhysDescrMem: %lX\n",
664 i
, (unsigned long) pDescrMem
,
666 pAC
->TxPort
[i
][0].pTxDescrRing
= pDescrMem
;
667 pAC
->TxPort
[i
][0].VTxDescrRing
= BusAddr
;
668 pDescrMem
+= TX_RING_SIZE
;
669 BusAddr
+= TX_RING_SIZE
;
671 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
672 ("RX%d: pDescrMem: %lX, PhysDescrMem: %lX\n",
673 i
, (unsigned long) pDescrMem
,
674 (unsigned long)BusAddr
));
675 pAC
->RxPort
[i
].pRxDescrRing
= pDescrMem
;
676 pAC
->RxPort
[i
].VRxDescrRing
= BusAddr
;
677 pDescrMem
+= RX_RING_SIZE
;
678 BusAddr
+= RX_RING_SIZE
;
682 } /* BoardAllocMem */
685 /****************************************************************************
687 * BoardFreeMem - reverse of BoardAllocMem
690 * Free all memory allocated in BoardAllocMem: adapter context,
691 * descriptor rings, locks.
695 static void BoardFreeMem(
698 size_t AllocLength
; /* length of complete descriptor area */
700 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
702 #if (BITS_PER_LONG == 32)
703 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
705 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
709 pci_free_consistent(pAC
->PciDev
, AllocLength
,
710 pAC
->pDescrMem
, pAC
->pDescrMemDMA
);
711 pAC
->pDescrMem
= NULL
;
715 /*****************************************************************************
717 * BoardInitMem - initiate the descriptor rings
720 * This function sets the descriptor rings up in memory.
721 * The adapter is initialized with the descriptor start addresses.
725 static __devinit
void BoardInitMem(SK_AC
*pAC
)
727 int i
; /* loop counter */
728 int RxDescrSize
; /* the size of a rx descriptor rounded up to alignment*/
729 int TxDescrSize
; /* the size of a tx descriptor rounded up to alignment*/
731 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
734 RxDescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
735 pAC
->RxDescrPerRing
= RX_RING_SIZE
/ RxDescrSize
;
736 TxDescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
737 pAC
->TxDescrPerRing
= TX_RING_SIZE
/ RxDescrSize
;
739 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
742 pAC
->TxPort
[i
][0].pTxDescrRing
,
743 pAC
->TxPort
[i
][0].VTxDescrRing
,
744 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingHead
,
745 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingTail
,
746 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingPrev
,
747 &pAC
->TxPort
[i
][0].TxdRingFree
,
751 pAC
->RxPort
[i
].pRxDescrRing
,
752 pAC
->RxPort
[i
].VRxDescrRing
,
753 &pAC
->RxPort
[i
].pRxdRingHead
,
754 &pAC
->RxPort
[i
].pRxdRingTail
,
755 &pAC
->RxPort
[i
].pRxdRingPrev
,
756 &pAC
->RxPort
[i
].RxdRingFree
,
762 /*****************************************************************************
764 * SetupRing - create one descriptor ring
767 * This function creates one descriptor ring in the given memory area.
768 * The head, tail and number of free descriptors in the ring are set.
773 static void SetupRing(
775 void *pMemArea
, /* a pointer to the memory area for the ring */
776 uintptr_t VMemArea
, /* the virtual bus address of the memory area */
777 RXD
**ppRingHead
, /* address where the head should be written */
778 RXD
**ppRingTail
, /* address where the tail should be written */
779 RXD
**ppRingPrev
, /* address where the tail should be written */
780 int *pRingFree
, /* address where the # of free descr. goes */
781 SK_BOOL IsTx
) /* flag: is this a tx ring */
783 int i
; /* loop counter */
784 int DescrSize
; /* the size of a descriptor rounded up to alignment*/
785 int DescrNum
; /* number of descriptors per ring */
786 RXD
*pDescr
; /* pointer to a descriptor (receive or transmit) */
787 RXD
*pNextDescr
; /* pointer to the next descriptor */
788 RXD
*pPrevDescr
; /* pointer to the previous descriptor */
789 uintptr_t VNextDescr
; /* the virtual bus address of the next descriptor */
791 if (IsTx
== SK_TRUE
) {
792 DescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) *
794 DescrNum
= TX_RING_SIZE
/ DescrSize
;
796 DescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) *
798 DescrNum
= RX_RING_SIZE
/ DescrSize
;
801 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
802 ("Descriptor size: %d Descriptor Number: %d\n",
803 DescrSize
,DescrNum
));
805 pDescr
= (RXD
*) pMemArea
;
807 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
808 VNextDescr
= VMemArea
+ DescrSize
;
809 for(i
=0; i
<DescrNum
; i
++) {
810 /* set the pointers right */
811 pDescr
->VNextRxd
= VNextDescr
& 0xffffffffULL
;
812 pDescr
->pNextRxd
= pNextDescr
;
813 if (!IsTx
) pDescr
->TcpSumStarts
= ETH_HLEN
<< 16 | ETH_HLEN
;
815 /* advance one step */
818 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
819 VNextDescr
+= DescrSize
;
821 pPrevDescr
->pNextRxd
= (RXD
*) pMemArea
;
822 pPrevDescr
->VNextRxd
= VMemArea
;
823 pDescr
= (RXD
*) pMemArea
;
824 *ppRingHead
= (RXD
*) pMemArea
;
825 *ppRingTail
= *ppRingHead
;
826 *ppRingPrev
= pPrevDescr
;
827 *pRingFree
= DescrNum
;
831 /*****************************************************************************
833 * PortReInitBmu - re-initiate the descriptor rings for one port
836 * This function reinitializes the descriptor rings of one port
837 * in memory. The port must be stopped before.
838 * The HW is initialized with the descriptor start addresses.
843 static void PortReInitBmu(
844 SK_AC
*pAC
, /* pointer to adapter context */
845 int PortIndex
) /* index of the port for which to re-init */
847 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
850 /* set address of first descriptor of ring in BMU */
851 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_L
,
852 (uint32_t)(((caddr_t
)
853 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
854 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
855 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) &
857 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_H
,
858 (uint32_t)(((caddr_t
)
859 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
860 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
861 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) >> 32));
862 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_L
,
863 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
864 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
865 pAC
->RxPort
[PortIndex
].VRxDescrRing
) & 0xFFFFFFFF));
866 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_H
,
867 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
868 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
869 pAC
->RxPort
[PortIndex
].VRxDescrRing
) >> 32));
870 } /* PortReInitBmu */
873 /****************************************************************************
875 * SkGeIsr - handle adapter interrupts
878 * The interrupt routine is called when the network adapter
879 * generates an interrupt. It may also be called if another device
880 * shares this interrupt vector with the driver.
885 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
)
887 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
890 SK_U32 IntSrc
; /* interrupts source register contents */
892 pNet
= netdev_priv(dev
);
896 * Check and process if its our interrupt
898 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
903 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
904 #if 0 /* software irq currently not used */
905 if (IntSrc
& IS_IRQ_SW
) {
906 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
907 SK_DBGCAT_DRV_INT_SRC
,
911 if (IntSrc
& IS_R1_F
) {
912 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
913 SK_DBGCAT_DRV_INT_SRC
,
915 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
916 SK_PNMI_CNT_RX_INTR(pAC
, 0);
918 if (IntSrc
& IS_R2_F
) {
919 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
920 SK_DBGCAT_DRV_INT_SRC
,
922 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_TRUE
);
923 SK_PNMI_CNT_RX_INTR(pAC
, 1);
925 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
926 if (IntSrc
& IS_XA1_F
) {
927 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
928 SK_DBGCAT_DRV_INT_SRC
,
929 ("EOF AS TX1 IRQ\n"));
930 SK_PNMI_CNT_TX_INTR(pAC
, 0);
931 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
932 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
933 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
935 if (IntSrc
& IS_XA2_F
) {
936 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
937 SK_DBGCAT_DRV_INT_SRC
,
938 ("EOF AS TX2 IRQ\n"));
939 SK_PNMI_CNT_TX_INTR(pAC
, 1);
940 spin_lock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
941 FreeTxDescriptors(pAC
, &pAC
->TxPort
[1][TX_PRIO_LOW
]);
942 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
944 #if 0 /* only if sync. queues used */
945 if (IntSrc
& IS_XS1_F
) {
946 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
947 SK_DBGCAT_DRV_INT_SRC
,
948 ("EOF SY TX1 IRQ\n"));
949 SK_PNMI_CNT_TX_INTR(pAC
, 1);
950 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
951 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
952 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
953 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
955 if (IntSrc
& IS_XS2_F
) {
956 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
957 SK_DBGCAT_DRV_INT_SRC
,
958 ("EOF SY TX2 IRQ\n"));
959 SK_PNMI_CNT_TX_INTR(pAC
, 1);
960 spin_lock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
961 FreeTxDescriptors(pAC
, 1, TX_PRIO_HIGH
);
962 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
963 ClearTxIrq(pAC
, 1, TX_PRIO_HIGH
);
968 /* do all IO at once */
969 if (IntSrc
& IS_R1_F
)
970 ClearAndStartRx(pAC
, 0);
971 if (IntSrc
& IS_R2_F
)
972 ClearAndStartRx(pAC
, 1);
973 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
974 if (IntSrc
& IS_XA1_F
)
975 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
976 if (IntSrc
& IS_XA2_F
)
977 ClearTxIrq(pAC
, 1, TX_PRIO_LOW
);
979 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
980 } /* while (IntSrc & IRQ_MASK != 0) */
982 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
983 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
984 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
985 ("SPECIAL IRQ DP-Cards => %x\n", IntSrc
));
986 pAC
->CheckQueue
= SK_FALSE
;
987 spin_lock(&pAC
->SlowPathLock
);
988 if (IntSrc
& SPECIAL_IRQS
)
989 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
991 SkEventDispatcher(pAC
, pAC
->IoBase
);
992 spin_unlock(&pAC
->SlowPathLock
);
995 * do it all again is case we cleared an interrupt that
996 * came in after handling the ring (OUTs may be delayed
997 * in hardware buffers, but are through after IN)
999 * rroesler: has been commented out and shifted to
1000 * SkGeDrvEvent(), because it is timer
1003 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1004 ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1007 if (pAC
->CheckQueue
) {
1008 pAC
->CheckQueue
= SK_FALSE
;
1009 spin_lock(&pAC
->SlowPathLock
);
1010 SkEventDispatcher(pAC
, pAC
->IoBase
);
1011 spin_unlock(&pAC
->SlowPathLock
);
1014 /* IRQ is processed - Enable IRQs again*/
1015 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1017 return SkIsrRetHandled
;
1021 /****************************************************************************
1023 * SkGeIsrOnePort - handle adapter interrupts for single port adapter
1026 * The interrupt routine is called when the network adapter
1027 * generates an interrupt. It may also be called if another device
1028 * shares this interrupt vector with the driver.
1029 * This is the same as above, but handles only one port.
1034 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
)
1036 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
1039 SK_U32 IntSrc
; /* interrupts source register contents */
1041 pNet
= netdev_priv(dev
);
1045 * Check and process if its our interrupt
1047 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
1049 return SkIsrRetNone
;
1052 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
1053 #if 0 /* software irq currently not used */
1054 if (IntSrc
& IS_IRQ_SW
) {
1055 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1056 SK_DBGCAT_DRV_INT_SRC
,
1057 ("Software IRQ\n"));
1060 if (IntSrc
& IS_R1_F
) {
1061 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1062 SK_DBGCAT_DRV_INT_SRC
,
1064 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
1065 SK_PNMI_CNT_RX_INTR(pAC
, 0);
1067 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1068 if (IntSrc
& IS_XA1_F
) {
1069 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1070 SK_DBGCAT_DRV_INT_SRC
,
1071 ("EOF AS TX1 IRQ\n"));
1072 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1073 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1074 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
1075 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1077 #if 0 /* only if sync. queues used */
1078 if (IntSrc
& IS_XS1_F
) {
1079 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1080 SK_DBGCAT_DRV_INT_SRC
,
1081 ("EOF SY TX1 IRQ\n"));
1082 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1083 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1084 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
1085 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1086 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
1091 /* do all IO at once */
1092 if (IntSrc
& IS_R1_F
)
1093 ClearAndStartRx(pAC
, 0);
1094 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1095 if (IntSrc
& IS_XA1_F
)
1096 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
1098 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
1099 } /* while (IntSrc & IRQ_MASK != 0) */
1101 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
1102 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
1103 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
1104 ("SPECIAL IRQ SP-Cards => %x\n", IntSrc
));
1105 pAC
->CheckQueue
= SK_FALSE
;
1106 spin_lock(&pAC
->SlowPathLock
);
1107 if (IntSrc
& SPECIAL_IRQS
)
1108 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
1110 SkEventDispatcher(pAC
, pAC
->IoBase
);
1111 spin_unlock(&pAC
->SlowPathLock
);
1114 * do it all again is case we cleared an interrupt that
1115 * came in after handling the ring (OUTs may be delayed
1116 * in hardware buffers, but are through after IN)
1118 * rroesler: has been commented out and shifted to
1119 * SkGeDrvEvent(), because it is timer
1122 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1125 /* IRQ is processed - Enable IRQs again*/
1126 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1128 return SkIsrRetHandled
;
1129 } /* SkGeIsrOnePort */
1131 #ifdef CONFIG_NET_POLL_CONTROLLER
1132 /****************************************************************************
1134 * SkGePollController - polling receive, for netconsole
1137 * Polling receive - used by netconsole and other diagnostic tools
1138 * to allow network i/o with interrupts disabled.
1142 static void SkGePollController(struct net_device
*dev
)
1144 disable_irq(dev
->irq
);
1145 SkGeIsr(dev
->irq
, dev
);
1146 enable_irq(dev
->irq
);
1150 /****************************************************************************
1152 * SkGeOpen - handle start of initialized adapter
1155 * This function starts the initialized adapter.
1156 * The board level variable is set and the adapter is
1157 * brought to full functionality.
1158 * The device flags are set for operation.
1159 * Do all necessary level 2 initialization, enable interrupts and
1160 * give start command to RLMT.
1166 static int SkGeOpen(
1167 struct SK_NET_DEVICE
*dev
)
1171 unsigned long Flags
; /* for spin lock */
1173 SK_EVPARA EvPara
; /* an event parameter union */
1175 pNet
= netdev_priv(dev
);
1178 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1179 ("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC
));
1181 #ifdef SK_DIAG_SUPPORT
1182 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1183 if (pAC
->Pnmi
.DiagAttached
== SK_DIAG_RUNNING
) {
1184 return (-1); /* still in use by diag; deny actions */
1189 /* Set blink mode */
1190 if ((pAC
->PciDev
->vendor
== 0x1186) || (pAC
->PciDev
->vendor
== 0x11ab ))
1191 pAC
->GIni
.GILedBlinkCtrl
= OEM_CONFIG_VALUE
;
1193 if (pAC
->BoardLevel
== SK_INIT_DATA
) {
1194 /* level 1 init common modules here */
1195 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
1196 printk("%s: HWInit (1) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1199 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1200 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1201 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1202 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1203 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1204 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1205 pAC
->BoardLevel
= SK_INIT_IO
;
1208 if (pAC
->BoardLevel
!= SK_INIT_RUN
) {
1209 /* tschilling: Level 2 init modules here, check return value. */
1210 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
) != 0) {
1211 printk("%s: HWInit (2) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1214 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1215 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1216 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1217 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1218 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1219 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1220 pAC
->BoardLevel
= SK_INIT_RUN
;
1223 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1224 /* Enable transmit descriptor polling. */
1225 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
1226 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
1228 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
1230 StartDrvCleanupTimer(pAC
);
1231 SkDimEnableModerationIfNeeded(pAC
);
1232 SkDimDisplayModerationSettings(pAC
);
1234 pAC
->GIni
.GIValIrqMask
&= IRQ_MASK
;
1236 /* enable Interrupts */
1237 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1238 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
1240 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1242 if ((pAC
->RlmtMode
!= 0) && (pAC
->MaxPorts
== 0)) {
1243 EvPara
.Para32
[0] = pAC
->RlmtNets
;
1244 EvPara
.Para32
[1] = -1;
1245 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
,
1247 EvPara
.Para32
[0] = pAC
->RlmtMode
;
1248 EvPara
.Para32
[1] = 0;
1249 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_MODE_CHANGE
,
1253 EvPara
.Para32
[0] = pNet
->NetNr
;
1254 EvPara
.Para32
[1] = -1;
1255 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
1256 SkEventDispatcher(pAC
, pAC
->IoBase
);
1257 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1262 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1263 ("SkGeOpen suceeded\n"));
1269 /****************************************************************************
1271 * SkGeClose - Stop initialized adapter
1274 * Close initialized adapter.
1278 * error code - on error
1280 static int SkGeClose(
1281 struct SK_NET_DEVICE
*dev
)
1287 unsigned long Flags
; /* for spin lock */
1292 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1293 ("SkGeClose: pAC=0x%lX ", (unsigned long)pAC
));
1295 pNet
= netdev_priv(dev
);
1298 #ifdef SK_DIAG_SUPPORT
1299 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1300 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
1302 ** notify that the interface which has been closed
1303 ** by operator interaction must not be started up
1304 ** again when the DIAG has finished.
1306 newPtrNet
= netdev_priv(pAC
->dev
[0]);
1307 if (newPtrNet
== pNet
) {
1308 pAC
->WasIfUp
[0] = SK_FALSE
;
1310 pAC
->WasIfUp
[1] = SK_FALSE
;
1312 return 0; /* return to system everything is fine... */
1314 pAC
->DiagFlowCtrl
= SK_FALSE
;
1319 netif_stop_queue(dev
);
1321 if (pAC
->RlmtNets
== 1)
1322 PortIdx
= pAC
->ActivePort
;
1324 PortIdx
= pNet
->NetNr
;
1326 StopDrvCleanupTimer(pAC
);
1329 * Clear multicast table, promiscuous mode ....
1331 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
1332 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
1335 if (pAC
->MaxPorts
== 1) {
1336 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1337 /* disable interrupts */
1338 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1339 EvPara
.Para32
[0] = pNet
->NetNr
;
1340 EvPara
.Para32
[1] = -1;
1341 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1342 SkEventDispatcher(pAC
, pAC
->IoBase
);
1343 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1344 /* stop the hardware */
1345 SkGeDeInit(pAC
, pAC
->IoBase
);
1346 pAC
->BoardLevel
= SK_INIT_DATA
;
1347 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1350 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1351 EvPara
.Para32
[0] = pNet
->NetNr
;
1352 EvPara
.Para32
[1] = -1;
1353 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1354 SkPnmiEvent(pAC
, pAC
->IoBase
, SK_PNMI_EVT_XMAC_RESET
, EvPara
);
1355 SkEventDispatcher(pAC
, pAC
->IoBase
);
1356 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1359 spin_lock_irqsave(&pAC
->TxPort
[pNet
->PortNr
]
1360 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1361 SkGeStopPort(pAC
, pAC
->IoBase
, pNet
->PortNr
,
1362 SK_STOP_ALL
, SK_HARD_RST
);
1363 spin_unlock_irqrestore(&pAC
->TxPort
[pNet
->PortNr
]
1364 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1367 if (pAC
->RlmtNets
== 1) {
1368 /* clear all descriptor rings */
1369 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1370 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
1371 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
1372 ClearTxRing(pAC
, &pAC
->TxPort
[i
][TX_PRIO_LOW
]);
1375 /* clear port descriptor rings */
1376 ReceiveIrq(pAC
, &pAC
->RxPort
[pNet
->PortNr
], SK_TRUE
);
1377 ClearRxRing(pAC
, &pAC
->RxPort
[pNet
->PortNr
]);
1378 ClearTxRing(pAC
, &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
]);
1381 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1382 ("SkGeClose: done "));
1384 SK_MEMSET(&(pAC
->PnmiBackup
), 0, sizeof(SK_PNMI_STRUCT_DATA
));
1385 SK_MEMCPY(&(pAC
->PnmiBackup
), &(pAC
->PnmiStruct
),
1386 sizeof(SK_PNMI_STRUCT_DATA
));
1394 /*****************************************************************************
1396 * SkGeXmit - Linux frame transmit function
1399 * The system calls this function to send frames onto the wire.
1400 * It puts the frame in the tx descriptor ring. If the ring is
1401 * full then, the 'tbusy' flag is set.
1404 * 0, if everything is ok
1406 * WARNING: returning 1 in 'tbusy' case caused system crashes (double
1407 * allocated skb's) !!!
1409 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
)
1413 int Rc
; /* return code of XmitFrame */
1415 pNet
= netdev_priv(dev
);
1418 if ((!skb_shinfo(skb
)->nr_frags
) ||
1419 (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
)) {
1420 /* Don't activate scatter-gather and hardware checksum */
1422 if (pAC
->RlmtNets
== 2)
1425 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1430 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1433 /* scatter-gather and hardware TCP checksumming anabled*/
1434 if (pAC
->RlmtNets
== 2)
1437 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1442 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1446 /* Transmitter out of resources? */
1448 netif_stop_queue(dev
);
1451 /* If not taken, give buffer ownership back to the
1457 dev
->trans_start
= jiffies
;
1462 /*****************************************************************************
1464 * XmitFrame - fill one socket buffer into the transmit ring
1467 * This function puts a message into the transmit descriptor ring
1468 * if there is a descriptors left.
1469 * Linux skb's consist of only one continuous buffer.
1470 * The first step locks the ring. It is held locked
1471 * all time to avoid problems with SWITCH_../PORT_RESET.
1472 * Then the descriptoris allocated.
1473 * The second part is linking the buffer to the descriptor.
1474 * At the very last, the Control field of the descriptor
1475 * is made valid for the BMU and a start TX command is given
1479 * > 0 - on succes: the number of bytes in the message
1480 * = 0 - on resource shortage: this frame sent or dropped, now
1481 * the ring is full ( -> set tbusy)
1482 * < 0 - on failure: other problems ( -> return failure to upper layers)
1484 static int XmitFrame(
1485 SK_AC
*pAC
, /* pointer to adapter context */
1486 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1487 struct sk_buff
*pMessage
) /* pointer to send-message */
1489 TXD
*pTxd
; /* the rxd to fill */
1491 unsigned long Flags
;
1493 int BytesSend
= pMessage
->len
;
1495 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
, ("X"));
1497 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1498 #ifndef USE_TX_COMPLETE
1499 FreeTxDescriptors(pAC
, pTxPort
);
1501 if (pTxPort
->TxdRingFree
== 0) {
1503 ** no enough free descriptors in ring at the moment.
1504 ** Maybe free'ing some old one help?
1506 FreeTxDescriptors(pAC
, pTxPort
);
1507 if (pTxPort
->TxdRingFree
== 0) {
1508 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1509 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1510 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1511 SK_DBGCAT_DRV_TX_PROGRESS
,
1512 ("XmitFrame failed\n"));
1514 ** the desired message can not be sent
1515 ** Because tbusy seems to be set, the message
1516 ** should not be freed here. It will be used
1517 ** by the scheduler of the ethernet handler
1524 ** If the passed socket buffer is of smaller MTU-size than 60,
1525 ** copy everything into new buffer and fill all bytes between
1526 ** the original packet end and the new packet end of 60 with 0x00.
1527 ** This is to resolve faulty padding by the HW with 0xaa bytes.
1529 if (BytesSend
< C_LEN_ETHERNET_MINSIZE
) {
1530 if (skb_padto(pMessage
, C_LEN_ETHERNET_MINSIZE
)) {
1531 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1534 pMessage
->len
= C_LEN_ETHERNET_MINSIZE
;
1538 ** advance head counter behind descriptor needed for this frame,
1539 ** so that needed descriptor is reserved from that on. The next
1540 ** action will be to add the passed buffer to the TX-descriptor
1542 pTxd
= pTxPort
->pTxdRingHead
;
1543 pTxPort
->pTxdRingHead
= pTxd
->pNextTxd
;
1544 pTxPort
->TxdRingFree
--;
1547 DumpMsg(pMessage
, "XmitFrame");
1551 ** First step is to map the data to be sent via the adapter onto
1552 ** the DMA memory. Kernel 2.2 uses virt_to_bus(), but kernels 2.4
1553 ** and 2.6 need to use pci_map_page() for that mapping.
1555 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1556 virt_to_page(pMessage
->data
),
1557 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1560 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1561 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1562 pTxd
->pMBuf
= pMessage
;
1564 if (pMessage
->ip_summed
== CHECKSUM_PARTIAL
) {
1565 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1566 u16 offset
= hdrlen
+ pMessage
->csum_offset
;
1568 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1569 (pAC
->GIni
.GIChipRev
== 0) &&
1570 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1571 pTxd
->TBControl
= BMU_TCP_CHECK
;
1573 pTxd
->TBControl
= BMU_UDP_CHECK
;
1576 pTxd
->TcpSumOfs
= 0;
1577 pTxd
->TcpSumSt
= hdrlen
;
1578 pTxd
->TcpSumWr
= offset
;
1580 pTxd
->TBControl
|= BMU_OWN
| BMU_STF
|
1582 #ifdef USE_TX_COMPLETE
1587 pTxd
->TBControl
= BMU_OWN
| BMU_STF
| BMU_CHECK
|
1589 #ifdef USE_TX_COMPLETE
1596 ** If previous descriptor already done, give TX start cmd
1598 pOldTxd
= xchg(&pTxPort
->pTxdRingPrev
, pTxd
);
1599 if ((pOldTxd
->TBControl
& BMU_OWN
) == 0) {
1600 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1604 ** after releasing the lock, the skb may immediately be free'd
1606 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1607 if (pTxPort
->TxdRingFree
!= 0) {
1615 /*****************************************************************************
1617 * XmitFrameSG - fill one socket buffer into the transmit ring
1618 * (use SG and TCP/UDP hardware checksumming)
1621 * This function puts a message into the transmit descriptor ring
1622 * if there is a descriptors left.
1625 * > 0 - on succes: the number of bytes in the message
1626 * = 0 - on resource shortage: this frame sent or dropped, now
1627 * the ring is full ( -> set tbusy)
1628 * < 0 - on failure: other problems ( -> return failure to upper layers)
1630 static int XmitFrameSG(
1631 SK_AC
*pAC
, /* pointer to adapter context */
1632 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1633 struct sk_buff
*pMessage
) /* pointer to send-message */
1641 skb_frag_t
*sk_frag
;
1643 unsigned long Flags
;
1646 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1647 #ifndef USE_TX_COMPLETE
1648 FreeTxDescriptors(pAC
, pTxPort
);
1650 if ((skb_shinfo(pMessage
)->nr_frags
+1) > pTxPort
->TxdRingFree
) {
1651 FreeTxDescriptors(pAC
, pTxPort
);
1652 if ((skb_shinfo(pMessage
)->nr_frags
+ 1) > pTxPort
->TxdRingFree
) {
1653 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1654 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1655 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1656 SK_DBGCAT_DRV_TX_PROGRESS
,
1657 ("XmitFrameSG failed - Ring full\n"));
1658 /* this message can not be sent now */
1663 pTxd
= pTxPort
->pTxdRingHead
;
1669 ** Map the first fragment (header) into the DMA-space
1671 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1672 virt_to_page(pMessage
->data
),
1673 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1674 skb_headlen(pMessage
),
1677 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1678 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1681 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1683 if (pMessage
->ip_summed
== CHECKSUM_PARTIAL
) {
1684 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1685 u16 offset
= hdrlen
+ pMessage
->csum_offset
;
1687 Control
= BMU_STFWD
;
1690 ** We have to use the opcode for tcp here, because the
1691 ** opcode for udp is not working in the hardware yet
1694 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1695 (pAC
->GIni
.GIChipRev
== 0) &&
1696 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1697 Control
|= BMU_TCP_CHECK
;
1699 Control
|= BMU_UDP_CHECK
;
1702 pTxd
->TcpSumOfs
= 0;
1703 pTxd
->TcpSumSt
= hdrlen
;
1704 pTxd
->TcpSumWr
= offset
;
1706 Control
= BMU_CHECK
| BMU_SW
;
1708 pTxd
->TBControl
= BMU_STF
| Control
| skb_headlen(pMessage
);
1710 pTxd
= pTxd
->pNextTxd
;
1711 pTxPort
->TxdRingFree
--;
1712 BytesSend
+= skb_headlen(pMessage
);
1715 ** Browse over all SG fragments and map each of them into the DMA space
1717 for (CurrFrag
= 0; CurrFrag
< skb_shinfo(pMessage
)->nr_frags
; CurrFrag
++) {
1718 sk_frag
= &skb_shinfo(pMessage
)->frags
[CurrFrag
];
1720 ** we already have the proper value in entry
1722 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1724 sk_frag
->page_offset
,
1728 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1729 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1730 pTxd
->pMBuf
= pMessage
;
1732 pTxd
->TBControl
= Control
| BMU_OWN
| sk_frag
->size
;
1735 ** Do we have the last fragment?
1737 if( (CurrFrag
+1) == skb_shinfo(pMessage
)->nr_frags
) {
1738 #ifdef USE_TX_COMPLETE
1739 pTxd
->TBControl
|= BMU_EOF
| BMU_IRQ_EOF
;
1741 pTxd
->TBControl
|= BMU_EOF
;
1743 pTxdFst
->TBControl
|= BMU_OWN
| BMU_SW
;
1746 pTxd
= pTxd
->pNextTxd
;
1747 pTxPort
->TxdRingFree
--;
1748 BytesSend
+= sk_frag
->size
;
1752 ** If previous descriptor already done, give TX start cmd
1754 if ((pTxPort
->pTxdRingPrev
->TBControl
& BMU_OWN
) == 0) {
1755 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1758 pTxPort
->pTxdRingPrev
= pTxdLst
;
1759 pTxPort
->pTxdRingHead
= pTxd
;
1761 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1763 if (pTxPort
->TxdRingFree
> 0) {
1770 /*****************************************************************************
1772 * FreeTxDescriptors - release descriptors from the descriptor ring
1775 * This function releases descriptors from a transmit ring if they
1776 * have been sent by the BMU.
1777 * If a descriptors is sent, it can be freed and the message can
1779 * The SOFTWARE controllable bit is used to prevent running around a
1780 * completely free ring for ever. If this bit is no set in the
1781 * frame (by XmitFrame), this frame has never been sent or is
1783 * The Tx descriptor ring lock must be held while calling this function !!!
1788 static void FreeTxDescriptors(
1789 SK_AC
*pAC
, /* pointer to the adapter context */
1790 TX_PORT
*pTxPort
) /* pointer to destination port structure */
1792 TXD
*pTxd
; /* pointer to the checked descriptor */
1793 TXD
*pNewTail
; /* pointer to 'end' of the ring */
1794 SK_U32 Control
; /* TBControl field of descriptor */
1795 SK_U64 PhysAddr
; /* address of DMA mapping */
1797 pNewTail
= pTxPort
->pTxdRingTail
;
1800 ** loop forever; exits if BMU_SW bit not set in start frame
1801 ** or BMU_OWN bit set in any frame
1804 Control
= pTxd
->TBControl
;
1805 if ((Control
& BMU_SW
) == 0) {
1807 ** software controllable bit is set in first
1808 ** fragment when given to BMU. Not set means that
1809 ** this fragment was never sent or is already
1810 ** freed ( -> ring completely free now).
1812 pTxPort
->pTxdRingTail
= pTxd
;
1813 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1816 if (Control
& BMU_OWN
) {
1817 pTxPort
->pTxdRingTail
= pTxd
;
1818 if (pTxPort
->TxdRingFree
> 0) {
1819 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1825 ** release the DMA mapping, because until not unmapped
1826 ** this buffer is considered being under control of the
1829 PhysAddr
= ((SK_U64
) pTxd
->VDataHigh
) << (SK_U64
) 32;
1830 PhysAddr
|= (SK_U64
) pTxd
->VDataLow
;
1831 pci_unmap_page(pAC
->PciDev
, PhysAddr
,
1835 if (Control
& BMU_EOF
)
1836 DEV_KFREE_SKB_ANY(pTxd
->pMBuf
); /* free message */
1838 pTxPort
->TxdRingFree
++;
1839 pTxd
->TBControl
&= ~BMU_SW
;
1840 pTxd
= pTxd
->pNextTxd
; /* point behind fragment with EOF */
1841 } /* while(forever) */
1842 } /* FreeTxDescriptors */
1844 /*****************************************************************************
1846 * FillRxRing - fill the receive ring with valid descriptors
1849 * This function fills the receive ring descriptors with data
1850 * segments and makes them valid for the BMU.
1851 * The active ring is filled completely, if possible.
1852 * The non-active ring is filled only partial to save memory.
1854 * Description of rx ring structure:
1855 * head - points to the descriptor which will be used next by the BMU
1856 * tail - points to the next descriptor to give to the BMU
1860 static void FillRxRing(
1861 SK_AC
*pAC
, /* pointer to the adapter context */
1862 RX_PORT
*pRxPort
) /* ptr to port struct for which the ring
1865 unsigned long Flags
;
1867 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
1868 while (pRxPort
->RxdRingFree
> pRxPort
->RxFillLimit
) {
1869 if(!FillRxDescriptor(pAC
, pRxPort
))
1872 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
1876 /*****************************************************************************
1878 * FillRxDescriptor - fill one buffer into the receive ring
1881 * The function allocates a new receive buffer and
1882 * puts it into the next descriptor.
1885 * SK_TRUE - a buffer was added to the ring
1886 * SK_FALSE - a buffer could not be added
1888 static SK_BOOL
FillRxDescriptor(
1889 SK_AC
*pAC
, /* pointer to the adapter context struct */
1890 RX_PORT
*pRxPort
) /* ptr to port struct of ring to fill */
1892 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
1893 RXD
*pRxd
; /* the rxd to fill */
1894 SK_U16 Length
; /* data fragment length */
1895 SK_U64 PhysAddr
; /* physical address of a rx buffer */
1897 pMsgBlock
= alloc_skb(pAC
->RxBufSize
, GFP_ATOMIC
);
1898 if (pMsgBlock
== NULL
) {
1899 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1900 SK_DBGCAT_DRV_ENTRY
,
1901 ("%s: Allocation of rx buffer failed !\n",
1902 pAC
->dev
[pRxPort
->PortIndex
]->name
));
1903 SK_PNMI_CNT_NO_RX_BUF(pAC
, pRxPort
->PortIndex
);
1906 skb_reserve(pMsgBlock
, 2); /* to align IP frames */
1907 /* skb allocated ok, so add buffer */
1908 pRxd
= pRxPort
->pRxdRingTail
;
1909 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1910 pRxPort
->RxdRingFree
--;
1911 Length
= pAC
->RxBufSize
;
1912 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1913 virt_to_page(pMsgBlock
->data
),
1914 ((unsigned long) pMsgBlock
->data
&
1917 PCI_DMA_FROMDEVICE
);
1919 pRxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1920 pRxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1921 pRxd
->pMBuf
= pMsgBlock
;
1922 pRxd
->RBControl
= BMU_OWN
|
1929 } /* FillRxDescriptor */
1932 /*****************************************************************************
1934 * ReQueueRxBuffer - fill one buffer back into the receive ring
1937 * Fill a given buffer back into the rx ring. The buffer
1938 * has been previously allocated and aligned, and its phys.
1939 * address calculated, so this is no more necessary.
1943 static void ReQueueRxBuffer(
1944 SK_AC
*pAC
, /* pointer to the adapter context struct */
1945 RX_PORT
*pRxPort
, /* ptr to port struct of ring to fill */
1946 struct sk_buff
*pMsg
, /* pointer to the buffer */
1947 SK_U32 PhysHigh
, /* phys address high dword */
1948 SK_U32 PhysLow
) /* phys address low dword */
1950 RXD
*pRxd
; /* the rxd to fill */
1951 SK_U16 Length
; /* data fragment length */
1953 pRxd
= pRxPort
->pRxdRingTail
;
1954 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1955 pRxPort
->RxdRingFree
--;
1956 Length
= pAC
->RxBufSize
;
1958 pRxd
->VDataLow
= PhysLow
;
1959 pRxd
->VDataHigh
= PhysHigh
;
1961 pRxd
->RBControl
= BMU_OWN
|
1967 } /* ReQueueRxBuffer */
1969 /*****************************************************************************
1971 * ReceiveIrq - handle a receive IRQ
1974 * This function is called when a receive IRQ is set.
1975 * It walks the receive descriptor ring and sends up all
1976 * frames that are complete.
1980 static void ReceiveIrq(
1981 SK_AC
*pAC
, /* pointer to adapter context */
1982 RX_PORT
*pRxPort
, /* pointer to receive port struct */
1983 SK_BOOL SlowPathLock
) /* indicates if SlowPathLock is needed */
1985 RXD
*pRxd
; /* pointer to receive descriptors */
1986 SK_U32 Control
; /* control field of descriptor */
1987 struct sk_buff
*pMsg
; /* pointer to message holding frame */
1988 struct sk_buff
*pNewMsg
; /* pointer to a new message for copying frame */
1989 int FrameLength
; /* total length of received frame */
1990 SK_MBUF
*pRlmtMbuf
; /* ptr to a buffer for giving a frame to rlmt */
1991 SK_EVPARA EvPara
; /* an event parameter union */
1992 unsigned long Flags
; /* for spin lock */
1993 int PortIndex
= pRxPort
->PortIndex
;
1994 unsigned int Offset
;
1995 unsigned int NumBytes
;
1996 unsigned int ForRlmt
;
1999 SK_BOOL IsBadFrame
; /* Bad frame */
2005 /* do forever; exit if BMU_OWN found */
2006 for ( pRxd
= pRxPort
->pRxdRingHead
;
2007 pRxPort
->RxdRingFree
< pAC
->RxDescrPerRing
;
2008 pRxd
= pRxd
->pNextRxd
,
2009 pRxPort
->pRxdRingHead
= pRxd
,
2010 pRxPort
->RxdRingFree
++) {
2013 * For a better understanding of this loop
2014 * Go through every descriptor beginning at the head
2015 * Please note: the ring might be completely received so the OWN bit
2016 * set is not a good crirteria to leave that loop.
2017 * Therefore the RingFree counter is used.
2018 * On entry of this loop pRxd is a pointer to the Rxd that needs
2019 * to be checked next.
2022 Control
= pRxd
->RBControl
;
2024 /* check if this descriptor is ready */
2025 if ((Control
& BMU_OWN
) != 0) {
2026 /* this descriptor is not yet ready */
2027 /* This is the usual end of the loop */
2028 /* We don't need to start the ring again */
2029 FillRxRing(pAC
, pRxPort
);
2032 pAC
->DynIrqModInfo
.NbrProcessedDescr
++;
2034 /* get length of frame and check it */
2035 FrameLength
= Control
& BMU_BBC
;
2036 if (FrameLength
> pAC
->RxBufSize
) {
2040 /* check for STF and EOF */
2041 if ((Control
& (BMU_STF
| BMU_EOF
)) != (BMU_STF
| BMU_EOF
)) {
2045 /* here we have a complete frame in the ring */
2048 FrameStat
= pRxd
->FrameStat
;
2050 /* check for frame length mismatch */
2051 #define XMR_FS_LEN_SHIFT 18
2052 #define GMR_FS_LEN_SHIFT 16
2053 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2054 if (FrameLength
!= (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)) {
2055 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2056 SK_DBGCAT_DRV_RX_PROGRESS
,
2057 ("skge: Frame length mismatch (%u/%u).\n",
2059 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2064 if (FrameLength
!= (SK_U32
) (FrameStat
>> GMR_FS_LEN_SHIFT
)) {
2065 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2066 SK_DBGCAT_DRV_RX_PROGRESS
,
2067 ("skge: Frame length mismatch (%u/%u).\n",
2069 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2075 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2076 IsBc
= (FrameStat
& XMR_FS_BC
) != 0;
2077 IsMc
= (FrameStat
& XMR_FS_MC
) != 0;
2078 IsBadFrame
= (FrameStat
&
2079 (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0;
2081 IsBc
= (FrameStat
& GMR_FS_BC
) != 0;
2082 IsMc
= (FrameStat
& GMR_FS_MC
) != 0;
2083 IsBadFrame
= (((FrameStat
& GMR_FS_ANY_ERR
) != 0) ||
2084 ((FrameStat
& GMR_FS_RX_OK
) == 0));
2087 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2088 ("Received frame of length %d on port %d\n",
2089 FrameLength
, PortIndex
));
2090 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2091 ("Number of free rx descriptors: %d\n",
2092 pRxPort
->RxdRingFree
));
2093 /* DumpMsg(pMsg, "Rx"); */
2095 if ((Control
& BMU_STAT_VAL
) != BMU_STAT_VAL
|| (IsBadFrame
)) {
2097 (FrameStat
& (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0) {
2099 /* there is a receive error in this frame */
2100 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2101 SK_DBGCAT_DRV_RX_PROGRESS
,
2102 ("skge: Error in received frame, dropped!\n"
2103 "Control: %x\nRxStat: %x\n",
2104 Control
, FrameStat
));
2106 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2107 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2113 * if short frame then copy data to reduce memory waste
2115 if ((FrameLength
< SK_COPY_THRESHOLD
) &&
2116 ((pNewMsg
= alloc_skb(FrameLength
+2, GFP_ATOMIC
)) != NULL
)) {
2118 * Short frame detected and allocation successfull
2120 /* use new skb and copy data */
2121 skb_reserve(pNewMsg
, 2);
2122 skb_put(pNewMsg
, FrameLength
);
2123 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2124 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2126 pci_dma_sync_single_for_cpu(pAC
->PciDev
,
2127 (dma_addr_t
) PhysAddr
,
2129 PCI_DMA_FROMDEVICE
);
2130 memcpy(pNewMsg
->data
, pMsg
, FrameLength
);
2132 pci_dma_sync_single_for_device(pAC
->PciDev
,
2133 (dma_addr_t
) PhysAddr
,
2135 PCI_DMA_FROMDEVICE
);
2136 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2137 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2144 * if large frame, or SKB allocation failed, pass
2145 * the SKB directly to the networking
2148 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2149 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2151 /* release the DMA mapping */
2152 pci_unmap_single(pAC
->PciDev
,
2155 PCI_DMA_FROMDEVICE
);
2157 /* set length in message */
2158 skb_put(pMsg
, FrameLength
);
2159 } /* frame > SK_COPY_TRESHOLD */
2161 #ifdef USE_SK_RX_CHECKSUM
2162 pMsg
->csum
= pRxd
->TcpSums
& 0xffff;
2163 pMsg
->ip_summed
= CHECKSUM_COMPLETE
;
2165 pMsg
->ip_summed
= CHECKSUM_NONE
;
2168 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("V"));
2169 ForRlmt
= SK_RLMT_RX_PROTOCOL
;
2171 IsBc
= (FrameStat
& XMR_FS_BC
)==XMR_FS_BC
;
2173 SK_RLMT_PRE_LOOKAHEAD(pAC
, PortIndex
, FrameLength
,
2174 IsBc
, &Offset
, &NumBytes
);
2175 if (NumBytes
!= 0) {
2177 IsMc
= (FrameStat
& XMR_FS_MC
)==XMR_FS_MC
;
2179 SK_RLMT_LOOKAHEAD(pAC
, PortIndex
,
2180 &pMsg
->data
[Offset
],
2181 IsBc
, IsMc
, &ForRlmt
);
2183 if (ForRlmt
== SK_RLMT_RX_PROTOCOL
) {
2184 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("W"));
2185 /* send up only frames from active port */
2186 if ((PortIndex
== pAC
->ActivePort
) ||
2187 (pAC
->RlmtNets
== 2)) {
2188 /* frame for upper layer */
2189 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("U"));
2191 DumpMsg(pMsg
, "Rx");
2193 SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC
,
2194 FrameLength
, pRxPort
->PortIndex
);
2196 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2197 pMsg
->protocol
= eth_type_trans(pMsg
,
2198 pAC
->dev
[pRxPort
->PortIndex
]);
2200 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2204 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2205 SK_DBGCAT_DRV_RX_PROGRESS
,
2207 DEV_KFREE_SKB(pMsg
);
2210 } /* if not for rlmt */
2212 /* packet for rlmt */
2213 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2214 SK_DBGCAT_DRV_RX_PROGRESS
, ("R"));
2215 pRlmtMbuf
= SkDrvAllocRlmtMbuf(pAC
,
2216 pAC
->IoBase
, FrameLength
);
2217 if (pRlmtMbuf
!= NULL
) {
2218 pRlmtMbuf
->pNext
= NULL
;
2219 pRlmtMbuf
->Length
= FrameLength
;
2220 pRlmtMbuf
->PortIdx
= PortIndex
;
2221 EvPara
.pParaPtr
= pRlmtMbuf
;
2222 memcpy((char*)(pRlmtMbuf
->pData
),
2223 (char*)(pMsg
->data
),
2226 /* SlowPathLock needed? */
2227 if (SlowPathLock
== SK_TRUE
) {
2228 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2229 SkEventQueue(pAC
, SKGE_RLMT
,
2230 SK_RLMT_PACKET_RECEIVED
,
2232 pAC
->CheckQueue
= SK_TRUE
;
2233 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2235 SkEventQueue(pAC
, SKGE_RLMT
,
2236 SK_RLMT_PACKET_RECEIVED
,
2238 pAC
->CheckQueue
= SK_TRUE
;
2241 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2242 SK_DBGCAT_DRV_RX_PROGRESS
,
2245 if ((pAC
->dev
[pRxPort
->PortIndex
]->flags
&
2246 (IFF_PROMISC
| IFF_ALLMULTI
)) != 0 ||
2247 (ForRlmt
& SK_RLMT_RX_PROTOCOL
) ==
2248 SK_RLMT_RX_PROTOCOL
) {
2249 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2250 pMsg
->protocol
= eth_type_trans(pMsg
,
2251 pAC
->dev
[pRxPort
->PortIndex
]);
2253 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2256 DEV_KFREE_SKB(pMsg
);
2259 } /* if packet for rlmt */
2260 } /* for ... scanning the RXD ring */
2262 /* RXD ring is empty -> fill and restart */
2263 FillRxRing(pAC
, pRxPort
);
2264 /* do not start if called from Close */
2265 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
2266 ClearAndStartRx(pAC
, PortIndex
);
2271 /* remove error frame */
2272 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ERROR
,
2273 ("Schrottdescriptor, length: 0x%x\n", FrameLength
));
2275 /* release the DMA mapping */
2277 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2278 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2279 pci_unmap_page(pAC
->PciDev
,
2282 PCI_DMA_FROMDEVICE
);
2283 DEV_KFREE_SKB_IRQ(pRxd
->pMBuf
);
2285 pRxPort
->RxdRingFree
++;
2286 pRxPort
->pRxdRingHead
= pRxd
->pNextRxd
;
2292 /*****************************************************************************
2294 * ClearAndStartRx - give a start receive command to BMU, clear IRQ
2297 * This function sends a start command and a clear interrupt
2298 * command for one receive queue to the BMU.
2303 static void ClearAndStartRx(
2304 SK_AC
*pAC
, /* pointer to the adapter context */
2305 int PortIndex
) /* index of the receive port (XMAC) */
2307 SK_OUT8(pAC
->IoBase
,
2308 RxQueueAddr
[PortIndex
]+Q_CSR
,
2309 CSR_START
| CSR_IRQ_CL_F
);
2310 } /* ClearAndStartRx */
2313 /*****************************************************************************
2315 * ClearTxIrq - give a clear transmit IRQ command to BMU
2318 * This function sends a clear tx IRQ command for one
2319 * transmit queue to the BMU.
2323 static void ClearTxIrq(
2324 SK_AC
*pAC
, /* pointer to the adapter context */
2325 int PortIndex
, /* index of the transmit port (XMAC) */
2326 int Prio
) /* priority or normal queue */
2328 SK_OUT8(pAC
->IoBase
,
2329 TxQueueAddr
[PortIndex
][Prio
]+Q_CSR
,
2334 /*****************************************************************************
2336 * ClearRxRing - remove all buffers from the receive ring
2339 * This function removes all receive buffers from the ring.
2340 * The receive BMU must be stopped before calling this function.
2344 static void ClearRxRing(
2345 SK_AC
*pAC
, /* pointer to adapter context */
2346 RX_PORT
*pRxPort
) /* pointer to rx port struct */
2348 RXD
*pRxd
; /* pointer to the current descriptor */
2349 unsigned long Flags
;
2352 if (pRxPort
->RxdRingFree
== pAC
->RxDescrPerRing
) {
2355 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
2356 pRxd
= pRxPort
->pRxdRingHead
;
2358 if (pRxd
->pMBuf
!= NULL
) {
2360 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2361 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2362 pci_unmap_page(pAC
->PciDev
,
2365 PCI_DMA_FROMDEVICE
);
2366 DEV_KFREE_SKB(pRxd
->pMBuf
);
2369 pRxd
->RBControl
&= BMU_OWN
;
2370 pRxd
= pRxd
->pNextRxd
;
2371 pRxPort
->RxdRingFree
++;
2372 } while (pRxd
!= pRxPort
->pRxdRingTail
);
2373 pRxPort
->pRxdRingTail
= pRxPort
->pRxdRingHead
;
2374 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
2377 /*****************************************************************************
2379 * ClearTxRing - remove all buffers from the transmit ring
2382 * This function removes all transmit buffers from the ring.
2383 * The transmit BMU must be stopped before calling this function
2384 * and transmitting at the upper level must be disabled.
2385 * The BMU own bit of all descriptors is cleared, the rest is
2386 * done by calling FreeTxDescriptors.
2390 static void ClearTxRing(
2391 SK_AC
*pAC
, /* pointer to adapter context */
2392 TX_PORT
*pTxPort
) /* pointer to tx prt struct */
2394 TXD
*pTxd
; /* pointer to the current descriptor */
2396 unsigned long Flags
;
2398 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
2399 pTxd
= pTxPort
->pTxdRingHead
;
2400 for (i
=0; i
<pAC
->TxDescrPerRing
; i
++) {
2401 pTxd
->TBControl
&= ~BMU_OWN
;
2402 pTxd
= pTxd
->pNextTxd
;
2404 FreeTxDescriptors(pAC
, pTxPort
);
2405 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
2408 /*****************************************************************************
2410 * SkGeSetMacAddr - Set the hardware MAC address
2413 * This function sets the MAC address used by the adapter.
2416 * 0, if everything is ok
2419 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
)
2422 DEV_NET
*pNet
= netdev_priv(dev
);
2423 SK_AC
*pAC
= pNet
->pAC
;
2425 struct sockaddr
*addr
= p
;
2426 unsigned long Flags
;
2428 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2429 ("SkGeSetMacAddr starts now...\n"));
2430 if(netif_running(dev
))
2433 memcpy(dev
->dev_addr
, addr
->sa_data
,dev
->addr_len
);
2435 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2437 if (pAC
->RlmtNets
== 2)
2438 SkAddrOverride(pAC
, pAC
->IoBase
, pNet
->NetNr
,
2439 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2441 SkAddrOverride(pAC
, pAC
->IoBase
, pAC
->ActivePort
,
2442 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2446 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2448 } /* SkGeSetMacAddr */
2451 /*****************************************************************************
2453 * SkGeSetRxMode - set receive mode
2456 * This function sets the receive mode of an adapter. The adapter
2457 * supports promiscuous mode, allmulticast mode and a number of
2458 * multicast addresses. If more multicast addresses the available
2459 * are selected, a hash function in the hardware is used.
2462 * 0, if everything is ok
2465 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
)
2471 struct dev_mc_list
*pMcList
;
2474 unsigned long Flags
;
2476 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2477 ("SkGeSetRxMode starts now... "));
2479 pNet
= netdev_priv(dev
);
2481 if (pAC
->RlmtNets
== 1)
2482 PortIdx
= pAC
->ActivePort
;
2484 PortIdx
= pNet
->NetNr
;
2486 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2487 if (dev
->flags
& IFF_PROMISC
) {
2488 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2489 ("PROMISCUOUS mode\n"));
2490 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2492 } else if (dev
->flags
& IFF_ALLMULTI
) {
2493 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2494 ("ALLMULTI mode\n"));
2495 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2496 SK_PROM_MODE_ALL_MC
);
2498 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2500 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
2502 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2503 ("Number of MC entries: %d ", dev
->mc_count
));
2505 pMcList
= dev
->mc_list
;
2506 for (i
=0; i
<dev
->mc_count
; i
++, pMcList
= pMcList
->next
) {
2507 SkAddrMcAdd(pAC
, pAC
->IoBase
, PortIdx
,
2508 (SK_MAC_ADDR
*)pMcList
->dmi_addr
, 0);
2509 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_MCA
,
2510 ("%02x:%02x:%02x:%02x:%02x:%02x\n",
2511 pMcList
->dmi_addr
[0],
2512 pMcList
->dmi_addr
[1],
2513 pMcList
->dmi_addr
[2],
2514 pMcList
->dmi_addr
[3],
2515 pMcList
->dmi_addr
[4],
2516 pMcList
->dmi_addr
[5]));
2518 SkAddrMcUpdate(pAC
, pAC
->IoBase
, PortIdx
);
2520 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2523 } /* SkGeSetRxMode */
2526 /*****************************************************************************
2528 * SkGeChangeMtu - set the MTU to another value
2531 * This function sets is called whenever the MTU size is changed
2532 * (ifconfig mtu xxx dev ethX). If the MTU is bigger than standard
2533 * ethernet MTU size, long frame support is activated.
2536 * 0, if everything is ok
2539 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int NewMtu
)
2542 struct net_device
*pOtherDev
;
2544 unsigned long Flags
;
2548 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2549 ("SkGeChangeMtu starts now...\n"));
2551 pNet
= netdev_priv(dev
);
2554 if ((NewMtu
< 68) || (NewMtu
> SK_JUMBO_MTU
)) {
2558 if(pAC
->BoardLevel
!= SK_INIT_RUN
) {
2562 #ifdef SK_DIAG_SUPPORT
2563 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
2564 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
2565 return -1; /* still in use, deny any actions of MTU */
2567 pAC
->DiagFlowCtrl
= SK_FALSE
;
2572 pOtherDev
= pAC
->dev
[1 - pNet
->NetNr
];
2574 if ( netif_running(pOtherDev
) && (pOtherDev
->mtu
> 1500)
2575 && (NewMtu
<= 1500))
2578 pAC
->RxBufSize
= NewMtu
+ 32;
2581 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2582 ("New MTU: %d\n", NewMtu
));
2585 ** Prevent any reconfiguration while changing the MTU
2586 ** by disabling any interrupts
2588 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
2589 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2592 ** Notify RLMT that any ports are to be stopped
2594 EvPara
.Para32
[0] = 0;
2595 EvPara
.Para32
[1] = -1;
2596 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2597 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2598 EvPara
.Para32
[0] = 1;
2599 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2601 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2605 ** After calling the SkEventDispatcher(), RLMT is aware about
2606 ** the stopped ports -> configuration can take place!
2608 SkEventDispatcher(pAC
, pAC
->IoBase
);
2610 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2611 spin_lock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2612 netif_stop_queue(pAC
->dev
[i
]);
2617 ** Depending on the desired MTU size change, a different number of
2618 ** RX buffers need to be allocated
2620 if (NewMtu
> 1500) {
2622 ** Use less rx buffers
2624 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2625 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2626 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2627 (pAC
->RxDescrPerRing
/ 4);
2629 if (i
== pAC
->ActivePort
) {
2630 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2631 (pAC
->RxDescrPerRing
/ 4);
2633 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2634 (pAC
->RxDescrPerRing
/ 10);
2640 ** Use the normal amount of rx buffers
2642 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2643 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2644 pAC
->RxPort
[i
].RxFillLimit
= 1;
2646 if (i
== pAC
->ActivePort
) {
2647 pAC
->RxPort
[i
].RxFillLimit
= 1;
2649 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2650 (pAC
->RxDescrPerRing
/ 4);
2656 SkGeDeInit(pAC
, pAC
->IoBase
);
2659 ** enable/disable hardware support for long frames
2661 if (NewMtu
> 1500) {
2662 // pAC->JumboActivated = SK_TRUE; /* is never set back !!! */
2663 pAC
->GIni
.GIPortUsage
= SK_JUMBO_LINK
;
2665 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2666 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
2668 pAC
->GIni
.GIPortUsage
= SK_RED_LINK
;
2672 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2673 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2674 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2675 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2676 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2677 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2678 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2682 ** Speed and others are set back to default in level 1 init!
2684 GetConfiguration(pAC
);
2686 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2687 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2688 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2689 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2690 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2691 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2692 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2695 ** clear and reinit the rx rings here
2697 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2698 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
2699 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
2700 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2703 ** Enable transmit descriptor polling
2705 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
2706 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2709 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
2710 SkDimEnableModerationIfNeeded(pAC
);
2711 SkDimDisplayModerationSettings(pAC
);
2713 netif_start_queue(pAC
->dev
[pNet
->PortNr
]);
2714 for (i
=pAC
->GIni
.GIMacsFound
-1; i
>=0; i
--) {
2715 spin_unlock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2719 ** Enable Interrupts again
2721 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
2722 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
2724 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2725 SkEventDispatcher(pAC
, pAC
->IoBase
);
2728 ** Notify RLMT about the changing and restarting one (or more) ports
2730 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2731 EvPara
.Para32
[0] = pAC
->RlmtNets
;
2732 EvPara
.Para32
[1] = -1;
2733 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
, EvPara
);
2734 EvPara
.Para32
[0] = pNet
->PortNr
;
2735 EvPara
.Para32
[1] = -1;
2736 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2738 if (netif_running(pOtherDev
)) {
2739 DEV_NET
*pOtherNet
= netdev_priv(pOtherDev
);
2740 EvPara
.Para32
[0] = pOtherNet
->PortNr
;
2741 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2744 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2747 SkEventDispatcher(pAC
, pAC
->IoBase
);
2748 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2751 ** While testing this driver with latest kernel 2.5 (2.5.70), it
2752 ** seems as if upper layers have a problem to handle a successful
2753 ** return value of '0'. If such a zero is returned, the complete
2754 ** system hangs for several minutes (!), which is in acceptable.
2756 ** Currently it is not clear, what the exact reason for this problem
2757 ** is. The implemented workaround for 2.5 is to return the desired
2758 ** new MTU size if all needed changes for the new MTU size where
2759 ** performed. In kernels 2.2 and 2.4, a zero value is returned,
2760 ** which indicates the successful change of the mtu-size.
2764 } /* SkGeChangeMtu */
2767 /*****************************************************************************
2769 * SkGeStats - return ethernet device statistics
2772 * This function return statistic data about the ethernet device
2773 * to the operating system.
2776 * pointer to the statistic structure.
2778 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
)
2780 DEV_NET
*pNet
= netdev_priv(dev
);
2781 SK_AC
*pAC
= pNet
->pAC
;
2782 SK_PNMI_STRUCT_DATA
*pPnmiStruct
; /* structure for all Pnmi-Data */
2783 SK_PNMI_STAT
*pPnmiStat
; /* pointer to virtual XMAC stat. data */
2784 SK_PNMI_CONF
*pPnmiConf
; /* pointer to virtual link config. */
2785 unsigned int Size
; /* size of pnmi struct */
2786 unsigned long Flags
; /* for spin lock */
2788 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2789 ("SkGeStats starts now...\n"));
2790 pPnmiStruct
= &pAC
->PnmiStruct
;
2792 #ifdef SK_DIAG_SUPPORT
2793 if ((pAC
->DiagModeActive
== DIAG_NOTACTIVE
) &&
2794 (pAC
->BoardLevel
== SK_INIT_RUN
)) {
2796 SK_MEMSET(pPnmiStruct
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
2797 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2798 Size
= SK_PNMI_STRUCT_SIZE
;
2799 SkPnmiGetStruct(pAC
, pAC
->IoBase
, pPnmiStruct
, &Size
, pNet
->NetNr
);
2800 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2801 #ifdef SK_DIAG_SUPPORT
2805 pPnmiStat
= &pPnmiStruct
->Stat
[0];
2806 pPnmiConf
= &pPnmiStruct
->Conf
[0];
2808 pAC
->stats
.rx_packets
= (SK_U32
) pPnmiStruct
->RxDeliveredCts
& 0xFFFFFFFF;
2809 pAC
->stats
.tx_packets
= (SK_U32
) pPnmiStat
->StatTxOkCts
& 0xFFFFFFFF;
2810 pAC
->stats
.rx_bytes
= (SK_U32
) pPnmiStruct
->RxOctetsDeliveredCts
;
2811 pAC
->stats
.tx_bytes
= (SK_U32
) pPnmiStat
->StatTxOctetsOkCts
;
2813 if (dev
->mtu
<= 1500) {
2814 pAC
->stats
.rx_errors
= (SK_U32
) pPnmiStruct
->InErrorsCts
& 0xFFFFFFFF;
2816 pAC
->stats
.rx_errors
= (SK_U32
) ((pPnmiStruct
->InErrorsCts
-
2817 pPnmiStat
->StatRxTooLongCts
) & 0xFFFFFFFF);
2821 if (pAC
->GIni
.GP
[0].PhyType
== SK_PHY_XMAC
&& pAC
->HWRevision
< 12)
2822 pAC
->stats
.rx_errors
= pAC
->stats
.rx_errors
- pPnmiStat
->StatRxShortsCts
;
2824 pAC
->stats
.tx_errors
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2825 pAC
->stats
.rx_dropped
= (SK_U32
) pPnmiStruct
->RxNoBufCts
& 0xFFFFFFFF;
2826 pAC
->stats
.tx_dropped
= (SK_U32
) pPnmiStruct
->TxNoBufCts
& 0xFFFFFFFF;
2827 pAC
->stats
.multicast
= (SK_U32
) pPnmiStat
->StatRxMulticastOkCts
& 0xFFFFFFFF;
2828 pAC
->stats
.collisions
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2830 /* detailed rx_errors: */
2831 pAC
->stats
.rx_length_errors
= (SK_U32
) pPnmiStat
->StatRxRuntCts
& 0xFFFFFFFF;
2832 pAC
->stats
.rx_over_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2833 pAC
->stats
.rx_crc_errors
= (SK_U32
) pPnmiStat
->StatRxFcsCts
& 0xFFFFFFFF;
2834 pAC
->stats
.rx_frame_errors
= (SK_U32
) pPnmiStat
->StatRxFramingCts
& 0xFFFFFFFF;
2835 pAC
->stats
.rx_fifo_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2836 pAC
->stats
.rx_missed_errors
= (SK_U32
) pPnmiStat
->StatRxMissedCts
& 0xFFFFFFFF;
2838 /* detailed tx_errors */
2839 pAC
->stats
.tx_aborted_errors
= (SK_U32
) 0;
2840 pAC
->stats
.tx_carrier_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2841 pAC
->stats
.tx_fifo_errors
= (SK_U32
) pPnmiStat
->StatTxFifoUnderrunCts
& 0xFFFFFFFF;
2842 pAC
->stats
.tx_heartbeat_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2843 pAC
->stats
.tx_window_errors
= (SK_U32
) 0;
2845 return(&pAC
->stats
);
2849 * Basic MII register access
2851 static int SkGeMiiIoctl(struct net_device
*dev
,
2852 struct mii_ioctl_data
*data
, int cmd
)
2854 DEV_NET
*pNet
= netdev_priv(dev
);
2855 SK_AC
*pAC
= pNet
->pAC
;
2856 SK_IOC IoC
= pAC
->IoBase
;
2857 int Port
= pNet
->PortNr
;
2858 SK_GEPORT
*pPrt
= &pAC
->GIni
.GP
[Port
];
2859 unsigned long Flags
;
2861 int reg
= data
->reg_num
& 0x1f;
2862 SK_U16 val
= data
->val_in
;
2864 if (!netif_running(dev
))
2865 return -ENODEV
; /* Phy still in reset */
2867 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2870 data
->phy_id
= pPrt
->PhyAddr
;
2874 if (pAC
->GIni
.GIGenesis
)
2875 SkXmPhyRead(pAC
, IoC
, Port
, reg
, &val
);
2877 SkGmPhyRead(pAC
, IoC
, Port
, reg
, &val
);
2879 data
->val_out
= val
;
2883 if (!capable(CAP_NET_ADMIN
))
2886 else if (pAC
->GIni
.GIGenesis
)
2887 SkXmPhyWrite(pAC
, IoC
, Port
, reg
, val
);
2889 SkGmPhyWrite(pAC
, IoC
, Port
, reg
, val
);
2894 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2899 /*****************************************************************************
2901 * SkGeIoctl - IO-control function
2904 * This function is called if an ioctl is issued on the device.
2905 * There are three subfunction for reading, writing and test-writing
2906 * the private MIB data structure (useful for SysKonnect-internal tools).
2909 * 0, if everything is ok
2912 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
)
2917 struct pci_dev
*pdev
= NULL
;
2919 unsigned int Err
= 0;
2922 unsigned int Length
= 0;
2923 int HeaderLength
= sizeof(SK_U32
) + sizeof(SK_U32
);
2925 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2926 ("SkGeIoctl starts now...\n"));
2928 pNet
= netdev_priv(dev
);
2931 if (cmd
== SIOCGMIIPHY
|| cmd
== SIOCSMIIREG
|| cmd
== SIOCGMIIREG
)
2932 return SkGeMiiIoctl(dev
, if_mii(rq
), cmd
);
2934 if(copy_from_user(&Ioctl
, rq
->ifr_data
, sizeof(SK_GE_IOCTL
))) {
2939 case SK_IOCTL_SETMIB
:
2940 case SK_IOCTL_PRESETMIB
:
2941 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2942 case SK_IOCTL_GETMIB
:
2943 if(copy_from_user(&pAC
->PnmiStruct
, Ioctl
.pData
,
2944 Ioctl
.Len
<sizeof(pAC
->PnmiStruct
)?
2945 Ioctl
.Len
: sizeof(pAC
->PnmiStruct
))) {
2948 Size
= SkGeIocMib(pNet
, Ioctl
.Len
, cmd
);
2949 if(copy_to_user(Ioctl
.pData
, &pAC
->PnmiStruct
,
2950 Ioctl
.Len
<Size
? Ioctl
.Len
: Size
)) {
2954 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2959 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2962 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2964 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2967 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2971 if ((Ret
= SkPnmiGenIoctl(pAC
, pAC
->IoBase
, pMemBuf
, &Length
, 0)) < 0) {
2975 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2980 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2985 kfree(pMemBuf
); /* cleanup everything */
2987 #ifdef SK_DIAG_SUPPORT
2989 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2990 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2993 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2995 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2998 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
3003 Length
= 3 * sizeof(SK_U32
); /* Error, Bus and Device */
3005 ** While coding this new IOCTL interface, only a few lines of code
3006 ** are to to be added. Therefore no dedicated function has been
3007 ** added. If more functionality is added, a separate function
3008 ** should be used...
3010 * ((SK_U32
*)pMemBuf
) = 0;
3011 * ((SK_U32
*)pMemBuf
+ 1) = pdev
->bus
->number
;
3012 * ((SK_U32
*)pMemBuf
+ 2) = ParseDeviceNbrFromSlotName(pci_name(pdev
));
3013 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
3018 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
3023 kfree(pMemBuf
); /* cleanup everything */
3035 /*****************************************************************************
3037 * SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message
3040 * This function reads/writes the MIB data using PNMI (Private Network
3041 * Management Interface).
3042 * The destination for the data must be provided with the
3043 * ioctl call and is given to the driver in the form of
3044 * a user space address.
3045 * Copying from the user-provided data area into kernel messages
3046 * and back is done by copy_from_user and copy_to_user calls in
3050 * returned size from PNMI call
3052 static int SkGeIocMib(
3053 DEV_NET
*pNet
, /* pointer to the adapter context */
3054 unsigned int Size
, /* length of ioctl data */
3055 int mode
) /* flag for set/preset */
3057 unsigned long Flags
; /* for spin lock */
3060 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3061 ("SkGeIocMib starts now...\n"));
3064 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3066 case SK_IOCTL_GETMIB
:
3067 SkPnmiGetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3070 case SK_IOCTL_PRESETMIB
:
3071 SkPnmiPreSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3074 case SK_IOCTL_SETMIB
:
3075 SkPnmiSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3081 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3082 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3083 ("MIB data access succeeded\n"));
3088 /*****************************************************************************
3090 * GetConfiguration - read configuration information
3093 * This function reads per-adapter configuration information from
3094 * the options provided on the command line.
3099 static void GetConfiguration(
3100 SK_AC
*pAC
) /* pointer to the adapter context structure */
3102 SK_I32 Port
; /* preferred port */
3105 int LinkSpeed
= SK_LSPEED_AUTO
; /* Link speed */
3106 int AutoNeg
= 1; /* autoneg off (0) or on (1) */
3107 int DuplexCap
= 0; /* 0=both,1=full,2=half */
3108 int FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
; /* FlowControl */
3109 int MSMode
= SK_MS_MODE_AUTO
; /* master/slave mode */
3111 SK_BOOL IsConTypeDefined
= SK_TRUE
;
3112 SK_BOOL IsLinkSpeedDefined
= SK_TRUE
;
3113 SK_BOOL IsFlowCtrlDefined
= SK_TRUE
;
3114 SK_BOOL IsRoleDefined
= SK_TRUE
;
3115 SK_BOOL IsModeDefined
= SK_TRUE
;
3117 * The two parameters AutoNeg. and DuplexCap. map to one configuration
3118 * parameter. The mapping is described by this table:
3119 * DuplexCap -> | both | full | half |
3121 * -----------------------------------------------------------------
3122 * Off | illegal | Full | Half |
3123 * -----------------------------------------------------------------
3124 * On | AutoBoth | AutoFull | AutoHalf |
3125 * -----------------------------------------------------------------
3126 * Sense | AutoSense | AutoSense | AutoSense |
3128 int Capabilities
[3][3] =
3129 { { -1, SK_LMODE_FULL
, SK_LMODE_HALF
},
3130 {SK_LMODE_AUTOBOTH
, SK_LMODE_AUTOFULL
, SK_LMODE_AUTOHALF
},
3131 {SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
} };
3139 #define M_CurrPort pAC->GIni.GP[Port]
3143 ** Set the default values first for both ports!
3145 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3146 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3147 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3148 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3149 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3153 ** Check merged parameter ConType. If it has not been used,
3154 ** verify any other parameter (e.g. AutoNeg) and use default values.
3156 ** Stating both ConType and other lowlevel link parameters is also
3157 ** possible. If this is the case, the passed ConType-parameter is
3158 ** overwritten by the lowlevel link parameter.
3160 ** The following settings are used for a merged ConType-parameter:
3162 ** ConType DupCap AutoNeg FlowCtrl Role Speed
3163 ** ------- ------ ------- -------- ---------- -----
3164 ** Auto Both On SymOrRem Auto Auto
3165 ** 100FD Full Off None <ignored> 100
3166 ** 100HD Half Off None <ignored> 100
3167 ** 10FD Full Off None <ignored> 10
3168 ** 10HD Half Off None <ignored> 10
3170 ** This ConType parameter is used for all ports of the adapter!
3172 if ( (ConType
!= NULL
) &&
3173 (pAC
->Index
< SK_MAX_CARD_PARAM
) &&
3174 (ConType
[pAC
->Index
] != NULL
) ) {
3176 /* Check chipset family */
3177 if ((!pAC
->ChipsetType
) &&
3178 (strcmp(ConType
[pAC
->Index
],"Auto")!=0) &&
3179 (strcmp(ConType
[pAC
->Index
],"")!=0)) {
3180 /* Set the speed parameter back */
3181 printk("sk98lin: Illegal value \"%s\" "
3184 ConType
[pAC
->Index
]);
3186 sprintf(ConType
[pAC
->Index
], "Auto");
3189 if (strcmp(ConType
[pAC
->Index
],"")==0) {
3190 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3191 } else if (strcmp(ConType
[pAC
->Index
],"Auto")==0) {
3192 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3193 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3194 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3195 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3196 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3198 } else if (strcmp(ConType
[pAC
->Index
],"100FD")==0) {
3199 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3200 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3201 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3202 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3203 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3205 } else if (strcmp(ConType
[pAC
->Index
],"100HD")==0) {
3206 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3207 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3208 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3209 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3210 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3212 } else if (strcmp(ConType
[pAC
->Index
],"10FD")==0) {
3213 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3214 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3215 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3216 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3217 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3219 } else if (strcmp(ConType
[pAC
->Index
],"10HD")==0) {
3220 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3221 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3222 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3223 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3224 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3227 printk("sk98lin: Illegal value \"%s\" for ConType\n",
3228 ConType
[pAC
->Index
]);
3229 IsConTypeDefined
= SK_FALSE
; /* Wrong ConType defined */
3232 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3236 ** Parse any parameter settings for port A:
3237 ** a) any LinkSpeed stated?
3239 if (Speed_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3240 Speed_A
[pAC
->Index
] != NULL
) {
3241 if (strcmp(Speed_A
[pAC
->Index
],"")==0) {
3242 IsLinkSpeedDefined
= SK_FALSE
;
3243 } else if (strcmp(Speed_A
[pAC
->Index
],"Auto")==0) {
3244 LinkSpeed
= SK_LSPEED_AUTO
;
3245 } else if (strcmp(Speed_A
[pAC
->Index
],"10")==0) {
3246 LinkSpeed
= SK_LSPEED_10MBPS
;
3247 } else if (strcmp(Speed_A
[pAC
->Index
],"100")==0) {
3248 LinkSpeed
= SK_LSPEED_100MBPS
;
3249 } else if (strcmp(Speed_A
[pAC
->Index
],"1000")==0) {
3250 LinkSpeed
= SK_LSPEED_1000MBPS
;
3252 printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
3253 Speed_A
[pAC
->Index
]);
3254 IsLinkSpeedDefined
= SK_FALSE
;
3257 IsLinkSpeedDefined
= SK_FALSE
;
3261 ** Check speed parameter:
3262 ** Only copper type adapter and GE V2 cards
3264 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3265 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3266 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3267 printk("sk98lin: Illegal value for Speed_A. "
3268 "Not a copper card or GE V2 card\n Using "
3270 LinkSpeed
= SK_LSPEED_1000MBPS
;
3274 ** Decide whether to set new config value if somethig valid has
3277 if (IsLinkSpeedDefined
) {
3278 pAC
->GIni
.GP
[0].PLinkSpeed
= LinkSpeed
;
3282 ** b) Any Autonegotiation and DuplexCapabilities set?
3283 ** Please note that both belong together...
3285 AutoNeg
= AN_ON
; /* tschilling: Default: Autonegotiation on! */
3287 if (AutoNeg_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3288 AutoNeg_A
[pAC
->Index
] != NULL
) {
3290 if (strcmp(AutoNeg_A
[pAC
->Index
],"")==0) {
3292 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"On")==0) {
3294 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Off")==0) {
3296 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Sense")==0) {
3299 printk("sk98lin: Illegal value \"%s\" for AutoNeg_A\n",
3300 AutoNeg_A
[pAC
->Index
]);
3304 DuplexCap
= DC_BOTH
;
3306 if (DupCap_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3307 DupCap_A
[pAC
->Index
] != NULL
) {
3309 if (strcmp(DupCap_A
[pAC
->Index
],"")==0) {
3311 } else if (strcmp(DupCap_A
[pAC
->Index
],"Both")==0) {
3312 DuplexCap
= DC_BOTH
;
3313 } else if (strcmp(DupCap_A
[pAC
->Index
],"Full")==0) {
3314 DuplexCap
= DC_FULL
;
3315 } else if (strcmp(DupCap_A
[pAC
->Index
],"Half")==0) {
3316 DuplexCap
= DC_HALF
;
3318 printk("sk98lin: Illegal value \"%s\" for DupCap_A\n",
3319 DupCap_A
[pAC
->Index
]);
3324 ** Check for illegal combinations
3326 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3327 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3328 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3329 (pAC
->ChipsetType
)) {
3330 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3331 " Using Full Duplex.\n");
3332 DuplexCap
= DC_FULL
;
3335 if ( AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3336 printk("sk98lin, Port A: DuplexCapabilities"
3337 " ignored using Sense mode\n");
3340 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3341 printk("sk98lin: Port A: Illegal combination"
3342 " of values AutoNeg. and DuplexCap.\n Using "
3344 DuplexCap
= DC_FULL
;
3347 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3348 DuplexCap
= DC_FULL
;
3351 if (!AutoSet
&& DupSet
) {
3352 printk("sk98lin: Port A: Duplex setting not"
3353 " possible in\n default AutoNegotiation mode"
3354 " (Sense).\n Using AutoNegotiation On\n");
3359 ** set the desired mode
3361 if (AutoSet
|| DupSet
) {
3362 pAC
->GIni
.GP
[0].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3366 ** c) Any Flowcontrol-parameter set?
3368 if (FlowCtrl_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3369 FlowCtrl_A
[pAC
->Index
] != NULL
) {
3370 if (strcmp(FlowCtrl_A
[pAC
->Index
],"") == 0) {
3371 IsFlowCtrlDefined
= SK_FALSE
;
3372 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"SymOrRem") == 0) {
3373 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3374 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"Sym")==0) {
3375 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3376 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"LocSend")==0) {
3377 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3378 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"None")==0) {
3379 FlowCtrl
= SK_FLOW_MODE_NONE
;
3381 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
3382 FlowCtrl_A
[pAC
->Index
]);
3383 IsFlowCtrlDefined
= SK_FALSE
;
3386 IsFlowCtrlDefined
= SK_FALSE
;
3389 if (IsFlowCtrlDefined
) {
3390 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3391 printk("sk98lin: Port A: FlowControl"
3392 " impossible without AutoNegotiation,"
3394 FlowCtrl
= SK_FLOW_MODE_NONE
;
3396 pAC
->GIni
.GP
[0].PFlowCtrlMode
= FlowCtrl
;
3400 ** d) What is with the RoleParameter?
3402 if (Role_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3403 Role_A
[pAC
->Index
] != NULL
) {
3404 if (strcmp(Role_A
[pAC
->Index
],"")==0) {
3405 IsRoleDefined
= SK_FALSE
;
3406 } else if (strcmp(Role_A
[pAC
->Index
],"Auto")==0) {
3407 MSMode
= SK_MS_MODE_AUTO
;
3408 } else if (strcmp(Role_A
[pAC
->Index
],"Master")==0) {
3409 MSMode
= SK_MS_MODE_MASTER
;
3410 } else if (strcmp(Role_A
[pAC
->Index
],"Slave")==0) {
3411 MSMode
= SK_MS_MODE_SLAVE
;
3413 printk("sk98lin: Illegal value \"%s\" for Role_A\n",
3414 Role_A
[pAC
->Index
]);
3415 IsRoleDefined
= SK_FALSE
;
3418 IsRoleDefined
= SK_FALSE
;
3421 if (IsRoleDefined
== SK_TRUE
) {
3422 pAC
->GIni
.GP
[0].PMSMode
= MSMode
;
3428 ** Parse any parameter settings for port B:
3429 ** a) any LinkSpeed stated?
3431 IsConTypeDefined
= SK_TRUE
;
3432 IsLinkSpeedDefined
= SK_TRUE
;
3433 IsFlowCtrlDefined
= SK_TRUE
;
3434 IsModeDefined
= SK_TRUE
;
3436 if (Speed_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3437 Speed_B
[pAC
->Index
] != NULL
) {
3438 if (strcmp(Speed_B
[pAC
->Index
],"")==0) {
3439 IsLinkSpeedDefined
= SK_FALSE
;
3440 } else if (strcmp(Speed_B
[pAC
->Index
],"Auto")==0) {
3441 LinkSpeed
= SK_LSPEED_AUTO
;
3442 } else if (strcmp(Speed_B
[pAC
->Index
],"10")==0) {
3443 LinkSpeed
= SK_LSPEED_10MBPS
;
3444 } else if (strcmp(Speed_B
[pAC
->Index
],"100")==0) {
3445 LinkSpeed
= SK_LSPEED_100MBPS
;
3446 } else if (strcmp(Speed_B
[pAC
->Index
],"1000")==0) {
3447 LinkSpeed
= SK_LSPEED_1000MBPS
;
3449 printk("sk98lin: Illegal value \"%s\" for Speed_B\n",
3450 Speed_B
[pAC
->Index
]);
3451 IsLinkSpeedDefined
= SK_FALSE
;
3454 IsLinkSpeedDefined
= SK_FALSE
;
3458 ** Check speed parameter:
3459 ** Only copper type adapter and GE V2 cards
3461 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3462 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3463 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3464 printk("sk98lin: Illegal value for Speed_B. "
3465 "Not a copper card or GE V2 card\n Using "
3467 LinkSpeed
= SK_LSPEED_1000MBPS
;
3471 ** Decide whether to set new config value if somethig valid has
3474 if (IsLinkSpeedDefined
) {
3475 pAC
->GIni
.GP
[1].PLinkSpeed
= LinkSpeed
;
3479 ** b) Any Autonegotiation and DuplexCapabilities set?
3480 ** Please note that both belong together...
3482 AutoNeg
= AN_SENS
; /* default: do auto Sense */
3484 if (AutoNeg_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3485 AutoNeg_B
[pAC
->Index
] != NULL
) {
3487 if (strcmp(AutoNeg_B
[pAC
->Index
],"")==0) {
3489 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"On")==0) {
3491 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Off")==0) {
3493 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Sense")==0) {
3496 printk("sk98lin: Illegal value \"%s\" for AutoNeg_B\n",
3497 AutoNeg_B
[pAC
->Index
]);
3501 DuplexCap
= DC_BOTH
;
3503 if (DupCap_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3504 DupCap_B
[pAC
->Index
] != NULL
) {
3506 if (strcmp(DupCap_B
[pAC
->Index
],"")==0) {
3508 } else if (strcmp(DupCap_B
[pAC
->Index
],"Both")==0) {
3509 DuplexCap
= DC_BOTH
;
3510 } else if (strcmp(DupCap_B
[pAC
->Index
],"Full")==0) {
3511 DuplexCap
= DC_FULL
;
3512 } else if (strcmp(DupCap_B
[pAC
->Index
],"Half")==0) {
3513 DuplexCap
= DC_HALF
;
3515 printk("sk98lin: Illegal value \"%s\" for DupCap_B\n",
3516 DupCap_B
[pAC
->Index
]);
3522 ** Check for illegal combinations
3524 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3525 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3526 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3527 (pAC
->ChipsetType
)) {
3528 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3529 " Using Full Duplex.\n");
3530 DuplexCap
= DC_FULL
;
3533 if (AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3534 printk("sk98lin, Port B: DuplexCapabilities"
3535 " ignored using Sense mode\n");
3538 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3539 printk("sk98lin: Port B: Illegal combination"
3540 " of values AutoNeg. and DuplexCap.\n Using "
3542 DuplexCap
= DC_FULL
;
3545 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3546 DuplexCap
= DC_FULL
;
3549 if (!AutoSet
&& DupSet
) {
3550 printk("sk98lin: Port B: Duplex setting not"
3551 " possible in\n default AutoNegotiation mode"
3552 " (Sense).\n Using AutoNegotiation On\n");
3557 ** set the desired mode
3559 if (AutoSet
|| DupSet
) {
3560 pAC
->GIni
.GP
[1].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3564 ** c) Any FlowCtrl parameter set?
3566 if (FlowCtrl_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3567 FlowCtrl_B
[pAC
->Index
] != NULL
) {
3568 if (strcmp(FlowCtrl_B
[pAC
->Index
],"") == 0) {
3569 IsFlowCtrlDefined
= SK_FALSE
;
3570 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"SymOrRem") == 0) {
3571 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3572 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"Sym")==0) {
3573 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3574 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"LocSend")==0) {
3575 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3576 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"None")==0) {
3577 FlowCtrl
= SK_FLOW_MODE_NONE
;
3579 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_B\n",
3580 FlowCtrl_B
[pAC
->Index
]);
3581 IsFlowCtrlDefined
= SK_FALSE
;
3584 IsFlowCtrlDefined
= SK_FALSE
;
3587 if (IsFlowCtrlDefined
) {
3588 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3589 printk("sk98lin: Port B: FlowControl"
3590 " impossible without AutoNegotiation,"
3592 FlowCtrl
= SK_FLOW_MODE_NONE
;
3594 pAC
->GIni
.GP
[1].PFlowCtrlMode
= FlowCtrl
;
3598 ** d) What is the RoleParameter?
3600 if (Role_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3601 Role_B
[pAC
->Index
] != NULL
) {
3602 if (strcmp(Role_B
[pAC
->Index
],"")==0) {
3603 IsRoleDefined
= SK_FALSE
;
3604 } else if (strcmp(Role_B
[pAC
->Index
],"Auto")==0) {
3605 MSMode
= SK_MS_MODE_AUTO
;
3606 } else if (strcmp(Role_B
[pAC
->Index
],"Master")==0) {
3607 MSMode
= SK_MS_MODE_MASTER
;
3608 } else if (strcmp(Role_B
[pAC
->Index
],"Slave")==0) {
3609 MSMode
= SK_MS_MODE_SLAVE
;
3611 printk("sk98lin: Illegal value \"%s\" for Role_B\n",
3612 Role_B
[pAC
->Index
]);
3613 IsRoleDefined
= SK_FALSE
;
3616 IsRoleDefined
= SK_FALSE
;
3619 if (IsRoleDefined
) {
3620 pAC
->GIni
.GP
[1].PMSMode
= MSMode
;
3624 ** Evaluate settings for both ports
3626 pAC
->ActivePort
= 0;
3627 if (PrefPort
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3628 PrefPort
[pAC
->Index
] != NULL
) {
3629 if (strcmp(PrefPort
[pAC
->Index
],"") == 0) { /* Auto */
3630 pAC
->ActivePort
= 0;
3631 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3632 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3633 } else if (strcmp(PrefPort
[pAC
->Index
],"A") == 0) {
3635 ** do not set ActivePort here, thus a port
3636 ** switch is issued after net up.
3639 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3640 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3641 } else if (strcmp(PrefPort
[pAC
->Index
],"B") == 0) {
3643 ** do not set ActivePort here, thus a port
3644 ** switch is issued after net up.
3646 if (pAC
->GIni
.GIMacsFound
== 1) {
3647 printk("sk98lin: Illegal value \"B\" for PrefPort.\n"
3648 " Port B not available on single port adapters.\n");
3650 pAC
->ActivePort
= 0;
3651 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3652 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3655 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3656 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3659 printk("sk98lin: Illegal value \"%s\" for PrefPort\n",
3660 PrefPort
[pAC
->Index
]);
3666 if (RlmtMode
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3667 RlmtMode
[pAC
->Index
] != NULL
) {
3668 if (strcmp(RlmtMode
[pAC
->Index
], "") == 0) {
3670 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLinkState") == 0) {
3671 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3672 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLocalPort") == 0) {
3673 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3674 SK_RLMT_CHECK_LOC_LINK
;
3675 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckSeg") == 0) {
3676 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3677 SK_RLMT_CHECK_LOC_LINK
|
3679 } else if ((strcmp(RlmtMode
[pAC
->Index
], "DualNet") == 0) &&
3680 (pAC
->GIni
.GIMacsFound
== 2)) {
3681 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3684 printk("sk98lin: Illegal value \"%s\" for"
3685 " RlmtMode, using default\n",
3686 RlmtMode
[pAC
->Index
]);
3694 ** Check the interrupt moderation parameters
3696 if (Moderation
[pAC
->Index
] != NULL
) {
3697 if (strcmp(Moderation
[pAC
->Index
], "") == 0) {
3698 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3699 } else if (strcmp(Moderation
[pAC
->Index
], "Static") == 0) {
3700 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_STATIC
;
3701 } else if (strcmp(Moderation
[pAC
->Index
], "Dynamic") == 0) {
3702 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_DYNAMIC
;
3703 } else if (strcmp(Moderation
[pAC
->Index
], "None") == 0) {
3704 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3706 printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
3707 " Disable interrupt moderation.\n",
3708 Moderation
[pAC
->Index
]);
3709 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3712 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3715 if (Stats
[pAC
->Index
] != NULL
) {
3716 if (strcmp(Stats
[pAC
->Index
], "Yes") == 0) {
3717 pAC
->DynIrqModInfo
.DisplayStats
= SK_TRUE
;
3719 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3722 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3725 if (ModerationMask
[pAC
->Index
] != NULL
) {
3726 if (strcmp(ModerationMask
[pAC
->Index
], "Rx") == 0) {
3727 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3728 } else if (strcmp(ModerationMask
[pAC
->Index
], "Tx") == 0) {
3729 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_ONLY
;
3730 } else if (strcmp(ModerationMask
[pAC
->Index
], "Sp") == 0) {
3731 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_ONLY
;
3732 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSp") == 0) {
3733 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3734 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRx") == 0) {
3735 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3736 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTx") == 0) {
3737 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3738 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRx") == 0) {
3739 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3740 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSp") == 0) {
3741 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3742 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTx") == 0) {
3743 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3744 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTxSp") == 0) {
3745 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3746 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSpTx") == 0) {
3747 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3748 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRxSp") == 0) {
3749 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3750 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSpRx") == 0) {
3751 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3752 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTxRx") == 0) {
3753 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3754 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRxTx") == 0) {
3755 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3756 } else { /* some rubbish */
3757 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3759 } else { /* operator has stated nothing */
3760 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3763 if (AutoSizing
[pAC
->Index
] != NULL
) {
3764 if (strcmp(AutoSizing
[pAC
->Index
], "On") == 0) {
3765 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3767 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3769 } else { /* operator has stated nothing */
3770 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3773 if (IntsPerSec
[pAC
->Index
] != 0) {
3774 if ((IntsPerSec
[pAC
->Index
]< C_INT_MOD_IPS_LOWER_RANGE
) ||
3775 (IntsPerSec
[pAC
->Index
] > C_INT_MOD_IPS_UPPER_RANGE
)) {
3776 printk("sk98lin: Illegal value \"%d\" for IntsPerSec. (Range: %d - %d)\n"
3777 " Using default value of %i.\n",
3778 IntsPerSec
[pAC
->Index
],
3779 C_INT_MOD_IPS_LOWER_RANGE
,
3780 C_INT_MOD_IPS_UPPER_RANGE
,
3781 C_INTS_PER_SEC_DEFAULT
);
3782 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3784 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= IntsPerSec
[pAC
->Index
];
3787 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3791 ** Evaluate upper and lower moderation threshold
3793 pAC
->DynIrqModInfo
.MaxModIntsPerSecUpperLimit
=
3794 pAC
->DynIrqModInfo
.MaxModIntsPerSec
+
3795 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3797 pAC
->DynIrqModInfo
.MaxModIntsPerSecLowerLimit
=
3798 pAC
->DynIrqModInfo
.MaxModIntsPerSec
-
3799 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3801 pAC
->DynIrqModInfo
.PrevTimeVal
= jiffies
; /* initial value */
3804 } /* GetConfiguration */
3807 /*****************************************************************************
3809 * ProductStr - return a adapter identification string from vpd
3812 * This function reads the product name string from the vpd area
3813 * and puts it the field pAC->DeviceString.
3817 static inline int ProductStr(
3818 SK_AC
*pAC
, /* pointer to adapter context */
3819 char *DeviceStr
, /* result string */
3820 int StrLen
/* length of the string */
3823 char Keyword
[] = VPD_NAME
; /* vpd productname identifier */
3824 int ReturnCode
; /* return code from vpd_read */
3825 unsigned long Flags
;
3827 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3828 ReturnCode
= VpdRead(pAC
, pAC
->IoBase
, Keyword
, DeviceStr
, &StrLen
);
3829 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3834 /*****************************************************************************
3836 * StartDrvCleanupTimer - Start timer to check for descriptors which
3837 * might be placed in descriptor ring, but
3838 * havent been handled up to now
3841 * This function requests a HW-timer fo the Yukon card. The actions to
3842 * perform when this timer expires, are located in the SkDrvEvent().
3847 StartDrvCleanupTimer(SK_AC
*pAC
) {
3848 SK_EVPARA EventParam
; /* Event struct for timer event */
3850 SK_MEMSET((char *) &EventParam
, 0, sizeof(EventParam
));
3851 EventParam
.Para32
[0] = SK_DRV_RX_CLEANUP_TIMER
;
3852 SkTimerStart(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
,
3853 SK_DRV_RX_CLEANUP_TIMER_LENGTH
,
3854 SKGE_DRV
, SK_DRV_TIMER
, EventParam
);
3857 /*****************************************************************************
3859 * StopDrvCleanupTimer - Stop timer to check for descriptors
3862 * This function requests a HW-timer fo the Yukon card. The actions to
3863 * perform when this timer expires, are located in the SkDrvEvent().
3868 StopDrvCleanupTimer(SK_AC
*pAC
) {
3869 SkTimerStop(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
);
3870 SK_MEMSET((char *) &pAC
->DrvCleanupTimer
, 0, sizeof(SK_TIMER
));
3873 /****************************************************************************/
3874 /* functions for common modules *********************************************/
3875 /****************************************************************************/
3878 /*****************************************************************************
3880 * SkDrvAllocRlmtMbuf - allocate an RLMT mbuf
3883 * This routine returns an RLMT mbuf or NULL. The RLMT Mbuf structure
3884 * is embedded into a socket buff data area.
3890 * NULL or pointer to Mbuf.
3892 SK_MBUF
*SkDrvAllocRlmtMbuf(
3893 SK_AC
*pAC
, /* pointer to adapter context */
3894 SK_IOC IoC
, /* the IO-context */
3895 unsigned BufferSize
) /* size of the requested buffer */
3897 SK_MBUF
*pRlmtMbuf
; /* pointer to a new rlmt-mbuf structure */
3898 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
3900 pMsgBlock
= alloc_skb(BufferSize
+ sizeof(SK_MBUF
), GFP_ATOMIC
);
3901 if (pMsgBlock
== NULL
) {
3904 pRlmtMbuf
= (SK_MBUF
*) pMsgBlock
->data
;
3905 skb_reserve(pMsgBlock
, sizeof(SK_MBUF
));
3906 pRlmtMbuf
->pNext
= NULL
;
3907 pRlmtMbuf
->pOs
= pMsgBlock
;
3908 pRlmtMbuf
->pData
= pMsgBlock
->data
; /* Data buffer. */
3909 pRlmtMbuf
->Size
= BufferSize
; /* Data buffer size. */
3910 pRlmtMbuf
->Length
= 0; /* Length of packet (<= Size). */
3913 } /* SkDrvAllocRlmtMbuf */
3916 /*****************************************************************************
3918 * SkDrvFreeRlmtMbuf - free an RLMT mbuf
3921 * This routine frees one or more RLMT mbuf(s).
3929 void SkDrvFreeRlmtMbuf(
3930 SK_AC
*pAC
, /* pointer to adapter context */
3931 SK_IOC IoC
, /* the IO-context */
3932 SK_MBUF
*pMbuf
) /* size of the requested buffer */
3939 pNextMbuf
= pFreeMbuf
->pNext
;
3940 DEV_KFREE_SKB_ANY(pFreeMbuf
->pOs
);
3941 pFreeMbuf
= pNextMbuf
;
3942 } while ( pFreeMbuf
!= NULL
);
3943 } /* SkDrvFreeRlmtMbuf */
3946 /*****************************************************************************
3948 * SkOsGetTime - provide a time value
3951 * This routine provides a time value. The unit is 1/HZ (defined by Linux).
3952 * It is not used for absolute time, but only for time differences.
3958 SK_U64
SkOsGetTime(SK_AC
*pAC
)
3960 SK_U64 PrivateJiffies
;
3961 SkOsGetTimeCurrent(pAC
, &PrivateJiffies
);
3962 return PrivateJiffies
;
3966 /*****************************************************************************
3968 * SkPciReadCfgDWord - read a 32 bit value from pci config space
3971 * This routine reads a 32 bit value from the pci configuration
3975 * 0 - indicate everything worked ok.
3976 * != 0 - error indication
3978 int SkPciReadCfgDWord(
3979 SK_AC
*pAC
, /* Adapter Control structure pointer */
3980 int PciAddr
, /* PCI register address */
3981 SK_U32
*pVal
) /* pointer to store the read value */
3983 pci_read_config_dword(pAC
->PciDev
, PciAddr
, pVal
);
3985 } /* SkPciReadCfgDWord */
3988 /*****************************************************************************
3990 * SkPciReadCfgWord - read a 16 bit value from pci config space
3993 * This routine reads a 16 bit value from the pci configuration
3997 * 0 - indicate everything worked ok.
3998 * != 0 - error indication
4000 int SkPciReadCfgWord(
4001 SK_AC
*pAC
, /* Adapter Control structure pointer */
4002 int PciAddr
, /* PCI register address */
4003 SK_U16
*pVal
) /* pointer to store the read value */
4005 pci_read_config_word(pAC
->PciDev
, PciAddr
, pVal
);
4007 } /* SkPciReadCfgWord */
4010 /*****************************************************************************
4012 * SkPciReadCfgByte - read a 8 bit value from pci config space
4015 * This routine reads a 8 bit value from the pci configuration
4019 * 0 - indicate everything worked ok.
4020 * != 0 - error indication
4022 int SkPciReadCfgByte(
4023 SK_AC
*pAC
, /* Adapter Control structure pointer */
4024 int PciAddr
, /* PCI register address */
4025 SK_U8
*pVal
) /* pointer to store the read value */
4027 pci_read_config_byte(pAC
->PciDev
, PciAddr
, pVal
);
4029 } /* SkPciReadCfgByte */
4032 /*****************************************************************************
4034 * SkPciWriteCfgWord - write a 16 bit value to pci config space
4037 * This routine writes a 16 bit value to the pci configuration
4038 * space. The flag PciConfigUp indicates whether the config space
4039 * is accesible or must be set up first.
4042 * 0 - indicate everything worked ok.
4043 * != 0 - error indication
4045 int SkPciWriteCfgWord(
4046 SK_AC
*pAC
, /* Adapter Control structure pointer */
4047 int PciAddr
, /* PCI register address */
4048 SK_U16 Val
) /* pointer to store the read value */
4050 pci_write_config_word(pAC
->PciDev
, PciAddr
, Val
);
4052 } /* SkPciWriteCfgWord */
4055 /*****************************************************************************
4057 * SkPciWriteCfgWord - write a 8 bit value to pci config space
4060 * This routine writes a 8 bit value to the pci configuration
4061 * space. The flag PciConfigUp indicates whether the config space
4062 * is accesible or must be set up first.
4065 * 0 - indicate everything worked ok.
4066 * != 0 - error indication
4068 int SkPciWriteCfgByte(
4069 SK_AC
*pAC
, /* Adapter Control structure pointer */
4070 int PciAddr
, /* PCI register address */
4071 SK_U8 Val
) /* pointer to store the read value */
4073 pci_write_config_byte(pAC
->PciDev
, PciAddr
, Val
);
4075 } /* SkPciWriteCfgByte */
4078 /*****************************************************************************
4080 * SkDrvEvent - handle driver events
4083 * This function handles events from all modules directed to the driver
4086 * Is called under protection of slow path lock.
4089 * 0 if everything ok
4094 SK_AC
*pAC
, /* pointer to adapter context */
4095 SK_IOC IoC
, /* io-context */
4096 SK_U32 Event
, /* event-id */
4097 SK_EVPARA Param
) /* event-parameter */
4099 SK_MBUF
*pRlmtMbuf
; /* pointer to a rlmt-mbuf structure */
4100 struct sk_buff
*pMsg
; /* pointer to a message block */
4101 int FromPort
; /* the port from which we switch away */
4102 int ToPort
; /* the port we switch to */
4103 SK_EVPARA NewPara
; /* parameter for further events */
4105 unsigned long Flags
;
4109 case SK_DRV_ADAP_FAIL
:
4110 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4111 ("ADAPTER FAIL EVENT\n"));
4112 printk("%s: Adapter failed.\n", pAC
->dev
[0]->name
);
4113 /* disable interrupts */
4114 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
4117 case SK_DRV_PORT_FAIL
:
4118 FromPort
= Param
.Para32
[0];
4119 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4120 ("PORT FAIL EVENT, Port: %d\n", FromPort
));
4121 if (FromPort
== 0) {
4122 printk("%s: Port A failed.\n", pAC
->dev
[0]->name
);
4124 printk("%s: Port B failed.\n", pAC
->dev
[1]->name
);
4128 case SK_DRV_PORT_RESET
: /* SK_U32 PortIdx */
4130 FromPort
= Param
.Para32
[0];
4131 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4132 ("PORT RESET EVENT, Port: %d ", FromPort
));
4133 NewPara
.Para64
= FromPort
;
4134 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4136 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4139 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_HARD_RST
);
4140 netif_carrier_off(pAC
->dev
[Param
.Para32
[0]]);
4141 spin_unlock_irqrestore(
4142 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4145 /* clear rx ring from received frames */
4146 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
);
4148 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4150 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4153 /* tschilling: Handling of return value inserted. */
4154 if (SkGeInitPort(pAC
, IoC
, FromPort
)) {
4155 if (FromPort
== 0) {
4156 printk("%s: SkGeInitPort A failed.\n", pAC
->dev
[0]->name
);
4158 printk("%s: SkGeInitPort B failed.\n", pAC
->dev
[1]->name
);
4161 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4162 PortReInitBmu(pAC
, FromPort
);
4163 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4164 ClearAndStartRx(pAC
, FromPort
);
4165 spin_unlock_irqrestore(
4166 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4169 case SK_DRV_NET_UP
: /* SK_U32 PortIdx */
4170 { struct net_device
*dev
= pAC
->dev
[Param
.Para32
[0]];
4172 FromPort
= Param
.Para32
[0];
4173 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4174 ("NET UP EVENT, Port: %d ", Param
.Para32
[0]));
4176 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4178 if (DoPrintInterfaceChange
) {
4179 printk("%s: network connection up using"
4180 " port %c\n", pAC
->dev
[Param
.Para32
[0]]->name
, 'A'+Param
.Para32
[0]);
4182 /* tschilling: Values changed according to LinkSpeedUsed. */
4183 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
;
4184 if (Stat
== SK_LSPEED_STAT_10MBPS
) {
4185 printk(" speed: 10\n");
4186 } else if (Stat
== SK_LSPEED_STAT_100MBPS
) {
4187 printk(" speed: 100\n");
4188 } else if (Stat
== SK_LSPEED_STAT_1000MBPS
) {
4189 printk(" speed: 1000\n");
4191 printk(" speed: unknown\n");
4195 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkModeStatus
;
4196 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4197 Stat
== SK_LMODE_STAT_AUTOFULL
) {
4198 printk(" autonegotiation: yes\n");
4201 printk(" autonegotiation: no\n");
4203 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4204 Stat
== SK_LMODE_STAT_HALF
) {
4205 printk(" duplex mode: half\n");
4208 printk(" duplex mode: full\n");
4210 Stat
= pAC
->GIni
.GP
[FromPort
].PFlowCtrlStatus
;
4211 if (Stat
== SK_FLOW_STAT_REM_SEND
) {
4212 printk(" flowctrl: remote send\n");
4214 else if (Stat
== SK_FLOW_STAT_LOC_SEND
){
4215 printk(" flowctrl: local send\n");
4217 else if (Stat
== SK_FLOW_STAT_SYMMETRIC
){
4218 printk(" flowctrl: symmetric\n");
4221 printk(" flowctrl: none\n");
4224 /* tschilling: Check against CopperType now. */
4225 if ((pAC
->GIni
.GICopperType
== SK_TRUE
) &&
4226 (pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
==
4227 SK_LSPEED_STAT_1000MBPS
)) {
4228 Stat
= pAC
->GIni
.GP
[FromPort
].PMSStatus
;
4229 if (Stat
== SK_MS_STAT_MASTER
) {
4230 printk(" role: master\n");
4232 else if (Stat
== SK_MS_STAT_SLAVE
) {
4233 printk(" role: slave\n");
4236 printk(" role: ???\n");
4241 Display dim (dynamic interrupt moderation)
4244 if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_STATIC
)
4245 printk(" irq moderation: static (%d ints/sec)\n",
4246 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4247 else if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_DYNAMIC
)
4248 printk(" irq moderation: dynamic (%d ints/sec)\n",
4249 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4251 printk(" irq moderation: disabled\n");
4254 printk(" scatter-gather: %s\n",
4255 (dev
->features
& NETIF_F_SG
) ? "enabled" : "disabled");
4256 printk(" tx-checksum: %s\n",
4257 (dev
->features
& NETIF_F_IP_CSUM
) ? "enabled" : "disabled");
4258 printk(" rx-checksum: %s\n",
4259 pAC
->RxPort
[Param
.Para32
[0]].RxCsum
? "enabled" : "disabled");
4262 DoPrintInterfaceChange
= SK_TRUE
;
4265 if ((Param
.Para32
[0] != pAC
->ActivePort
) &&
4266 (pAC
->RlmtNets
== 1)) {
4267 NewPara
.Para32
[0] = pAC
->ActivePort
;
4268 NewPara
.Para32
[1] = Param
.Para32
[0];
4269 SkEventQueue(pAC
, SKGE_DRV
, SK_DRV_SWITCH_INTERN
,
4273 /* Inform the world that link protocol is up. */
4274 netif_carrier_on(dev
);
4277 case SK_DRV_NET_DOWN
: /* SK_U32 Reason */
4279 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4280 ("NET DOWN EVENT "));
4281 if (DoPrintInterfaceChange
) {
4282 printk("%s: network connection down\n",
4283 pAC
->dev
[Param
.Para32
[1]]->name
);
4285 DoPrintInterfaceChange
= SK_TRUE
;
4287 netif_carrier_off(pAC
->dev
[Param
.Para32
[1]]);
4289 case SK_DRV_SWITCH_HARD
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4290 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4291 ("PORT SWITCH HARD "));
4292 case SK_DRV_SWITCH_SOFT
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4294 printk("%s: switching to port %c\n", pAC
->dev
[0]->name
,
4295 'A'+Param
.Para32
[1]);
4296 case SK_DRV_SWITCH_INTERN
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4297 FromPort
= Param
.Para32
[0];
4298 ToPort
= Param
.Para32
[1];
4299 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4300 ("PORT SWITCH EVENT, From: %d To: %d (Pref %d) ",
4301 FromPort
, ToPort
, pAC
->Rlmt
.Net
[0].PrefPort
));
4302 NewPara
.Para64
= FromPort
;
4303 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4304 NewPara
.Para64
= ToPort
;
4305 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4307 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4309 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4310 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4311 SkGeStopPort(pAC
, IoC
, ToPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4312 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4313 spin_unlock_irqrestore(
4314 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4317 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
); /* clears rx ring */
4318 ReceiveIrq(pAC
, &pAC
->RxPort
[ToPort
], SK_FALSE
); /* clears rx ring */
4320 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4321 ClearTxRing(pAC
, &pAC
->TxPort
[ToPort
][TX_PRIO_LOW
]);
4323 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4325 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4326 pAC
->ActivePort
= ToPort
;
4330 /* tschilling: New common function with minimum size check. */
4332 if (pAC
->RlmtNets
== 2) {
4336 if (SkGeInitAssignRamToQueues(
4340 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4341 spin_unlock_irqrestore(
4342 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4344 printk("SkGeInitAssignRamToQueues failed.\n");
4348 /* tschilling: Handling of return values inserted. */
4349 if (SkGeInitPort(pAC
, IoC
, FromPort
) ||
4350 SkGeInitPort(pAC
, IoC
, ToPort
)) {
4351 printk("%s: SkGeInitPort failed.\n", pAC
->dev
[0]->name
);
4353 if (Event
== SK_DRV_SWITCH_SOFT
) {
4354 SkMacRxTxEnable(pAC
, IoC
, FromPort
);
4356 SkMacRxTxEnable(pAC
, IoC
, ToPort
);
4357 SkAddrSwap(pAC
, IoC
, FromPort
, ToPort
);
4358 SkAddrMcUpdate(pAC
, IoC
, FromPort
);
4359 SkAddrMcUpdate(pAC
, IoC
, ToPort
);
4360 PortReInitBmu(pAC
, FromPort
);
4361 PortReInitBmu(pAC
, ToPort
);
4362 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4363 SkGePollTxD(pAC
, IoC
, ToPort
, SK_TRUE
);
4364 ClearAndStartRx(pAC
, FromPort
);
4365 ClearAndStartRx(pAC
, ToPort
);
4366 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4367 spin_unlock_irqrestore(
4368 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4371 case SK_DRV_RLMT_SEND
: /* SK_MBUF *pMb */
4372 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4374 pRlmtMbuf
= (SK_MBUF
*) Param
.pParaPtr
;
4375 pMsg
= (struct sk_buff
*) pRlmtMbuf
->pOs
;
4376 skb_put(pMsg
, pRlmtMbuf
->Length
);
4377 if (XmitFrame(pAC
, &pAC
->TxPort
[pRlmtMbuf
->PortIdx
][TX_PRIO_LOW
],
4380 DEV_KFREE_SKB_ANY(pMsg
);
4383 if (Param
.Para32
[0] == SK_DRV_MODERATION_TIMER
) {
4385 ** expiration of the moderation timer implies that
4386 ** dynamic moderation is to be applied
4388 SkDimStartModerationTimer(pAC
);
4390 if (pAC
->DynIrqModInfo
.DisplayStats
) {
4391 SkDimDisplayModerationSettings(pAC
);
4393 } else if (Param
.Para32
[0] == SK_DRV_RX_CLEANUP_TIMER
) {
4395 ** check if we need to check for descriptors which
4396 ** haven't been handled the last millisecs
4398 StartDrvCleanupTimer(pAC
);
4399 if (pAC
->GIni
.GIMacsFound
== 2) {
4400 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_FALSE
);
4402 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_FALSE
);
4404 printk("Expiration of unknown timer\n");
4410 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4417 /*****************************************************************************
4419 * SkErrorLog - log errors
4422 * This function logs errors to the system buffer and to the console
4425 * 0 if everything ok
4438 case SK_ERRCL_OTHER
:
4439 strcpy(ClassStr
, "Other error");
4441 case SK_ERRCL_CONFIG
:
4442 strcpy(ClassStr
, "Configuration error");
4445 strcpy(ClassStr
, "Initialization error");
4447 case SK_ERRCL_NORES
:
4448 strcpy(ClassStr
, "Out of resources error");
4451 strcpy(ClassStr
, "internal Software error");
4454 strcpy(ClassStr
, "Hardware failure");
4457 strcpy(ClassStr
, "Communication error");
4460 printk(KERN_INFO
"%s: -- ERROR --\n Class: %s\n"
4461 " Nr: 0x%x\n Msg: %s\n", pAC
->dev
[0]->name
,
4462 ClassStr
, ErrNum
, pErrorMsg
);
4466 #ifdef SK_DIAG_SUPPORT
4468 /*****************************************************************************
4470 * SkDrvEnterDiagMode - handles DIAG attach request
4473 * Notify the kernel to NOT access the card any longer due to DIAG
4474 * Deinitialize the Card
4479 int SkDrvEnterDiagMode(
4480 SK_AC
*pAc
) /* pointer to adapter context */
4482 DEV_NET
*pNet
= netdev_priv(pAc
->dev
[0]);
4483 SK_AC
*pAC
= pNet
->pAC
;
4485 SK_MEMCPY(&(pAc
->PnmiBackup
), &(pAc
->PnmiStruct
),
4486 sizeof(SK_PNMI_STRUCT_DATA
));
4488 pAC
->DiagModeActive
= DIAG_ACTIVE
;
4489 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
4490 if (netif_running(pAC
->dev
[0])) {
4491 pAC
->WasIfUp
[0] = SK_TRUE
;
4492 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4493 DoPrintInterfaceChange
= SK_FALSE
;
4494 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
4496 pAC
->WasIfUp
[0] = SK_FALSE
;
4498 if (pNet
!= netdev_priv(pAC
->dev
[1])) {
4499 pNet
= netdev_priv(pAC
->dev
[1]);
4500 if (netif_running(pAC
->dev
[1])) {
4501 pAC
->WasIfUp
[1] = SK_TRUE
;
4502 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4503 DoPrintInterfaceChange
= SK_FALSE
;
4504 SkDrvDeInitAdapter(pAC
, 1); /* do SkGeClose */
4506 pAC
->WasIfUp
[1] = SK_FALSE
;
4509 pAC
->BoardLevel
= SK_INIT_DATA
;
4514 /*****************************************************************************
4516 * SkDrvLeaveDiagMode - handles DIAG detach request
4519 * Notify the kernel to may access the card again after use by DIAG
4520 * Initialize the Card
4525 int SkDrvLeaveDiagMode(
4526 SK_AC
*pAc
) /* pointer to adapter control context */
4528 SK_MEMCPY(&(pAc
->PnmiStruct
), &(pAc
->PnmiBackup
),
4529 sizeof(SK_PNMI_STRUCT_DATA
));
4530 pAc
->DiagModeActive
= DIAG_NOTACTIVE
;
4531 pAc
->Pnmi
.DiagAttached
= SK_DIAG_IDLE
;
4532 if (pAc
->WasIfUp
[0] == SK_TRUE
) {
4533 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4534 DoPrintInterfaceChange
= SK_FALSE
;
4535 SkDrvInitAdapter(pAc
, 0); /* first device */
4537 if (pAc
->WasIfUp
[1] == SK_TRUE
) {
4538 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4539 DoPrintInterfaceChange
= SK_FALSE
;
4540 SkDrvInitAdapter(pAc
, 1); /* second device */
4545 /*****************************************************************************
4547 * ParseDeviceNbrFromSlotName - Evaluate PCI device number
4550 * This function parses the PCI slot name information string and will
4551 * retrieve the devcie number out of it. The slot_name maintianed by
4552 * linux is in the form of '02:0a.0', whereas the first two characters
4553 * represent the bus number in hex (in the sample above this is
4554 * pci bus 0x02) and the next two characters the device number (0x0a).
4557 * SK_U32: The device number from the PCI slot name
4560 static SK_U32
ParseDeviceNbrFromSlotName(
4561 const char *SlotName
) /* pointer to pci slot name eg. '02:0a.0' */
4563 char *CurrCharPos
= (char *) SlotName
;
4564 int FirstNibble
= -1;
4565 int SecondNibble
= -1;
4568 while (*CurrCharPos
!= '\0') {
4569 if (*CurrCharPos
== ':') {
4570 while (*CurrCharPos
!= '.') {
4572 if ( (*CurrCharPos
>= '0') &&
4573 (*CurrCharPos
<= '9')) {
4574 if (FirstNibble
== -1) {
4575 /* dec. value for '0' */
4576 FirstNibble
= *CurrCharPos
- 48;
4578 SecondNibble
= *CurrCharPos
- 48;
4580 } else if ( (*CurrCharPos
>= 'a') &&
4581 (*CurrCharPos
<= 'f') ) {
4582 if (FirstNibble
== -1) {
4583 FirstNibble
= *CurrCharPos
- 87;
4585 SecondNibble
= *CurrCharPos
- 87;
4592 Result
= FirstNibble
;
4593 Result
= Result
<< 4; /* first nibble is higher one */
4594 Result
= Result
| SecondNibble
;
4596 CurrCharPos
++; /* next character */
4601 /****************************************************************************
4603 * SkDrvDeInitAdapter - deinitialize adapter (this function is only
4604 * called if Diag attaches to that card)
4607 * Close initialized adapter.
4611 * error code - on error
4613 static int SkDrvDeInitAdapter(
4614 SK_AC
*pAC
, /* pointer to adapter context */
4615 int devNbr
) /* what device is to be handled */
4617 struct SK_NET_DEVICE
*dev
;
4619 dev
= pAC
->dev
[devNbr
];
4621 /* On Linux 2.6 the network driver does NOT mess with reference
4622 ** counts. The driver MUST be able to be unloaded at any time
4623 ** due to the possibility of hotplug.
4625 if (SkGeClose(dev
) != 0) {
4630 } /* SkDrvDeInitAdapter() */
4632 /****************************************************************************
4634 * SkDrvInitAdapter - Initialize adapter (this function is only
4635 * called if Diag deattaches from that card)
4638 * Close initialized adapter.
4642 * error code - on error
4644 static int SkDrvInitAdapter(
4645 SK_AC
*pAC
, /* pointer to adapter context */
4646 int devNbr
) /* what device is to be handled */
4648 struct SK_NET_DEVICE
*dev
;
4650 dev
= pAC
->dev
[devNbr
];
4652 if (SkGeOpen(dev
) != 0) {
4657 ** Use correct MTU size and indicate to kernel TX queue can be started
4659 if (SkGeChangeMtu(dev
, dev
->mtu
) != 0) {
4664 } /* SkDrvInitAdapter */
4669 /****************************************************************************/
4670 /* "debug only" section *****************************************************/
4671 /****************************************************************************/
4674 /*****************************************************************************
4676 * DumpMsg - print a frame
4679 * This function prints frames to the system logfile/to the console.
4684 static void DumpMsg(struct sk_buff
*skb
, char *str
)
4689 printk("DumpMsg(): NULL-Message\n");
4693 if (skb
->data
== NULL
) {
4694 printk("DumpMsg(): Message empty\n");
4702 printk("--- Begin of message from %s , len %d (from %d) ----\n", str
, msglen
, skb
->len
);
4704 DumpData((char *)skb
->data
, msglen
);
4706 printk("------- End of message ---------\n");
4711 /*****************************************************************************
4713 * DumpData - print a data area
4716 * This function prints a area of data to the system logfile/to the
4722 static void DumpData(char *p
, int size
)
4726 char hex_buffer
[180];
4727 char asc_buffer
[180];
4728 char HEXCHAR
[] = "0123456789ABCDEF";
4734 for (i
=0; i
< size
; ) {
4735 if (*p
>= '0' && *p
<='z')
4736 asc_buffer
[addr
] = *p
;
4738 asc_buffer
[addr
] = '.';
4740 asc_buffer
[addr
] = 0;
4741 hex_buffer
[haddr
] = HEXCHAR
[(*p
& 0xf0) >> 4];
4743 hex_buffer
[haddr
] = HEXCHAR
[*p
& 0x0f];
4745 hex_buffer
[haddr
] = ' ';
4747 hex_buffer
[haddr
] = 0;
4751 printk("%s %s\n", hex_buffer
, asc_buffer
);
4759 /*****************************************************************************
4761 * DumpLong - print a data area as long values
4764 * This function prints a area of data to the system logfile/to the
4770 static void DumpLong(char *pc
, int size
)
4774 char hex_buffer
[180];
4775 char asc_buffer
[180];
4776 char HEXCHAR
[] = "0123456789ABCDEF";
4785 for (i
=0; i
< size
; ) {
4787 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 28) & 0xf];
4789 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 24) & 0xf];
4791 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 20) & 0xf];
4793 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 16) & 0xf];
4795 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 12) & 0xf];
4797 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 8) & 0xf];
4799 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 4) & 0xf];
4801 hex_buffer
[haddr
] = HEXCHAR
[l
& 0x0f];
4803 hex_buffer
[haddr
] = ' ';
4805 hex_buffer
[haddr
] = 0;
4809 printk("%4x %s\n", (i
-8)*4, hex_buffer
);
4813 printk("------------------------\n");
4818 static int __devinit
skge_probe_one(struct pci_dev
*pdev
,
4819 const struct pci_device_id
*ent
)
4822 DEV_NET
*pNet
= NULL
;
4823 struct net_device
*dev
= NULL
;
4824 static int boards_found
= 0;
4825 int error
= -ENODEV
;
4829 if (pci_enable_device(pdev
))
4832 /* Configure DMA attributes. */
4833 if (sizeof(dma_addr_t
) > sizeof(u32
) &&
4834 !(error
= pci_set_dma_mask(pdev
, DMA_64BIT_MASK
))) {
4836 error
= pci_set_consistent_dma_mask(pdev
, DMA_64BIT_MASK
);
4838 printk(KERN_ERR
"sk98lin %s unable to obtain 64 bit DMA "
4839 "for consistent allocations\n", pci_name(pdev
));
4840 goto out_disable_device
;
4843 error
= pci_set_dma_mask(pdev
, DMA_32BIT_MASK
);
4845 printk(KERN_ERR
"sk98lin %s no usable DMA configuration\n",
4847 goto out_disable_device
;
4852 dev
= alloc_etherdev(sizeof(DEV_NET
));
4854 printk(KERN_ERR
"sk98lin: unable to allocate etherdev "
4856 goto out_disable_device
;
4859 pNet
= netdev_priv(dev
);
4860 pNet
->pAC
= kzalloc(sizeof(SK_AC
), GFP_KERNEL
);
4862 printk(KERN_ERR
"sk98lin: unable to allocate adapter "
4864 goto out_free_netdev
;
4872 pAC
->CheckQueue
= SK_FALSE
;
4874 dev
->irq
= pdev
->irq
;
4876 error
= SkGeInitPCI(pAC
);
4878 printk(KERN_ERR
"sk98lin: PCI setup failed: %i\n", error
);
4879 goto out_free_netdev
;
4882 SET_MODULE_OWNER(dev
);
4883 dev
->open
= &SkGeOpen
;
4884 dev
->stop
= &SkGeClose
;
4885 dev
->hard_start_xmit
= &SkGeXmit
;
4886 dev
->get_stats
= &SkGeStats
;
4887 dev
->set_multicast_list
= &SkGeSetRxMode
;
4888 dev
->set_mac_address
= &SkGeSetMacAddr
;
4889 dev
->do_ioctl
= &SkGeIoctl
;
4890 dev
->change_mtu
= &SkGeChangeMtu
;
4891 #ifdef CONFIG_NET_POLL_CONTROLLER
4892 dev
->poll_controller
= &SkGePollController
;
4894 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4895 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4897 /* Use only if yukon hardware */
4898 if (pAC
->ChipsetType
) {
4899 #ifdef USE_SK_TX_CHECKSUM
4900 dev
->features
|= NETIF_F_IP_CSUM
;
4903 dev
->features
|= NETIF_F_SG
;
4905 #ifdef USE_SK_RX_CHECKSUM
4906 pAC
->RxPort
[0].RxCsum
= 1;
4911 dev
->features
|= NETIF_F_HIGHDMA
;
4913 pAC
->Index
= boards_found
++;
4915 error
= SkGeBoardInit(dev
, pAC
);
4917 goto out_free_netdev
;
4919 /* Read Adapter name from VPD */
4920 if (ProductStr(pAC
, DeviceStr
, sizeof(DeviceStr
)) != 0) {
4922 printk(KERN_ERR
"sk98lin: Could not read VPD data.\n");
4923 goto out_free_resources
;
4926 /* Register net device */
4927 error
= register_netdev(dev
);
4929 printk(KERN_ERR
"sk98lin: Could not register device.\n");
4930 goto out_free_resources
;
4933 /* Print adapter specific string from vpd */
4934 printk("%s: %s\n", dev
->name
, DeviceStr
);
4936 /* Print configuration settings */
4937 printk(" PrefPort:%c RlmtMode:%s\n",
4938 'A' + pAC
->Rlmt
.Net
[0].Port
[pAC
->Rlmt
.Net
[0].PrefPort
]->PortNumber
,
4939 (pAC
->RlmtMode
==0) ? "Check Link State" :
4940 ((pAC
->RlmtMode
==1) ? "Check Link State" :
4941 ((pAC
->RlmtMode
==3) ? "Check Local Port" :
4942 ((pAC
->RlmtMode
==7) ? "Check Segmentation" :
4943 ((pAC
->RlmtMode
==17) ? "Dual Check Link State" :"Error")))));
4945 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
4947 memcpy(&dev
->dev_addr
, &pAC
->Addr
.Net
[0].CurrentMacAddress
, 6);
4948 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4955 pci_set_drvdata(pdev
, dev
);
4957 /* More then one port found */
4958 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
4959 dev
= alloc_etherdev(sizeof(DEV_NET
));
4961 printk(KERN_ERR
"sk98lin: unable to allocate etherdev "
4966 pNet
= netdev_priv(dev
);
4971 dev
->open
= &SkGeOpen
;
4972 dev
->stop
= &SkGeClose
;
4973 dev
->hard_start_xmit
= &SkGeXmit
;
4974 dev
->get_stats
= &SkGeStats
;
4975 dev
->set_multicast_list
= &SkGeSetRxMode
;
4976 dev
->set_mac_address
= &SkGeSetMacAddr
;
4977 dev
->do_ioctl
= &SkGeIoctl
;
4978 dev
->change_mtu
= &SkGeChangeMtu
;
4979 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4980 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4982 if (pAC
->ChipsetType
) {
4983 #ifdef USE_SK_TX_CHECKSUM
4984 dev
->features
|= NETIF_F_IP_CSUM
;
4987 dev
->features
|= NETIF_F_SG
;
4989 #ifdef USE_SK_RX_CHECKSUM
4990 pAC
->RxPort
[1].RxCsum
= 1;
4995 dev
->features
|= NETIF_F_HIGHDMA
;
4997 error
= register_netdev(dev
);
4999 printk(KERN_ERR
"sk98lin: Could not register device"
5000 " for second port. (%d)\n", error
);
5006 memcpy(&dev
->dev_addr
,
5007 &pAC
->Addr
.Net
[1].CurrentMacAddress
, 6);
5008 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
5010 printk("%s: %s\n", dev
->name
, DeviceStr
);
5011 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
5016 /* Save the hardware revision */
5017 pAC
->HWRevision
= (((pAC
->GIni
.GIPciHwRev
>> 4) & 0x0F)*10) +
5018 (pAC
->GIni
.GIPciHwRev
& 0x0F);
5020 /* Set driver globals */
5021 pAC
->Pnmi
.pDriverFileName
= DRIVER_FILE_NAME
;
5022 pAC
->Pnmi
.pDriverReleaseDate
= DRIVER_REL_DATE
;
5024 memset(&pAC
->PnmiBackup
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
5025 memcpy(&pAC
->PnmiBackup
, &pAC
->PnmiStruct
, sizeof(SK_PNMI_STRUCT_DATA
));
5034 pci_disable_device(pdev
);
5039 static void __devexit
skge_remove_one(struct pci_dev
*pdev
)
5041 struct net_device
*dev
= pci_get_drvdata(pdev
);
5042 DEV_NET
*pNet
= netdev_priv(dev
);
5043 SK_AC
*pAC
= pNet
->pAC
;
5044 struct net_device
*otherdev
= pAC
->dev
[1];
5046 unregister_netdev(dev
);
5048 SkGeYellowLED(pAC
, pAC
->IoBase
, 0);
5050 if (pAC
->BoardLevel
== SK_INIT_RUN
) {
5052 unsigned long Flags
;
5054 /* board is still alive */
5055 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
5056 EvPara
.Para32
[0] = 0;
5057 EvPara
.Para32
[1] = -1;
5058 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
5059 EvPara
.Para32
[0] = 1;
5060 EvPara
.Para32
[1] = -1;
5061 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
5062 SkEventDispatcher(pAC
, pAC
->IoBase
);
5063 /* disable interrupts */
5064 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
5065 SkGeDeInit(pAC
, pAC
->IoBase
);
5066 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
5067 pAC
->BoardLevel
= SK_INIT_DATA
;
5068 /* We do NOT check here, if IRQ was pending, of course*/
5071 if (pAC
->BoardLevel
== SK_INIT_IO
) {
5072 /* board is still alive */
5073 SkGeDeInit(pAC
, pAC
->IoBase
);
5074 pAC
->BoardLevel
= SK_INIT_DATA
;
5079 if (otherdev
!= dev
)
5080 free_netdev(otherdev
);
5085 static int skge_suspend(struct pci_dev
*pdev
, pm_message_t state
)
5087 struct net_device
*dev
= pci_get_drvdata(pdev
);
5088 DEV_NET
*pNet
= netdev_priv(dev
);
5089 SK_AC
*pAC
= pNet
->pAC
;
5090 struct net_device
*otherdev
= pAC
->dev
[1];
5092 if (netif_running(dev
)) {
5093 netif_carrier_off(dev
);
5094 DoPrintInterfaceChange
= SK_FALSE
;
5095 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
5096 netif_device_detach(dev
);
5098 if (otherdev
!= dev
) {
5099 if (netif_running(otherdev
)) {
5100 netif_carrier_off(otherdev
);
5101 DoPrintInterfaceChange
= SK_FALSE
;
5102 SkDrvDeInitAdapter(pAC
, 1); /* performs SkGeClose */
5103 netif_device_detach(otherdev
);
5107 pci_save_state(pdev
);
5108 pci_enable_wake(pdev
, pci_choose_state(pdev
, state
), 0);
5109 if (pAC
->AllocFlag
& SK_ALLOC_IRQ
) {
5110 free_irq(dev
->irq
, dev
);
5112 pci_disable_device(pdev
);
5113 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
5118 static int skge_resume(struct pci_dev
*pdev
)
5120 struct net_device
*dev
= pci_get_drvdata(pdev
);
5121 DEV_NET
*pNet
= netdev_priv(dev
);
5122 SK_AC
*pAC
= pNet
->pAC
;
5123 struct net_device
*otherdev
= pAC
->dev
[1];
5126 pci_set_power_state(pdev
, PCI_D0
);
5127 pci_restore_state(pdev
);
5128 pci_enable_device(pdev
);
5129 pci_set_master(pdev
);
5130 if (pAC
->GIni
.GIMacsFound
== 2)
5131 ret
= request_irq(dev
->irq
, SkGeIsr
, IRQF_SHARED
, "sk98lin", dev
);
5133 ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, IRQF_SHARED
, "sk98lin", dev
);
5135 printk(KERN_WARNING
"sk98lin: unable to acquire IRQ %d\n", dev
->irq
);
5136 pAC
->AllocFlag
&= ~SK_ALLOC_IRQ
;
5138 pci_disable_device(pdev
);
5142 netif_device_attach(dev
);
5143 if (netif_running(dev
)) {
5144 DoPrintInterfaceChange
= SK_FALSE
;
5145 SkDrvInitAdapter(pAC
, 0); /* first device */
5147 if (otherdev
!= dev
) {
5148 netif_device_attach(otherdev
);
5149 if (netif_running(otherdev
)) {
5150 DoPrintInterfaceChange
= SK_FALSE
;
5151 SkDrvInitAdapter(pAC
, 1); /* second device */
5158 #define skge_suspend NULL
5159 #define skge_resume NULL
5162 static struct pci_device_id skge_pci_tbl
[] = {
5163 { PCI_VENDOR_ID_3COM
, 0x1700, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5164 { PCI_VENDOR_ID_3COM
, 0x80eb, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5165 { PCI_VENDOR_ID_SYSKONNECT
, 0x4300, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5166 { PCI_VENDOR_ID_SYSKONNECT
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5167 /* DLink card does not have valid VPD so this driver gags
5168 * { PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5170 { PCI_VENDOR_ID_MARVELL
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5171 { PCI_VENDOR_ID_MARVELL
, 0x5005, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5172 { PCI_VENDOR_ID_CNET
, 0x434e, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5173 { PCI_VENDOR_ID_LINKSYS
, 0x1032, PCI_ANY_ID
, 0x0015, },
5174 { PCI_VENDOR_ID_LINKSYS
, 0x1064, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5178 MODULE_DEVICE_TABLE(pci
, skge_pci_tbl
);
5180 static struct pci_driver skge_driver
= {
5182 .id_table
= skge_pci_tbl
,
5183 .probe
= skge_probe_one
,
5184 .remove
= __devexit_p(skge_remove_one
),
5185 .suspend
= skge_suspend
,
5186 .resume
= skge_resume
,
5189 static int __init
skge_init(void)
5191 printk(KERN_NOTICE
"sk98lin: driver has been replaced by the skge driver"
5192 " and is scheduled for removal\n");
5194 return pci_register_driver(&skge_driver
);
5197 static void __exit
skge_exit(void)
5199 pci_unregister_driver(&skge_driver
);
5202 module_init(skge_init
);
5203 module_exit(skge_exit
);