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/module.h>
111 #include <linux/moduleparam.h>
112 #include <linux/init.h>
113 #include <linux/dma-mapping.h>
114 #include <linux/ip.h>
116 #include "h/skdrv1st.h"
117 #include "h/skdrv2nd.h"
119 /*******************************************************************************
123 ******************************************************************************/
125 /* for debuging on x86 only */
126 /* #define BREAKPOINT() asm(" int $3"); */
128 /* use the transmit hw checksum driver functionality */
129 #define USE_SK_TX_CHECKSUM
131 /* use the receive hw checksum driver functionality */
132 #define USE_SK_RX_CHECKSUM
134 /* use the scatter-gather functionality with sendfile() */
137 /* use of a transmit complete interrupt */
138 #define USE_TX_COMPLETE
141 * threshold for copying small receive frames
142 * set to 0 to avoid copying, set to 9001 to copy all frames
144 #define SK_COPY_THRESHOLD 50
146 /* number of adapters that can be configured via command line params */
147 #define SK_MAX_CARD_PARAM 16
152 * use those defines for a compile-in version of the driver instead
153 * of command line parameters
155 // #define LINK_SPEED_A {"Auto", }
156 // #define LINK_SPEED_B {"Auto", }
157 // #define AUTO_NEG_A {"Sense", }
158 // #define AUTO_NEG_B {"Sense", }
159 // #define DUP_CAP_A {"Both", }
160 // #define DUP_CAP_B {"Both", }
161 // #define FLOW_CTRL_A {"SymOrRem", }
162 // #define FLOW_CTRL_B {"SymOrRem", }
163 // #define ROLE_A {"Auto", }
164 // #define ROLE_B {"Auto", }
165 // #define PREF_PORT {"A", }
166 // #define CON_TYPE {"Auto", }
167 // #define RLMT_MODE {"CheckLinkState", }
169 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
170 #define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
171 #define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
175 #define OEM_CONFIG_VALUE ( SK_ACT_LED_BLINK | \
176 SK_DUP_LED_NORMAL | \
180 /* Isr return value */
181 #define SkIsrRetVar irqreturn_t
182 #define SkIsrRetNone IRQ_NONE
183 #define SkIsrRetHandled IRQ_HANDLED
186 /*******************************************************************************
188 * Local Function Prototypes
190 ******************************************************************************/
192 static void FreeResources(struct SK_NET_DEVICE
*dev
);
193 static int SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
);
194 static SK_BOOL
BoardAllocMem(SK_AC
*pAC
);
195 static void BoardFreeMem(SK_AC
*pAC
);
196 static void BoardInitMem(SK_AC
*pAC
);
197 static void SetupRing(SK_AC
*, void*, uintptr_t, RXD
**, RXD
**, RXD
**, int*, SK_BOOL
);
198 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
, struct pt_regs
*ptregs
);
199 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
, struct pt_regs
*ptregs
);
200 static int SkGeOpen(struct SK_NET_DEVICE
*dev
);
201 static int SkGeClose(struct SK_NET_DEVICE
*dev
);
202 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
);
203 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
);
204 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
);
205 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
);
206 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
);
207 static void GetConfiguration(SK_AC
*);
208 static int XmitFrame(SK_AC
*, TX_PORT
*, struct sk_buff
*);
209 static void FreeTxDescriptors(SK_AC
*pAC
, TX_PORT
*);
210 static void FillRxRing(SK_AC
*, RX_PORT
*);
211 static SK_BOOL
FillRxDescriptor(SK_AC
*, RX_PORT
*);
212 static void ReceiveIrq(SK_AC
*, RX_PORT
*, SK_BOOL
);
213 static void ClearAndStartRx(SK_AC
*, int);
214 static void ClearTxIrq(SK_AC
*, int, int);
215 static void ClearRxRing(SK_AC
*, RX_PORT
*);
216 static void ClearTxRing(SK_AC
*, TX_PORT
*);
217 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int new_mtu
);
218 static void PortReInitBmu(SK_AC
*, int);
219 static int SkGeIocMib(DEV_NET
*, unsigned int, int);
220 static int SkGeInitPCI(SK_AC
*pAC
);
221 static void StartDrvCleanupTimer(SK_AC
*pAC
);
222 static void StopDrvCleanupTimer(SK_AC
*pAC
);
223 static int XmitFrameSG(SK_AC
*, TX_PORT
*, struct sk_buff
*);
225 #ifdef SK_DIAG_SUPPORT
226 static SK_U32
ParseDeviceNbrFromSlotName(const char *SlotName
);
227 static int SkDrvInitAdapter(SK_AC
*pAC
, int devNbr
);
228 static int SkDrvDeInitAdapter(SK_AC
*pAC
, int devNbr
);
231 /*******************************************************************************
233 * Extern Function Prototypes
235 ******************************************************************************/
236 extern void SkDimEnableModerationIfNeeded(SK_AC
*pAC
);
237 extern void SkDimDisplayModerationSettings(SK_AC
*pAC
);
238 extern void SkDimStartModerationTimer(SK_AC
*pAC
);
239 extern void SkDimModerate(SK_AC
*pAC
);
240 extern void SkGeBlinkTimer(unsigned long data
);
243 static void DumpMsg(struct sk_buff
*, char*);
244 static void DumpData(char*, int);
245 static void DumpLong(char*, int);
248 /* global variables *********************************************************/
249 static SK_BOOL DoPrintInterfaceChange
= SK_TRUE
;
250 extern struct ethtool_ops SkGeEthtoolOps
;
252 /* local variables **********************************************************/
253 static uintptr_t TxQueueAddr
[SK_MAX_MACS
][2] = {{0x680, 0x600},{0x780, 0x700}};
254 static uintptr_t RxQueueAddr
[SK_MAX_MACS
] = {0x400, 0x480};
256 /*****************************************************************************
258 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
261 * This routine writes a 32 bit value to the pci configuration
265 * 0 - indicate everything worked ok.
266 * != 0 - error indication
268 static inline int SkPciWriteCfgDWord(
269 SK_AC
*pAC
, /* Adapter Control structure pointer */
270 int PciAddr
, /* PCI register address */
271 SK_U32 Val
) /* pointer to store the read value */
273 pci_write_config_dword(pAC
->PciDev
, PciAddr
, Val
);
275 } /* SkPciWriteCfgDWord */
277 /*****************************************************************************
279 * SkGeInitPCI - Init the PCI resources
282 * This function initialize the PCI resources and IO
287 int SkGeInitPCI(SK_AC
*pAC
)
289 struct SK_NET_DEVICE
*dev
= pAC
->dev
[0];
290 struct pci_dev
*pdev
= pAC
->PciDev
;
293 if (pci_enable_device(pdev
) != 0) {
297 dev
->mem_start
= pci_resource_start (pdev
, 0);
298 pci_set_master(pdev
);
300 if (pci_request_regions(pdev
, "sk98lin") != 0) {
307 * On big endian machines, we use the adapter's aibility of
308 * reading the descriptors as big endian.
312 SkPciReadCfgDWord(pAC
, PCI_OUR_REG_2
, &our2
);
313 our2
|= PCI_REV_DESC
;
314 SkPciWriteCfgDWord(pAC
, PCI_OUR_REG_2
, our2
);
319 * Remap the regs into kernel space.
321 pAC
->IoBase
= ioremap_nocache(dev
->mem_start
, 0x4000);
331 pci_release_regions(pdev
);
333 pci_disable_device(pdev
);
338 /*****************************************************************************
340 * FreeResources - release resources allocated for adapter
343 * This function releases the IRQ, unmaps the IO and
344 * frees the desriptor ring.
349 static void FreeResources(struct SK_NET_DEVICE
*dev
)
355 pNet
= netdev_priv(dev
);
357 AllocFlag
= pAC
->AllocFlag
;
359 pci_release_regions(pAC
->PciDev
);
361 if (AllocFlag
& SK_ALLOC_IRQ
) {
362 free_irq(dev
->irq
, dev
);
365 iounmap(pAC
->IoBase
);
367 if (pAC
->pDescrMem
) {
371 } /* FreeResources */
373 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
374 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
375 MODULE_LICENSE("GPL");
378 static char *Speed_A
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
380 static char *Speed_A
[SK_MAX_CARD_PARAM
] = {"", };
384 static char *Speed_B
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
386 static char *Speed_B
[SK_MAX_CARD_PARAM
] = {"", };
390 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = AUTO_NEG_A
;
392 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = {"", };
396 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = DUP_CAP_A
;
398 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = {"", };
402 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_A
;
404 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = {"", };
408 static char *Role_A
[SK_MAX_CARD_PARAM
] = ROLE_A
;
410 static char *Role_A
[SK_MAX_CARD_PARAM
] = {"", };
414 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = AUTO_NEG_B
;
416 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = {"", };
420 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = DUP_CAP_B
;
422 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = {"", };
426 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_B
;
428 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = {"", };
432 static char *Role_B
[SK_MAX_CARD_PARAM
] = ROLE_B
;
434 static char *Role_B
[SK_MAX_CARD_PARAM
] = {"", };
438 static char *ConType
[SK_MAX_CARD_PARAM
] = CON_TYPE
;
440 static char *ConType
[SK_MAX_CARD_PARAM
] = {"", };
444 static char *PrefPort
[SK_MAX_CARD_PARAM
] = PREF_PORT
;
446 static char *PrefPort
[SK_MAX_CARD_PARAM
] = {"", };
450 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = RLMT_MODE
;
452 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = {"", };
455 static int IntsPerSec
[SK_MAX_CARD_PARAM
];
456 static char *Moderation
[SK_MAX_CARD_PARAM
];
457 static char *ModerationMask
[SK_MAX_CARD_PARAM
];
458 static char *AutoSizing
[SK_MAX_CARD_PARAM
];
459 static char *Stats
[SK_MAX_CARD_PARAM
];
461 module_param_array(Speed_A
, charp
, NULL
, 0);
462 module_param_array(Speed_B
, charp
, NULL
, 0);
463 module_param_array(AutoNeg_A
, charp
, NULL
, 0);
464 module_param_array(AutoNeg_B
, charp
, NULL
, 0);
465 module_param_array(DupCap_A
, charp
, NULL
, 0);
466 module_param_array(DupCap_B
, charp
, NULL
, 0);
467 module_param_array(FlowCtrl_A
, charp
, NULL
, 0);
468 module_param_array(FlowCtrl_B
, charp
, NULL
, 0);
469 module_param_array(Role_A
, charp
, NULL
, 0);
470 module_param_array(Role_B
, charp
, NULL
, 0);
471 module_param_array(ConType
, charp
, NULL
, 0);
472 module_param_array(PrefPort
, charp
, NULL
, 0);
473 module_param_array(RlmtMode
, charp
, NULL
, 0);
474 /* used for interrupt moderation */
475 module_param_array(IntsPerSec
, int, NULL
, 0);
476 module_param_array(Moderation
, charp
, NULL
, 0);
477 module_param_array(Stats
, charp
, NULL
, 0);
478 module_param_array(ModerationMask
, charp
, NULL
, 0);
479 module_param_array(AutoSizing
, charp
, NULL
, 0);
481 /*****************************************************************************
483 * SkGeBoardInit - do level 0 and 1 initialization
486 * This function prepares the board hardware for running. The desriptor
487 * ring is set up, the IRQ is allocated and the configuration settings
491 * 0, if everything is ok
494 static int __init
SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
)
498 char *DescrString
= "sk98lin: Driver for Linux"; /* this is given to PNMI */
499 char *VerStr
= VER_STRING
;
500 int Ret
; /* return code of request_irq */
503 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
504 ("IoBase: %08lX\n", (unsigned long)pAC
->IoBase
));
505 for (i
=0; i
<SK_MAX_MACS
; i
++) {
506 pAC
->TxPort
[i
][0].HwAddr
= pAC
->IoBase
+ TxQueueAddr
[i
][0];
507 pAC
->TxPort
[i
][0].PortIndex
= i
;
508 pAC
->RxPort
[i
].HwAddr
= pAC
->IoBase
+ RxQueueAddr
[i
];
509 pAC
->RxPort
[i
].PortIndex
= i
;
512 /* Initialize the mutexes */
513 for (i
=0; i
<SK_MAX_MACS
; i
++) {
514 spin_lock_init(&pAC
->TxPort
[i
][0].TxDesRingLock
);
515 spin_lock_init(&pAC
->RxPort
[i
].RxDesRingLock
);
517 spin_lock_init(&pAC
->SlowPathLock
);
519 /* setup phy_id blink timer */
520 pAC
->BlinkTimer
.function
= SkGeBlinkTimer
;
521 pAC
->BlinkTimer
.data
= (unsigned long) dev
;
522 init_timer(&pAC
->BlinkTimer
);
524 /* level 0 init common modules here */
526 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
527 /* Does a RESET on board ...*/
528 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
) != 0) {
529 printk("HWInit (0) failed.\n");
530 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
533 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
534 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
535 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
536 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
537 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
538 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
540 pAC
->BoardLevel
= SK_INIT_DATA
;
541 pAC
->RxBufSize
= ETH_BUF_SIZE
;
543 SK_PNMI_SET_DRIVER_DESCR(pAC
, DescrString
);
544 SK_PNMI_SET_DRIVER_VER(pAC
, VerStr
);
546 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
548 /* level 1 init common modules here (HW init) */
549 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
550 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
551 printk("sk98lin: HWInit (1) failed.\n");
552 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
555 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
556 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
557 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
558 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
559 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
560 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
562 /* Set chipset type support */
563 pAC
->ChipsetType
= 0;
564 if ((pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
) ||
565 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON_LITE
)) {
566 pAC
->ChipsetType
= 1;
569 GetConfiguration(pAC
);
570 if (pAC
->RlmtNets
== 2) {
571 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
574 pAC
->BoardLevel
= SK_INIT_IO
;
575 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
577 if (pAC
->GIni
.GIMacsFound
== 2) {
578 Ret
= request_irq(dev
->irq
, SkGeIsr
, SA_SHIRQ
, "sk98lin", dev
);
579 } else if (pAC
->GIni
.GIMacsFound
== 1) {
580 Ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, SA_SHIRQ
,
583 printk(KERN_WARNING
"sk98lin: Illegal number of ports: %d\n",
584 pAC
->GIni
.GIMacsFound
);
589 printk(KERN_WARNING
"sk98lin: Requested IRQ %d is busy.\n",
593 pAC
->AllocFlag
|= SK_ALLOC_IRQ
;
595 /* Alloc memory for this board (Mem for RxD/TxD) : */
596 if(!BoardAllocMem(pAC
)) {
597 printk("No memory for descriptor rings.\n");
602 /* tschilling: New common function with minimum size check. */
604 if (pAC
->RlmtNets
== 2) {
608 if (SkGeInitAssignRamToQueues(
613 printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
618 } /* SkGeBoardInit */
621 /*****************************************************************************
623 * BoardAllocMem - allocate the memory for the descriptor rings
626 * This function allocates the memory for all descriptor rings.
627 * Each ring is aligned for the desriptor alignment and no ring
628 * has a 4 GByte boundary in it (because the upper 32 bit must
629 * be constant for all descriptiors in one rings).
632 * SK_TRUE, if all memory could be allocated
635 static SK_BOOL
BoardAllocMem(
638 caddr_t pDescrMem
; /* pointer to descriptor memory area */
639 size_t AllocLength
; /* length of complete descriptor area */
640 int i
; /* loop counter */
641 unsigned long BusAddr
;
644 /* rings plus one for alignment (do not cross 4 GB boundary) */
645 /* RX_RING_SIZE is assumed bigger than TX_RING_SIZE */
646 #if (BITS_PER_LONG == 32)
647 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
649 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
653 pDescrMem
= pci_alloc_consistent(pAC
->PciDev
, AllocLength
,
656 if (pDescrMem
== NULL
) {
659 pAC
->pDescrMem
= pDescrMem
;
660 BusAddr
= (unsigned long) pAC
->pDescrMemDMA
;
662 /* Descriptors need 8 byte alignment, and this is ensured
663 * by pci_alloc_consistent.
665 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
666 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
667 ("TX%d/A: pDescrMem: %lX, PhysDescrMem: %lX\n",
668 i
, (unsigned long) pDescrMem
,
670 pAC
->TxPort
[i
][0].pTxDescrRing
= pDescrMem
;
671 pAC
->TxPort
[i
][0].VTxDescrRing
= BusAddr
;
672 pDescrMem
+= TX_RING_SIZE
;
673 BusAddr
+= TX_RING_SIZE
;
675 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
676 ("RX%d: pDescrMem: %lX, PhysDescrMem: %lX\n",
677 i
, (unsigned long) pDescrMem
,
678 (unsigned long)BusAddr
));
679 pAC
->RxPort
[i
].pRxDescrRing
= pDescrMem
;
680 pAC
->RxPort
[i
].VRxDescrRing
= BusAddr
;
681 pDescrMem
+= RX_RING_SIZE
;
682 BusAddr
+= RX_RING_SIZE
;
686 } /* BoardAllocMem */
689 /****************************************************************************
691 * BoardFreeMem - reverse of BoardAllocMem
694 * Free all memory allocated in BoardAllocMem: adapter context,
695 * descriptor rings, locks.
699 static void BoardFreeMem(
702 size_t AllocLength
; /* length of complete descriptor area */
704 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
706 #if (BITS_PER_LONG == 32)
707 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
709 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
713 pci_free_consistent(pAC
->PciDev
, AllocLength
,
714 pAC
->pDescrMem
, pAC
->pDescrMemDMA
);
715 pAC
->pDescrMem
= NULL
;
719 /*****************************************************************************
721 * BoardInitMem - initiate the descriptor rings
724 * This function sets the descriptor rings up in memory.
725 * The adapter is initialized with the descriptor start addresses.
729 static void BoardInitMem(
730 SK_AC
*pAC
) /* pointer to adapter context */
732 int i
; /* loop counter */
733 int RxDescrSize
; /* the size of a rx descriptor rounded up to alignment*/
734 int TxDescrSize
; /* the size of a tx descriptor rounded up to alignment*/
736 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
739 RxDescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
740 pAC
->RxDescrPerRing
= RX_RING_SIZE
/ RxDescrSize
;
741 TxDescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
742 pAC
->TxDescrPerRing
= TX_RING_SIZE
/ RxDescrSize
;
744 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
747 pAC
->TxPort
[i
][0].pTxDescrRing
,
748 pAC
->TxPort
[i
][0].VTxDescrRing
,
749 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingHead
,
750 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingTail
,
751 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingPrev
,
752 &pAC
->TxPort
[i
][0].TxdRingFree
,
756 pAC
->RxPort
[i
].pRxDescrRing
,
757 pAC
->RxPort
[i
].VRxDescrRing
,
758 &pAC
->RxPort
[i
].pRxdRingHead
,
759 &pAC
->RxPort
[i
].pRxdRingTail
,
760 &pAC
->RxPort
[i
].pRxdRingPrev
,
761 &pAC
->RxPort
[i
].RxdRingFree
,
767 /*****************************************************************************
769 * SetupRing - create one descriptor ring
772 * This function creates one descriptor ring in the given memory area.
773 * The head, tail and number of free descriptors in the ring are set.
778 static void SetupRing(
780 void *pMemArea
, /* a pointer to the memory area for the ring */
781 uintptr_t VMemArea
, /* the virtual bus address of the memory area */
782 RXD
**ppRingHead
, /* address where the head should be written */
783 RXD
**ppRingTail
, /* address where the tail should be written */
784 RXD
**ppRingPrev
, /* address where the tail should be written */
785 int *pRingFree
, /* address where the # of free descr. goes */
786 SK_BOOL IsTx
) /* flag: is this a tx ring */
788 int i
; /* loop counter */
789 int DescrSize
; /* the size of a descriptor rounded up to alignment*/
790 int DescrNum
; /* number of descriptors per ring */
791 RXD
*pDescr
; /* pointer to a descriptor (receive or transmit) */
792 RXD
*pNextDescr
; /* pointer to the next descriptor */
793 RXD
*pPrevDescr
; /* pointer to the previous descriptor */
794 uintptr_t VNextDescr
; /* the virtual bus address of the next descriptor */
796 if (IsTx
== SK_TRUE
) {
797 DescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) *
799 DescrNum
= TX_RING_SIZE
/ DescrSize
;
801 DescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) *
803 DescrNum
= RX_RING_SIZE
/ DescrSize
;
806 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
807 ("Descriptor size: %d Descriptor Number: %d\n",
808 DescrSize
,DescrNum
));
810 pDescr
= (RXD
*) pMemArea
;
812 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
813 VNextDescr
= VMemArea
+ DescrSize
;
814 for(i
=0; i
<DescrNum
; i
++) {
815 /* set the pointers right */
816 pDescr
->VNextRxd
= VNextDescr
& 0xffffffffULL
;
817 pDescr
->pNextRxd
= pNextDescr
;
818 if (!IsTx
) pDescr
->TcpSumStarts
= ETH_HLEN
<< 16 | ETH_HLEN
;
820 /* advance one step */
823 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
824 VNextDescr
+= DescrSize
;
826 pPrevDescr
->pNextRxd
= (RXD
*) pMemArea
;
827 pPrevDescr
->VNextRxd
= VMemArea
;
828 pDescr
= (RXD
*) pMemArea
;
829 *ppRingHead
= (RXD
*) pMemArea
;
830 *ppRingTail
= *ppRingHead
;
831 *ppRingPrev
= pPrevDescr
;
832 *pRingFree
= DescrNum
;
836 /*****************************************************************************
838 * PortReInitBmu - re-initiate the descriptor rings for one port
841 * This function reinitializes the descriptor rings of one port
842 * in memory. The port must be stopped before.
843 * The HW is initialized with the descriptor start addresses.
848 static void PortReInitBmu(
849 SK_AC
*pAC
, /* pointer to adapter context */
850 int PortIndex
) /* index of the port for which to re-init */
852 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
855 /* set address of first descriptor of ring in BMU */
856 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_L
,
857 (uint32_t)(((caddr_t
)
858 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
859 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
860 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) &
862 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_H
,
863 (uint32_t)(((caddr_t
)
864 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
865 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
866 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) >> 32));
867 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_L
,
868 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
869 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
870 pAC
->RxPort
[PortIndex
].VRxDescrRing
) & 0xFFFFFFFF));
871 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_H
,
872 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
873 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
874 pAC
->RxPort
[PortIndex
].VRxDescrRing
) >> 32));
875 } /* PortReInitBmu */
878 /****************************************************************************
880 * SkGeIsr - handle adapter interrupts
883 * The interrupt routine is called when the network adapter
884 * generates an interrupt. It may also be called if another device
885 * shares this interrupt vector with the driver.
890 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
, struct pt_regs
*ptregs
)
892 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
895 SK_U32 IntSrc
; /* interrupts source register contents */
897 pNet
= netdev_priv(dev
);
901 * Check and process if its our interrupt
903 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
908 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
909 #if 0 /* software irq currently not used */
910 if (IntSrc
& IS_IRQ_SW
) {
911 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
912 SK_DBGCAT_DRV_INT_SRC
,
916 if (IntSrc
& IS_R1_F
) {
917 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
918 SK_DBGCAT_DRV_INT_SRC
,
920 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
921 SK_PNMI_CNT_RX_INTR(pAC
, 0);
923 if (IntSrc
& IS_R2_F
) {
924 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
925 SK_DBGCAT_DRV_INT_SRC
,
927 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_TRUE
);
928 SK_PNMI_CNT_RX_INTR(pAC
, 1);
930 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
931 if (IntSrc
& IS_XA1_F
) {
932 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
933 SK_DBGCAT_DRV_INT_SRC
,
934 ("EOF AS TX1 IRQ\n"));
935 SK_PNMI_CNT_TX_INTR(pAC
, 0);
936 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
937 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
938 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
940 if (IntSrc
& IS_XA2_F
) {
941 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
942 SK_DBGCAT_DRV_INT_SRC
,
943 ("EOF AS TX2 IRQ\n"));
944 SK_PNMI_CNT_TX_INTR(pAC
, 1);
945 spin_lock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
946 FreeTxDescriptors(pAC
, &pAC
->TxPort
[1][TX_PRIO_LOW
]);
947 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
949 #if 0 /* only if sync. queues used */
950 if (IntSrc
& IS_XS1_F
) {
951 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
952 SK_DBGCAT_DRV_INT_SRC
,
953 ("EOF SY TX1 IRQ\n"));
954 SK_PNMI_CNT_TX_INTR(pAC
, 1);
955 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
956 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
957 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
958 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
960 if (IntSrc
& IS_XS2_F
) {
961 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
962 SK_DBGCAT_DRV_INT_SRC
,
963 ("EOF SY TX2 IRQ\n"));
964 SK_PNMI_CNT_TX_INTR(pAC
, 1);
965 spin_lock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
966 FreeTxDescriptors(pAC
, 1, TX_PRIO_HIGH
);
967 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
968 ClearTxIrq(pAC
, 1, TX_PRIO_HIGH
);
973 /* do all IO at once */
974 if (IntSrc
& IS_R1_F
)
975 ClearAndStartRx(pAC
, 0);
976 if (IntSrc
& IS_R2_F
)
977 ClearAndStartRx(pAC
, 1);
978 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
979 if (IntSrc
& IS_XA1_F
)
980 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
981 if (IntSrc
& IS_XA2_F
)
982 ClearTxIrq(pAC
, 1, TX_PRIO_LOW
);
984 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
985 } /* while (IntSrc & IRQ_MASK != 0) */
987 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
988 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
989 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
990 ("SPECIAL IRQ DP-Cards => %x\n", IntSrc
));
991 pAC
->CheckQueue
= SK_FALSE
;
992 spin_lock(&pAC
->SlowPathLock
);
993 if (IntSrc
& SPECIAL_IRQS
)
994 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
996 SkEventDispatcher(pAC
, pAC
->IoBase
);
997 spin_unlock(&pAC
->SlowPathLock
);
1000 * do it all again is case we cleared an interrupt that
1001 * came in after handling the ring (OUTs may be delayed
1002 * in hardware buffers, but are through after IN)
1004 * rroesler: has been commented out and shifted to
1005 * SkGeDrvEvent(), because it is timer
1008 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1009 ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1012 if (pAC
->CheckQueue
) {
1013 pAC
->CheckQueue
= SK_FALSE
;
1014 spin_lock(&pAC
->SlowPathLock
);
1015 SkEventDispatcher(pAC
, pAC
->IoBase
);
1016 spin_unlock(&pAC
->SlowPathLock
);
1019 /* IRQ is processed - Enable IRQs again*/
1020 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1022 return SkIsrRetHandled
;
1026 /****************************************************************************
1028 * SkGeIsrOnePort - handle adapter interrupts for single port adapter
1031 * The interrupt routine is called when the network adapter
1032 * generates an interrupt. It may also be called if another device
1033 * shares this interrupt vector with the driver.
1034 * This is the same as above, but handles only one port.
1039 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
, struct pt_regs
*ptregs
)
1041 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
1044 SK_U32 IntSrc
; /* interrupts source register contents */
1046 pNet
= netdev_priv(dev
);
1050 * Check and process if its our interrupt
1052 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
1054 return SkIsrRetNone
;
1057 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
1058 #if 0 /* software irq currently not used */
1059 if (IntSrc
& IS_IRQ_SW
) {
1060 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1061 SK_DBGCAT_DRV_INT_SRC
,
1062 ("Software IRQ\n"));
1065 if (IntSrc
& IS_R1_F
) {
1066 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1067 SK_DBGCAT_DRV_INT_SRC
,
1069 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
1070 SK_PNMI_CNT_RX_INTR(pAC
, 0);
1072 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1073 if (IntSrc
& IS_XA1_F
) {
1074 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1075 SK_DBGCAT_DRV_INT_SRC
,
1076 ("EOF AS TX1 IRQ\n"));
1077 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1078 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1079 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
1080 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1082 #if 0 /* only if sync. queues used */
1083 if (IntSrc
& IS_XS1_F
) {
1084 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1085 SK_DBGCAT_DRV_INT_SRC
,
1086 ("EOF SY TX1 IRQ\n"));
1087 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1088 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1089 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
1090 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1091 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
1096 /* do all IO at once */
1097 if (IntSrc
& IS_R1_F
)
1098 ClearAndStartRx(pAC
, 0);
1099 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1100 if (IntSrc
& IS_XA1_F
)
1101 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
1103 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
1104 } /* while (IntSrc & IRQ_MASK != 0) */
1106 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
1107 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
1108 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
1109 ("SPECIAL IRQ SP-Cards => %x\n", IntSrc
));
1110 pAC
->CheckQueue
= SK_FALSE
;
1111 spin_lock(&pAC
->SlowPathLock
);
1112 if (IntSrc
& SPECIAL_IRQS
)
1113 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
1115 SkEventDispatcher(pAC
, pAC
->IoBase
);
1116 spin_unlock(&pAC
->SlowPathLock
);
1119 * do it all again is case we cleared an interrupt that
1120 * came in after handling the ring (OUTs may be delayed
1121 * in hardware buffers, but are through after IN)
1123 * rroesler: has been commented out and shifted to
1124 * SkGeDrvEvent(), because it is timer
1127 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1130 /* IRQ is processed - Enable IRQs again*/
1131 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1133 return SkIsrRetHandled
;
1134 } /* SkGeIsrOnePort */
1136 #ifdef CONFIG_NET_POLL_CONTROLLER
1137 /****************************************************************************
1139 * SkGePollController - polling receive, for netconsole
1142 * Polling receive - used by netconsole and other diagnostic tools
1143 * to allow network i/o with interrupts disabled.
1147 static void SkGePollController(struct net_device
*dev
)
1149 disable_irq(dev
->irq
);
1150 SkGeIsr(dev
->irq
, dev
, NULL
);
1151 enable_irq(dev
->irq
);
1155 /****************************************************************************
1157 * SkGeOpen - handle start of initialized adapter
1160 * This function starts the initialized adapter.
1161 * The board level variable is set and the adapter is
1162 * brought to full functionality.
1163 * The device flags are set for operation.
1164 * Do all necessary level 2 initialization, enable interrupts and
1165 * give start command to RLMT.
1171 static int SkGeOpen(
1172 struct SK_NET_DEVICE
*dev
)
1176 unsigned long Flags
; /* for spin lock */
1178 SK_EVPARA EvPara
; /* an event parameter union */
1180 pNet
= netdev_priv(dev
);
1183 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1184 ("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC
));
1186 #ifdef SK_DIAG_SUPPORT
1187 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1188 if (pAC
->Pnmi
.DiagAttached
== SK_DIAG_RUNNING
) {
1189 return (-1); /* still in use by diag; deny actions */
1194 /* Set blink mode */
1195 if ((pAC
->PciDev
->vendor
== 0x1186) || (pAC
->PciDev
->vendor
== 0x11ab ))
1196 pAC
->GIni
.GILedBlinkCtrl
= OEM_CONFIG_VALUE
;
1198 if (pAC
->BoardLevel
== SK_INIT_DATA
) {
1199 /* level 1 init common modules here */
1200 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
1201 printk("%s: HWInit (1) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1204 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1205 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1206 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1207 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1208 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1209 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1210 pAC
->BoardLevel
= SK_INIT_IO
;
1213 if (pAC
->BoardLevel
!= SK_INIT_RUN
) {
1214 /* tschilling: Level 2 init modules here, check return value. */
1215 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
) != 0) {
1216 printk("%s: HWInit (2) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1219 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1220 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1221 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1222 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1223 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1224 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1225 pAC
->BoardLevel
= SK_INIT_RUN
;
1228 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1229 /* Enable transmit descriptor polling. */
1230 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
1231 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
1233 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
1235 StartDrvCleanupTimer(pAC
);
1236 SkDimEnableModerationIfNeeded(pAC
);
1237 SkDimDisplayModerationSettings(pAC
);
1239 pAC
->GIni
.GIValIrqMask
&= IRQ_MASK
;
1241 /* enable Interrupts */
1242 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1243 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
1245 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1247 if ((pAC
->RlmtMode
!= 0) && (pAC
->MaxPorts
== 0)) {
1248 EvPara
.Para32
[0] = pAC
->RlmtNets
;
1249 EvPara
.Para32
[1] = -1;
1250 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
,
1252 EvPara
.Para32
[0] = pAC
->RlmtMode
;
1253 EvPara
.Para32
[1] = 0;
1254 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_MODE_CHANGE
,
1258 EvPara
.Para32
[0] = pNet
->NetNr
;
1259 EvPara
.Para32
[1] = -1;
1260 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
1261 SkEventDispatcher(pAC
, pAC
->IoBase
);
1262 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1267 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1268 ("SkGeOpen suceeded\n"));
1274 /****************************************************************************
1276 * SkGeClose - Stop initialized adapter
1279 * Close initialized adapter.
1283 * error code - on error
1285 static int SkGeClose(
1286 struct SK_NET_DEVICE
*dev
)
1292 unsigned long Flags
; /* for spin lock */
1297 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1298 ("SkGeClose: pAC=0x%lX ", (unsigned long)pAC
));
1300 pNet
= netdev_priv(dev
);
1303 #ifdef SK_DIAG_SUPPORT
1304 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1305 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
1307 ** notify that the interface which has been closed
1308 ** by operator interaction must not be started up
1309 ** again when the DIAG has finished.
1311 newPtrNet
= netdev_priv(pAC
->dev
[0]);
1312 if (newPtrNet
== pNet
) {
1313 pAC
->WasIfUp
[0] = SK_FALSE
;
1315 pAC
->WasIfUp
[1] = SK_FALSE
;
1317 return 0; /* return to system everything is fine... */
1319 pAC
->DiagFlowCtrl
= SK_FALSE
;
1324 netif_stop_queue(dev
);
1326 if (pAC
->RlmtNets
== 1)
1327 PortIdx
= pAC
->ActivePort
;
1329 PortIdx
= pNet
->NetNr
;
1331 StopDrvCleanupTimer(pAC
);
1334 * Clear multicast table, promiscuous mode ....
1336 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
1337 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
1340 if (pAC
->MaxPorts
== 1) {
1341 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1342 /* disable interrupts */
1343 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1344 EvPara
.Para32
[0] = pNet
->NetNr
;
1345 EvPara
.Para32
[1] = -1;
1346 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1347 SkEventDispatcher(pAC
, pAC
->IoBase
);
1348 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1349 /* stop the hardware */
1350 SkGeDeInit(pAC
, pAC
->IoBase
);
1351 pAC
->BoardLevel
= SK_INIT_DATA
;
1352 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1355 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1356 EvPara
.Para32
[0] = pNet
->NetNr
;
1357 EvPara
.Para32
[1] = -1;
1358 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1359 SkPnmiEvent(pAC
, pAC
->IoBase
, SK_PNMI_EVT_XMAC_RESET
, EvPara
);
1360 SkEventDispatcher(pAC
, pAC
->IoBase
);
1361 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1364 spin_lock_irqsave(&pAC
->TxPort
[pNet
->PortNr
]
1365 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1366 SkGeStopPort(pAC
, pAC
->IoBase
, pNet
->PortNr
,
1367 SK_STOP_ALL
, SK_HARD_RST
);
1368 spin_unlock_irqrestore(&pAC
->TxPort
[pNet
->PortNr
]
1369 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1372 if (pAC
->RlmtNets
== 1) {
1373 /* clear all descriptor rings */
1374 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1375 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
1376 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
1377 ClearTxRing(pAC
, &pAC
->TxPort
[i
][TX_PRIO_LOW
]);
1380 /* clear port descriptor rings */
1381 ReceiveIrq(pAC
, &pAC
->RxPort
[pNet
->PortNr
], SK_TRUE
);
1382 ClearRxRing(pAC
, &pAC
->RxPort
[pNet
->PortNr
]);
1383 ClearTxRing(pAC
, &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
]);
1386 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1387 ("SkGeClose: done "));
1389 SK_MEMSET(&(pAC
->PnmiBackup
), 0, sizeof(SK_PNMI_STRUCT_DATA
));
1390 SK_MEMCPY(&(pAC
->PnmiBackup
), &(pAC
->PnmiStruct
),
1391 sizeof(SK_PNMI_STRUCT_DATA
));
1399 /*****************************************************************************
1401 * SkGeXmit - Linux frame transmit function
1404 * The system calls this function to send frames onto the wire.
1405 * It puts the frame in the tx descriptor ring. If the ring is
1406 * full then, the 'tbusy' flag is set.
1409 * 0, if everything is ok
1411 * WARNING: returning 1 in 'tbusy' case caused system crashes (double
1412 * allocated skb's) !!!
1414 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
)
1418 int Rc
; /* return code of XmitFrame */
1420 pNet
= netdev_priv(dev
);
1423 if ((!skb_shinfo(skb
)->nr_frags
) ||
1424 (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
)) {
1425 /* Don't activate scatter-gather and hardware checksum */
1427 if (pAC
->RlmtNets
== 2)
1430 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1435 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1438 /* scatter-gather and hardware TCP checksumming anabled*/
1439 if (pAC
->RlmtNets
== 2)
1442 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1447 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1451 /* Transmitter out of resources? */
1453 netif_stop_queue(dev
);
1456 /* If not taken, give buffer ownership back to the
1462 dev
->trans_start
= jiffies
;
1467 /*****************************************************************************
1469 * XmitFrame - fill one socket buffer into the transmit ring
1472 * This function puts a message into the transmit descriptor ring
1473 * if there is a descriptors left.
1474 * Linux skb's consist of only one continuous buffer.
1475 * The first step locks the ring. It is held locked
1476 * all time to avoid problems with SWITCH_../PORT_RESET.
1477 * Then the descriptoris allocated.
1478 * The second part is linking the buffer to the descriptor.
1479 * At the very last, the Control field of the descriptor
1480 * is made valid for the BMU and a start TX command is given
1484 * > 0 - on succes: the number of bytes in the message
1485 * = 0 - on resource shortage: this frame sent or dropped, now
1486 * the ring is full ( -> set tbusy)
1487 * < 0 - on failure: other problems ( -> return failure to upper layers)
1489 static int XmitFrame(
1490 SK_AC
*pAC
, /* pointer to adapter context */
1491 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1492 struct sk_buff
*pMessage
) /* pointer to send-message */
1494 TXD
*pTxd
; /* the rxd to fill */
1496 unsigned long Flags
;
1498 int BytesSend
= pMessage
->len
;
1500 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
, ("X"));
1502 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1503 #ifndef USE_TX_COMPLETE
1504 FreeTxDescriptors(pAC
, pTxPort
);
1506 if (pTxPort
->TxdRingFree
== 0) {
1508 ** no enough free descriptors in ring at the moment.
1509 ** Maybe free'ing some old one help?
1511 FreeTxDescriptors(pAC
, pTxPort
);
1512 if (pTxPort
->TxdRingFree
== 0) {
1513 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1514 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1515 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1516 SK_DBGCAT_DRV_TX_PROGRESS
,
1517 ("XmitFrame failed\n"));
1519 ** the desired message can not be sent
1520 ** Because tbusy seems to be set, the message
1521 ** should not be freed here. It will be used
1522 ** by the scheduler of the ethernet handler
1529 ** If the passed socket buffer is of smaller MTU-size than 60,
1530 ** copy everything into new buffer and fill all bytes between
1531 ** the original packet end and the new packet end of 60 with 0x00.
1532 ** This is to resolve faulty padding by the HW with 0xaa bytes.
1534 if (BytesSend
< C_LEN_ETHERNET_MINSIZE
) {
1535 if ((pMessage
= skb_padto(pMessage
, C_LEN_ETHERNET_MINSIZE
)) == NULL
) {
1536 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1539 pMessage
->len
= C_LEN_ETHERNET_MINSIZE
;
1543 ** advance head counter behind descriptor needed for this frame,
1544 ** so that needed descriptor is reserved from that on. The next
1545 ** action will be to add the passed buffer to the TX-descriptor
1547 pTxd
= pTxPort
->pTxdRingHead
;
1548 pTxPort
->pTxdRingHead
= pTxd
->pNextTxd
;
1549 pTxPort
->TxdRingFree
--;
1552 DumpMsg(pMessage
, "XmitFrame");
1556 ** First step is to map the data to be sent via the adapter onto
1557 ** the DMA memory. Kernel 2.2 uses virt_to_bus(), but kernels 2.4
1558 ** and 2.6 need to use pci_map_page() for that mapping.
1560 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1561 virt_to_page(pMessage
->data
),
1562 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1565 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1566 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1567 pTxd
->pMBuf
= pMessage
;
1569 if (pMessage
->ip_summed
== CHECKSUM_HW
) {
1570 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1571 u16 offset
= hdrlen
+ pMessage
->csum
;
1573 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1574 (pAC
->GIni
.GIChipRev
== 0) &&
1575 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1576 pTxd
->TBControl
= BMU_TCP_CHECK
;
1578 pTxd
->TBControl
= BMU_UDP_CHECK
;
1581 pTxd
->TcpSumOfs
= 0;
1582 pTxd
->TcpSumSt
= hdrlen
;
1583 pTxd
->TcpSumWr
= offset
;
1585 pTxd
->TBControl
|= BMU_OWN
| BMU_STF
|
1587 #ifdef USE_TX_COMPLETE
1592 pTxd
->TBControl
= BMU_OWN
| BMU_STF
| BMU_CHECK
|
1594 #ifdef USE_TX_COMPLETE
1601 ** If previous descriptor already done, give TX start cmd
1603 pOldTxd
= xchg(&pTxPort
->pTxdRingPrev
, pTxd
);
1604 if ((pOldTxd
->TBControl
& BMU_OWN
) == 0) {
1605 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1609 ** after releasing the lock, the skb may immediately be free'd
1611 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1612 if (pTxPort
->TxdRingFree
!= 0) {
1620 /*****************************************************************************
1622 * XmitFrameSG - fill one socket buffer into the transmit ring
1623 * (use SG and TCP/UDP hardware checksumming)
1626 * This function puts a message into the transmit descriptor ring
1627 * if there is a descriptors left.
1630 * > 0 - on succes: the number of bytes in the message
1631 * = 0 - on resource shortage: this frame sent or dropped, now
1632 * the ring is full ( -> set tbusy)
1633 * < 0 - on failure: other problems ( -> return failure to upper layers)
1635 static int XmitFrameSG(
1636 SK_AC
*pAC
, /* pointer to adapter context */
1637 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1638 struct sk_buff
*pMessage
) /* pointer to send-message */
1646 skb_frag_t
*sk_frag
;
1648 unsigned long Flags
;
1651 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1652 #ifndef USE_TX_COMPLETE
1653 FreeTxDescriptors(pAC
, pTxPort
);
1655 if ((skb_shinfo(pMessage
)->nr_frags
+1) > pTxPort
->TxdRingFree
) {
1656 FreeTxDescriptors(pAC
, pTxPort
);
1657 if ((skb_shinfo(pMessage
)->nr_frags
+ 1) > pTxPort
->TxdRingFree
) {
1658 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1659 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1660 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1661 SK_DBGCAT_DRV_TX_PROGRESS
,
1662 ("XmitFrameSG failed - Ring full\n"));
1663 /* this message can not be sent now */
1668 pTxd
= pTxPort
->pTxdRingHead
;
1674 ** Map the first fragment (header) into the DMA-space
1676 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1677 virt_to_page(pMessage
->data
),
1678 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1679 skb_headlen(pMessage
),
1682 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1683 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1686 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1688 if (pMessage
->ip_summed
== CHECKSUM_HW
) {
1689 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1690 u16 offset
= hdrlen
+ pMessage
->csum
;
1692 Control
= BMU_STFWD
;
1695 ** We have to use the opcode for tcp here, because the
1696 ** opcode for udp is not working in the hardware yet
1699 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1700 (pAC
->GIni
.GIChipRev
== 0) &&
1701 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1702 Control
|= BMU_TCP_CHECK
;
1704 Control
|= BMU_UDP_CHECK
;
1707 pTxd
->TcpSumOfs
= 0;
1708 pTxd
->TcpSumSt
= hdrlen
;
1709 pTxd
->TcpSumWr
= offset
;
1711 Control
= BMU_CHECK
| BMU_SW
;
1713 pTxd
->TBControl
= BMU_STF
| Control
| skb_headlen(pMessage
);
1715 pTxd
= pTxd
->pNextTxd
;
1716 pTxPort
->TxdRingFree
--;
1717 BytesSend
+= skb_headlen(pMessage
);
1720 ** Browse over all SG fragments and map each of them into the DMA space
1722 for (CurrFrag
= 0; CurrFrag
< skb_shinfo(pMessage
)->nr_frags
; CurrFrag
++) {
1723 sk_frag
= &skb_shinfo(pMessage
)->frags
[CurrFrag
];
1725 ** we already have the proper value in entry
1727 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1729 sk_frag
->page_offset
,
1733 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1734 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1735 pTxd
->pMBuf
= pMessage
;
1737 pTxd
->TBControl
= Control
| BMU_OWN
| sk_frag
->size
;;
1740 ** Do we have the last fragment?
1742 if( (CurrFrag
+1) == skb_shinfo(pMessage
)->nr_frags
) {
1743 #ifdef USE_TX_COMPLETE
1744 pTxd
->TBControl
|= BMU_EOF
| BMU_IRQ_EOF
;
1746 pTxd
->TBControl
|= BMU_EOF
;
1748 pTxdFst
->TBControl
|= BMU_OWN
| BMU_SW
;
1751 pTxd
= pTxd
->pNextTxd
;
1752 pTxPort
->TxdRingFree
--;
1753 BytesSend
+= sk_frag
->size
;
1757 ** If previous descriptor already done, give TX start cmd
1759 if ((pTxPort
->pTxdRingPrev
->TBControl
& BMU_OWN
) == 0) {
1760 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1763 pTxPort
->pTxdRingPrev
= pTxdLst
;
1764 pTxPort
->pTxdRingHead
= pTxd
;
1766 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1768 if (pTxPort
->TxdRingFree
> 0) {
1775 /*****************************************************************************
1777 * FreeTxDescriptors - release descriptors from the descriptor ring
1780 * This function releases descriptors from a transmit ring if they
1781 * have been sent by the BMU.
1782 * If a descriptors is sent, it can be freed and the message can
1784 * The SOFTWARE controllable bit is used to prevent running around a
1785 * completely free ring for ever. If this bit is no set in the
1786 * frame (by XmitFrame), this frame has never been sent or is
1788 * The Tx descriptor ring lock must be held while calling this function !!!
1793 static void FreeTxDescriptors(
1794 SK_AC
*pAC
, /* pointer to the adapter context */
1795 TX_PORT
*pTxPort
) /* pointer to destination port structure */
1797 TXD
*pTxd
; /* pointer to the checked descriptor */
1798 TXD
*pNewTail
; /* pointer to 'end' of the ring */
1799 SK_U32 Control
; /* TBControl field of descriptor */
1800 SK_U64 PhysAddr
; /* address of DMA mapping */
1802 pNewTail
= pTxPort
->pTxdRingTail
;
1805 ** loop forever; exits if BMU_SW bit not set in start frame
1806 ** or BMU_OWN bit set in any frame
1809 Control
= pTxd
->TBControl
;
1810 if ((Control
& BMU_SW
) == 0) {
1812 ** software controllable bit is set in first
1813 ** fragment when given to BMU. Not set means that
1814 ** this fragment was never sent or is already
1815 ** freed ( -> ring completely free now).
1817 pTxPort
->pTxdRingTail
= pTxd
;
1818 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1821 if (Control
& BMU_OWN
) {
1822 pTxPort
->pTxdRingTail
= pTxd
;
1823 if (pTxPort
->TxdRingFree
> 0) {
1824 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1830 ** release the DMA mapping, because until not unmapped
1831 ** this buffer is considered being under control of the
1834 PhysAddr
= ((SK_U64
) pTxd
->VDataHigh
) << (SK_U64
) 32;
1835 PhysAddr
|= (SK_U64
) pTxd
->VDataLow
;
1836 pci_unmap_page(pAC
->PciDev
, PhysAddr
,
1840 if (Control
& BMU_EOF
)
1841 DEV_KFREE_SKB_ANY(pTxd
->pMBuf
); /* free message */
1843 pTxPort
->TxdRingFree
++;
1844 pTxd
->TBControl
&= ~BMU_SW
;
1845 pTxd
= pTxd
->pNextTxd
; /* point behind fragment with EOF */
1846 } /* while(forever) */
1847 } /* FreeTxDescriptors */
1849 /*****************************************************************************
1851 * FillRxRing - fill the receive ring with valid descriptors
1854 * This function fills the receive ring descriptors with data
1855 * segments and makes them valid for the BMU.
1856 * The active ring is filled completely, if possible.
1857 * The non-active ring is filled only partial to save memory.
1859 * Description of rx ring structure:
1860 * head - points to the descriptor which will be used next by the BMU
1861 * tail - points to the next descriptor to give to the BMU
1865 static void FillRxRing(
1866 SK_AC
*pAC
, /* pointer to the adapter context */
1867 RX_PORT
*pRxPort
) /* ptr to port struct for which the ring
1870 unsigned long Flags
;
1872 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
1873 while (pRxPort
->RxdRingFree
> pRxPort
->RxFillLimit
) {
1874 if(!FillRxDescriptor(pAC
, pRxPort
))
1877 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
1881 /*****************************************************************************
1883 * FillRxDescriptor - fill one buffer into the receive ring
1886 * The function allocates a new receive buffer and
1887 * puts it into the next descriptor.
1890 * SK_TRUE - a buffer was added to the ring
1891 * SK_FALSE - a buffer could not be added
1893 static SK_BOOL
FillRxDescriptor(
1894 SK_AC
*pAC
, /* pointer to the adapter context struct */
1895 RX_PORT
*pRxPort
) /* ptr to port struct of ring to fill */
1897 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
1898 RXD
*pRxd
; /* the rxd to fill */
1899 SK_U16 Length
; /* data fragment length */
1900 SK_U64 PhysAddr
; /* physical address of a rx buffer */
1902 pMsgBlock
= alloc_skb(pAC
->RxBufSize
, GFP_ATOMIC
);
1903 if (pMsgBlock
== NULL
) {
1904 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1905 SK_DBGCAT_DRV_ENTRY
,
1906 ("%s: Allocation of rx buffer failed !\n",
1907 pAC
->dev
[pRxPort
->PortIndex
]->name
));
1908 SK_PNMI_CNT_NO_RX_BUF(pAC
, pRxPort
->PortIndex
);
1911 skb_reserve(pMsgBlock
, 2); /* to align IP frames */
1912 /* skb allocated ok, so add buffer */
1913 pRxd
= pRxPort
->pRxdRingTail
;
1914 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1915 pRxPort
->RxdRingFree
--;
1916 Length
= pAC
->RxBufSize
;
1917 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1918 virt_to_page(pMsgBlock
->data
),
1919 ((unsigned long) pMsgBlock
->data
&
1922 PCI_DMA_FROMDEVICE
);
1924 pRxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1925 pRxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1926 pRxd
->pMBuf
= pMsgBlock
;
1927 pRxd
->RBControl
= BMU_OWN
|
1934 } /* FillRxDescriptor */
1937 /*****************************************************************************
1939 * ReQueueRxBuffer - fill one buffer back into the receive ring
1942 * Fill a given buffer back into the rx ring. The buffer
1943 * has been previously allocated and aligned, and its phys.
1944 * address calculated, so this is no more necessary.
1948 static void ReQueueRxBuffer(
1949 SK_AC
*pAC
, /* pointer to the adapter context struct */
1950 RX_PORT
*pRxPort
, /* ptr to port struct of ring to fill */
1951 struct sk_buff
*pMsg
, /* pointer to the buffer */
1952 SK_U32 PhysHigh
, /* phys address high dword */
1953 SK_U32 PhysLow
) /* phys address low dword */
1955 RXD
*pRxd
; /* the rxd to fill */
1956 SK_U16 Length
; /* data fragment length */
1958 pRxd
= pRxPort
->pRxdRingTail
;
1959 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1960 pRxPort
->RxdRingFree
--;
1961 Length
= pAC
->RxBufSize
;
1963 pRxd
->VDataLow
= PhysLow
;
1964 pRxd
->VDataHigh
= PhysHigh
;
1966 pRxd
->RBControl
= BMU_OWN
|
1972 } /* ReQueueRxBuffer */
1974 /*****************************************************************************
1976 * ReceiveIrq - handle a receive IRQ
1979 * This function is called when a receive IRQ is set.
1980 * It walks the receive descriptor ring and sends up all
1981 * frames that are complete.
1985 static void ReceiveIrq(
1986 SK_AC
*pAC
, /* pointer to adapter context */
1987 RX_PORT
*pRxPort
, /* pointer to receive port struct */
1988 SK_BOOL SlowPathLock
) /* indicates if SlowPathLock is needed */
1990 RXD
*pRxd
; /* pointer to receive descriptors */
1991 SK_U32 Control
; /* control field of descriptor */
1992 struct sk_buff
*pMsg
; /* pointer to message holding frame */
1993 struct sk_buff
*pNewMsg
; /* pointer to a new message for copying frame */
1994 int FrameLength
; /* total length of received frame */
1995 SK_MBUF
*pRlmtMbuf
; /* ptr to a buffer for giving a frame to rlmt */
1996 SK_EVPARA EvPara
; /* an event parameter union */
1997 unsigned long Flags
; /* for spin lock */
1998 int PortIndex
= pRxPort
->PortIndex
;
1999 unsigned int Offset
;
2000 unsigned int NumBytes
;
2001 unsigned int ForRlmt
;
2004 SK_BOOL IsBadFrame
; /* Bad frame */
2010 /* do forever; exit if BMU_OWN found */
2011 for ( pRxd
= pRxPort
->pRxdRingHead
;
2012 pRxPort
->RxdRingFree
< pAC
->RxDescrPerRing
;
2013 pRxd
= pRxd
->pNextRxd
,
2014 pRxPort
->pRxdRingHead
= pRxd
,
2015 pRxPort
->RxdRingFree
++) {
2018 * For a better understanding of this loop
2019 * Go through every descriptor beginning at the head
2020 * Please note: the ring might be completely received so the OWN bit
2021 * set is not a good crirteria to leave that loop.
2022 * Therefore the RingFree counter is used.
2023 * On entry of this loop pRxd is a pointer to the Rxd that needs
2024 * to be checked next.
2027 Control
= pRxd
->RBControl
;
2029 /* check if this descriptor is ready */
2030 if ((Control
& BMU_OWN
) != 0) {
2031 /* this descriptor is not yet ready */
2032 /* This is the usual end of the loop */
2033 /* We don't need to start the ring again */
2034 FillRxRing(pAC
, pRxPort
);
2037 pAC
->DynIrqModInfo
.NbrProcessedDescr
++;
2039 /* get length of frame and check it */
2040 FrameLength
= Control
& BMU_BBC
;
2041 if (FrameLength
> pAC
->RxBufSize
) {
2045 /* check for STF and EOF */
2046 if ((Control
& (BMU_STF
| BMU_EOF
)) != (BMU_STF
| BMU_EOF
)) {
2050 /* here we have a complete frame in the ring */
2053 FrameStat
= pRxd
->FrameStat
;
2055 /* check for frame length mismatch */
2056 #define XMR_FS_LEN_SHIFT 18
2057 #define GMR_FS_LEN_SHIFT 16
2058 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2059 if (FrameLength
!= (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)) {
2060 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2061 SK_DBGCAT_DRV_RX_PROGRESS
,
2062 ("skge: Frame length mismatch (%u/%u).\n",
2064 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2069 if (FrameLength
!= (SK_U32
) (FrameStat
>> GMR_FS_LEN_SHIFT
)) {
2070 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2071 SK_DBGCAT_DRV_RX_PROGRESS
,
2072 ("skge: Frame length mismatch (%u/%u).\n",
2074 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2080 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2081 IsBc
= (FrameStat
& XMR_FS_BC
) != 0;
2082 IsMc
= (FrameStat
& XMR_FS_MC
) != 0;
2083 IsBadFrame
= (FrameStat
&
2084 (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0;
2086 IsBc
= (FrameStat
& GMR_FS_BC
) != 0;
2087 IsMc
= (FrameStat
& GMR_FS_MC
) != 0;
2088 IsBadFrame
= (((FrameStat
& GMR_FS_ANY_ERR
) != 0) ||
2089 ((FrameStat
& GMR_FS_RX_OK
) == 0));
2092 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2093 ("Received frame of length %d on port %d\n",
2094 FrameLength
, PortIndex
));
2095 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2096 ("Number of free rx descriptors: %d\n",
2097 pRxPort
->RxdRingFree
));
2098 /* DumpMsg(pMsg, "Rx"); */
2100 if ((Control
& BMU_STAT_VAL
) != BMU_STAT_VAL
|| (IsBadFrame
)) {
2102 (FrameStat
& (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0) {
2104 /* there is a receive error in this frame */
2105 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2106 SK_DBGCAT_DRV_RX_PROGRESS
,
2107 ("skge: Error in received frame, dropped!\n"
2108 "Control: %x\nRxStat: %x\n",
2109 Control
, FrameStat
));
2111 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2112 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2118 * if short frame then copy data to reduce memory waste
2120 if ((FrameLength
< SK_COPY_THRESHOLD
) &&
2121 ((pNewMsg
= alloc_skb(FrameLength
+2, GFP_ATOMIC
)) != NULL
)) {
2123 * Short frame detected and allocation successfull
2125 /* use new skb and copy data */
2126 skb_reserve(pNewMsg
, 2);
2127 skb_put(pNewMsg
, FrameLength
);
2128 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2129 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2131 pci_dma_sync_single_for_cpu(pAC
->PciDev
,
2132 (dma_addr_t
) PhysAddr
,
2134 PCI_DMA_FROMDEVICE
);
2135 memcpy(pNewMsg
->data
, pMsg
, FrameLength
);
2137 pci_dma_sync_single_for_device(pAC
->PciDev
,
2138 (dma_addr_t
) PhysAddr
,
2140 PCI_DMA_FROMDEVICE
);
2141 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2142 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2149 * if large frame, or SKB allocation failed, pass
2150 * the SKB directly to the networking
2153 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2154 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2156 /* release the DMA mapping */
2157 pci_unmap_single(pAC
->PciDev
,
2160 PCI_DMA_FROMDEVICE
);
2162 /* set length in message */
2163 skb_put(pMsg
, FrameLength
);
2164 } /* frame > SK_COPY_TRESHOLD */
2166 #ifdef USE_SK_RX_CHECKSUM
2167 pMsg
->csum
= pRxd
->TcpSums
& 0xffff;
2168 pMsg
->ip_summed
= CHECKSUM_HW
;
2170 pMsg
->ip_summed
= CHECKSUM_NONE
;
2173 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("V"));
2174 ForRlmt
= SK_RLMT_RX_PROTOCOL
;
2176 IsBc
= (FrameStat
& XMR_FS_BC
)==XMR_FS_BC
;
2178 SK_RLMT_PRE_LOOKAHEAD(pAC
, PortIndex
, FrameLength
,
2179 IsBc
, &Offset
, &NumBytes
);
2180 if (NumBytes
!= 0) {
2182 IsMc
= (FrameStat
& XMR_FS_MC
)==XMR_FS_MC
;
2184 SK_RLMT_LOOKAHEAD(pAC
, PortIndex
,
2185 &pMsg
->data
[Offset
],
2186 IsBc
, IsMc
, &ForRlmt
);
2188 if (ForRlmt
== SK_RLMT_RX_PROTOCOL
) {
2189 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("W"));
2190 /* send up only frames from active port */
2191 if ((PortIndex
== pAC
->ActivePort
) ||
2192 (pAC
->RlmtNets
== 2)) {
2193 /* frame for upper layer */
2194 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("U"));
2196 DumpMsg(pMsg
, "Rx");
2198 SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC
,
2199 FrameLength
, pRxPort
->PortIndex
);
2201 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2202 pMsg
->protocol
= eth_type_trans(pMsg
,
2203 pAC
->dev
[pRxPort
->PortIndex
]);
2205 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2209 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2210 SK_DBGCAT_DRV_RX_PROGRESS
,
2212 DEV_KFREE_SKB(pMsg
);
2215 } /* if not for rlmt */
2217 /* packet for rlmt */
2218 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2219 SK_DBGCAT_DRV_RX_PROGRESS
, ("R"));
2220 pRlmtMbuf
= SkDrvAllocRlmtMbuf(pAC
,
2221 pAC
->IoBase
, FrameLength
);
2222 if (pRlmtMbuf
!= NULL
) {
2223 pRlmtMbuf
->pNext
= NULL
;
2224 pRlmtMbuf
->Length
= FrameLength
;
2225 pRlmtMbuf
->PortIdx
= PortIndex
;
2226 EvPara
.pParaPtr
= pRlmtMbuf
;
2227 memcpy((char*)(pRlmtMbuf
->pData
),
2228 (char*)(pMsg
->data
),
2231 /* SlowPathLock needed? */
2232 if (SlowPathLock
== SK_TRUE
) {
2233 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2234 SkEventQueue(pAC
, SKGE_RLMT
,
2235 SK_RLMT_PACKET_RECEIVED
,
2237 pAC
->CheckQueue
= SK_TRUE
;
2238 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2240 SkEventQueue(pAC
, SKGE_RLMT
,
2241 SK_RLMT_PACKET_RECEIVED
,
2243 pAC
->CheckQueue
= SK_TRUE
;
2246 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2247 SK_DBGCAT_DRV_RX_PROGRESS
,
2250 if ((pAC
->dev
[pRxPort
->PortIndex
]->flags
&
2251 (IFF_PROMISC
| IFF_ALLMULTI
)) != 0 ||
2252 (ForRlmt
& SK_RLMT_RX_PROTOCOL
) ==
2253 SK_RLMT_RX_PROTOCOL
) {
2254 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2255 pMsg
->protocol
= eth_type_trans(pMsg
,
2256 pAC
->dev
[pRxPort
->PortIndex
]);
2258 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2261 DEV_KFREE_SKB(pMsg
);
2264 } /* if packet for rlmt */
2265 } /* for ... scanning the RXD ring */
2267 /* RXD ring is empty -> fill and restart */
2268 FillRxRing(pAC
, pRxPort
);
2269 /* do not start if called from Close */
2270 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
2271 ClearAndStartRx(pAC
, PortIndex
);
2276 /* remove error frame */
2277 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ERROR
,
2278 ("Schrottdescriptor, length: 0x%x\n", FrameLength
));
2280 /* release the DMA mapping */
2282 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2283 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2284 pci_unmap_page(pAC
->PciDev
,
2287 PCI_DMA_FROMDEVICE
);
2288 DEV_KFREE_SKB_IRQ(pRxd
->pMBuf
);
2290 pRxPort
->RxdRingFree
++;
2291 pRxPort
->pRxdRingHead
= pRxd
->pNextRxd
;
2297 /*****************************************************************************
2299 * ClearAndStartRx - give a start receive command to BMU, clear IRQ
2302 * This function sends a start command and a clear interrupt
2303 * command for one receive queue to the BMU.
2308 static void ClearAndStartRx(
2309 SK_AC
*pAC
, /* pointer to the adapter context */
2310 int PortIndex
) /* index of the receive port (XMAC) */
2312 SK_OUT8(pAC
->IoBase
,
2313 RxQueueAddr
[PortIndex
]+Q_CSR
,
2314 CSR_START
| CSR_IRQ_CL_F
);
2315 } /* ClearAndStartRx */
2318 /*****************************************************************************
2320 * ClearTxIrq - give a clear transmit IRQ command to BMU
2323 * This function sends a clear tx IRQ command for one
2324 * transmit queue to the BMU.
2328 static void ClearTxIrq(
2329 SK_AC
*pAC
, /* pointer to the adapter context */
2330 int PortIndex
, /* index of the transmit port (XMAC) */
2331 int Prio
) /* priority or normal queue */
2333 SK_OUT8(pAC
->IoBase
,
2334 TxQueueAddr
[PortIndex
][Prio
]+Q_CSR
,
2339 /*****************************************************************************
2341 * ClearRxRing - remove all buffers from the receive ring
2344 * This function removes all receive buffers from the ring.
2345 * The receive BMU must be stopped before calling this function.
2349 static void ClearRxRing(
2350 SK_AC
*pAC
, /* pointer to adapter context */
2351 RX_PORT
*pRxPort
) /* pointer to rx port struct */
2353 RXD
*pRxd
; /* pointer to the current descriptor */
2354 unsigned long Flags
;
2357 if (pRxPort
->RxdRingFree
== pAC
->RxDescrPerRing
) {
2360 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
2361 pRxd
= pRxPort
->pRxdRingHead
;
2363 if (pRxd
->pMBuf
!= NULL
) {
2365 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2366 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2367 pci_unmap_page(pAC
->PciDev
,
2370 PCI_DMA_FROMDEVICE
);
2371 DEV_KFREE_SKB(pRxd
->pMBuf
);
2374 pRxd
->RBControl
&= BMU_OWN
;
2375 pRxd
= pRxd
->pNextRxd
;
2376 pRxPort
->RxdRingFree
++;
2377 } while (pRxd
!= pRxPort
->pRxdRingTail
);
2378 pRxPort
->pRxdRingTail
= pRxPort
->pRxdRingHead
;
2379 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
2382 /*****************************************************************************
2384 * ClearTxRing - remove all buffers from the transmit ring
2387 * This function removes all transmit buffers from the ring.
2388 * The transmit BMU must be stopped before calling this function
2389 * and transmitting at the upper level must be disabled.
2390 * The BMU own bit of all descriptors is cleared, the rest is
2391 * done by calling FreeTxDescriptors.
2395 static void ClearTxRing(
2396 SK_AC
*pAC
, /* pointer to adapter context */
2397 TX_PORT
*pTxPort
) /* pointer to tx prt struct */
2399 TXD
*pTxd
; /* pointer to the current descriptor */
2401 unsigned long Flags
;
2403 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
2404 pTxd
= pTxPort
->pTxdRingHead
;
2405 for (i
=0; i
<pAC
->TxDescrPerRing
; i
++) {
2406 pTxd
->TBControl
&= ~BMU_OWN
;
2407 pTxd
= pTxd
->pNextTxd
;
2409 FreeTxDescriptors(pAC
, pTxPort
);
2410 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
2413 /*****************************************************************************
2415 * SkGeSetMacAddr - Set the hardware MAC address
2418 * This function sets the MAC address used by the adapter.
2421 * 0, if everything is ok
2424 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
)
2427 DEV_NET
*pNet
= netdev_priv(dev
);
2428 SK_AC
*pAC
= pNet
->pAC
;
2430 struct sockaddr
*addr
= p
;
2431 unsigned long Flags
;
2433 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2434 ("SkGeSetMacAddr starts now...\n"));
2435 if(netif_running(dev
))
2438 memcpy(dev
->dev_addr
, addr
->sa_data
,dev
->addr_len
);
2440 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2442 if (pAC
->RlmtNets
== 2)
2443 SkAddrOverride(pAC
, pAC
->IoBase
, pNet
->NetNr
,
2444 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2446 SkAddrOverride(pAC
, pAC
->IoBase
, pAC
->ActivePort
,
2447 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2451 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2453 } /* SkGeSetMacAddr */
2456 /*****************************************************************************
2458 * SkGeSetRxMode - set receive mode
2461 * This function sets the receive mode of an adapter. The adapter
2462 * supports promiscuous mode, allmulticast mode and a number of
2463 * multicast addresses. If more multicast addresses the available
2464 * are selected, a hash function in the hardware is used.
2467 * 0, if everything is ok
2470 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
)
2476 struct dev_mc_list
*pMcList
;
2479 unsigned long Flags
;
2481 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2482 ("SkGeSetRxMode starts now... "));
2484 pNet
= netdev_priv(dev
);
2486 if (pAC
->RlmtNets
== 1)
2487 PortIdx
= pAC
->ActivePort
;
2489 PortIdx
= pNet
->NetNr
;
2491 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2492 if (dev
->flags
& IFF_PROMISC
) {
2493 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2494 ("PROMISCUOUS mode\n"));
2495 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2497 } else if (dev
->flags
& IFF_ALLMULTI
) {
2498 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2499 ("ALLMULTI mode\n"));
2500 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2501 SK_PROM_MODE_ALL_MC
);
2503 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2505 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
2507 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2508 ("Number of MC entries: %d ", dev
->mc_count
));
2510 pMcList
= dev
->mc_list
;
2511 for (i
=0; i
<dev
->mc_count
; i
++, pMcList
= pMcList
->next
) {
2512 SkAddrMcAdd(pAC
, pAC
->IoBase
, PortIdx
,
2513 (SK_MAC_ADDR
*)pMcList
->dmi_addr
, 0);
2514 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_MCA
,
2515 ("%02x:%02x:%02x:%02x:%02x:%02x\n",
2516 pMcList
->dmi_addr
[0],
2517 pMcList
->dmi_addr
[1],
2518 pMcList
->dmi_addr
[2],
2519 pMcList
->dmi_addr
[3],
2520 pMcList
->dmi_addr
[4],
2521 pMcList
->dmi_addr
[5]));
2523 SkAddrMcUpdate(pAC
, pAC
->IoBase
, PortIdx
);
2525 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2528 } /* SkGeSetRxMode */
2531 /*****************************************************************************
2533 * SkGeChangeMtu - set the MTU to another value
2536 * This function sets is called whenever the MTU size is changed
2537 * (ifconfig mtu xxx dev ethX). If the MTU is bigger than standard
2538 * ethernet MTU size, long frame support is activated.
2541 * 0, if everything is ok
2544 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int NewMtu
)
2547 struct net_device
*pOtherDev
;
2549 unsigned long Flags
;
2553 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2554 ("SkGeChangeMtu starts now...\n"));
2556 pNet
= netdev_priv(dev
);
2559 if ((NewMtu
< 68) || (NewMtu
> SK_JUMBO_MTU
)) {
2563 if(pAC
->BoardLevel
!= SK_INIT_RUN
) {
2567 #ifdef SK_DIAG_SUPPORT
2568 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
2569 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
2570 return -1; /* still in use, deny any actions of MTU */
2572 pAC
->DiagFlowCtrl
= SK_FALSE
;
2577 pOtherDev
= pAC
->dev
[1 - pNet
->NetNr
];
2579 if ( netif_running(pOtherDev
) && (pOtherDev
->mtu
> 1500)
2580 && (NewMtu
<= 1500))
2583 pAC
->RxBufSize
= NewMtu
+ 32;
2586 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2587 ("New MTU: %d\n", NewMtu
));
2590 ** Prevent any reconfiguration while changing the MTU
2591 ** by disabling any interrupts
2593 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
2594 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2597 ** Notify RLMT that any ports are to be stopped
2599 EvPara
.Para32
[0] = 0;
2600 EvPara
.Para32
[1] = -1;
2601 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2602 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2603 EvPara
.Para32
[0] = 1;
2604 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2606 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2610 ** After calling the SkEventDispatcher(), RLMT is aware about
2611 ** the stopped ports -> configuration can take place!
2613 SkEventDispatcher(pAC
, pAC
->IoBase
);
2615 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2616 spin_lock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2617 netif_stop_queue(pAC
->dev
[i
]);
2622 ** Depending on the desired MTU size change, a different number of
2623 ** RX buffers need to be allocated
2625 if (NewMtu
> 1500) {
2627 ** Use less rx buffers
2629 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2630 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2631 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2632 (pAC
->RxDescrPerRing
/ 4);
2634 if (i
== pAC
->ActivePort
) {
2635 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2636 (pAC
->RxDescrPerRing
/ 4);
2638 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2639 (pAC
->RxDescrPerRing
/ 10);
2645 ** Use the normal amount of rx buffers
2647 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2648 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2649 pAC
->RxPort
[i
].RxFillLimit
= 1;
2651 if (i
== pAC
->ActivePort
) {
2652 pAC
->RxPort
[i
].RxFillLimit
= 1;
2654 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2655 (pAC
->RxDescrPerRing
/ 4);
2661 SkGeDeInit(pAC
, pAC
->IoBase
);
2664 ** enable/disable hardware support for long frames
2666 if (NewMtu
> 1500) {
2667 // pAC->JumboActivated = SK_TRUE; /* is never set back !!! */
2668 pAC
->GIni
.GIPortUsage
= SK_JUMBO_LINK
;
2670 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2671 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
2673 pAC
->GIni
.GIPortUsage
= SK_RED_LINK
;
2677 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2678 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2679 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2680 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2681 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2682 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2683 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2687 ** Speed and others are set back to default in level 1 init!
2689 GetConfiguration(pAC
);
2691 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2692 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2693 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2694 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2695 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2696 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2697 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2700 ** clear and reinit the rx rings here
2702 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2703 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
2704 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
2705 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2708 ** Enable transmit descriptor polling
2710 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
2711 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2714 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
2715 SkDimEnableModerationIfNeeded(pAC
);
2716 SkDimDisplayModerationSettings(pAC
);
2718 netif_start_queue(pAC
->dev
[pNet
->PortNr
]);
2719 for (i
=pAC
->GIni
.GIMacsFound
-1; i
>=0; i
--) {
2720 spin_unlock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2724 ** Enable Interrupts again
2726 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
2727 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
2729 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2730 SkEventDispatcher(pAC
, pAC
->IoBase
);
2733 ** Notify RLMT about the changing and restarting one (or more) ports
2735 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2736 EvPara
.Para32
[0] = pAC
->RlmtNets
;
2737 EvPara
.Para32
[1] = -1;
2738 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
, EvPara
);
2739 EvPara
.Para32
[0] = pNet
->PortNr
;
2740 EvPara
.Para32
[1] = -1;
2741 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2743 if (netif_running(pOtherDev
)) {
2744 DEV_NET
*pOtherNet
= netdev_priv(pOtherDev
);
2745 EvPara
.Para32
[0] = pOtherNet
->PortNr
;
2746 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2749 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2752 SkEventDispatcher(pAC
, pAC
->IoBase
);
2753 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2756 ** While testing this driver with latest kernel 2.5 (2.5.70), it
2757 ** seems as if upper layers have a problem to handle a successful
2758 ** return value of '0'. If such a zero is returned, the complete
2759 ** system hangs for several minutes (!), which is in acceptable.
2761 ** Currently it is not clear, what the exact reason for this problem
2762 ** is. The implemented workaround for 2.5 is to return the desired
2763 ** new MTU size if all needed changes for the new MTU size where
2764 ** performed. In kernels 2.2 and 2.4, a zero value is returned,
2765 ** which indicates the successful change of the mtu-size.
2769 } /* SkGeChangeMtu */
2772 /*****************************************************************************
2774 * SkGeStats - return ethernet device statistics
2777 * This function return statistic data about the ethernet device
2778 * to the operating system.
2781 * pointer to the statistic structure.
2783 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
)
2785 DEV_NET
*pNet
= netdev_priv(dev
);
2786 SK_AC
*pAC
= pNet
->pAC
;
2787 SK_PNMI_STRUCT_DATA
*pPnmiStruct
; /* structure for all Pnmi-Data */
2788 SK_PNMI_STAT
*pPnmiStat
; /* pointer to virtual XMAC stat. data */
2789 SK_PNMI_CONF
*pPnmiConf
; /* pointer to virtual link config. */
2790 unsigned int Size
; /* size of pnmi struct */
2791 unsigned long Flags
; /* for spin lock */
2793 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2794 ("SkGeStats starts now...\n"));
2795 pPnmiStruct
= &pAC
->PnmiStruct
;
2797 #ifdef SK_DIAG_SUPPORT
2798 if ((pAC
->DiagModeActive
== DIAG_NOTACTIVE
) &&
2799 (pAC
->BoardLevel
== SK_INIT_RUN
)) {
2801 SK_MEMSET(pPnmiStruct
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
2802 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2803 Size
= SK_PNMI_STRUCT_SIZE
;
2804 SkPnmiGetStruct(pAC
, pAC
->IoBase
, pPnmiStruct
, &Size
, pNet
->NetNr
);
2805 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2806 #ifdef SK_DIAG_SUPPORT
2810 pPnmiStat
= &pPnmiStruct
->Stat
[0];
2811 pPnmiConf
= &pPnmiStruct
->Conf
[0];
2813 pAC
->stats
.rx_packets
= (SK_U32
) pPnmiStruct
->RxDeliveredCts
& 0xFFFFFFFF;
2814 pAC
->stats
.tx_packets
= (SK_U32
) pPnmiStat
->StatTxOkCts
& 0xFFFFFFFF;
2815 pAC
->stats
.rx_bytes
= (SK_U32
) pPnmiStruct
->RxOctetsDeliveredCts
;
2816 pAC
->stats
.tx_bytes
= (SK_U32
) pPnmiStat
->StatTxOctetsOkCts
;
2818 if (dev
->mtu
<= 1500) {
2819 pAC
->stats
.rx_errors
= (SK_U32
) pPnmiStruct
->InErrorsCts
& 0xFFFFFFFF;
2821 pAC
->stats
.rx_errors
= (SK_U32
) ((pPnmiStruct
->InErrorsCts
-
2822 pPnmiStat
->StatRxTooLongCts
) & 0xFFFFFFFF);
2826 if (pAC
->GIni
.GP
[0].PhyType
== SK_PHY_XMAC
&& pAC
->HWRevision
< 12)
2827 pAC
->stats
.rx_errors
= pAC
->stats
.rx_errors
- pPnmiStat
->StatRxShortsCts
;
2829 pAC
->stats
.tx_errors
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2830 pAC
->stats
.rx_dropped
= (SK_U32
) pPnmiStruct
->RxNoBufCts
& 0xFFFFFFFF;
2831 pAC
->stats
.tx_dropped
= (SK_U32
) pPnmiStruct
->TxNoBufCts
& 0xFFFFFFFF;
2832 pAC
->stats
.multicast
= (SK_U32
) pPnmiStat
->StatRxMulticastOkCts
& 0xFFFFFFFF;
2833 pAC
->stats
.collisions
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2835 /* detailed rx_errors: */
2836 pAC
->stats
.rx_length_errors
= (SK_U32
) pPnmiStat
->StatRxRuntCts
& 0xFFFFFFFF;
2837 pAC
->stats
.rx_over_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2838 pAC
->stats
.rx_crc_errors
= (SK_U32
) pPnmiStat
->StatRxFcsCts
& 0xFFFFFFFF;
2839 pAC
->stats
.rx_frame_errors
= (SK_U32
) pPnmiStat
->StatRxFramingCts
& 0xFFFFFFFF;
2840 pAC
->stats
.rx_fifo_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2841 pAC
->stats
.rx_missed_errors
= (SK_U32
) pPnmiStat
->StatRxMissedCts
& 0xFFFFFFFF;
2843 /* detailed tx_errors */
2844 pAC
->stats
.tx_aborted_errors
= (SK_U32
) 0;
2845 pAC
->stats
.tx_carrier_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2846 pAC
->stats
.tx_fifo_errors
= (SK_U32
) pPnmiStat
->StatTxFifoUnderrunCts
& 0xFFFFFFFF;
2847 pAC
->stats
.tx_heartbeat_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2848 pAC
->stats
.tx_window_errors
= (SK_U32
) 0;
2850 return(&pAC
->stats
);
2854 /*****************************************************************************
2856 * SkGeIoctl - IO-control function
2859 * This function is called if an ioctl is issued on the device.
2860 * There are three subfunction for reading, writing and test-writing
2861 * the private MIB data structure (usefull for SysKonnect-internal tools).
2864 * 0, if everything is ok
2867 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
)
2872 struct pci_dev
*pdev
= NULL
;
2874 unsigned int Err
= 0;
2877 unsigned int Length
= 0;
2878 int HeaderLength
= sizeof(SK_U32
) + sizeof(SK_U32
);
2880 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2881 ("SkGeIoctl starts now...\n"));
2883 pNet
= netdev_priv(dev
);
2886 if(copy_from_user(&Ioctl
, rq
->ifr_data
, sizeof(SK_GE_IOCTL
))) {
2891 case SK_IOCTL_SETMIB
:
2892 case SK_IOCTL_PRESETMIB
:
2893 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2894 case SK_IOCTL_GETMIB
:
2895 if(copy_from_user(&pAC
->PnmiStruct
, Ioctl
.pData
,
2896 Ioctl
.Len
<sizeof(pAC
->PnmiStruct
)?
2897 Ioctl
.Len
: sizeof(pAC
->PnmiStruct
))) {
2900 Size
= SkGeIocMib(pNet
, Ioctl
.Len
, cmd
);
2901 if(copy_to_user(Ioctl
.pData
, &pAC
->PnmiStruct
,
2902 Ioctl
.Len
<Size
? Ioctl
.Len
: Size
)) {
2906 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2911 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2914 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2916 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2919 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2923 if ((Ret
= SkPnmiGenIoctl(pAC
, pAC
->IoBase
, pMemBuf
, &Length
, 0)) < 0) {
2927 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2932 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2937 kfree(pMemBuf
); /* cleanup everything */
2939 #ifdef SK_DIAG_SUPPORT
2941 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2942 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2945 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2947 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2950 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2955 Length
= 3 * sizeof(SK_U32
); /* Error, Bus and Device */
2957 ** While coding this new IOCTL interface, only a few lines of code
2958 ** are to to be added. Therefore no dedicated function has been
2959 ** added. If more functionality is added, a separate function
2960 ** should be used...
2962 * ((SK_U32
*)pMemBuf
) = 0;
2963 * ((SK_U32
*)pMemBuf
+ 1) = pdev
->bus
->number
;
2964 * ((SK_U32
*)pMemBuf
+ 2) = ParseDeviceNbrFromSlotName(pci_name(pdev
));
2965 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2970 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2975 kfree(pMemBuf
); /* cleanup everything */
2987 /*****************************************************************************
2989 * SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message
2992 * This function reads/writes the MIB data using PNMI (Private Network
2993 * Management Interface).
2994 * The destination for the data must be provided with the
2995 * ioctl call and is given to the driver in the form of
2996 * a user space address.
2997 * Copying from the user-provided data area into kernel messages
2998 * and back is done by copy_from_user and copy_to_user calls in
3002 * returned size from PNMI call
3004 static int SkGeIocMib(
3005 DEV_NET
*pNet
, /* pointer to the adapter context */
3006 unsigned int Size
, /* length of ioctl data */
3007 int mode
) /* flag for set/preset */
3009 unsigned long Flags
; /* for spin lock */
3012 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3013 ("SkGeIocMib starts now...\n"));
3016 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3018 case SK_IOCTL_GETMIB
:
3019 SkPnmiGetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3022 case SK_IOCTL_PRESETMIB
:
3023 SkPnmiPreSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3026 case SK_IOCTL_SETMIB
:
3027 SkPnmiSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3033 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3034 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3035 ("MIB data access succeeded\n"));
3040 /*****************************************************************************
3042 * GetConfiguration - read configuration information
3045 * This function reads per-adapter configuration information from
3046 * the options provided on the command line.
3051 static void GetConfiguration(
3052 SK_AC
*pAC
) /* pointer to the adapter context structure */
3054 SK_I32 Port
; /* preferred port */
3057 int LinkSpeed
= SK_LSPEED_AUTO
; /* Link speed */
3058 int AutoNeg
= 1; /* autoneg off (0) or on (1) */
3059 int DuplexCap
= 0; /* 0=both,1=full,2=half */
3060 int FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
; /* FlowControl */
3061 int MSMode
= SK_MS_MODE_AUTO
; /* master/slave mode */
3063 SK_BOOL IsConTypeDefined
= SK_TRUE
;
3064 SK_BOOL IsLinkSpeedDefined
= SK_TRUE
;
3065 SK_BOOL IsFlowCtrlDefined
= SK_TRUE
;
3066 SK_BOOL IsRoleDefined
= SK_TRUE
;
3067 SK_BOOL IsModeDefined
= SK_TRUE
;
3069 * The two parameters AutoNeg. and DuplexCap. map to one configuration
3070 * parameter. The mapping is described by this table:
3071 * DuplexCap -> | both | full | half |
3073 * -----------------------------------------------------------------
3074 * Off | illegal | Full | Half |
3075 * -----------------------------------------------------------------
3076 * On | AutoBoth | AutoFull | AutoHalf |
3077 * -----------------------------------------------------------------
3078 * Sense | AutoSense | AutoSense | AutoSense |
3080 int Capabilities
[3][3] =
3081 { { -1, SK_LMODE_FULL
, SK_LMODE_HALF
},
3082 {SK_LMODE_AUTOBOTH
, SK_LMODE_AUTOFULL
, SK_LMODE_AUTOHALF
},
3083 {SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
} };
3091 #define M_CurrPort pAC->GIni.GP[Port]
3095 ** Set the default values first for both ports!
3097 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3098 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3099 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3100 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3101 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3105 ** Check merged parameter ConType. If it has not been used,
3106 ** verify any other parameter (e.g. AutoNeg) and use default values.
3108 ** Stating both ConType and other lowlevel link parameters is also
3109 ** possible. If this is the case, the passed ConType-parameter is
3110 ** overwritten by the lowlevel link parameter.
3112 ** The following settings are used for a merged ConType-parameter:
3114 ** ConType DupCap AutoNeg FlowCtrl Role Speed
3115 ** ------- ------ ------- -------- ---------- -----
3116 ** Auto Both On SymOrRem Auto Auto
3117 ** 100FD Full Off None <ignored> 100
3118 ** 100HD Half Off None <ignored> 100
3119 ** 10FD Full Off None <ignored> 10
3120 ** 10HD Half Off None <ignored> 10
3122 ** This ConType parameter is used for all ports of the adapter!
3124 if ( (ConType
!= NULL
) &&
3125 (pAC
->Index
< SK_MAX_CARD_PARAM
) &&
3126 (ConType
[pAC
->Index
] != NULL
) ) {
3128 /* Check chipset family */
3129 if ((!pAC
->ChipsetType
) &&
3130 (strcmp(ConType
[pAC
->Index
],"Auto")!=0) &&
3131 (strcmp(ConType
[pAC
->Index
],"")!=0)) {
3132 /* Set the speed parameter back */
3133 printk("sk98lin: Illegal value \"%s\" "
3136 ConType
[pAC
->Index
]);
3138 sprintf(ConType
[pAC
->Index
], "Auto");
3141 if (strcmp(ConType
[pAC
->Index
],"")==0) {
3142 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3143 } else if (strcmp(ConType
[pAC
->Index
],"Auto")==0) {
3144 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3145 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3146 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3147 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3148 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3150 } else if (strcmp(ConType
[pAC
->Index
],"100FD")==0) {
3151 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3152 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3153 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3154 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3155 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3157 } else if (strcmp(ConType
[pAC
->Index
],"100HD")==0) {
3158 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3159 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3160 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3161 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3162 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3164 } else if (strcmp(ConType
[pAC
->Index
],"10FD")==0) {
3165 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3166 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3167 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3168 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3169 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3171 } else if (strcmp(ConType
[pAC
->Index
],"10HD")==0) {
3172 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3173 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3174 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3175 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3176 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3179 printk("sk98lin: Illegal value \"%s\" for ConType\n",
3180 ConType
[pAC
->Index
]);
3181 IsConTypeDefined
= SK_FALSE
; /* Wrong ConType defined */
3184 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3188 ** Parse any parameter settings for port A:
3189 ** a) any LinkSpeed stated?
3191 if (Speed_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3192 Speed_A
[pAC
->Index
] != NULL
) {
3193 if (strcmp(Speed_A
[pAC
->Index
],"")==0) {
3194 IsLinkSpeedDefined
= SK_FALSE
;
3195 } else if (strcmp(Speed_A
[pAC
->Index
],"Auto")==0) {
3196 LinkSpeed
= SK_LSPEED_AUTO
;
3197 } else if (strcmp(Speed_A
[pAC
->Index
],"10")==0) {
3198 LinkSpeed
= SK_LSPEED_10MBPS
;
3199 } else if (strcmp(Speed_A
[pAC
->Index
],"100")==0) {
3200 LinkSpeed
= SK_LSPEED_100MBPS
;
3201 } else if (strcmp(Speed_A
[pAC
->Index
],"1000")==0) {
3202 LinkSpeed
= SK_LSPEED_1000MBPS
;
3204 printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
3205 Speed_A
[pAC
->Index
]);
3206 IsLinkSpeedDefined
= SK_FALSE
;
3209 IsLinkSpeedDefined
= SK_FALSE
;
3213 ** Check speed parameter:
3214 ** Only copper type adapter and GE V2 cards
3216 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3217 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3218 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3219 printk("sk98lin: Illegal value for Speed_A. "
3220 "Not a copper card or GE V2 card\n Using "
3222 LinkSpeed
= SK_LSPEED_1000MBPS
;
3226 ** Decide whether to set new config value if somethig valid has
3229 if (IsLinkSpeedDefined
) {
3230 pAC
->GIni
.GP
[0].PLinkSpeed
= LinkSpeed
;
3234 ** b) Any Autonegotiation and DuplexCapabilities set?
3235 ** Please note that both belong together...
3237 AutoNeg
= AN_ON
; /* tschilling: Default: Autonegotiation on! */
3239 if (AutoNeg_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3240 AutoNeg_A
[pAC
->Index
] != NULL
) {
3242 if (strcmp(AutoNeg_A
[pAC
->Index
],"")==0) {
3244 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"On")==0) {
3246 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Off")==0) {
3248 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Sense")==0) {
3251 printk("sk98lin: Illegal value \"%s\" for AutoNeg_A\n",
3252 AutoNeg_A
[pAC
->Index
]);
3256 DuplexCap
= DC_BOTH
;
3258 if (DupCap_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3259 DupCap_A
[pAC
->Index
] != NULL
) {
3261 if (strcmp(DupCap_A
[pAC
->Index
],"")==0) {
3263 } else if (strcmp(DupCap_A
[pAC
->Index
],"Both")==0) {
3264 DuplexCap
= DC_BOTH
;
3265 } else if (strcmp(DupCap_A
[pAC
->Index
],"Full")==0) {
3266 DuplexCap
= DC_FULL
;
3267 } else if (strcmp(DupCap_A
[pAC
->Index
],"Half")==0) {
3268 DuplexCap
= DC_HALF
;
3270 printk("sk98lin: Illegal value \"%s\" for DupCap_A\n",
3271 DupCap_A
[pAC
->Index
]);
3276 ** Check for illegal combinations
3278 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3279 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3280 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3281 (pAC
->ChipsetType
)) {
3282 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3283 " Using Full Duplex.\n");
3284 DuplexCap
= DC_FULL
;
3287 if ( AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3288 printk("sk98lin, Port A: DuplexCapabilities"
3289 " ignored using Sense mode\n");
3292 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3293 printk("sk98lin: Port A: Illegal combination"
3294 " of values AutoNeg. and DuplexCap.\n Using "
3296 DuplexCap
= DC_FULL
;
3299 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3300 DuplexCap
= DC_FULL
;
3303 if (!AutoSet
&& DupSet
) {
3304 printk("sk98lin: Port A: Duplex setting not"
3305 " possible in\n default AutoNegotiation mode"
3306 " (Sense).\n Using AutoNegotiation On\n");
3311 ** set the desired mode
3313 if (AutoSet
|| DupSet
) {
3314 pAC
->GIni
.GP
[0].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3318 ** c) Any Flowcontrol-parameter set?
3320 if (FlowCtrl_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3321 FlowCtrl_A
[pAC
->Index
] != NULL
) {
3322 if (strcmp(FlowCtrl_A
[pAC
->Index
],"") == 0) {
3323 IsFlowCtrlDefined
= SK_FALSE
;
3324 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"SymOrRem") == 0) {
3325 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3326 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"Sym")==0) {
3327 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3328 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"LocSend")==0) {
3329 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3330 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"None")==0) {
3331 FlowCtrl
= SK_FLOW_MODE_NONE
;
3333 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
3334 FlowCtrl_A
[pAC
->Index
]);
3335 IsFlowCtrlDefined
= SK_FALSE
;
3338 IsFlowCtrlDefined
= SK_FALSE
;
3341 if (IsFlowCtrlDefined
) {
3342 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3343 printk("sk98lin: Port A: FlowControl"
3344 " impossible without AutoNegotiation,"
3346 FlowCtrl
= SK_FLOW_MODE_NONE
;
3348 pAC
->GIni
.GP
[0].PFlowCtrlMode
= FlowCtrl
;
3352 ** d) What is with the RoleParameter?
3354 if (Role_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3355 Role_A
[pAC
->Index
] != NULL
) {
3356 if (strcmp(Role_A
[pAC
->Index
],"")==0) {
3357 IsRoleDefined
= SK_FALSE
;
3358 } else if (strcmp(Role_A
[pAC
->Index
],"Auto")==0) {
3359 MSMode
= SK_MS_MODE_AUTO
;
3360 } else if (strcmp(Role_A
[pAC
->Index
],"Master")==0) {
3361 MSMode
= SK_MS_MODE_MASTER
;
3362 } else if (strcmp(Role_A
[pAC
->Index
],"Slave")==0) {
3363 MSMode
= SK_MS_MODE_SLAVE
;
3365 printk("sk98lin: Illegal value \"%s\" for Role_A\n",
3366 Role_A
[pAC
->Index
]);
3367 IsRoleDefined
= SK_FALSE
;
3370 IsRoleDefined
= SK_FALSE
;
3373 if (IsRoleDefined
== SK_TRUE
) {
3374 pAC
->GIni
.GP
[0].PMSMode
= MSMode
;
3380 ** Parse any parameter settings for port B:
3381 ** a) any LinkSpeed stated?
3383 IsConTypeDefined
= SK_TRUE
;
3384 IsLinkSpeedDefined
= SK_TRUE
;
3385 IsFlowCtrlDefined
= SK_TRUE
;
3386 IsModeDefined
= SK_TRUE
;
3388 if (Speed_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3389 Speed_B
[pAC
->Index
] != NULL
) {
3390 if (strcmp(Speed_B
[pAC
->Index
],"")==0) {
3391 IsLinkSpeedDefined
= SK_FALSE
;
3392 } else if (strcmp(Speed_B
[pAC
->Index
],"Auto")==0) {
3393 LinkSpeed
= SK_LSPEED_AUTO
;
3394 } else if (strcmp(Speed_B
[pAC
->Index
],"10")==0) {
3395 LinkSpeed
= SK_LSPEED_10MBPS
;
3396 } else if (strcmp(Speed_B
[pAC
->Index
],"100")==0) {
3397 LinkSpeed
= SK_LSPEED_100MBPS
;
3398 } else if (strcmp(Speed_B
[pAC
->Index
],"1000")==0) {
3399 LinkSpeed
= SK_LSPEED_1000MBPS
;
3401 printk("sk98lin: Illegal value \"%s\" for Speed_B\n",
3402 Speed_B
[pAC
->Index
]);
3403 IsLinkSpeedDefined
= SK_FALSE
;
3406 IsLinkSpeedDefined
= SK_FALSE
;
3410 ** Check speed parameter:
3411 ** Only copper type adapter and GE V2 cards
3413 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3414 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3415 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3416 printk("sk98lin: Illegal value for Speed_B. "
3417 "Not a copper card or GE V2 card\n Using "
3419 LinkSpeed
= SK_LSPEED_1000MBPS
;
3423 ** Decide whether to set new config value if somethig valid has
3426 if (IsLinkSpeedDefined
) {
3427 pAC
->GIni
.GP
[1].PLinkSpeed
= LinkSpeed
;
3431 ** b) Any Autonegotiation and DuplexCapabilities set?
3432 ** Please note that both belong together...
3434 AutoNeg
= AN_SENS
; /* default: do auto Sense */
3436 if (AutoNeg_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3437 AutoNeg_B
[pAC
->Index
] != NULL
) {
3439 if (strcmp(AutoNeg_B
[pAC
->Index
],"")==0) {
3441 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"On")==0) {
3443 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Off")==0) {
3445 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Sense")==0) {
3448 printk("sk98lin: Illegal value \"%s\" for AutoNeg_B\n",
3449 AutoNeg_B
[pAC
->Index
]);
3453 DuplexCap
= DC_BOTH
;
3455 if (DupCap_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3456 DupCap_B
[pAC
->Index
] != NULL
) {
3458 if (strcmp(DupCap_B
[pAC
->Index
],"")==0) {
3460 } else if (strcmp(DupCap_B
[pAC
->Index
],"Both")==0) {
3461 DuplexCap
= DC_BOTH
;
3462 } else if (strcmp(DupCap_B
[pAC
->Index
],"Full")==0) {
3463 DuplexCap
= DC_FULL
;
3464 } else if (strcmp(DupCap_B
[pAC
->Index
],"Half")==0) {
3465 DuplexCap
= DC_HALF
;
3467 printk("sk98lin: Illegal value \"%s\" for DupCap_B\n",
3468 DupCap_B
[pAC
->Index
]);
3474 ** Check for illegal combinations
3476 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3477 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3478 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3479 (pAC
->ChipsetType
)) {
3480 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3481 " Using Full Duplex.\n");
3482 DuplexCap
= DC_FULL
;
3485 if (AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3486 printk("sk98lin, Port B: DuplexCapabilities"
3487 " ignored using Sense mode\n");
3490 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3491 printk("sk98lin: Port B: Illegal combination"
3492 " of values AutoNeg. and DuplexCap.\n Using "
3494 DuplexCap
= DC_FULL
;
3497 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3498 DuplexCap
= DC_FULL
;
3501 if (!AutoSet
&& DupSet
) {
3502 printk("sk98lin: Port B: Duplex setting not"
3503 " possible in\n default AutoNegotiation mode"
3504 " (Sense).\n Using AutoNegotiation On\n");
3509 ** set the desired mode
3511 if (AutoSet
|| DupSet
) {
3512 pAC
->GIni
.GP
[1].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3516 ** c) Any FlowCtrl parameter set?
3518 if (FlowCtrl_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3519 FlowCtrl_B
[pAC
->Index
] != NULL
) {
3520 if (strcmp(FlowCtrl_B
[pAC
->Index
],"") == 0) {
3521 IsFlowCtrlDefined
= SK_FALSE
;
3522 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"SymOrRem") == 0) {
3523 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3524 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"Sym")==0) {
3525 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3526 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"LocSend")==0) {
3527 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3528 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"None")==0) {
3529 FlowCtrl
= SK_FLOW_MODE_NONE
;
3531 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_B\n",
3532 FlowCtrl_B
[pAC
->Index
]);
3533 IsFlowCtrlDefined
= SK_FALSE
;
3536 IsFlowCtrlDefined
= SK_FALSE
;
3539 if (IsFlowCtrlDefined
) {
3540 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3541 printk("sk98lin: Port B: FlowControl"
3542 " impossible without AutoNegotiation,"
3544 FlowCtrl
= SK_FLOW_MODE_NONE
;
3546 pAC
->GIni
.GP
[1].PFlowCtrlMode
= FlowCtrl
;
3550 ** d) What is the RoleParameter?
3552 if (Role_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3553 Role_B
[pAC
->Index
] != NULL
) {
3554 if (strcmp(Role_B
[pAC
->Index
],"")==0) {
3555 IsRoleDefined
= SK_FALSE
;
3556 } else if (strcmp(Role_B
[pAC
->Index
],"Auto")==0) {
3557 MSMode
= SK_MS_MODE_AUTO
;
3558 } else if (strcmp(Role_B
[pAC
->Index
],"Master")==0) {
3559 MSMode
= SK_MS_MODE_MASTER
;
3560 } else if (strcmp(Role_B
[pAC
->Index
],"Slave")==0) {
3561 MSMode
= SK_MS_MODE_SLAVE
;
3563 printk("sk98lin: Illegal value \"%s\" for Role_B\n",
3564 Role_B
[pAC
->Index
]);
3565 IsRoleDefined
= SK_FALSE
;
3568 IsRoleDefined
= SK_FALSE
;
3571 if (IsRoleDefined
) {
3572 pAC
->GIni
.GP
[1].PMSMode
= MSMode
;
3576 ** Evaluate settings for both ports
3578 pAC
->ActivePort
= 0;
3579 if (PrefPort
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3580 PrefPort
[pAC
->Index
] != NULL
) {
3581 if (strcmp(PrefPort
[pAC
->Index
],"") == 0) { /* Auto */
3582 pAC
->ActivePort
= 0;
3583 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3584 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3585 } else if (strcmp(PrefPort
[pAC
->Index
],"A") == 0) {
3587 ** do not set ActivePort here, thus a port
3588 ** switch is issued after net up.
3591 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3592 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3593 } else if (strcmp(PrefPort
[pAC
->Index
],"B") == 0) {
3595 ** do not set ActivePort here, thus a port
3596 ** switch is issued after net up.
3598 if (pAC
->GIni
.GIMacsFound
== 1) {
3599 printk("sk98lin: Illegal value \"B\" for PrefPort.\n"
3600 " Port B not available on single port adapters.\n");
3602 pAC
->ActivePort
= 0;
3603 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3604 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3607 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3608 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3611 printk("sk98lin: Illegal value \"%s\" for PrefPort\n",
3612 PrefPort
[pAC
->Index
]);
3618 if (RlmtMode
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3619 RlmtMode
[pAC
->Index
] != NULL
) {
3620 if (strcmp(RlmtMode
[pAC
->Index
], "") == 0) {
3622 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLinkState") == 0) {
3623 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3624 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLocalPort") == 0) {
3625 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3626 SK_RLMT_CHECK_LOC_LINK
;
3627 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckSeg") == 0) {
3628 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3629 SK_RLMT_CHECK_LOC_LINK
|
3631 } else if ((strcmp(RlmtMode
[pAC
->Index
], "DualNet") == 0) &&
3632 (pAC
->GIni
.GIMacsFound
== 2)) {
3633 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3636 printk("sk98lin: Illegal value \"%s\" for"
3637 " RlmtMode, using default\n",
3638 RlmtMode
[pAC
->Index
]);
3646 ** Check the interrupt moderation parameters
3648 if (Moderation
[pAC
->Index
] != NULL
) {
3649 if (strcmp(Moderation
[pAC
->Index
], "") == 0) {
3650 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3651 } else if (strcmp(Moderation
[pAC
->Index
], "Static") == 0) {
3652 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_STATIC
;
3653 } else if (strcmp(Moderation
[pAC
->Index
], "Dynamic") == 0) {
3654 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_DYNAMIC
;
3655 } else if (strcmp(Moderation
[pAC
->Index
], "None") == 0) {
3656 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3658 printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
3659 " Disable interrupt moderation.\n",
3660 Moderation
[pAC
->Index
]);
3661 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3664 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3667 if (Stats
[pAC
->Index
] != NULL
) {
3668 if (strcmp(Stats
[pAC
->Index
], "Yes") == 0) {
3669 pAC
->DynIrqModInfo
.DisplayStats
= SK_TRUE
;
3671 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3674 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3677 if (ModerationMask
[pAC
->Index
] != NULL
) {
3678 if (strcmp(ModerationMask
[pAC
->Index
], "Rx") == 0) {
3679 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3680 } else if (strcmp(ModerationMask
[pAC
->Index
], "Tx") == 0) {
3681 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_ONLY
;
3682 } else if (strcmp(ModerationMask
[pAC
->Index
], "Sp") == 0) {
3683 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_ONLY
;
3684 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSp") == 0) {
3685 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3686 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRx") == 0) {
3687 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3688 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTx") == 0) {
3689 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3690 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRx") == 0) {
3691 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3692 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSp") == 0) {
3693 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3694 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTx") == 0) {
3695 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3696 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTxSp") == 0) {
3697 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3698 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSpTx") == 0) {
3699 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3700 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRxSp") == 0) {
3701 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3702 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSpRx") == 0) {
3703 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3704 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTxRx") == 0) {
3705 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3706 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRxTx") == 0) {
3707 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3708 } else { /* some rubbish */
3709 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3711 } else { /* operator has stated nothing */
3712 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3715 if (AutoSizing
[pAC
->Index
] != NULL
) {
3716 if (strcmp(AutoSizing
[pAC
->Index
], "On") == 0) {
3717 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3719 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3721 } else { /* operator has stated nothing */
3722 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3725 if (IntsPerSec
[pAC
->Index
] != 0) {
3726 if ((IntsPerSec
[pAC
->Index
]< C_INT_MOD_IPS_LOWER_RANGE
) ||
3727 (IntsPerSec
[pAC
->Index
] > C_INT_MOD_IPS_UPPER_RANGE
)) {
3728 printk("sk98lin: Illegal value \"%d\" for IntsPerSec. (Range: %d - %d)\n"
3729 " Using default value of %i.\n",
3730 IntsPerSec
[pAC
->Index
],
3731 C_INT_MOD_IPS_LOWER_RANGE
,
3732 C_INT_MOD_IPS_UPPER_RANGE
,
3733 C_INTS_PER_SEC_DEFAULT
);
3734 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3736 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= IntsPerSec
[pAC
->Index
];
3739 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3743 ** Evaluate upper and lower moderation threshold
3745 pAC
->DynIrqModInfo
.MaxModIntsPerSecUpperLimit
=
3746 pAC
->DynIrqModInfo
.MaxModIntsPerSec
+
3747 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3749 pAC
->DynIrqModInfo
.MaxModIntsPerSecLowerLimit
=
3750 pAC
->DynIrqModInfo
.MaxModIntsPerSec
-
3751 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3753 pAC
->DynIrqModInfo
.PrevTimeVal
= jiffies
; /* initial value */
3756 } /* GetConfiguration */
3759 /*****************************************************************************
3761 * ProductStr - return a adapter identification string from vpd
3764 * This function reads the product name string from the vpd area
3765 * and puts it the field pAC->DeviceString.
3769 static inline int ProductStr(
3770 SK_AC
*pAC
, /* pointer to adapter context */
3771 char *DeviceStr
, /* result string */
3772 int StrLen
/* length of the string */
3775 char Keyword
[] = VPD_NAME
; /* vpd productname identifier */
3776 int ReturnCode
; /* return code from vpd_read */
3777 unsigned long Flags
;
3779 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3780 ReturnCode
= VpdRead(pAC
, pAC
->IoBase
, Keyword
, DeviceStr
, &StrLen
);
3781 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3786 /*****************************************************************************
3788 * StartDrvCleanupTimer - Start timer to check for descriptors which
3789 * might be placed in descriptor ring, but
3790 * havent been handled up to now
3793 * This function requests a HW-timer fo the Yukon card. The actions to
3794 * perform when this timer expires, are located in the SkDrvEvent().
3799 StartDrvCleanupTimer(SK_AC
*pAC
) {
3800 SK_EVPARA EventParam
; /* Event struct for timer event */
3802 SK_MEMSET((char *) &EventParam
, 0, sizeof(EventParam
));
3803 EventParam
.Para32
[0] = SK_DRV_RX_CLEANUP_TIMER
;
3804 SkTimerStart(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
,
3805 SK_DRV_RX_CLEANUP_TIMER_LENGTH
,
3806 SKGE_DRV
, SK_DRV_TIMER
, EventParam
);
3809 /*****************************************************************************
3811 * StopDrvCleanupTimer - Stop timer to check for descriptors
3814 * This function requests a HW-timer fo the Yukon card. The actions to
3815 * perform when this timer expires, are located in the SkDrvEvent().
3820 StopDrvCleanupTimer(SK_AC
*pAC
) {
3821 SkTimerStop(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
);
3822 SK_MEMSET((char *) &pAC
->DrvCleanupTimer
, 0, sizeof(SK_TIMER
));
3825 /****************************************************************************/
3826 /* functions for common modules *********************************************/
3827 /****************************************************************************/
3830 /*****************************************************************************
3832 * SkDrvAllocRlmtMbuf - allocate an RLMT mbuf
3835 * This routine returns an RLMT mbuf or NULL. The RLMT Mbuf structure
3836 * is embedded into a socket buff data area.
3842 * NULL or pointer to Mbuf.
3844 SK_MBUF
*SkDrvAllocRlmtMbuf(
3845 SK_AC
*pAC
, /* pointer to adapter context */
3846 SK_IOC IoC
, /* the IO-context */
3847 unsigned BufferSize
) /* size of the requested buffer */
3849 SK_MBUF
*pRlmtMbuf
; /* pointer to a new rlmt-mbuf structure */
3850 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
3852 pMsgBlock
= alloc_skb(BufferSize
+ sizeof(SK_MBUF
), GFP_ATOMIC
);
3853 if (pMsgBlock
== NULL
) {
3856 pRlmtMbuf
= (SK_MBUF
*) pMsgBlock
->data
;
3857 skb_reserve(pMsgBlock
, sizeof(SK_MBUF
));
3858 pRlmtMbuf
->pNext
= NULL
;
3859 pRlmtMbuf
->pOs
= pMsgBlock
;
3860 pRlmtMbuf
->pData
= pMsgBlock
->data
; /* Data buffer. */
3861 pRlmtMbuf
->Size
= BufferSize
; /* Data buffer size. */
3862 pRlmtMbuf
->Length
= 0; /* Length of packet (<= Size). */
3865 } /* SkDrvAllocRlmtMbuf */
3868 /*****************************************************************************
3870 * SkDrvFreeRlmtMbuf - free an RLMT mbuf
3873 * This routine frees one or more RLMT mbuf(s).
3881 void SkDrvFreeRlmtMbuf(
3882 SK_AC
*pAC
, /* pointer to adapter context */
3883 SK_IOC IoC
, /* the IO-context */
3884 SK_MBUF
*pMbuf
) /* size of the requested buffer */
3891 pNextMbuf
= pFreeMbuf
->pNext
;
3892 DEV_KFREE_SKB_ANY(pFreeMbuf
->pOs
);
3893 pFreeMbuf
= pNextMbuf
;
3894 } while ( pFreeMbuf
!= NULL
);
3895 } /* SkDrvFreeRlmtMbuf */
3898 /*****************************************************************************
3900 * SkOsGetTime - provide a time value
3903 * This routine provides a time value. The unit is 1/HZ (defined by Linux).
3904 * It is not used for absolute time, but only for time differences.
3910 SK_U64
SkOsGetTime(SK_AC
*pAC
)
3912 SK_U64 PrivateJiffies
;
3913 SkOsGetTimeCurrent(pAC
, &PrivateJiffies
);
3914 return PrivateJiffies
;
3918 /*****************************************************************************
3920 * SkPciReadCfgDWord - read a 32 bit value from pci config space
3923 * This routine reads a 32 bit value from the pci configuration
3927 * 0 - indicate everything worked ok.
3928 * != 0 - error indication
3930 int SkPciReadCfgDWord(
3931 SK_AC
*pAC
, /* Adapter Control structure pointer */
3932 int PciAddr
, /* PCI register address */
3933 SK_U32
*pVal
) /* pointer to store the read value */
3935 pci_read_config_dword(pAC
->PciDev
, PciAddr
, pVal
);
3937 } /* SkPciReadCfgDWord */
3940 /*****************************************************************************
3942 * SkPciReadCfgWord - read a 16 bit value from pci config space
3945 * This routine reads a 16 bit value from the pci configuration
3949 * 0 - indicate everything worked ok.
3950 * != 0 - error indication
3952 int SkPciReadCfgWord(
3953 SK_AC
*pAC
, /* Adapter Control structure pointer */
3954 int PciAddr
, /* PCI register address */
3955 SK_U16
*pVal
) /* pointer to store the read value */
3957 pci_read_config_word(pAC
->PciDev
, PciAddr
, pVal
);
3959 } /* SkPciReadCfgWord */
3962 /*****************************************************************************
3964 * SkPciReadCfgByte - read a 8 bit value from pci config space
3967 * This routine reads a 8 bit value from the pci configuration
3971 * 0 - indicate everything worked ok.
3972 * != 0 - error indication
3974 int SkPciReadCfgByte(
3975 SK_AC
*pAC
, /* Adapter Control structure pointer */
3976 int PciAddr
, /* PCI register address */
3977 SK_U8
*pVal
) /* pointer to store the read value */
3979 pci_read_config_byte(pAC
->PciDev
, PciAddr
, pVal
);
3981 } /* SkPciReadCfgByte */
3984 /*****************************************************************************
3986 * SkPciWriteCfgWord - write a 16 bit value to pci config space
3989 * This routine writes a 16 bit value to the pci configuration
3990 * space. The flag PciConfigUp indicates whether the config space
3991 * is accesible or must be set up first.
3994 * 0 - indicate everything worked ok.
3995 * != 0 - error indication
3997 int SkPciWriteCfgWord(
3998 SK_AC
*pAC
, /* Adapter Control structure pointer */
3999 int PciAddr
, /* PCI register address */
4000 SK_U16 Val
) /* pointer to store the read value */
4002 pci_write_config_word(pAC
->PciDev
, PciAddr
, Val
);
4004 } /* SkPciWriteCfgWord */
4007 /*****************************************************************************
4009 * SkPciWriteCfgWord - write a 8 bit value to pci config space
4012 * This routine writes a 8 bit value to the pci configuration
4013 * space. The flag PciConfigUp indicates whether the config space
4014 * is accesible or must be set up first.
4017 * 0 - indicate everything worked ok.
4018 * != 0 - error indication
4020 int SkPciWriteCfgByte(
4021 SK_AC
*pAC
, /* Adapter Control structure pointer */
4022 int PciAddr
, /* PCI register address */
4023 SK_U8 Val
) /* pointer to store the read value */
4025 pci_write_config_byte(pAC
->PciDev
, PciAddr
, Val
);
4027 } /* SkPciWriteCfgByte */
4030 /*****************************************************************************
4032 * SkDrvEvent - handle driver events
4035 * This function handles events from all modules directed to the driver
4038 * Is called under protection of slow path lock.
4041 * 0 if everything ok
4046 SK_AC
*pAC
, /* pointer to adapter context */
4047 SK_IOC IoC
, /* io-context */
4048 SK_U32 Event
, /* event-id */
4049 SK_EVPARA Param
) /* event-parameter */
4051 SK_MBUF
*pRlmtMbuf
; /* pointer to a rlmt-mbuf structure */
4052 struct sk_buff
*pMsg
; /* pointer to a message block */
4053 int FromPort
; /* the port from which we switch away */
4054 int ToPort
; /* the port we switch to */
4055 SK_EVPARA NewPara
; /* parameter for further events */
4057 unsigned long Flags
;
4061 case SK_DRV_ADAP_FAIL
:
4062 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4063 ("ADAPTER FAIL EVENT\n"));
4064 printk("%s: Adapter failed.\n", pAC
->dev
[0]->name
);
4065 /* disable interrupts */
4066 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
4069 case SK_DRV_PORT_FAIL
:
4070 FromPort
= Param
.Para32
[0];
4071 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4072 ("PORT FAIL EVENT, Port: %d\n", FromPort
));
4073 if (FromPort
== 0) {
4074 printk("%s: Port A failed.\n", pAC
->dev
[0]->name
);
4076 printk("%s: Port B failed.\n", pAC
->dev
[1]->name
);
4080 case SK_DRV_PORT_RESET
: /* SK_U32 PortIdx */
4082 FromPort
= Param
.Para32
[0];
4083 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4084 ("PORT RESET EVENT, Port: %d ", FromPort
));
4085 NewPara
.Para64
= FromPort
;
4086 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4088 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4091 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_HARD_RST
);
4092 netif_carrier_off(pAC
->dev
[Param
.Para32
[0]]);
4093 spin_unlock_irqrestore(
4094 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4097 /* clear rx ring from received frames */
4098 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
);
4100 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4102 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4105 /* tschilling: Handling of return value inserted. */
4106 if (SkGeInitPort(pAC
, IoC
, FromPort
)) {
4107 if (FromPort
== 0) {
4108 printk("%s: SkGeInitPort A failed.\n", pAC
->dev
[0]->name
);
4110 printk("%s: SkGeInitPort B failed.\n", pAC
->dev
[1]->name
);
4113 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4114 PortReInitBmu(pAC
, FromPort
);
4115 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4116 ClearAndStartRx(pAC
, FromPort
);
4117 spin_unlock_irqrestore(
4118 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4121 case SK_DRV_NET_UP
: /* SK_U32 PortIdx */
4122 { struct net_device
*dev
= pAC
->dev
[Param
.Para32
[0]];
4124 FromPort
= Param
.Para32
[0];
4125 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4126 ("NET UP EVENT, Port: %d ", Param
.Para32
[0]));
4128 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4130 if (DoPrintInterfaceChange
) {
4131 printk("%s: network connection up using"
4132 " port %c\n", pAC
->dev
[Param
.Para32
[0]]->name
, 'A'+Param
.Para32
[0]);
4134 /* tschilling: Values changed according to LinkSpeedUsed. */
4135 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
;
4136 if (Stat
== SK_LSPEED_STAT_10MBPS
) {
4137 printk(" speed: 10\n");
4138 } else if (Stat
== SK_LSPEED_STAT_100MBPS
) {
4139 printk(" speed: 100\n");
4140 } else if (Stat
== SK_LSPEED_STAT_1000MBPS
) {
4141 printk(" speed: 1000\n");
4143 printk(" speed: unknown\n");
4147 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkModeStatus
;
4148 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4149 Stat
== SK_LMODE_STAT_AUTOFULL
) {
4150 printk(" autonegotiation: yes\n");
4153 printk(" autonegotiation: no\n");
4155 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4156 Stat
== SK_LMODE_STAT_HALF
) {
4157 printk(" duplex mode: half\n");
4160 printk(" duplex mode: full\n");
4162 Stat
= pAC
->GIni
.GP
[FromPort
].PFlowCtrlStatus
;
4163 if (Stat
== SK_FLOW_STAT_REM_SEND
) {
4164 printk(" flowctrl: remote send\n");
4166 else if (Stat
== SK_FLOW_STAT_LOC_SEND
){
4167 printk(" flowctrl: local send\n");
4169 else if (Stat
== SK_FLOW_STAT_SYMMETRIC
){
4170 printk(" flowctrl: symmetric\n");
4173 printk(" flowctrl: none\n");
4176 /* tschilling: Check against CopperType now. */
4177 if ((pAC
->GIni
.GICopperType
== SK_TRUE
) &&
4178 (pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
==
4179 SK_LSPEED_STAT_1000MBPS
)) {
4180 Stat
= pAC
->GIni
.GP
[FromPort
].PMSStatus
;
4181 if (Stat
== SK_MS_STAT_MASTER
) {
4182 printk(" role: master\n");
4184 else if (Stat
== SK_MS_STAT_SLAVE
) {
4185 printk(" role: slave\n");
4188 printk(" role: ???\n");
4193 Display dim (dynamic interrupt moderation)
4196 if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_STATIC
)
4197 printk(" irq moderation: static (%d ints/sec)\n",
4198 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4199 else if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_DYNAMIC
)
4200 printk(" irq moderation: dynamic (%d ints/sec)\n",
4201 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4203 printk(" irq moderation: disabled\n");
4206 printk(" scatter-gather: %s\n",
4207 (dev
->features
& NETIF_F_SG
) ? "enabled" : "disabled");
4208 printk(" tx-checksum: %s\n",
4209 (dev
->features
& NETIF_F_IP_CSUM
) ? "enabled" : "disabled");
4210 printk(" rx-checksum: %s\n",
4211 pAC
->RxPort
[Param
.Para32
[0]].RxCsum
? "enabled" : "disabled");
4214 DoPrintInterfaceChange
= SK_TRUE
;
4217 if ((Param
.Para32
[0] != pAC
->ActivePort
) &&
4218 (pAC
->RlmtNets
== 1)) {
4219 NewPara
.Para32
[0] = pAC
->ActivePort
;
4220 NewPara
.Para32
[1] = Param
.Para32
[0];
4221 SkEventQueue(pAC
, SKGE_DRV
, SK_DRV_SWITCH_INTERN
,
4225 /* Inform the world that link protocol is up. */
4226 netif_carrier_on(dev
);
4229 case SK_DRV_NET_DOWN
: /* SK_U32 Reason */
4231 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4232 ("NET DOWN EVENT "));
4233 if (DoPrintInterfaceChange
) {
4234 printk("%s: network connection down\n",
4235 pAC
->dev
[Param
.Para32
[1]]->name
);
4237 DoPrintInterfaceChange
= SK_TRUE
;
4239 netif_carrier_off(pAC
->dev
[Param
.Para32
[1]]);
4241 case SK_DRV_SWITCH_HARD
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4242 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4243 ("PORT SWITCH HARD "));
4244 case SK_DRV_SWITCH_SOFT
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4246 printk("%s: switching to port %c\n", pAC
->dev
[0]->name
,
4247 'A'+Param
.Para32
[1]);
4248 case SK_DRV_SWITCH_INTERN
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4249 FromPort
= Param
.Para32
[0];
4250 ToPort
= Param
.Para32
[1];
4251 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4252 ("PORT SWITCH EVENT, From: %d To: %d (Pref %d) ",
4253 FromPort
, ToPort
, pAC
->Rlmt
.Net
[0].PrefPort
));
4254 NewPara
.Para64
= FromPort
;
4255 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4256 NewPara
.Para64
= ToPort
;
4257 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4259 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4261 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4262 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4263 SkGeStopPort(pAC
, IoC
, ToPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4264 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4265 spin_unlock_irqrestore(
4266 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4269 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
); /* clears rx ring */
4270 ReceiveIrq(pAC
, &pAC
->RxPort
[ToPort
], SK_FALSE
); /* clears rx ring */
4272 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4273 ClearTxRing(pAC
, &pAC
->TxPort
[ToPort
][TX_PRIO_LOW
]);
4275 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4277 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4278 pAC
->ActivePort
= ToPort
;
4282 /* tschilling: New common function with minimum size check. */
4284 if (pAC
->RlmtNets
== 2) {
4288 if (SkGeInitAssignRamToQueues(
4292 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4293 spin_unlock_irqrestore(
4294 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4296 printk("SkGeInitAssignRamToQueues failed.\n");
4300 /* tschilling: Handling of return values inserted. */
4301 if (SkGeInitPort(pAC
, IoC
, FromPort
) ||
4302 SkGeInitPort(pAC
, IoC
, ToPort
)) {
4303 printk("%s: SkGeInitPort failed.\n", pAC
->dev
[0]->name
);
4305 if (Event
== SK_DRV_SWITCH_SOFT
) {
4306 SkMacRxTxEnable(pAC
, IoC
, FromPort
);
4308 SkMacRxTxEnable(pAC
, IoC
, ToPort
);
4309 SkAddrSwap(pAC
, IoC
, FromPort
, ToPort
);
4310 SkAddrMcUpdate(pAC
, IoC
, FromPort
);
4311 SkAddrMcUpdate(pAC
, IoC
, ToPort
);
4312 PortReInitBmu(pAC
, FromPort
);
4313 PortReInitBmu(pAC
, ToPort
);
4314 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4315 SkGePollTxD(pAC
, IoC
, ToPort
, SK_TRUE
);
4316 ClearAndStartRx(pAC
, FromPort
);
4317 ClearAndStartRx(pAC
, ToPort
);
4318 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4319 spin_unlock_irqrestore(
4320 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4323 case SK_DRV_RLMT_SEND
: /* SK_MBUF *pMb */
4324 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4326 pRlmtMbuf
= (SK_MBUF
*) Param
.pParaPtr
;
4327 pMsg
= (struct sk_buff
*) pRlmtMbuf
->pOs
;
4328 skb_put(pMsg
, pRlmtMbuf
->Length
);
4329 if (XmitFrame(pAC
, &pAC
->TxPort
[pRlmtMbuf
->PortIdx
][TX_PRIO_LOW
],
4332 DEV_KFREE_SKB_ANY(pMsg
);
4335 if (Param
.Para32
[0] == SK_DRV_MODERATION_TIMER
) {
4337 ** expiration of the moderation timer implies that
4338 ** dynamic moderation is to be applied
4340 SkDimStartModerationTimer(pAC
);
4342 if (pAC
->DynIrqModInfo
.DisplayStats
) {
4343 SkDimDisplayModerationSettings(pAC
);
4345 } else if (Param
.Para32
[0] == SK_DRV_RX_CLEANUP_TIMER
) {
4347 ** check if we need to check for descriptors which
4348 ** haven't been handled the last millisecs
4350 StartDrvCleanupTimer(pAC
);
4351 if (pAC
->GIni
.GIMacsFound
== 2) {
4352 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_FALSE
);
4354 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_FALSE
);
4356 printk("Expiration of unknown timer\n");
4362 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4369 /*****************************************************************************
4371 * SkErrorLog - log errors
4374 * This function logs errors to the system buffer and to the console
4377 * 0 if everything ok
4390 case SK_ERRCL_OTHER
:
4391 strcpy(ClassStr
, "Other error");
4393 case SK_ERRCL_CONFIG
:
4394 strcpy(ClassStr
, "Configuration error");
4397 strcpy(ClassStr
, "Initialization error");
4399 case SK_ERRCL_NORES
:
4400 strcpy(ClassStr
, "Out of resources error");
4403 strcpy(ClassStr
, "internal Software error");
4406 strcpy(ClassStr
, "Hardware failure");
4409 strcpy(ClassStr
, "Communication error");
4412 printk(KERN_INFO
"%s: -- ERROR --\n Class: %s\n"
4413 " Nr: 0x%x\n Msg: %s\n", pAC
->dev
[0]->name
,
4414 ClassStr
, ErrNum
, pErrorMsg
);
4418 #ifdef SK_DIAG_SUPPORT
4420 /*****************************************************************************
4422 * SkDrvEnterDiagMode - handles DIAG attach request
4425 * Notify the kernel to NOT access the card any longer due to DIAG
4426 * Deinitialize the Card
4431 int SkDrvEnterDiagMode(
4432 SK_AC
*pAc
) /* pointer to adapter context */
4434 DEV_NET
*pNet
= netdev_priv(pAc
->dev
[0]);
4435 SK_AC
*pAC
= pNet
->pAC
;
4437 SK_MEMCPY(&(pAc
->PnmiBackup
), &(pAc
->PnmiStruct
),
4438 sizeof(SK_PNMI_STRUCT_DATA
));
4440 pAC
->DiagModeActive
= DIAG_ACTIVE
;
4441 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
4442 if (netif_running(pAC
->dev
[0])) {
4443 pAC
->WasIfUp
[0] = SK_TRUE
;
4444 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4445 DoPrintInterfaceChange
= SK_FALSE
;
4446 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
4448 pAC
->WasIfUp
[0] = SK_FALSE
;
4450 if (pNet
!= netdev_priv(pAC
->dev
[1])) {
4451 pNet
= netdev_priv(pAC
->dev
[1]);
4452 if (netif_running(pAC
->dev
[1])) {
4453 pAC
->WasIfUp
[1] = SK_TRUE
;
4454 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4455 DoPrintInterfaceChange
= SK_FALSE
;
4456 SkDrvDeInitAdapter(pAC
, 1); /* do SkGeClose */
4458 pAC
->WasIfUp
[1] = SK_FALSE
;
4461 pAC
->BoardLevel
= SK_INIT_DATA
;
4466 /*****************************************************************************
4468 * SkDrvLeaveDiagMode - handles DIAG detach request
4471 * Notify the kernel to may access the card again after use by DIAG
4472 * Initialize the Card
4477 int SkDrvLeaveDiagMode(
4478 SK_AC
*pAc
) /* pointer to adapter control context */
4480 SK_MEMCPY(&(pAc
->PnmiStruct
), &(pAc
->PnmiBackup
),
4481 sizeof(SK_PNMI_STRUCT_DATA
));
4482 pAc
->DiagModeActive
= DIAG_NOTACTIVE
;
4483 pAc
->Pnmi
.DiagAttached
= SK_DIAG_IDLE
;
4484 if (pAc
->WasIfUp
[0] == SK_TRUE
) {
4485 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4486 DoPrintInterfaceChange
= SK_FALSE
;
4487 SkDrvInitAdapter(pAc
, 0); /* first device */
4489 if (pAc
->WasIfUp
[1] == SK_TRUE
) {
4490 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4491 DoPrintInterfaceChange
= SK_FALSE
;
4492 SkDrvInitAdapter(pAc
, 1); /* second device */
4497 /*****************************************************************************
4499 * ParseDeviceNbrFromSlotName - Evaluate PCI device number
4502 * This function parses the PCI slot name information string and will
4503 * retrieve the devcie number out of it. The slot_name maintianed by
4504 * linux is in the form of '02:0a.0', whereas the first two characters
4505 * represent the bus number in hex (in the sample above this is
4506 * pci bus 0x02) and the next two characters the device number (0x0a).
4509 * SK_U32: The device number from the PCI slot name
4512 static SK_U32
ParseDeviceNbrFromSlotName(
4513 const char *SlotName
) /* pointer to pci slot name eg. '02:0a.0' */
4515 char *CurrCharPos
= (char *) SlotName
;
4516 int FirstNibble
= -1;
4517 int SecondNibble
= -1;
4520 while (*CurrCharPos
!= '\0') {
4521 if (*CurrCharPos
== ':') {
4522 while (*CurrCharPos
!= '.') {
4524 if ( (*CurrCharPos
>= '0') &&
4525 (*CurrCharPos
<= '9')) {
4526 if (FirstNibble
== -1) {
4527 /* dec. value for '0' */
4528 FirstNibble
= *CurrCharPos
- 48;
4530 SecondNibble
= *CurrCharPos
- 48;
4532 } else if ( (*CurrCharPos
>= 'a') &&
4533 (*CurrCharPos
<= 'f') ) {
4534 if (FirstNibble
== -1) {
4535 FirstNibble
= *CurrCharPos
- 87;
4537 SecondNibble
= *CurrCharPos
- 87;
4544 Result
= FirstNibble
;
4545 Result
= Result
<< 4; /* first nibble is higher one */
4546 Result
= Result
| SecondNibble
;
4548 CurrCharPos
++; /* next character */
4553 /****************************************************************************
4555 * SkDrvDeInitAdapter - deinitialize adapter (this function is only
4556 * called if Diag attaches to that card)
4559 * Close initialized adapter.
4563 * error code - on error
4565 static int SkDrvDeInitAdapter(
4566 SK_AC
*pAC
, /* pointer to adapter context */
4567 int devNbr
) /* what device is to be handled */
4569 struct SK_NET_DEVICE
*dev
;
4571 dev
= pAC
->dev
[devNbr
];
4573 /* On Linux 2.6 the network driver does NOT mess with reference
4574 ** counts. The driver MUST be able to be unloaded at any time
4575 ** due to the possibility of hotplug.
4577 if (SkGeClose(dev
) != 0) {
4582 } /* SkDrvDeInitAdapter() */
4584 /****************************************************************************
4586 * SkDrvInitAdapter - Initialize adapter (this function is only
4587 * called if Diag deattaches from that card)
4590 * Close initialized adapter.
4594 * error code - on error
4596 static int SkDrvInitAdapter(
4597 SK_AC
*pAC
, /* pointer to adapter context */
4598 int devNbr
) /* what device is to be handled */
4600 struct SK_NET_DEVICE
*dev
;
4602 dev
= pAC
->dev
[devNbr
];
4604 if (SkGeOpen(dev
) != 0) {
4609 ** Use correct MTU size and indicate to kernel TX queue can be started
4611 if (SkGeChangeMtu(dev
, dev
->mtu
) != 0) {
4616 } /* SkDrvInitAdapter */
4621 /****************************************************************************/
4622 /* "debug only" section *****************************************************/
4623 /****************************************************************************/
4626 /*****************************************************************************
4628 * DumpMsg - print a frame
4631 * This function prints frames to the system logfile/to the console.
4636 static void DumpMsg(struct sk_buff
*skb
, char *str
)
4641 printk("DumpMsg(): NULL-Message\n");
4645 if (skb
->data
== NULL
) {
4646 printk("DumpMsg(): Message empty\n");
4654 printk("--- Begin of message from %s , len %d (from %d) ----\n", str
, msglen
, skb
->len
);
4656 DumpData((char *)skb
->data
, msglen
);
4658 printk("------- End of message ---------\n");
4663 /*****************************************************************************
4665 * DumpData - print a data area
4668 * This function prints a area of data to the system logfile/to the
4674 static void DumpData(char *p
, int size
)
4678 char hex_buffer
[180];
4679 char asc_buffer
[180];
4680 char HEXCHAR
[] = "0123456789ABCDEF";
4686 for (i
=0; i
< size
; ) {
4687 if (*p
>= '0' && *p
<='z')
4688 asc_buffer
[addr
] = *p
;
4690 asc_buffer
[addr
] = '.';
4692 asc_buffer
[addr
] = 0;
4693 hex_buffer
[haddr
] = HEXCHAR
[(*p
& 0xf0) >> 4];
4695 hex_buffer
[haddr
] = HEXCHAR
[*p
& 0x0f];
4697 hex_buffer
[haddr
] = ' ';
4699 hex_buffer
[haddr
] = 0;
4703 printk("%s %s\n", hex_buffer
, asc_buffer
);
4711 /*****************************************************************************
4713 * DumpLong - print a data area as long values
4716 * This function prints a area of data to the system logfile/to the
4722 static void DumpLong(char *pc
, int size
)
4726 char hex_buffer
[180];
4727 char asc_buffer
[180];
4728 char HEXCHAR
[] = "0123456789ABCDEF";
4737 for (i
=0; i
< size
; ) {
4739 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 28) & 0xf];
4741 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 24) & 0xf];
4743 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 20) & 0xf];
4745 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 16) & 0xf];
4747 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 12) & 0xf];
4749 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 8) & 0xf];
4751 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 4) & 0xf];
4753 hex_buffer
[haddr
] = HEXCHAR
[l
& 0x0f];
4755 hex_buffer
[haddr
] = ' ';
4757 hex_buffer
[haddr
] = 0;
4761 printk("%4x %s\n", (i
-8)*4, hex_buffer
);
4765 printk("------------------------\n");
4770 static int __devinit
skge_probe_one(struct pci_dev
*pdev
,
4771 const struct pci_device_id
*ent
)
4774 DEV_NET
*pNet
= NULL
;
4775 struct net_device
*dev
= NULL
;
4776 static int boards_found
= 0;
4777 int error
= -ENODEV
;
4780 if (pci_enable_device(pdev
))
4783 /* Configure DMA attributes. */
4784 if (pci_set_dma_mask(pdev
, DMA_64BIT_MASK
) &&
4785 pci_set_dma_mask(pdev
, DMA_32BIT_MASK
))
4786 goto out_disable_device
;
4789 if ((dev
= alloc_etherdev(sizeof(DEV_NET
))) == NULL
) {
4790 printk(KERN_ERR
"Unable to allocate etherdev "
4792 goto out_disable_device
;
4795 pNet
= netdev_priv(dev
);
4796 pNet
->pAC
= kmalloc(sizeof(SK_AC
), GFP_KERNEL
);
4798 printk(KERN_ERR
"Unable to allocate adapter "
4800 goto out_free_netdev
;
4803 memset(pNet
->pAC
, 0, sizeof(SK_AC
));
4809 pAC
->CheckQueue
= SK_FALSE
;
4811 dev
->irq
= pdev
->irq
;
4812 error
= SkGeInitPCI(pAC
);
4814 printk(KERN_ERR
"sk98lin: PCI setup failed: %i\n", error
);
4815 goto out_free_netdev
;
4818 SET_MODULE_OWNER(dev
);
4819 dev
->open
= &SkGeOpen
;
4820 dev
->stop
= &SkGeClose
;
4821 dev
->hard_start_xmit
= &SkGeXmit
;
4822 dev
->get_stats
= &SkGeStats
;
4823 dev
->set_multicast_list
= &SkGeSetRxMode
;
4824 dev
->set_mac_address
= &SkGeSetMacAddr
;
4825 dev
->do_ioctl
= &SkGeIoctl
;
4826 dev
->change_mtu
= &SkGeChangeMtu
;
4827 #ifdef CONFIG_NET_POLL_CONTROLLER
4828 dev
->poll_controller
= &SkGePollController
;
4830 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4831 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4833 /* Use only if yukon hardware */
4834 if (pAC
->ChipsetType
) {
4835 #ifdef USE_SK_TX_CHECKSUM
4836 dev
->features
|= NETIF_F_IP_CSUM
;
4839 dev
->features
|= NETIF_F_SG
;
4841 #ifdef USE_SK_RX_CHECKSUM
4842 pAC
->RxPort
[0].RxCsum
= 1;
4846 pAC
->Index
= boards_found
++;
4848 if (SkGeBoardInit(dev
, pAC
))
4849 goto out_free_netdev
;
4851 /* Read Adapter name from VPD */
4852 if (ProductStr(pAC
, DeviceStr
, sizeof(DeviceStr
)) != 0) {
4853 printk(KERN_ERR
"sk98lin: Could not read VPD data.\n");
4854 goto out_free_resources
;
4857 /* Register net device */
4858 if (register_netdev(dev
)) {
4859 printk(KERN_ERR
"sk98lin: Could not register device.\n");
4860 goto out_free_resources
;
4863 /* Print adapter specific string from vpd */
4864 printk("%s: %s\n", dev
->name
, DeviceStr
);
4866 /* Print configuration settings */
4867 printk(" PrefPort:%c RlmtMode:%s\n",
4868 'A' + pAC
->Rlmt
.Net
[0].Port
[pAC
->Rlmt
.Net
[0].PrefPort
]->PortNumber
,
4869 (pAC
->RlmtMode
==0) ? "Check Link State" :
4870 ((pAC
->RlmtMode
==1) ? "Check Link State" :
4871 ((pAC
->RlmtMode
==3) ? "Check Local Port" :
4872 ((pAC
->RlmtMode
==7) ? "Check Segmentation" :
4873 ((pAC
->RlmtMode
==17) ? "Dual Check Link State" :"Error")))));
4875 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
4877 memcpy(&dev
->dev_addr
, &pAC
->Addr
.Net
[0].CurrentMacAddress
, 6);
4878 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4885 /* More then one port found */
4886 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
4887 if ((dev
= alloc_etherdev(sizeof(DEV_NET
))) == 0) {
4888 printk(KERN_ERR
"Unable to allocate etherdev "
4894 pNet
= netdev_priv(dev
);
4899 dev
->open
= &SkGeOpen
;
4900 dev
->stop
= &SkGeClose
;
4901 dev
->hard_start_xmit
= &SkGeXmit
;
4902 dev
->get_stats
= &SkGeStats
;
4903 dev
->set_multicast_list
= &SkGeSetRxMode
;
4904 dev
->set_mac_address
= &SkGeSetMacAddr
;
4905 dev
->do_ioctl
= &SkGeIoctl
;
4906 dev
->change_mtu
= &SkGeChangeMtu
;
4907 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4908 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4910 if (pAC
->ChipsetType
) {
4911 #ifdef USE_SK_TX_CHECKSUM
4912 dev
->features
|= NETIF_F_IP_CSUM
;
4915 dev
->features
|= NETIF_F_SG
;
4917 #ifdef USE_SK_RX_CHECKSUM
4918 pAC
->RxPort
[1].RxCsum
= 1;
4922 if (register_netdev(dev
)) {
4923 printk(KERN_ERR
"sk98lin: Could not register device for seconf port.\n");
4925 pAC
->dev
[1] = pAC
->dev
[0];
4927 memcpy(&dev
->dev_addr
,
4928 &pAC
->Addr
.Net
[1].CurrentMacAddress
, 6);
4929 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4931 printk("%s: %s\n", dev
->name
, DeviceStr
);
4932 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4936 /* Save the hardware revision */
4937 pAC
->HWRevision
= (((pAC
->GIni
.GIPciHwRev
>> 4) & 0x0F)*10) +
4938 (pAC
->GIni
.GIPciHwRev
& 0x0F);
4940 /* Set driver globals */
4941 pAC
->Pnmi
.pDriverFileName
= DRIVER_FILE_NAME
;
4942 pAC
->Pnmi
.pDriverReleaseDate
= DRIVER_REL_DATE
;
4944 memset(&pAC
->PnmiBackup
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
4945 memcpy(&pAC
->PnmiBackup
, &pAC
->PnmiStruct
, sizeof(SK_PNMI_STRUCT_DATA
));
4947 pci_set_drvdata(pdev
, dev
);
4955 pci_disable_device(pdev
);
4960 static void __devexit
skge_remove_one(struct pci_dev
*pdev
)
4962 struct net_device
*dev
= pci_get_drvdata(pdev
);
4963 DEV_NET
*pNet
= netdev_priv(dev
);
4964 SK_AC
*pAC
= pNet
->pAC
;
4965 struct net_device
*otherdev
= pAC
->dev
[1];
4967 unregister_netdev(dev
);
4969 SkGeYellowLED(pAC
, pAC
->IoBase
, 0);
4971 if (pAC
->BoardLevel
== SK_INIT_RUN
) {
4973 unsigned long Flags
;
4975 /* board is still alive */
4976 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
4977 EvPara
.Para32
[0] = 0;
4978 EvPara
.Para32
[1] = -1;
4979 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
4980 EvPara
.Para32
[0] = 1;
4981 EvPara
.Para32
[1] = -1;
4982 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
4983 SkEventDispatcher(pAC
, pAC
->IoBase
);
4984 /* disable interrupts */
4985 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
4986 SkGeDeInit(pAC
, pAC
->IoBase
);
4987 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
4988 pAC
->BoardLevel
= SK_INIT_DATA
;
4989 /* We do NOT check here, if IRQ was pending, of course*/
4992 if (pAC
->BoardLevel
== SK_INIT_IO
) {
4993 /* board is still alive */
4994 SkGeDeInit(pAC
, pAC
->IoBase
);
4995 pAC
->BoardLevel
= SK_INIT_DATA
;
5000 if (otherdev
!= dev
)
5001 free_netdev(otherdev
);
5006 static int skge_suspend(struct pci_dev
*pdev
, pm_message_t state
)
5008 struct net_device
*dev
= pci_get_drvdata(pdev
);
5009 DEV_NET
*pNet
= netdev_priv(dev
);
5010 SK_AC
*pAC
= pNet
->pAC
;
5011 struct net_device
*otherdev
= pAC
->dev
[1];
5013 if (netif_running(dev
)) {
5014 netif_carrier_off(dev
);
5015 DoPrintInterfaceChange
= SK_FALSE
;
5016 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
5017 netif_device_detach(dev
);
5019 if (otherdev
!= dev
) {
5020 if (netif_running(otherdev
)) {
5021 netif_carrier_off(otherdev
);
5022 DoPrintInterfaceChange
= SK_FALSE
;
5023 SkDrvDeInitAdapter(pAC
, 1); /* performs SkGeClose */
5024 netif_device_detach(otherdev
);
5028 pci_save_state(pdev
);
5029 pci_enable_wake(pdev
, pci_choose_state(pdev
, state
), 0);
5030 if (pAC
->AllocFlag
& SK_ALLOC_IRQ
) {
5031 free_irq(dev
->irq
, dev
);
5033 pci_disable_device(pdev
);
5034 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
5039 static int skge_resume(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];
5047 pci_set_power_state(pdev
, PCI_D0
);
5048 pci_restore_state(pdev
);
5049 pci_enable_device(pdev
);
5050 pci_set_master(pdev
);
5051 if (pAC
->GIni
.GIMacsFound
== 2)
5052 ret
= request_irq(dev
->irq
, SkGeIsr
, SA_SHIRQ
, "sk98lin", dev
);
5054 ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, SA_SHIRQ
, "sk98lin", dev
);
5056 printk(KERN_WARNING
"sk98lin: unable to acquire IRQ %d\n", dev
->irq
);
5057 pAC
->AllocFlag
&= ~SK_ALLOC_IRQ
;
5059 pci_disable_device(pdev
);
5063 netif_device_attach(dev
);
5064 if (netif_running(dev
)) {
5065 DoPrintInterfaceChange
= SK_FALSE
;
5066 SkDrvInitAdapter(pAC
, 0); /* first device */
5068 if (otherdev
!= dev
) {
5069 netif_device_attach(otherdev
);
5070 if (netif_running(otherdev
)) {
5071 DoPrintInterfaceChange
= SK_FALSE
;
5072 SkDrvInitAdapter(pAC
, 1); /* second device */
5079 #define skge_suspend NULL
5080 #define skge_resume NULL
5083 static struct pci_device_id skge_pci_tbl
[] = {
5084 { PCI_VENDOR_ID_3COM
, 0x1700, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5085 { PCI_VENDOR_ID_3COM
, 0x80eb, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5086 { PCI_VENDOR_ID_SYSKONNECT
, 0x4300, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5087 { PCI_VENDOR_ID_SYSKONNECT
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5088 /* DLink card does not have valid VPD so this driver gags
5089 * { PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5091 { PCI_VENDOR_ID_MARVELL
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5092 { PCI_VENDOR_ID_MARVELL
, 0x5005, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5093 { PCI_VENDOR_ID_CNET
, 0x434e, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5094 { PCI_VENDOR_ID_LINKSYS
, 0x1032, PCI_ANY_ID
, 0x0015, },
5095 { PCI_VENDOR_ID_LINKSYS
, 0x1064, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5099 MODULE_DEVICE_TABLE(pci
, skge_pci_tbl
);
5101 static struct pci_driver skge_driver
= {
5103 .id_table
= skge_pci_tbl
,
5104 .probe
= skge_probe_one
,
5105 .remove
= __devexit_p(skge_remove_one
),
5106 .suspend
= skge_suspend
,
5107 .resume
= skge_resume
,
5110 static int __init
skge_init(void)
5112 return pci_module_init(&skge_driver
);
5115 static void __exit
skge_exit(void)
5117 pci_unregister_driver(&skge_driver
);
5120 module_init(skge_init
);
5121 module_exit(skge_exit
);