1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.45 $
6 * Date: $Date: 2004/02/12 14:41:02 $
7 * Purpose: The main driver source module
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
16 * Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet
19 * Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and
20 * SysKonnects GEnesis Solaris driver
21 * Author: Christoph Goos (cgoos@syskonnect.de)
22 * Mirko Lindner (mlindner@syskonnect.de)
24 * Address all question to: linux@syskonnect.de
26 * The technical manual for the adapters is available from SysKonnect's
27 * web pages: www.syskonnect.com
28 * Goto "Support" and search Knowledge Base for "manual".
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
35 * The information in this file is provided "AS IS" without warranty.
37 ******************************************************************************/
39 /******************************************************************************
41 * Possible compiler options (#define xxx / -Dxxx):
43 * debugging can be enable by changing SK_DEBUG_CHKMOD and
44 * SK_DEBUG_CHKCAT in makefile (described there).
46 ******************************************************************************/
48 /******************************************************************************
52 * This is the main module of the Linux GE driver.
54 * All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h
55 * are part of SysKonnect's COMMON MODULES for the SK-98xx adapters.
56 * Those are used for drivers on multiple OS', so some thing may seem
57 * unnecessary complicated on Linux. Please do not try to 'clean up'
58 * them without VERY good reasons, because this will make it more
59 * difficult to keep the Linux driver in synchronisation with the
62 * Include file hierarchy:
79 * <linux/etherdevice.h>
81 * those three depending on kernel version used:
106 ******************************************************************************/
108 #include "h/skversion.h"
110 #include <linux/in.h>
111 #include <linux/module.h>
112 #include <linux/moduleparam.h>
113 #include <linux/init.h>
114 #include <linux/proc_fs.h>
115 #include <linux/dma-mapping.h>
116 #include <linux/ip.h>
118 #include "h/skdrv1st.h"
119 #include "h/skdrv2nd.h"
121 /*******************************************************************************
125 ******************************************************************************/
127 /* for debuging on x86 only */
128 /* #define BREAKPOINT() asm(" int $3"); */
130 /* use the transmit hw checksum driver functionality */
131 #define USE_SK_TX_CHECKSUM
133 /* use the receive hw checksum driver functionality */
134 #define USE_SK_RX_CHECKSUM
136 /* use the scatter-gather functionality with sendfile() */
139 /* use of a transmit complete interrupt */
140 #define USE_TX_COMPLETE
143 * threshold for copying small receive frames
144 * set to 0 to avoid copying, set to 9001 to copy all frames
146 #define SK_COPY_THRESHOLD 50
148 /* number of adapters that can be configured via command line params */
149 #define SK_MAX_CARD_PARAM 16
154 * use those defines for a compile-in version of the driver instead
155 * of command line parameters
157 // #define LINK_SPEED_A {"Auto", }
158 // #define LINK_SPEED_B {"Auto", }
159 // #define AUTO_NEG_A {"Sense", }
160 // #define AUTO_NEG_B {"Sense", }
161 // #define DUP_CAP_A {"Both", }
162 // #define DUP_CAP_B {"Both", }
163 // #define FLOW_CTRL_A {"SymOrRem", }
164 // #define FLOW_CTRL_B {"SymOrRem", }
165 // #define ROLE_A {"Auto", }
166 // #define ROLE_B {"Auto", }
167 // #define PREF_PORT {"A", }
168 // #define CON_TYPE {"Auto", }
169 // #define RLMT_MODE {"CheckLinkState", }
171 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
172 #define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
173 #define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
177 #define OEM_CONFIG_VALUE ( SK_ACT_LED_BLINK | \
178 SK_DUP_LED_NORMAL | \
182 /* Isr return value */
183 #define SkIsrRetVar irqreturn_t
184 #define SkIsrRetNone IRQ_NONE
185 #define SkIsrRetHandled IRQ_HANDLED
188 /*******************************************************************************
190 * Local Function Prototypes
192 ******************************************************************************/
194 static void FreeResources(struct SK_NET_DEVICE
*dev
);
195 static int SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
);
196 static SK_BOOL
BoardAllocMem(SK_AC
*pAC
);
197 static void BoardFreeMem(SK_AC
*pAC
);
198 static void BoardInitMem(SK_AC
*pAC
);
199 static void SetupRing(SK_AC
*, void*, uintptr_t, RXD
**, RXD
**, RXD
**, int*, SK_BOOL
);
200 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
, struct pt_regs
*ptregs
);
201 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
, struct pt_regs
*ptregs
);
202 static int SkGeOpen(struct SK_NET_DEVICE
*dev
);
203 static int SkGeClose(struct SK_NET_DEVICE
*dev
);
204 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
);
205 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
);
206 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
);
207 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
);
208 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
);
209 static void GetConfiguration(SK_AC
*);
210 static void ProductStr(SK_AC
*);
211 static int XmitFrame(SK_AC
*, TX_PORT
*, struct sk_buff
*);
212 static void FreeTxDescriptors(SK_AC
*pAC
, TX_PORT
*);
213 static void FillRxRing(SK_AC
*, RX_PORT
*);
214 static SK_BOOL
FillRxDescriptor(SK_AC
*, RX_PORT
*);
215 static void ReceiveIrq(SK_AC
*, RX_PORT
*, SK_BOOL
);
216 static void ClearAndStartRx(SK_AC
*, int);
217 static void ClearTxIrq(SK_AC
*, int, int);
218 static void ClearRxRing(SK_AC
*, RX_PORT
*);
219 static void ClearTxRing(SK_AC
*, TX_PORT
*);
220 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int new_mtu
);
221 static void PortReInitBmu(SK_AC
*, int);
222 static int SkGeIocMib(DEV_NET
*, unsigned int, int);
223 static int SkGeInitPCI(SK_AC
*pAC
);
224 static void StartDrvCleanupTimer(SK_AC
*pAC
);
225 static void StopDrvCleanupTimer(SK_AC
*pAC
);
226 static int XmitFrameSG(SK_AC
*, TX_PORT
*, struct sk_buff
*);
228 #ifdef SK_DIAG_SUPPORT
229 static SK_U32
ParseDeviceNbrFromSlotName(const char *SlotName
);
230 static int SkDrvInitAdapter(SK_AC
*pAC
, int devNbr
);
231 static int SkDrvDeInitAdapter(SK_AC
*pAC
, int devNbr
);
234 /*******************************************************************************
236 * Extern Function Prototypes
238 ******************************************************************************/
239 static const char SKRootName
[] = "net/sk98lin";
240 static struct proc_dir_entry
*pSkRootDir
;
241 extern struct file_operations sk_proc_fops
;
243 static inline void SkGeProcCreate(struct net_device
*dev
)
245 struct proc_dir_entry
*pe
;
248 (pe
= create_proc_entry(dev
->name
, S_IRUGO
, pSkRootDir
))) {
249 pe
->proc_fops
= &sk_proc_fops
;
251 pe
->owner
= THIS_MODULE
;
255 static inline void SkGeProcRemove(struct net_device
*dev
)
258 remove_proc_entry(dev
->name
, pSkRootDir
);
261 extern void SkDimEnableModerationIfNeeded(SK_AC
*pAC
);
262 extern void SkDimDisplayModerationSettings(SK_AC
*pAC
);
263 extern void SkDimStartModerationTimer(SK_AC
*pAC
);
264 extern void SkDimModerate(SK_AC
*pAC
);
265 extern void SkGeBlinkTimer(unsigned long data
);
268 static void DumpMsg(struct sk_buff
*, char*);
269 static void DumpData(char*, int);
270 static void DumpLong(char*, int);
273 /* global variables *********************************************************/
274 static SK_BOOL DoPrintInterfaceChange
= SK_TRUE
;
275 extern struct ethtool_ops SkGeEthtoolOps
;
277 /* local variables **********************************************************/
278 static uintptr_t TxQueueAddr
[SK_MAX_MACS
][2] = {{0x680, 0x600},{0x780, 0x700}};
279 static uintptr_t RxQueueAddr
[SK_MAX_MACS
] = {0x400, 0x480};
281 /*****************************************************************************
283 * SkGeInitPCI - Init the PCI resources
286 * This function initialize the PCI resources and IO
291 int SkGeInitPCI(SK_AC
*pAC
)
293 struct SK_NET_DEVICE
*dev
= pAC
->dev
[0];
294 struct pci_dev
*pdev
= pAC
->PciDev
;
297 if (pci_enable_device(pdev
) != 0) {
301 dev
->mem_start
= pci_resource_start (pdev
, 0);
302 pci_set_master(pdev
);
304 if (pci_request_regions(pdev
, pAC
->Name
) != 0) {
311 * On big endian machines, we use the adapter's aibility of
312 * reading the descriptors as big endian.
316 SkPciReadCfgDWord(pAC
, PCI_OUR_REG_2
, &our2
);
317 our2
|= PCI_REV_DESC
;
318 SkPciWriteCfgDWord(pAC
, PCI_OUR_REG_2
, our2
);
323 * Remap the regs into kernel space.
325 pAC
->IoBase
= ioremap_nocache(dev
->mem_start
, 0x4000);
335 pci_release_regions(pdev
);
337 pci_disable_device(pdev
);
342 /*****************************************************************************
344 * FreeResources - release resources allocated for adapter
347 * This function releases the IRQ, unmaps the IO and
348 * frees the desriptor ring.
353 static void FreeResources(struct SK_NET_DEVICE
*dev
)
359 pNet
= netdev_priv(dev
);
361 AllocFlag
= pAC
->AllocFlag
;
363 pci_release_regions(pAC
->PciDev
);
365 if (AllocFlag
& SK_ALLOC_IRQ
) {
366 free_irq(dev
->irq
, dev
);
369 iounmap(pAC
->IoBase
);
371 if (pAC
->pDescrMem
) {
375 } /* FreeResources */
377 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
378 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
379 MODULE_LICENSE("GPL");
382 static char *Speed_A
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
384 static char *Speed_A
[SK_MAX_CARD_PARAM
] = {"", };
388 static char *Speed_B
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
390 static char *Speed_B
[SK_MAX_CARD_PARAM
] = {"", };
394 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = AUTO_NEG_A
;
396 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = {"", };
400 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = DUP_CAP_A
;
402 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = {"", };
406 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_A
;
408 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = {"", };
412 static char *Role_A
[SK_MAX_CARD_PARAM
] = ROLE_A
;
414 static char *Role_A
[SK_MAX_CARD_PARAM
] = {"", };
418 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = AUTO_NEG_B
;
420 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = {"", };
424 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = DUP_CAP_B
;
426 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = {"", };
430 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_B
;
432 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = {"", };
436 static char *Role_B
[SK_MAX_CARD_PARAM
] = ROLE_B
;
438 static char *Role_B
[SK_MAX_CARD_PARAM
] = {"", };
442 static char *ConType
[SK_MAX_CARD_PARAM
] = CON_TYPE
;
444 static char *ConType
[SK_MAX_CARD_PARAM
] = {"", };
448 static char *PrefPort
[SK_MAX_CARD_PARAM
] = PREF_PORT
;
450 static char *PrefPort
[SK_MAX_CARD_PARAM
] = {"", };
454 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = RLMT_MODE
;
456 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = {"", };
459 static int IntsPerSec
[SK_MAX_CARD_PARAM
];
460 static char *Moderation
[SK_MAX_CARD_PARAM
];
461 static char *ModerationMask
[SK_MAX_CARD_PARAM
];
462 static char *AutoSizing
[SK_MAX_CARD_PARAM
];
463 static char *Stats
[SK_MAX_CARD_PARAM
];
465 module_param_array(Speed_A
, charp
, NULL
, 0);
466 module_param_array(Speed_B
, charp
, NULL
, 0);
467 module_param_array(AutoNeg_A
, charp
, NULL
, 0);
468 module_param_array(AutoNeg_B
, charp
, NULL
, 0);
469 module_param_array(DupCap_A
, charp
, NULL
, 0);
470 module_param_array(DupCap_B
, charp
, NULL
, 0);
471 module_param_array(FlowCtrl_A
, charp
, NULL
, 0);
472 module_param_array(FlowCtrl_B
, charp
, NULL
, 0);
473 module_param_array(Role_A
, charp
, NULL
, 0);
474 module_param_array(Role_B
, charp
, NULL
, 0);
475 module_param_array(ConType
, charp
, NULL
, 0);
476 module_param_array(PrefPort
, charp
, NULL
, 0);
477 module_param_array(RlmtMode
, charp
, NULL
, 0);
478 /* used for interrupt moderation */
479 module_param_array(IntsPerSec
, int, NULL
, 0);
480 module_param_array(Moderation
, charp
, NULL
, 0);
481 module_param_array(Stats
, charp
, NULL
, 0);
482 module_param_array(ModerationMask
, charp
, NULL
, 0);
483 module_param_array(AutoSizing
, charp
, NULL
, 0);
485 /*****************************************************************************
487 * SkGeBoardInit - do level 0 and 1 initialization
490 * This function prepares the board hardware for running. The desriptor
491 * ring is set up, the IRQ is allocated and the configuration settings
495 * 0, if everything is ok
498 static int __init
SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
)
502 char *DescrString
= "sk98lin: Driver for Linux"; /* this is given to PNMI */
503 char *VerStr
= VER_STRING
;
504 int Ret
; /* return code of request_irq */
507 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
508 ("IoBase: %08lX\n", (unsigned long)pAC
->IoBase
));
509 for (i
=0; i
<SK_MAX_MACS
; i
++) {
510 pAC
->TxPort
[i
][0].HwAddr
= pAC
->IoBase
+ TxQueueAddr
[i
][0];
511 pAC
->TxPort
[i
][0].PortIndex
= i
;
512 pAC
->RxPort
[i
].HwAddr
= pAC
->IoBase
+ RxQueueAddr
[i
];
513 pAC
->RxPort
[i
].PortIndex
= i
;
516 /* Initialize the mutexes */
517 for (i
=0; i
<SK_MAX_MACS
; i
++) {
518 spin_lock_init(&pAC
->TxPort
[i
][0].TxDesRingLock
);
519 spin_lock_init(&pAC
->RxPort
[i
].RxDesRingLock
);
521 spin_lock_init(&pAC
->SlowPathLock
);
523 /* setup phy_id blink timer */
524 pAC
->BlinkTimer
.function
= SkGeBlinkTimer
;
525 pAC
->BlinkTimer
.data
= (unsigned long) dev
;
526 init_timer(&pAC
->BlinkTimer
);
528 /* level 0 init common modules here */
530 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
531 /* Does a RESET on board ...*/
532 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
) != 0) {
533 printk("HWInit (0) failed.\n");
534 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
537 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
538 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
539 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
540 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
541 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
542 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
544 pAC
->BoardLevel
= SK_INIT_DATA
;
545 pAC
->RxBufSize
= ETH_BUF_SIZE
;
547 SK_PNMI_SET_DRIVER_DESCR(pAC
, DescrString
);
548 SK_PNMI_SET_DRIVER_VER(pAC
, VerStr
);
550 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
552 /* level 1 init common modules here (HW init) */
553 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
554 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
555 printk("sk98lin: HWInit (1) failed.\n");
556 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
559 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
560 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
561 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
562 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
563 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
564 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
566 /* Set chipset type support */
567 pAC
->ChipsetType
= 0;
568 if ((pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
) ||
569 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON_LITE
)) {
570 pAC
->ChipsetType
= 1;
573 GetConfiguration(pAC
);
574 if (pAC
->RlmtNets
== 2) {
575 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
578 pAC
->BoardLevel
= SK_INIT_IO
;
579 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
581 if (pAC
->GIni
.GIMacsFound
== 2) {
582 Ret
= request_irq(dev
->irq
, SkGeIsr
, SA_SHIRQ
, pAC
->Name
, dev
);
583 } else if (pAC
->GIni
.GIMacsFound
== 1) {
584 Ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, SA_SHIRQ
,
587 printk(KERN_WARNING
"sk98lin: Illegal number of ports: %d\n",
588 pAC
->GIni
.GIMacsFound
);
593 printk(KERN_WARNING
"sk98lin: Requested IRQ %d is busy.\n",
597 pAC
->AllocFlag
|= SK_ALLOC_IRQ
;
599 /* Alloc memory for this board (Mem for RxD/TxD) : */
600 if(!BoardAllocMem(pAC
)) {
601 printk("No memory for descriptor rings.\n");
606 /* tschilling: New common function with minimum size check. */
608 if (pAC
->RlmtNets
== 2) {
612 if (SkGeInitAssignRamToQueues(
617 printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
622 } /* SkGeBoardInit */
625 /*****************************************************************************
627 * BoardAllocMem - allocate the memory for the descriptor rings
630 * This function allocates the memory for all descriptor rings.
631 * Each ring is aligned for the desriptor alignment and no ring
632 * has a 4 GByte boundary in it (because the upper 32 bit must
633 * be constant for all descriptiors in one rings).
636 * SK_TRUE, if all memory could be allocated
639 static SK_BOOL
BoardAllocMem(
642 caddr_t pDescrMem
; /* pointer to descriptor memory area */
643 size_t AllocLength
; /* length of complete descriptor area */
644 int i
; /* loop counter */
645 unsigned long BusAddr
;
648 /* rings plus one for alignment (do not cross 4 GB boundary) */
649 /* RX_RING_SIZE is assumed bigger than TX_RING_SIZE */
650 #if (BITS_PER_LONG == 32)
651 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
653 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
657 pDescrMem
= pci_alloc_consistent(pAC
->PciDev
, AllocLength
,
660 if (pDescrMem
== NULL
) {
663 pAC
->pDescrMem
= pDescrMem
;
664 BusAddr
= (unsigned long) pAC
->pDescrMemDMA
;
666 /* Descriptors need 8 byte alignment, and this is ensured
667 * by pci_alloc_consistent.
669 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
670 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
671 ("TX%d/A: pDescrMem: %lX, PhysDescrMem: %lX\n",
672 i
, (unsigned long) pDescrMem
,
674 pAC
->TxPort
[i
][0].pTxDescrRing
= pDescrMem
;
675 pAC
->TxPort
[i
][0].VTxDescrRing
= BusAddr
;
676 pDescrMem
+= TX_RING_SIZE
;
677 BusAddr
+= TX_RING_SIZE
;
679 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
680 ("RX%d: pDescrMem: %lX, PhysDescrMem: %lX\n",
681 i
, (unsigned long) pDescrMem
,
682 (unsigned long)BusAddr
));
683 pAC
->RxPort
[i
].pRxDescrRing
= pDescrMem
;
684 pAC
->RxPort
[i
].VRxDescrRing
= BusAddr
;
685 pDescrMem
+= RX_RING_SIZE
;
686 BusAddr
+= RX_RING_SIZE
;
690 } /* BoardAllocMem */
693 /****************************************************************************
695 * BoardFreeMem - reverse of BoardAllocMem
698 * Free all memory allocated in BoardAllocMem: adapter context,
699 * descriptor rings, locks.
703 static void BoardFreeMem(
706 size_t AllocLength
; /* length of complete descriptor area */
708 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
710 #if (BITS_PER_LONG == 32)
711 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
713 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
717 pci_free_consistent(pAC
->PciDev
, AllocLength
,
718 pAC
->pDescrMem
, pAC
->pDescrMemDMA
);
719 pAC
->pDescrMem
= NULL
;
723 /*****************************************************************************
725 * BoardInitMem - initiate the descriptor rings
728 * This function sets the descriptor rings up in memory.
729 * The adapter is initialized with the descriptor start addresses.
733 static void BoardInitMem(
734 SK_AC
*pAC
) /* pointer to adapter context */
736 int i
; /* loop counter */
737 int RxDescrSize
; /* the size of a rx descriptor rounded up to alignment*/
738 int TxDescrSize
; /* the size of a tx descriptor rounded up to alignment*/
740 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
743 RxDescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
744 pAC
->RxDescrPerRing
= RX_RING_SIZE
/ RxDescrSize
;
745 TxDescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
746 pAC
->TxDescrPerRing
= TX_RING_SIZE
/ RxDescrSize
;
748 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
751 pAC
->TxPort
[i
][0].pTxDescrRing
,
752 pAC
->TxPort
[i
][0].VTxDescrRing
,
753 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingHead
,
754 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingTail
,
755 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingPrev
,
756 &pAC
->TxPort
[i
][0].TxdRingFree
,
760 pAC
->RxPort
[i
].pRxDescrRing
,
761 pAC
->RxPort
[i
].VRxDescrRing
,
762 &pAC
->RxPort
[i
].pRxdRingHead
,
763 &pAC
->RxPort
[i
].pRxdRingTail
,
764 &pAC
->RxPort
[i
].pRxdRingPrev
,
765 &pAC
->RxPort
[i
].RxdRingFree
,
771 /*****************************************************************************
773 * SetupRing - create one descriptor ring
776 * This function creates one descriptor ring in the given memory area.
777 * The head, tail and number of free descriptors in the ring are set.
782 static void SetupRing(
784 void *pMemArea
, /* a pointer to the memory area for the ring */
785 uintptr_t VMemArea
, /* the virtual bus address of the memory area */
786 RXD
**ppRingHead
, /* address where the head should be written */
787 RXD
**ppRingTail
, /* address where the tail should be written */
788 RXD
**ppRingPrev
, /* address where the tail should be written */
789 int *pRingFree
, /* address where the # of free descr. goes */
790 SK_BOOL IsTx
) /* flag: is this a tx ring */
792 int i
; /* loop counter */
793 int DescrSize
; /* the size of a descriptor rounded up to alignment*/
794 int DescrNum
; /* number of descriptors per ring */
795 RXD
*pDescr
; /* pointer to a descriptor (receive or transmit) */
796 RXD
*pNextDescr
; /* pointer to the next descriptor */
797 RXD
*pPrevDescr
; /* pointer to the previous descriptor */
798 uintptr_t VNextDescr
; /* the virtual bus address of the next descriptor */
800 if (IsTx
== SK_TRUE
) {
801 DescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) *
803 DescrNum
= TX_RING_SIZE
/ DescrSize
;
805 DescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) *
807 DescrNum
= RX_RING_SIZE
/ DescrSize
;
810 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
811 ("Descriptor size: %d Descriptor Number: %d\n",
812 DescrSize
,DescrNum
));
814 pDescr
= (RXD
*) pMemArea
;
816 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
817 VNextDescr
= VMemArea
+ DescrSize
;
818 for(i
=0; i
<DescrNum
; i
++) {
819 /* set the pointers right */
820 pDescr
->VNextRxd
= VNextDescr
& 0xffffffffULL
;
821 pDescr
->pNextRxd
= pNextDescr
;
822 if (!IsTx
) pDescr
->TcpSumStarts
= ETH_HLEN
<< 16 | ETH_HLEN
;
824 /* advance one step */
827 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
828 VNextDescr
+= DescrSize
;
830 pPrevDescr
->pNextRxd
= (RXD
*) pMemArea
;
831 pPrevDescr
->VNextRxd
= VMemArea
;
832 pDescr
= (RXD
*) pMemArea
;
833 *ppRingHead
= (RXD
*) pMemArea
;
834 *ppRingTail
= *ppRingHead
;
835 *ppRingPrev
= pPrevDescr
;
836 *pRingFree
= DescrNum
;
840 /*****************************************************************************
842 * PortReInitBmu - re-initiate the descriptor rings for one port
845 * This function reinitializes the descriptor rings of one port
846 * in memory. The port must be stopped before.
847 * The HW is initialized with the descriptor start addresses.
852 static void PortReInitBmu(
853 SK_AC
*pAC
, /* pointer to adapter context */
854 int PortIndex
) /* index of the port for which to re-init */
856 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
859 /* set address of first descriptor of ring in BMU */
860 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_L
,
861 (uint32_t)(((caddr_t
)
862 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
863 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
864 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) &
866 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_H
,
867 (uint32_t)(((caddr_t
)
868 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
869 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
870 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) >> 32));
871 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_L
,
872 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
873 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
874 pAC
->RxPort
[PortIndex
].VRxDescrRing
) & 0xFFFFFFFF));
875 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_H
,
876 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
877 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
878 pAC
->RxPort
[PortIndex
].VRxDescrRing
) >> 32));
879 } /* PortReInitBmu */
882 /****************************************************************************
884 * SkGeIsr - handle adapter interrupts
887 * The interrupt routine is called when the network adapter
888 * generates an interrupt. It may also be called if another device
889 * shares this interrupt vector with the driver.
894 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
, struct pt_regs
*ptregs
)
896 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
899 SK_U32 IntSrc
; /* interrupts source register contents */
901 pNet
= netdev_priv(dev
);
905 * Check and process if its our interrupt
907 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
912 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
913 #if 0 /* software irq currently not used */
914 if (IntSrc
& IS_IRQ_SW
) {
915 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
916 SK_DBGCAT_DRV_INT_SRC
,
920 if (IntSrc
& IS_R1_F
) {
921 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
922 SK_DBGCAT_DRV_INT_SRC
,
924 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
925 SK_PNMI_CNT_RX_INTR(pAC
, 0);
927 if (IntSrc
& IS_R2_F
) {
928 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
929 SK_DBGCAT_DRV_INT_SRC
,
931 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_TRUE
);
932 SK_PNMI_CNT_RX_INTR(pAC
, 1);
934 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
935 if (IntSrc
& IS_XA1_F
) {
936 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
937 SK_DBGCAT_DRV_INT_SRC
,
938 ("EOF AS TX1 IRQ\n"));
939 SK_PNMI_CNT_TX_INTR(pAC
, 0);
940 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
941 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
942 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
944 if (IntSrc
& IS_XA2_F
) {
945 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
946 SK_DBGCAT_DRV_INT_SRC
,
947 ("EOF AS TX2 IRQ\n"));
948 SK_PNMI_CNT_TX_INTR(pAC
, 1);
949 spin_lock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
950 FreeTxDescriptors(pAC
, &pAC
->TxPort
[1][TX_PRIO_LOW
]);
951 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
953 #if 0 /* only if sync. queues used */
954 if (IntSrc
& IS_XS1_F
) {
955 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
956 SK_DBGCAT_DRV_INT_SRC
,
957 ("EOF SY TX1 IRQ\n"));
958 SK_PNMI_CNT_TX_INTR(pAC
, 1);
959 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
960 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
961 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
962 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
964 if (IntSrc
& IS_XS2_F
) {
965 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
966 SK_DBGCAT_DRV_INT_SRC
,
967 ("EOF SY TX2 IRQ\n"));
968 SK_PNMI_CNT_TX_INTR(pAC
, 1);
969 spin_lock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
970 FreeTxDescriptors(pAC
, 1, TX_PRIO_HIGH
);
971 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
972 ClearTxIrq(pAC
, 1, TX_PRIO_HIGH
);
977 /* do all IO at once */
978 if (IntSrc
& IS_R1_F
)
979 ClearAndStartRx(pAC
, 0);
980 if (IntSrc
& IS_R2_F
)
981 ClearAndStartRx(pAC
, 1);
982 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
983 if (IntSrc
& IS_XA1_F
)
984 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
985 if (IntSrc
& IS_XA2_F
)
986 ClearTxIrq(pAC
, 1, TX_PRIO_LOW
);
988 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
989 } /* while (IntSrc & IRQ_MASK != 0) */
991 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
992 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
993 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
994 ("SPECIAL IRQ DP-Cards => %x\n", IntSrc
));
995 pAC
->CheckQueue
= SK_FALSE
;
996 spin_lock(&pAC
->SlowPathLock
);
997 if (IntSrc
& SPECIAL_IRQS
)
998 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
1000 SkEventDispatcher(pAC
, pAC
->IoBase
);
1001 spin_unlock(&pAC
->SlowPathLock
);
1004 * do it all again is case we cleared an interrupt that
1005 * came in after handling the ring (OUTs may be delayed
1006 * in hardware buffers, but are through after IN)
1008 * rroesler: has been commented out and shifted to
1009 * SkGeDrvEvent(), because it is timer
1012 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1013 ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1016 if (pAC
->CheckQueue
) {
1017 pAC
->CheckQueue
= SK_FALSE
;
1018 spin_lock(&pAC
->SlowPathLock
);
1019 SkEventDispatcher(pAC
, pAC
->IoBase
);
1020 spin_unlock(&pAC
->SlowPathLock
);
1023 /* IRQ is processed - Enable IRQs again*/
1024 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1026 return SkIsrRetHandled
;
1030 /****************************************************************************
1032 * SkGeIsrOnePort - handle adapter interrupts for single port adapter
1035 * The interrupt routine is called when the network adapter
1036 * generates an interrupt. It may also be called if another device
1037 * shares this interrupt vector with the driver.
1038 * This is the same as above, but handles only one port.
1043 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
, struct pt_regs
*ptregs
)
1045 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
1048 SK_U32 IntSrc
; /* interrupts source register contents */
1050 pNet
= netdev_priv(dev
);
1054 * Check and process if its our interrupt
1056 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
1058 return SkIsrRetNone
;
1061 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
1062 #if 0 /* software irq currently not used */
1063 if (IntSrc
& IS_IRQ_SW
) {
1064 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1065 SK_DBGCAT_DRV_INT_SRC
,
1066 ("Software IRQ\n"));
1069 if (IntSrc
& IS_R1_F
) {
1070 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1071 SK_DBGCAT_DRV_INT_SRC
,
1073 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
1074 SK_PNMI_CNT_RX_INTR(pAC
, 0);
1076 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1077 if (IntSrc
& IS_XA1_F
) {
1078 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1079 SK_DBGCAT_DRV_INT_SRC
,
1080 ("EOF AS TX1 IRQ\n"));
1081 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1082 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1083 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
1084 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1086 #if 0 /* only if sync. queues used */
1087 if (IntSrc
& IS_XS1_F
) {
1088 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1089 SK_DBGCAT_DRV_INT_SRC
,
1090 ("EOF SY TX1 IRQ\n"));
1091 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1092 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1093 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
1094 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1095 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
1100 /* do all IO at once */
1101 if (IntSrc
& IS_R1_F
)
1102 ClearAndStartRx(pAC
, 0);
1103 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1104 if (IntSrc
& IS_XA1_F
)
1105 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
1107 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
1108 } /* while (IntSrc & IRQ_MASK != 0) */
1110 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
1111 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
1112 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
1113 ("SPECIAL IRQ SP-Cards => %x\n", IntSrc
));
1114 pAC
->CheckQueue
= SK_FALSE
;
1115 spin_lock(&pAC
->SlowPathLock
);
1116 if (IntSrc
& SPECIAL_IRQS
)
1117 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
1119 SkEventDispatcher(pAC
, pAC
->IoBase
);
1120 spin_unlock(&pAC
->SlowPathLock
);
1123 * do it all again is case we cleared an interrupt that
1124 * came in after handling the ring (OUTs may be delayed
1125 * in hardware buffers, but are through after IN)
1127 * rroesler: has been commented out and shifted to
1128 * SkGeDrvEvent(), because it is timer
1131 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1134 /* IRQ is processed - Enable IRQs again*/
1135 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1137 return SkIsrRetHandled
;
1138 } /* SkGeIsrOnePort */
1140 #ifdef CONFIG_NET_POLL_CONTROLLER
1141 /****************************************************************************
1143 * SkGePollController - polling receive, for netconsole
1146 * Polling receive - used by netconsole and other diagnostic tools
1147 * to allow network i/o with interrupts disabled.
1151 static void SkGePollController(struct net_device
*dev
)
1153 disable_irq(dev
->irq
);
1154 SkGeIsr(dev
->irq
, dev
, NULL
);
1155 enable_irq(dev
->irq
);
1159 /****************************************************************************
1161 * SkGeOpen - handle start of initialized adapter
1164 * This function starts the initialized adapter.
1165 * The board level variable is set and the adapter is
1166 * brought to full functionality.
1167 * The device flags are set for operation.
1168 * Do all necessary level 2 initialization, enable interrupts and
1169 * give start command to RLMT.
1175 static int SkGeOpen(
1176 struct SK_NET_DEVICE
*dev
)
1180 unsigned long Flags
; /* for spin lock */
1182 SK_EVPARA EvPara
; /* an event parameter union */
1184 pNet
= netdev_priv(dev
);
1187 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1188 ("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC
));
1190 #ifdef SK_DIAG_SUPPORT
1191 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1192 if (pAC
->Pnmi
.DiagAttached
== SK_DIAG_RUNNING
) {
1193 return (-1); /* still in use by diag; deny actions */
1198 /* Set blink mode */
1199 if ((pAC
->PciDev
->vendor
== 0x1186) || (pAC
->PciDev
->vendor
== 0x11ab ))
1200 pAC
->GIni
.GILedBlinkCtrl
= OEM_CONFIG_VALUE
;
1202 if (pAC
->BoardLevel
== SK_INIT_DATA
) {
1203 /* level 1 init common modules here */
1204 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
1205 printk("%s: HWInit (1) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1208 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1209 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1210 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1211 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1212 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1213 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1214 pAC
->BoardLevel
= SK_INIT_IO
;
1217 if (pAC
->BoardLevel
!= SK_INIT_RUN
) {
1218 /* tschilling: Level 2 init modules here, check return value. */
1219 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
) != 0) {
1220 printk("%s: HWInit (2) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1223 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1224 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1225 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1226 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1227 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1228 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1229 pAC
->BoardLevel
= SK_INIT_RUN
;
1232 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1233 /* Enable transmit descriptor polling. */
1234 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
1235 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
1237 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
1239 StartDrvCleanupTimer(pAC
);
1240 SkDimEnableModerationIfNeeded(pAC
);
1241 SkDimDisplayModerationSettings(pAC
);
1243 pAC
->GIni
.GIValIrqMask
&= IRQ_MASK
;
1245 /* enable Interrupts */
1246 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1247 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
1249 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1251 if ((pAC
->RlmtMode
!= 0) && (pAC
->MaxPorts
== 0)) {
1252 EvPara
.Para32
[0] = pAC
->RlmtNets
;
1253 EvPara
.Para32
[1] = -1;
1254 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
,
1256 EvPara
.Para32
[0] = pAC
->RlmtMode
;
1257 EvPara
.Para32
[1] = 0;
1258 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_MODE_CHANGE
,
1262 EvPara
.Para32
[0] = pNet
->NetNr
;
1263 EvPara
.Para32
[1] = -1;
1264 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
1265 SkEventDispatcher(pAC
, pAC
->IoBase
);
1266 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1272 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1273 ("SkGeOpen suceeded\n"));
1279 /****************************************************************************
1281 * SkGeClose - Stop initialized adapter
1284 * Close initialized adapter.
1288 * error code - on error
1290 static int SkGeClose(
1291 struct SK_NET_DEVICE
*dev
)
1297 unsigned long Flags
; /* for spin lock */
1302 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1303 ("SkGeClose: pAC=0x%lX ", (unsigned long)pAC
));
1305 pNet
= netdev_priv(dev
);
1308 #ifdef SK_DIAG_SUPPORT
1309 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1310 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
1312 ** notify that the interface which has been closed
1313 ** by operator interaction must not be started up
1314 ** again when the DIAG has finished.
1316 newPtrNet
= netdev_priv(pAC
->dev
[0]);
1317 if (newPtrNet
== pNet
) {
1318 pAC
->WasIfUp
[0] = SK_FALSE
;
1320 pAC
->WasIfUp
[1] = SK_FALSE
;
1322 return 0; /* return to system everything is fine... */
1324 pAC
->DiagFlowCtrl
= SK_FALSE
;
1329 netif_stop_queue(dev
);
1331 if (pAC
->RlmtNets
== 1)
1332 PortIdx
= pAC
->ActivePort
;
1334 PortIdx
= pNet
->NetNr
;
1336 StopDrvCleanupTimer(pAC
);
1339 * Clear multicast table, promiscuous mode ....
1341 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
1342 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
1345 if (pAC
->MaxPorts
== 1) {
1346 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1347 /* disable interrupts */
1348 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1349 EvPara
.Para32
[0] = pNet
->NetNr
;
1350 EvPara
.Para32
[1] = -1;
1351 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1352 SkEventDispatcher(pAC
, pAC
->IoBase
);
1353 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1354 /* stop the hardware */
1355 SkGeDeInit(pAC
, pAC
->IoBase
);
1356 pAC
->BoardLevel
= SK_INIT_DATA
;
1357 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1360 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1361 EvPara
.Para32
[0] = pNet
->NetNr
;
1362 EvPara
.Para32
[1] = -1;
1363 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1364 SkPnmiEvent(pAC
, pAC
->IoBase
, SK_PNMI_EVT_XMAC_RESET
, EvPara
);
1365 SkEventDispatcher(pAC
, pAC
->IoBase
);
1366 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1369 spin_lock_irqsave(&pAC
->TxPort
[pNet
->PortNr
]
1370 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1371 SkGeStopPort(pAC
, pAC
->IoBase
, pNet
->PortNr
,
1372 SK_STOP_ALL
, SK_HARD_RST
);
1373 spin_unlock_irqrestore(&pAC
->TxPort
[pNet
->PortNr
]
1374 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1377 if (pAC
->RlmtNets
== 1) {
1378 /* clear all descriptor rings */
1379 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1380 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
1381 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
1382 ClearTxRing(pAC
, &pAC
->TxPort
[i
][TX_PRIO_LOW
]);
1385 /* clear port descriptor rings */
1386 ReceiveIrq(pAC
, &pAC
->RxPort
[pNet
->PortNr
], SK_TRUE
);
1387 ClearRxRing(pAC
, &pAC
->RxPort
[pNet
->PortNr
]);
1388 ClearTxRing(pAC
, &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
]);
1391 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1392 ("SkGeClose: done "));
1394 SK_MEMSET(&(pAC
->PnmiBackup
), 0, sizeof(SK_PNMI_STRUCT_DATA
));
1395 SK_MEMCPY(&(pAC
->PnmiBackup
), &(pAC
->PnmiStruct
),
1396 sizeof(SK_PNMI_STRUCT_DATA
));
1405 /*****************************************************************************
1407 * SkGeXmit - Linux frame transmit function
1410 * The system calls this function to send frames onto the wire.
1411 * It puts the frame in the tx descriptor ring. If the ring is
1412 * full then, the 'tbusy' flag is set.
1415 * 0, if everything is ok
1417 * WARNING: returning 1 in 'tbusy' case caused system crashes (double
1418 * allocated skb's) !!!
1420 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
)
1424 int Rc
; /* return code of XmitFrame */
1426 pNet
= netdev_priv(dev
);
1429 if ((!skb_shinfo(skb
)->nr_frags
) ||
1430 (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
)) {
1431 /* Don't activate scatter-gather and hardware checksum */
1433 if (pAC
->RlmtNets
== 2)
1436 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1441 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1444 /* scatter-gather and hardware TCP checksumming anabled*/
1445 if (pAC
->RlmtNets
== 2)
1448 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1453 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1457 /* Transmitter out of resources? */
1459 netif_stop_queue(dev
);
1462 /* If not taken, give buffer ownership back to the
1468 dev
->trans_start
= jiffies
;
1473 /*****************************************************************************
1475 * XmitFrame - fill one socket buffer into the transmit ring
1478 * This function puts a message into the transmit descriptor ring
1479 * if there is a descriptors left.
1480 * Linux skb's consist of only one continuous buffer.
1481 * The first step locks the ring. It is held locked
1482 * all time to avoid problems with SWITCH_../PORT_RESET.
1483 * Then the descriptoris allocated.
1484 * The second part is linking the buffer to the descriptor.
1485 * At the very last, the Control field of the descriptor
1486 * is made valid for the BMU and a start TX command is given
1490 * > 0 - on succes: the number of bytes in the message
1491 * = 0 - on resource shortage: this frame sent or dropped, now
1492 * the ring is full ( -> set tbusy)
1493 * < 0 - on failure: other problems ( -> return failure to upper layers)
1495 static int XmitFrame(
1496 SK_AC
*pAC
, /* pointer to adapter context */
1497 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1498 struct sk_buff
*pMessage
) /* pointer to send-message */
1500 TXD
*pTxd
; /* the rxd to fill */
1502 unsigned long Flags
;
1504 int BytesSend
= pMessage
->len
;
1506 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
, ("X"));
1508 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1509 #ifndef USE_TX_COMPLETE
1510 FreeTxDescriptors(pAC
, pTxPort
);
1512 if (pTxPort
->TxdRingFree
== 0) {
1514 ** no enough free descriptors in ring at the moment.
1515 ** Maybe free'ing some old one help?
1517 FreeTxDescriptors(pAC
, pTxPort
);
1518 if (pTxPort
->TxdRingFree
== 0) {
1519 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1520 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1521 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1522 SK_DBGCAT_DRV_TX_PROGRESS
,
1523 ("XmitFrame failed\n"));
1525 ** the desired message can not be sent
1526 ** Because tbusy seems to be set, the message
1527 ** should not be freed here. It will be used
1528 ** by the scheduler of the ethernet handler
1535 ** If the passed socket buffer is of smaller MTU-size than 60,
1536 ** copy everything into new buffer and fill all bytes between
1537 ** the original packet end and the new packet end of 60 with 0x00.
1538 ** This is to resolve faulty padding by the HW with 0xaa bytes.
1540 if (BytesSend
< C_LEN_ETHERNET_MINSIZE
) {
1541 if ((pMessage
= skb_padto(pMessage
, C_LEN_ETHERNET_MINSIZE
)) == NULL
) {
1542 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1545 pMessage
->len
= C_LEN_ETHERNET_MINSIZE
;
1549 ** advance head counter behind descriptor needed for this frame,
1550 ** so that needed descriptor is reserved from that on. The next
1551 ** action will be to add the passed buffer to the TX-descriptor
1553 pTxd
= pTxPort
->pTxdRingHead
;
1554 pTxPort
->pTxdRingHead
= pTxd
->pNextTxd
;
1555 pTxPort
->TxdRingFree
--;
1558 DumpMsg(pMessage
, "XmitFrame");
1562 ** First step is to map the data to be sent via the adapter onto
1563 ** the DMA memory. Kernel 2.2 uses virt_to_bus(), but kernels 2.4
1564 ** and 2.6 need to use pci_map_page() for that mapping.
1566 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1567 virt_to_page(pMessage
->data
),
1568 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1571 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1572 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1573 pTxd
->pMBuf
= pMessage
;
1575 if (pMessage
->ip_summed
== CHECKSUM_HW
) {
1576 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1577 u16 offset
= hdrlen
+ pMessage
->csum
;
1579 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1580 (pAC
->GIni
.GIChipRev
== 0) &&
1581 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1582 pTxd
->TBControl
= BMU_TCP_CHECK
;
1584 pTxd
->TBControl
= BMU_UDP_CHECK
;
1587 pTxd
->TcpSumOfs
= 0;
1588 pTxd
->TcpSumSt
= hdrlen
;
1589 pTxd
->TcpSumWr
= offset
;
1591 pTxd
->TBControl
|= BMU_OWN
| BMU_STF
|
1593 #ifdef USE_TX_COMPLETE
1598 pTxd
->TBControl
= BMU_OWN
| BMU_STF
| BMU_CHECK
|
1600 #ifdef USE_TX_COMPLETE
1607 ** If previous descriptor already done, give TX start cmd
1609 pOldTxd
= xchg(&pTxPort
->pTxdRingPrev
, pTxd
);
1610 if ((pOldTxd
->TBControl
& BMU_OWN
) == 0) {
1611 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1615 ** after releasing the lock, the skb may immediately be free'd
1617 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1618 if (pTxPort
->TxdRingFree
!= 0) {
1626 /*****************************************************************************
1628 * XmitFrameSG - fill one socket buffer into the transmit ring
1629 * (use SG and TCP/UDP hardware checksumming)
1632 * This function puts a message into the transmit descriptor ring
1633 * if there is a descriptors left.
1636 * > 0 - on succes: the number of bytes in the message
1637 * = 0 - on resource shortage: this frame sent or dropped, now
1638 * the ring is full ( -> set tbusy)
1639 * < 0 - on failure: other problems ( -> return failure to upper layers)
1641 static int XmitFrameSG(
1642 SK_AC
*pAC
, /* pointer to adapter context */
1643 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1644 struct sk_buff
*pMessage
) /* pointer to send-message */
1652 skb_frag_t
*sk_frag
;
1654 unsigned long Flags
;
1657 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1658 #ifndef USE_TX_COMPLETE
1659 FreeTxDescriptors(pAC
, pTxPort
);
1661 if ((skb_shinfo(pMessage
)->nr_frags
+1) > pTxPort
->TxdRingFree
) {
1662 FreeTxDescriptors(pAC
, pTxPort
);
1663 if ((skb_shinfo(pMessage
)->nr_frags
+ 1) > pTxPort
->TxdRingFree
) {
1664 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1665 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1666 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1667 SK_DBGCAT_DRV_TX_PROGRESS
,
1668 ("XmitFrameSG failed - Ring full\n"));
1669 /* this message can not be sent now */
1674 pTxd
= pTxPort
->pTxdRingHead
;
1680 ** Map the first fragment (header) into the DMA-space
1682 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1683 virt_to_page(pMessage
->data
),
1684 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1685 skb_headlen(pMessage
),
1688 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1689 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1692 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1694 if (pMessage
->ip_summed
== CHECKSUM_HW
) {
1695 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1696 u16 offset
= hdrlen
+ pMessage
->csum
;
1698 Control
= BMU_STFWD
;
1701 ** We have to use the opcode for tcp here, because the
1702 ** opcode for udp is not working in the hardware yet
1705 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1706 (pAC
->GIni
.GIChipRev
== 0) &&
1707 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1708 Control
|= BMU_TCP_CHECK
;
1710 Control
|= BMU_UDP_CHECK
;
1713 pTxd
->TcpSumOfs
= 0;
1714 pTxd
->TcpSumSt
= hdrlen
;
1715 pTxd
->TcpSumWr
= offset
;
1717 Control
= BMU_CHECK
| BMU_SW
;
1719 pTxd
->TBControl
= BMU_STF
| Control
| skb_headlen(pMessage
);
1721 pTxd
= pTxd
->pNextTxd
;
1722 pTxPort
->TxdRingFree
--;
1723 BytesSend
+= skb_headlen(pMessage
);
1726 ** Browse over all SG fragments and map each of them into the DMA space
1728 for (CurrFrag
= 0; CurrFrag
< skb_shinfo(pMessage
)->nr_frags
; CurrFrag
++) {
1729 sk_frag
= &skb_shinfo(pMessage
)->frags
[CurrFrag
];
1731 ** we already have the proper value in entry
1733 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1735 sk_frag
->page_offset
,
1739 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1740 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1741 pTxd
->pMBuf
= pMessage
;
1743 pTxd
->TBControl
= Control
| BMU_OWN
| sk_frag
->size
;;
1746 ** Do we have the last fragment?
1748 if( (CurrFrag
+1) == skb_shinfo(pMessage
)->nr_frags
) {
1749 #ifdef USE_TX_COMPLETE
1750 pTxd
->TBControl
|= BMU_EOF
| BMU_IRQ_EOF
;
1752 pTxd
->TBControl
|= BMU_EOF
;
1754 pTxdFst
->TBControl
|= BMU_OWN
| BMU_SW
;
1757 pTxd
= pTxd
->pNextTxd
;
1758 pTxPort
->TxdRingFree
--;
1759 BytesSend
+= sk_frag
->size
;
1763 ** If previous descriptor already done, give TX start cmd
1765 if ((pTxPort
->pTxdRingPrev
->TBControl
& BMU_OWN
) == 0) {
1766 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1769 pTxPort
->pTxdRingPrev
= pTxdLst
;
1770 pTxPort
->pTxdRingHead
= pTxd
;
1772 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1774 if (pTxPort
->TxdRingFree
> 0) {
1781 /*****************************************************************************
1783 * FreeTxDescriptors - release descriptors from the descriptor ring
1786 * This function releases descriptors from a transmit ring if they
1787 * have been sent by the BMU.
1788 * If a descriptors is sent, it can be freed and the message can
1790 * The SOFTWARE controllable bit is used to prevent running around a
1791 * completely free ring for ever. If this bit is no set in the
1792 * frame (by XmitFrame), this frame has never been sent or is
1794 * The Tx descriptor ring lock must be held while calling this function !!!
1799 static void FreeTxDescriptors(
1800 SK_AC
*pAC
, /* pointer to the adapter context */
1801 TX_PORT
*pTxPort
) /* pointer to destination port structure */
1803 TXD
*pTxd
; /* pointer to the checked descriptor */
1804 TXD
*pNewTail
; /* pointer to 'end' of the ring */
1805 SK_U32 Control
; /* TBControl field of descriptor */
1806 SK_U64 PhysAddr
; /* address of DMA mapping */
1808 pNewTail
= pTxPort
->pTxdRingTail
;
1811 ** loop forever; exits if BMU_SW bit not set in start frame
1812 ** or BMU_OWN bit set in any frame
1815 Control
= pTxd
->TBControl
;
1816 if ((Control
& BMU_SW
) == 0) {
1818 ** software controllable bit is set in first
1819 ** fragment when given to BMU. Not set means that
1820 ** this fragment was never sent or is already
1821 ** freed ( -> ring completely free now).
1823 pTxPort
->pTxdRingTail
= pTxd
;
1824 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1827 if (Control
& BMU_OWN
) {
1828 pTxPort
->pTxdRingTail
= pTxd
;
1829 if (pTxPort
->TxdRingFree
> 0) {
1830 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1836 ** release the DMA mapping, because until not unmapped
1837 ** this buffer is considered being under control of the
1840 PhysAddr
= ((SK_U64
) pTxd
->VDataHigh
) << (SK_U64
) 32;
1841 PhysAddr
|= (SK_U64
) pTxd
->VDataLow
;
1842 pci_unmap_page(pAC
->PciDev
, PhysAddr
,
1846 if (Control
& BMU_EOF
)
1847 DEV_KFREE_SKB_ANY(pTxd
->pMBuf
); /* free message */
1849 pTxPort
->TxdRingFree
++;
1850 pTxd
->TBControl
&= ~BMU_SW
;
1851 pTxd
= pTxd
->pNextTxd
; /* point behind fragment with EOF */
1852 } /* while(forever) */
1853 } /* FreeTxDescriptors */
1855 /*****************************************************************************
1857 * FillRxRing - fill the receive ring with valid descriptors
1860 * This function fills the receive ring descriptors with data
1861 * segments and makes them valid for the BMU.
1862 * The active ring is filled completely, if possible.
1863 * The non-active ring is filled only partial to save memory.
1865 * Description of rx ring structure:
1866 * head - points to the descriptor which will be used next by the BMU
1867 * tail - points to the next descriptor to give to the BMU
1871 static void FillRxRing(
1872 SK_AC
*pAC
, /* pointer to the adapter context */
1873 RX_PORT
*pRxPort
) /* ptr to port struct for which the ring
1876 unsigned long Flags
;
1878 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
1879 while (pRxPort
->RxdRingFree
> pRxPort
->RxFillLimit
) {
1880 if(!FillRxDescriptor(pAC
, pRxPort
))
1883 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
1887 /*****************************************************************************
1889 * FillRxDescriptor - fill one buffer into the receive ring
1892 * The function allocates a new receive buffer and
1893 * puts it into the next descriptor.
1896 * SK_TRUE - a buffer was added to the ring
1897 * SK_FALSE - a buffer could not be added
1899 static SK_BOOL
FillRxDescriptor(
1900 SK_AC
*pAC
, /* pointer to the adapter context struct */
1901 RX_PORT
*pRxPort
) /* ptr to port struct of ring to fill */
1903 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
1904 RXD
*pRxd
; /* the rxd to fill */
1905 SK_U16 Length
; /* data fragment length */
1906 SK_U64 PhysAddr
; /* physical address of a rx buffer */
1908 pMsgBlock
= alloc_skb(pAC
->RxBufSize
, GFP_ATOMIC
);
1909 if (pMsgBlock
== NULL
) {
1910 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1911 SK_DBGCAT_DRV_ENTRY
,
1912 ("%s: Allocation of rx buffer failed !\n",
1913 pAC
->dev
[pRxPort
->PortIndex
]->name
));
1914 SK_PNMI_CNT_NO_RX_BUF(pAC
, pRxPort
->PortIndex
);
1917 skb_reserve(pMsgBlock
, 2); /* to align IP frames */
1918 /* skb allocated ok, so add buffer */
1919 pRxd
= pRxPort
->pRxdRingTail
;
1920 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1921 pRxPort
->RxdRingFree
--;
1922 Length
= pAC
->RxBufSize
;
1923 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1924 virt_to_page(pMsgBlock
->data
),
1925 ((unsigned long) pMsgBlock
->data
&
1928 PCI_DMA_FROMDEVICE
);
1930 pRxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1931 pRxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1932 pRxd
->pMBuf
= pMsgBlock
;
1933 pRxd
->RBControl
= BMU_OWN
|
1940 } /* FillRxDescriptor */
1943 /*****************************************************************************
1945 * ReQueueRxBuffer - fill one buffer back into the receive ring
1948 * Fill a given buffer back into the rx ring. The buffer
1949 * has been previously allocated and aligned, and its phys.
1950 * address calculated, so this is no more necessary.
1954 static void ReQueueRxBuffer(
1955 SK_AC
*pAC
, /* pointer to the adapter context struct */
1956 RX_PORT
*pRxPort
, /* ptr to port struct of ring to fill */
1957 struct sk_buff
*pMsg
, /* pointer to the buffer */
1958 SK_U32 PhysHigh
, /* phys address high dword */
1959 SK_U32 PhysLow
) /* phys address low dword */
1961 RXD
*pRxd
; /* the rxd to fill */
1962 SK_U16 Length
; /* data fragment length */
1964 pRxd
= pRxPort
->pRxdRingTail
;
1965 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1966 pRxPort
->RxdRingFree
--;
1967 Length
= pAC
->RxBufSize
;
1969 pRxd
->VDataLow
= PhysLow
;
1970 pRxd
->VDataHigh
= PhysHigh
;
1972 pRxd
->RBControl
= BMU_OWN
|
1978 } /* ReQueueRxBuffer */
1980 /*****************************************************************************
1982 * ReceiveIrq - handle a receive IRQ
1985 * This function is called when a receive IRQ is set.
1986 * It walks the receive descriptor ring and sends up all
1987 * frames that are complete.
1991 static void ReceiveIrq(
1992 SK_AC
*pAC
, /* pointer to adapter context */
1993 RX_PORT
*pRxPort
, /* pointer to receive port struct */
1994 SK_BOOL SlowPathLock
) /* indicates if SlowPathLock is needed */
1996 RXD
*pRxd
; /* pointer to receive descriptors */
1997 SK_U32 Control
; /* control field of descriptor */
1998 struct sk_buff
*pMsg
; /* pointer to message holding frame */
1999 struct sk_buff
*pNewMsg
; /* pointer to a new message for copying frame */
2000 int FrameLength
; /* total length of received frame */
2001 SK_MBUF
*pRlmtMbuf
; /* ptr to a buffer for giving a frame to rlmt */
2002 SK_EVPARA EvPara
; /* an event parameter union */
2003 unsigned long Flags
; /* for spin lock */
2004 int PortIndex
= pRxPort
->PortIndex
;
2005 unsigned int Offset
;
2006 unsigned int NumBytes
;
2007 unsigned int ForRlmt
;
2010 SK_BOOL IsBadFrame
; /* Bad frame */
2016 /* do forever; exit if BMU_OWN found */
2017 for ( pRxd
= pRxPort
->pRxdRingHead
;
2018 pRxPort
->RxdRingFree
< pAC
->RxDescrPerRing
;
2019 pRxd
= pRxd
->pNextRxd
,
2020 pRxPort
->pRxdRingHead
= pRxd
,
2021 pRxPort
->RxdRingFree
++) {
2024 * For a better understanding of this loop
2025 * Go through every descriptor beginning at the head
2026 * Please note: the ring might be completely received so the OWN bit
2027 * set is not a good crirteria to leave that loop.
2028 * Therefore the RingFree counter is used.
2029 * On entry of this loop pRxd is a pointer to the Rxd that needs
2030 * to be checked next.
2033 Control
= pRxd
->RBControl
;
2035 /* check if this descriptor is ready */
2036 if ((Control
& BMU_OWN
) != 0) {
2037 /* this descriptor is not yet ready */
2038 /* This is the usual end of the loop */
2039 /* We don't need to start the ring again */
2040 FillRxRing(pAC
, pRxPort
);
2043 pAC
->DynIrqModInfo
.NbrProcessedDescr
++;
2045 /* get length of frame and check it */
2046 FrameLength
= Control
& BMU_BBC
;
2047 if (FrameLength
> pAC
->RxBufSize
) {
2051 /* check for STF and EOF */
2052 if ((Control
& (BMU_STF
| BMU_EOF
)) != (BMU_STF
| BMU_EOF
)) {
2056 /* here we have a complete frame in the ring */
2059 FrameStat
= pRxd
->FrameStat
;
2061 /* check for frame length mismatch */
2062 #define XMR_FS_LEN_SHIFT 18
2063 #define GMR_FS_LEN_SHIFT 16
2064 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2065 if (FrameLength
!= (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)) {
2066 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2067 SK_DBGCAT_DRV_RX_PROGRESS
,
2068 ("skge: Frame length mismatch (%u/%u).\n",
2070 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2075 if (FrameLength
!= (SK_U32
) (FrameStat
>> GMR_FS_LEN_SHIFT
)) {
2076 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2077 SK_DBGCAT_DRV_RX_PROGRESS
,
2078 ("skge: Frame length mismatch (%u/%u).\n",
2080 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2086 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2087 IsBc
= (FrameStat
& XMR_FS_BC
) != 0;
2088 IsMc
= (FrameStat
& XMR_FS_MC
) != 0;
2089 IsBadFrame
= (FrameStat
&
2090 (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0;
2092 IsBc
= (FrameStat
& GMR_FS_BC
) != 0;
2093 IsMc
= (FrameStat
& GMR_FS_MC
) != 0;
2094 IsBadFrame
= (((FrameStat
& GMR_FS_ANY_ERR
) != 0) ||
2095 ((FrameStat
& GMR_FS_RX_OK
) == 0));
2098 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2099 ("Received frame of length %d on port %d\n",
2100 FrameLength
, PortIndex
));
2101 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2102 ("Number of free rx descriptors: %d\n",
2103 pRxPort
->RxdRingFree
));
2104 /* DumpMsg(pMsg, "Rx"); */
2106 if ((Control
& BMU_STAT_VAL
) != BMU_STAT_VAL
|| (IsBadFrame
)) {
2108 (FrameStat
& (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0) {
2110 /* there is a receive error in this frame */
2111 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2112 SK_DBGCAT_DRV_RX_PROGRESS
,
2113 ("skge: Error in received frame, dropped!\n"
2114 "Control: %x\nRxStat: %x\n",
2115 Control
, FrameStat
));
2117 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2118 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2124 * if short frame then copy data to reduce memory waste
2126 if ((FrameLength
< SK_COPY_THRESHOLD
) &&
2127 ((pNewMsg
= alloc_skb(FrameLength
+2, GFP_ATOMIC
)) != NULL
)) {
2129 * Short frame detected and allocation successfull
2131 /* use new skb and copy data */
2132 skb_reserve(pNewMsg
, 2);
2133 skb_put(pNewMsg
, FrameLength
);
2134 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2135 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2137 pci_dma_sync_single_for_cpu(pAC
->PciDev
,
2138 (dma_addr_t
) PhysAddr
,
2140 PCI_DMA_FROMDEVICE
);
2141 memcpy(pNewMsg
->data
, pMsg
, FrameLength
);
2143 pci_dma_sync_single_for_device(pAC
->PciDev
,
2144 (dma_addr_t
) PhysAddr
,
2146 PCI_DMA_FROMDEVICE
);
2147 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2148 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2155 * if large frame, or SKB allocation failed, pass
2156 * the SKB directly to the networking
2159 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2160 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2162 /* release the DMA mapping */
2163 pci_unmap_single(pAC
->PciDev
,
2166 PCI_DMA_FROMDEVICE
);
2168 /* set length in message */
2169 skb_put(pMsg
, FrameLength
);
2170 } /* frame > SK_COPY_TRESHOLD */
2172 #ifdef USE_SK_RX_CHECKSUM
2173 pMsg
->csum
= pRxd
->TcpSums
& 0xffff;
2174 pMsg
->ip_summed
= CHECKSUM_HW
;
2176 pMsg
->ip_summed
= CHECKSUM_NONE
;
2180 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("V"));
2181 ForRlmt
= SK_RLMT_RX_PROTOCOL
;
2183 IsBc
= (FrameStat
& XMR_FS_BC
)==XMR_FS_BC
;
2185 SK_RLMT_PRE_LOOKAHEAD(pAC
, PortIndex
, FrameLength
,
2186 IsBc
, &Offset
, &NumBytes
);
2187 if (NumBytes
!= 0) {
2189 IsMc
= (FrameStat
& XMR_FS_MC
)==XMR_FS_MC
;
2191 SK_RLMT_LOOKAHEAD(pAC
, PortIndex
,
2192 &pMsg
->data
[Offset
],
2193 IsBc
, IsMc
, &ForRlmt
);
2195 if (ForRlmt
== SK_RLMT_RX_PROTOCOL
) {
2196 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("W"));
2197 /* send up only frames from active port */
2198 if ((PortIndex
== pAC
->ActivePort
) ||
2199 (pAC
->RlmtNets
== 2)) {
2200 /* frame for upper layer */
2201 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("U"));
2203 DumpMsg(pMsg
, "Rx");
2205 SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC
,
2206 FrameLength
, pRxPort
->PortIndex
);
2208 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2209 pMsg
->protocol
= eth_type_trans(pMsg
,
2210 pAC
->dev
[pRxPort
->PortIndex
]);
2212 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2216 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2217 SK_DBGCAT_DRV_RX_PROGRESS
,
2219 DEV_KFREE_SKB(pMsg
);
2222 } /* if not for rlmt */
2224 /* packet for rlmt */
2225 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2226 SK_DBGCAT_DRV_RX_PROGRESS
, ("R"));
2227 pRlmtMbuf
= SkDrvAllocRlmtMbuf(pAC
,
2228 pAC
->IoBase
, FrameLength
);
2229 if (pRlmtMbuf
!= NULL
) {
2230 pRlmtMbuf
->pNext
= NULL
;
2231 pRlmtMbuf
->Length
= FrameLength
;
2232 pRlmtMbuf
->PortIdx
= PortIndex
;
2233 EvPara
.pParaPtr
= pRlmtMbuf
;
2234 memcpy((char*)(pRlmtMbuf
->pData
),
2235 (char*)(pMsg
->data
),
2238 /* SlowPathLock needed? */
2239 if (SlowPathLock
== SK_TRUE
) {
2240 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2241 SkEventQueue(pAC
, SKGE_RLMT
,
2242 SK_RLMT_PACKET_RECEIVED
,
2244 pAC
->CheckQueue
= SK_TRUE
;
2245 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2247 SkEventQueue(pAC
, SKGE_RLMT
,
2248 SK_RLMT_PACKET_RECEIVED
,
2250 pAC
->CheckQueue
= SK_TRUE
;
2253 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2254 SK_DBGCAT_DRV_RX_PROGRESS
,
2257 if ((pAC
->dev
[pRxPort
->PortIndex
]->flags
&
2258 (IFF_PROMISC
| IFF_ALLMULTI
)) != 0 ||
2259 (ForRlmt
& SK_RLMT_RX_PROTOCOL
) ==
2260 SK_RLMT_RX_PROTOCOL
) {
2261 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2262 pMsg
->protocol
= eth_type_trans(pMsg
,
2263 pAC
->dev
[pRxPort
->PortIndex
]);
2265 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2268 DEV_KFREE_SKB(pMsg
);
2271 } /* if packet for rlmt */
2272 } /* for ... scanning the RXD ring */
2274 /* RXD ring is empty -> fill and restart */
2275 FillRxRing(pAC
, pRxPort
);
2276 /* do not start if called from Close */
2277 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
2278 ClearAndStartRx(pAC
, PortIndex
);
2283 /* remove error frame */
2284 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ERROR
,
2285 ("Schrottdescriptor, length: 0x%x\n", FrameLength
));
2287 /* release the DMA mapping */
2289 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2290 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2291 pci_unmap_page(pAC
->PciDev
,
2294 PCI_DMA_FROMDEVICE
);
2295 DEV_KFREE_SKB_IRQ(pRxd
->pMBuf
);
2297 pRxPort
->RxdRingFree
++;
2298 pRxPort
->pRxdRingHead
= pRxd
->pNextRxd
;
2304 /*****************************************************************************
2306 * ClearAndStartRx - give a start receive command to BMU, clear IRQ
2309 * This function sends a start command and a clear interrupt
2310 * command for one receive queue to the BMU.
2315 static void ClearAndStartRx(
2316 SK_AC
*pAC
, /* pointer to the adapter context */
2317 int PortIndex
) /* index of the receive port (XMAC) */
2319 SK_OUT8(pAC
->IoBase
,
2320 RxQueueAddr
[PortIndex
]+Q_CSR
,
2321 CSR_START
| CSR_IRQ_CL_F
);
2322 } /* ClearAndStartRx */
2325 /*****************************************************************************
2327 * ClearTxIrq - give a clear transmit IRQ command to BMU
2330 * This function sends a clear tx IRQ command for one
2331 * transmit queue to the BMU.
2335 static void ClearTxIrq(
2336 SK_AC
*pAC
, /* pointer to the adapter context */
2337 int PortIndex
, /* index of the transmit port (XMAC) */
2338 int Prio
) /* priority or normal queue */
2340 SK_OUT8(pAC
->IoBase
,
2341 TxQueueAddr
[PortIndex
][Prio
]+Q_CSR
,
2346 /*****************************************************************************
2348 * ClearRxRing - remove all buffers from the receive ring
2351 * This function removes all receive buffers from the ring.
2352 * The receive BMU must be stopped before calling this function.
2356 static void ClearRxRing(
2357 SK_AC
*pAC
, /* pointer to adapter context */
2358 RX_PORT
*pRxPort
) /* pointer to rx port struct */
2360 RXD
*pRxd
; /* pointer to the current descriptor */
2361 unsigned long Flags
;
2364 if (pRxPort
->RxdRingFree
== pAC
->RxDescrPerRing
) {
2367 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
2368 pRxd
= pRxPort
->pRxdRingHead
;
2370 if (pRxd
->pMBuf
!= NULL
) {
2372 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2373 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2374 pci_unmap_page(pAC
->PciDev
,
2377 PCI_DMA_FROMDEVICE
);
2378 DEV_KFREE_SKB(pRxd
->pMBuf
);
2381 pRxd
->RBControl
&= BMU_OWN
;
2382 pRxd
= pRxd
->pNextRxd
;
2383 pRxPort
->RxdRingFree
++;
2384 } while (pRxd
!= pRxPort
->pRxdRingTail
);
2385 pRxPort
->pRxdRingTail
= pRxPort
->pRxdRingHead
;
2386 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
2389 /*****************************************************************************
2391 * ClearTxRing - remove all buffers from the transmit ring
2394 * This function removes all transmit buffers from the ring.
2395 * The transmit BMU must be stopped before calling this function
2396 * and transmitting at the upper level must be disabled.
2397 * The BMU own bit of all descriptors is cleared, the rest is
2398 * done by calling FreeTxDescriptors.
2402 static void ClearTxRing(
2403 SK_AC
*pAC
, /* pointer to adapter context */
2404 TX_PORT
*pTxPort
) /* pointer to tx prt struct */
2406 TXD
*pTxd
; /* pointer to the current descriptor */
2408 unsigned long Flags
;
2410 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
2411 pTxd
= pTxPort
->pTxdRingHead
;
2412 for (i
=0; i
<pAC
->TxDescrPerRing
; i
++) {
2413 pTxd
->TBControl
&= ~BMU_OWN
;
2414 pTxd
= pTxd
->pNextTxd
;
2416 FreeTxDescriptors(pAC
, pTxPort
);
2417 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
2420 /*****************************************************************************
2422 * SkGeSetMacAddr - Set the hardware MAC address
2425 * This function sets the MAC address used by the adapter.
2428 * 0, if everything is ok
2431 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
)
2434 DEV_NET
*pNet
= netdev_priv(dev
);
2435 SK_AC
*pAC
= pNet
->pAC
;
2437 struct sockaddr
*addr
= p
;
2438 unsigned long Flags
;
2440 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2441 ("SkGeSetMacAddr starts now...\n"));
2442 if(netif_running(dev
))
2445 memcpy(dev
->dev_addr
, addr
->sa_data
,dev
->addr_len
);
2447 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2449 if (pAC
->RlmtNets
== 2)
2450 SkAddrOverride(pAC
, pAC
->IoBase
, pNet
->NetNr
,
2451 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2453 SkAddrOverride(pAC
, pAC
->IoBase
, pAC
->ActivePort
,
2454 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2458 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2460 } /* SkGeSetMacAddr */
2463 /*****************************************************************************
2465 * SkGeSetRxMode - set receive mode
2468 * This function sets the receive mode of an adapter. The adapter
2469 * supports promiscuous mode, allmulticast mode and a number of
2470 * multicast addresses. If more multicast addresses the available
2471 * are selected, a hash function in the hardware is used.
2474 * 0, if everything is ok
2477 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
)
2483 struct dev_mc_list
*pMcList
;
2486 unsigned long Flags
;
2488 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2489 ("SkGeSetRxMode starts now... "));
2491 pNet
= netdev_priv(dev
);
2493 if (pAC
->RlmtNets
== 1)
2494 PortIdx
= pAC
->ActivePort
;
2496 PortIdx
= pNet
->NetNr
;
2498 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2499 if (dev
->flags
& IFF_PROMISC
) {
2500 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2501 ("PROMISCUOUS mode\n"));
2502 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2504 } else if (dev
->flags
& IFF_ALLMULTI
) {
2505 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2506 ("ALLMULTI mode\n"));
2507 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2508 SK_PROM_MODE_ALL_MC
);
2510 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2512 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
2514 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2515 ("Number of MC entries: %d ", dev
->mc_count
));
2517 pMcList
= dev
->mc_list
;
2518 for (i
=0; i
<dev
->mc_count
; i
++, pMcList
= pMcList
->next
) {
2519 SkAddrMcAdd(pAC
, pAC
->IoBase
, PortIdx
,
2520 (SK_MAC_ADDR
*)pMcList
->dmi_addr
, 0);
2521 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_MCA
,
2522 ("%02x:%02x:%02x:%02x:%02x:%02x\n",
2523 pMcList
->dmi_addr
[0],
2524 pMcList
->dmi_addr
[1],
2525 pMcList
->dmi_addr
[2],
2526 pMcList
->dmi_addr
[3],
2527 pMcList
->dmi_addr
[4],
2528 pMcList
->dmi_addr
[5]));
2530 SkAddrMcUpdate(pAC
, pAC
->IoBase
, PortIdx
);
2532 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2535 } /* SkGeSetRxMode */
2538 /*****************************************************************************
2540 * SkGeChangeMtu - set the MTU to another value
2543 * This function sets is called whenever the MTU size is changed
2544 * (ifconfig mtu xxx dev ethX). If the MTU is bigger than standard
2545 * ethernet MTU size, long frame support is activated.
2548 * 0, if everything is ok
2551 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int NewMtu
)
2556 unsigned long Flags
;
2560 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2561 ("SkGeChangeMtu starts now...\n"));
2563 pNet
= netdev_priv(dev
);
2566 if ((NewMtu
< 68) || (NewMtu
> SK_JUMBO_MTU
)) {
2570 if(pAC
->BoardLevel
!= SK_INIT_RUN
) {
2574 #ifdef SK_DIAG_SUPPORT
2575 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
2576 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
2577 return -1; /* still in use, deny any actions of MTU */
2579 pAC
->DiagFlowCtrl
= SK_FALSE
;
2585 pOtherNet
= netdev_priv(pAC
->dev
[1 - pNet
->NetNr
]);
2586 if ((pOtherNet
->Mtu
>1500) && (NewMtu
<=1500) && (pOtherNet
->Up
==1)) {
2590 pAC
->RxBufSize
= NewMtu
+ 32;
2593 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2594 ("New MTU: %d\n", NewMtu
));
2597 ** Prevent any reconfiguration while changing the MTU
2598 ** by disabling any interrupts
2600 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
2601 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2604 ** Notify RLMT that any ports are to be stopped
2606 EvPara
.Para32
[0] = 0;
2607 EvPara
.Para32
[1] = -1;
2608 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2609 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2610 EvPara
.Para32
[0] = 1;
2611 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2613 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2617 ** After calling the SkEventDispatcher(), RLMT is aware about
2618 ** the stopped ports -> configuration can take place!
2620 SkEventDispatcher(pAC
, pAC
->IoBase
);
2622 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2623 spin_lock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2624 netif_stop_queue(pAC
->dev
[i
]);
2629 ** Depending on the desired MTU size change, a different number of
2630 ** RX buffers need to be allocated
2632 if (NewMtu
> 1500) {
2634 ** Use less rx buffers
2636 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2637 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2638 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2639 (pAC
->RxDescrPerRing
/ 4);
2641 if (i
== pAC
->ActivePort
) {
2642 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2643 (pAC
->RxDescrPerRing
/ 4);
2645 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2646 (pAC
->RxDescrPerRing
/ 10);
2652 ** Use the normal amount of rx buffers
2654 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2655 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2656 pAC
->RxPort
[i
].RxFillLimit
= 1;
2658 if (i
== pAC
->ActivePort
) {
2659 pAC
->RxPort
[i
].RxFillLimit
= 1;
2661 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2662 (pAC
->RxDescrPerRing
/ 4);
2668 SkGeDeInit(pAC
, pAC
->IoBase
);
2671 ** enable/disable hardware support for long frames
2673 if (NewMtu
> 1500) {
2674 // pAC->JumboActivated = SK_TRUE; /* is never set back !!! */
2675 pAC
->GIni
.GIPortUsage
= SK_JUMBO_LINK
;
2677 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2678 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
2680 pAC
->GIni
.GIPortUsage
= SK_RED_LINK
;
2684 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2685 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2686 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2687 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2688 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2689 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2690 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2694 ** Speed and others are set back to default in level 1 init!
2696 GetConfiguration(pAC
);
2698 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2699 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2700 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2701 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2702 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2703 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2704 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2707 ** clear and reinit the rx rings here
2709 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2710 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
2711 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
2712 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2715 ** Enable transmit descriptor polling
2717 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
2718 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2721 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
2722 SkDimEnableModerationIfNeeded(pAC
);
2723 SkDimDisplayModerationSettings(pAC
);
2725 netif_start_queue(pAC
->dev
[pNet
->PortNr
]);
2726 for (i
=pAC
->GIni
.GIMacsFound
-1; i
>=0; i
--) {
2727 spin_unlock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2731 ** Enable Interrupts again
2733 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
2734 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
2736 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2737 SkEventDispatcher(pAC
, pAC
->IoBase
);
2740 ** Notify RLMT about the changing and restarting one (or more) ports
2742 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2743 EvPara
.Para32
[0] = pAC
->RlmtNets
;
2744 EvPara
.Para32
[1] = -1;
2745 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
, EvPara
);
2746 EvPara
.Para32
[0] = pNet
->PortNr
;
2747 EvPara
.Para32
[1] = -1;
2748 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2750 if (pOtherNet
->Up
) {
2751 EvPara
.Para32
[0] = pOtherNet
->PortNr
;
2752 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2755 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2758 SkEventDispatcher(pAC
, pAC
->IoBase
);
2759 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2762 ** While testing this driver with latest kernel 2.5 (2.5.70), it
2763 ** seems as if upper layers have a problem to handle a successful
2764 ** return value of '0'. If such a zero is returned, the complete
2765 ** system hangs for several minutes (!), which is in acceptable.
2767 ** Currently it is not clear, what the exact reason for this problem
2768 ** is. The implemented workaround for 2.5 is to return the desired
2769 ** new MTU size if all needed changes for the new MTU size where
2770 ** performed. In kernels 2.2 and 2.4, a zero value is returned,
2771 ** which indicates the successful change of the mtu-size.
2775 } /* SkGeChangeMtu */
2778 /*****************************************************************************
2780 * SkGeStats - return ethernet device statistics
2783 * This function return statistic data about the ethernet device
2784 * to the operating system.
2787 * pointer to the statistic structure.
2789 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
)
2791 DEV_NET
*pNet
= netdev_priv(dev
);
2792 SK_AC
*pAC
= pNet
->pAC
;
2793 SK_PNMI_STRUCT_DATA
*pPnmiStruct
; /* structure for all Pnmi-Data */
2794 SK_PNMI_STAT
*pPnmiStat
; /* pointer to virtual XMAC stat. data */
2795 SK_PNMI_CONF
*pPnmiConf
; /* pointer to virtual link config. */
2796 unsigned int Size
; /* size of pnmi struct */
2797 unsigned long Flags
; /* for spin lock */
2799 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2800 ("SkGeStats starts now...\n"));
2801 pPnmiStruct
= &pAC
->PnmiStruct
;
2803 #ifdef SK_DIAG_SUPPORT
2804 if ((pAC
->DiagModeActive
== DIAG_NOTACTIVE
) &&
2805 (pAC
->BoardLevel
== SK_INIT_RUN
)) {
2807 SK_MEMSET(pPnmiStruct
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
2808 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2809 Size
= SK_PNMI_STRUCT_SIZE
;
2810 SkPnmiGetStruct(pAC
, pAC
->IoBase
, pPnmiStruct
, &Size
, pNet
->NetNr
);
2811 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2812 #ifdef SK_DIAG_SUPPORT
2816 pPnmiStat
= &pPnmiStruct
->Stat
[0];
2817 pPnmiConf
= &pPnmiStruct
->Conf
[0];
2819 pAC
->stats
.rx_packets
= (SK_U32
) pPnmiStruct
->RxDeliveredCts
& 0xFFFFFFFF;
2820 pAC
->stats
.tx_packets
= (SK_U32
) pPnmiStat
->StatTxOkCts
& 0xFFFFFFFF;
2821 pAC
->stats
.rx_bytes
= (SK_U32
) pPnmiStruct
->RxOctetsDeliveredCts
;
2822 pAC
->stats
.tx_bytes
= (SK_U32
) pPnmiStat
->StatTxOctetsOkCts
;
2824 if (pNet
->Mtu
<= 1500) {
2825 pAC
->stats
.rx_errors
= (SK_U32
) pPnmiStruct
->InErrorsCts
& 0xFFFFFFFF;
2827 pAC
->stats
.rx_errors
= (SK_U32
) ((pPnmiStruct
->InErrorsCts
-
2828 pPnmiStat
->StatRxTooLongCts
) & 0xFFFFFFFF);
2832 if (pAC
->GIni
.GP
[0].PhyType
== SK_PHY_XMAC
&& pAC
->HWRevision
< 12)
2833 pAC
->stats
.rx_errors
= pAC
->stats
.rx_errors
- pPnmiStat
->StatRxShortsCts
;
2835 pAC
->stats
.tx_errors
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2836 pAC
->stats
.rx_dropped
= (SK_U32
) pPnmiStruct
->RxNoBufCts
& 0xFFFFFFFF;
2837 pAC
->stats
.tx_dropped
= (SK_U32
) pPnmiStruct
->TxNoBufCts
& 0xFFFFFFFF;
2838 pAC
->stats
.multicast
= (SK_U32
) pPnmiStat
->StatRxMulticastOkCts
& 0xFFFFFFFF;
2839 pAC
->stats
.collisions
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2841 /* detailed rx_errors: */
2842 pAC
->stats
.rx_length_errors
= (SK_U32
) pPnmiStat
->StatRxRuntCts
& 0xFFFFFFFF;
2843 pAC
->stats
.rx_over_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2844 pAC
->stats
.rx_crc_errors
= (SK_U32
) pPnmiStat
->StatRxFcsCts
& 0xFFFFFFFF;
2845 pAC
->stats
.rx_frame_errors
= (SK_U32
) pPnmiStat
->StatRxFramingCts
& 0xFFFFFFFF;
2846 pAC
->stats
.rx_fifo_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2847 pAC
->stats
.rx_missed_errors
= (SK_U32
) pPnmiStat
->StatRxMissedCts
& 0xFFFFFFFF;
2849 /* detailed tx_errors */
2850 pAC
->stats
.tx_aborted_errors
= (SK_U32
) 0;
2851 pAC
->stats
.tx_carrier_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2852 pAC
->stats
.tx_fifo_errors
= (SK_U32
) pPnmiStat
->StatTxFifoUnderrunCts
& 0xFFFFFFFF;
2853 pAC
->stats
.tx_heartbeat_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2854 pAC
->stats
.tx_window_errors
= (SK_U32
) 0;
2856 return(&pAC
->stats
);
2860 /*****************************************************************************
2862 * SkGeIoctl - IO-control function
2865 * This function is called if an ioctl is issued on the device.
2866 * There are three subfunction for reading, writing and test-writing
2867 * the private MIB data structure (usefull for SysKonnect-internal tools).
2870 * 0, if everything is ok
2873 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
)
2878 struct pci_dev
*pdev
= NULL
;
2880 unsigned int Err
= 0;
2883 unsigned int Length
= 0;
2884 int HeaderLength
= sizeof(SK_U32
) + sizeof(SK_U32
);
2886 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2887 ("SkGeIoctl starts now...\n"));
2889 pNet
= netdev_priv(dev
);
2892 if(copy_from_user(&Ioctl
, rq
->ifr_data
, sizeof(SK_GE_IOCTL
))) {
2897 case SK_IOCTL_SETMIB
:
2898 case SK_IOCTL_PRESETMIB
:
2899 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2900 case SK_IOCTL_GETMIB
:
2901 if(copy_from_user(&pAC
->PnmiStruct
, Ioctl
.pData
,
2902 Ioctl
.Len
<sizeof(pAC
->PnmiStruct
)?
2903 Ioctl
.Len
: sizeof(pAC
->PnmiStruct
))) {
2906 Size
= SkGeIocMib(pNet
, Ioctl
.Len
, cmd
);
2907 if(copy_to_user(Ioctl
.pData
, &pAC
->PnmiStruct
,
2908 Ioctl
.Len
<Size
? Ioctl
.Len
: Size
)) {
2912 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2917 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2920 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2922 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2925 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2929 if ((Ret
= SkPnmiGenIoctl(pAC
, pAC
->IoBase
, pMemBuf
, &Length
, 0)) < 0) {
2933 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2938 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2943 kfree(pMemBuf
); /* cleanup everything */
2945 #ifdef SK_DIAG_SUPPORT
2947 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2948 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2951 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2953 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2956 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2961 Length
= 3 * sizeof(SK_U32
); /* Error, Bus and Device */
2963 ** While coding this new IOCTL interface, only a few lines of code
2964 ** are to to be added. Therefore no dedicated function has been
2965 ** added. If more functionality is added, a separate function
2966 ** should be used...
2968 * ((SK_U32
*)pMemBuf
) = 0;
2969 * ((SK_U32
*)pMemBuf
+ 1) = pdev
->bus
->number
;
2970 * ((SK_U32
*)pMemBuf
+ 2) = ParseDeviceNbrFromSlotName(pci_name(pdev
));
2971 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2976 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2981 kfree(pMemBuf
); /* cleanup everything */
2993 /*****************************************************************************
2995 * SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message
2998 * This function reads/writes the MIB data using PNMI (Private Network
2999 * Management Interface).
3000 * The destination for the data must be provided with the
3001 * ioctl call and is given to the driver in the form of
3002 * a user space address.
3003 * Copying from the user-provided data area into kernel messages
3004 * and back is done by copy_from_user and copy_to_user calls in
3008 * returned size from PNMI call
3010 static int SkGeIocMib(
3011 DEV_NET
*pNet
, /* pointer to the adapter context */
3012 unsigned int Size
, /* length of ioctl data */
3013 int mode
) /* flag for set/preset */
3015 unsigned long Flags
; /* for spin lock */
3018 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3019 ("SkGeIocMib starts now...\n"));
3022 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3024 case SK_IOCTL_GETMIB
:
3025 SkPnmiGetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3028 case SK_IOCTL_PRESETMIB
:
3029 SkPnmiPreSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3032 case SK_IOCTL_SETMIB
:
3033 SkPnmiSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3039 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3040 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3041 ("MIB data access succeeded\n"));
3046 /*****************************************************************************
3048 * GetConfiguration - read configuration information
3051 * This function reads per-adapter configuration information from
3052 * the options provided on the command line.
3057 static void GetConfiguration(
3058 SK_AC
*pAC
) /* pointer to the adapter context structure */
3060 SK_I32 Port
; /* preferred port */
3063 int LinkSpeed
= SK_LSPEED_AUTO
; /* Link speed */
3064 int AutoNeg
= 1; /* autoneg off (0) or on (1) */
3065 int DuplexCap
= 0; /* 0=both,1=full,2=half */
3066 int FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
; /* FlowControl */
3067 int MSMode
= SK_MS_MODE_AUTO
; /* master/slave mode */
3069 SK_BOOL IsConTypeDefined
= SK_TRUE
;
3070 SK_BOOL IsLinkSpeedDefined
= SK_TRUE
;
3071 SK_BOOL IsFlowCtrlDefined
= SK_TRUE
;
3072 SK_BOOL IsRoleDefined
= SK_TRUE
;
3073 SK_BOOL IsModeDefined
= SK_TRUE
;
3075 * The two parameters AutoNeg. and DuplexCap. map to one configuration
3076 * parameter. The mapping is described by this table:
3077 * DuplexCap -> | both | full | half |
3079 * -----------------------------------------------------------------
3080 * Off | illegal | Full | Half |
3081 * -----------------------------------------------------------------
3082 * On | AutoBoth | AutoFull | AutoHalf |
3083 * -----------------------------------------------------------------
3084 * Sense | AutoSense | AutoSense | AutoSense |
3086 int Capabilities
[3][3] =
3087 { { -1, SK_LMODE_FULL
, SK_LMODE_HALF
},
3088 {SK_LMODE_AUTOBOTH
, SK_LMODE_AUTOFULL
, SK_LMODE_AUTOHALF
},
3089 {SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
} };
3097 #define M_CurrPort pAC->GIni.GP[Port]
3101 ** Set the default values first for both ports!
3103 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3104 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3105 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3106 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3107 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3111 ** Check merged parameter ConType. If it has not been used,
3112 ** verify any other parameter (e.g. AutoNeg) and use default values.
3114 ** Stating both ConType and other lowlevel link parameters is also
3115 ** possible. If this is the case, the passed ConType-parameter is
3116 ** overwritten by the lowlevel link parameter.
3118 ** The following settings are used for a merged ConType-parameter:
3120 ** ConType DupCap AutoNeg FlowCtrl Role Speed
3121 ** ------- ------ ------- -------- ---------- -----
3122 ** Auto Both On SymOrRem Auto Auto
3123 ** 100FD Full Off None <ignored> 100
3124 ** 100HD Half Off None <ignored> 100
3125 ** 10FD Full Off None <ignored> 10
3126 ** 10HD Half Off None <ignored> 10
3128 ** This ConType parameter is used for all ports of the adapter!
3130 if ( (ConType
!= NULL
) &&
3131 (pAC
->Index
< SK_MAX_CARD_PARAM
) &&
3132 (ConType
[pAC
->Index
] != NULL
) ) {
3134 /* Check chipset family */
3135 if ((!pAC
->ChipsetType
) &&
3136 (strcmp(ConType
[pAC
->Index
],"Auto")!=0) &&
3137 (strcmp(ConType
[pAC
->Index
],"")!=0)) {
3138 /* Set the speed parameter back */
3139 printk("sk98lin: Illegal value \"%s\" "
3142 ConType
[pAC
->Index
]);
3144 sprintf(ConType
[pAC
->Index
], "Auto");
3147 if (strcmp(ConType
[pAC
->Index
],"")==0) {
3148 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3149 } else if (strcmp(ConType
[pAC
->Index
],"Auto")==0) {
3150 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3151 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3152 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3153 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3154 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3156 } else if (strcmp(ConType
[pAC
->Index
],"100FD")==0) {
3157 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3158 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3159 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3160 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3161 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3163 } else if (strcmp(ConType
[pAC
->Index
],"100HD")==0) {
3164 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3165 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3166 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3167 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3168 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3170 } else if (strcmp(ConType
[pAC
->Index
],"10FD")==0) {
3171 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3172 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3173 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3174 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3175 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3177 } else if (strcmp(ConType
[pAC
->Index
],"10HD")==0) {
3178 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3179 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3180 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3181 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3182 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3185 printk("sk98lin: Illegal value \"%s\" for ConType\n",
3186 ConType
[pAC
->Index
]);
3187 IsConTypeDefined
= SK_FALSE
; /* Wrong ConType defined */
3190 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3194 ** Parse any parameter settings for port A:
3195 ** a) any LinkSpeed stated?
3197 if (Speed_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3198 Speed_A
[pAC
->Index
] != NULL
) {
3199 if (strcmp(Speed_A
[pAC
->Index
],"")==0) {
3200 IsLinkSpeedDefined
= SK_FALSE
;
3201 } else if (strcmp(Speed_A
[pAC
->Index
],"Auto")==0) {
3202 LinkSpeed
= SK_LSPEED_AUTO
;
3203 } else if (strcmp(Speed_A
[pAC
->Index
],"10")==0) {
3204 LinkSpeed
= SK_LSPEED_10MBPS
;
3205 } else if (strcmp(Speed_A
[pAC
->Index
],"100")==0) {
3206 LinkSpeed
= SK_LSPEED_100MBPS
;
3207 } else if (strcmp(Speed_A
[pAC
->Index
],"1000")==0) {
3208 LinkSpeed
= SK_LSPEED_1000MBPS
;
3210 printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
3211 Speed_A
[pAC
->Index
]);
3212 IsLinkSpeedDefined
= SK_FALSE
;
3215 IsLinkSpeedDefined
= SK_FALSE
;
3219 ** Check speed parameter:
3220 ** Only copper type adapter and GE V2 cards
3222 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3223 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3224 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3225 printk("sk98lin: Illegal value for Speed_A. "
3226 "Not a copper card or GE V2 card\n Using "
3228 LinkSpeed
= SK_LSPEED_1000MBPS
;
3232 ** Decide whether to set new config value if somethig valid has
3235 if (IsLinkSpeedDefined
) {
3236 pAC
->GIni
.GP
[0].PLinkSpeed
= LinkSpeed
;
3240 ** b) Any Autonegotiation and DuplexCapabilities set?
3241 ** Please note that both belong together...
3243 AutoNeg
= AN_ON
; /* tschilling: Default: Autonegotiation on! */
3245 if (AutoNeg_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3246 AutoNeg_A
[pAC
->Index
] != NULL
) {
3248 if (strcmp(AutoNeg_A
[pAC
->Index
],"")==0) {
3250 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"On")==0) {
3252 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Off")==0) {
3254 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Sense")==0) {
3257 printk("sk98lin: Illegal value \"%s\" for AutoNeg_A\n",
3258 AutoNeg_A
[pAC
->Index
]);
3262 DuplexCap
= DC_BOTH
;
3264 if (DupCap_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3265 DupCap_A
[pAC
->Index
] != NULL
) {
3267 if (strcmp(DupCap_A
[pAC
->Index
],"")==0) {
3269 } else if (strcmp(DupCap_A
[pAC
->Index
],"Both")==0) {
3270 DuplexCap
= DC_BOTH
;
3271 } else if (strcmp(DupCap_A
[pAC
->Index
],"Full")==0) {
3272 DuplexCap
= DC_FULL
;
3273 } else if (strcmp(DupCap_A
[pAC
->Index
],"Half")==0) {
3274 DuplexCap
= DC_HALF
;
3276 printk("sk98lin: Illegal value \"%s\" for DupCap_A\n",
3277 DupCap_A
[pAC
->Index
]);
3282 ** Check for illegal combinations
3284 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3285 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3286 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3287 (pAC
->ChipsetType
)) {
3288 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3289 " Using Full Duplex.\n");
3290 DuplexCap
= DC_FULL
;
3293 if ( AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3294 printk("sk98lin, Port A: DuplexCapabilities"
3295 " ignored using Sense mode\n");
3298 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3299 printk("sk98lin: Port A: Illegal combination"
3300 " of values AutoNeg. and DuplexCap.\n Using "
3302 DuplexCap
= DC_FULL
;
3305 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3306 DuplexCap
= DC_FULL
;
3309 if (!AutoSet
&& DupSet
) {
3310 printk("sk98lin: Port A: Duplex setting not"
3311 " possible in\n default AutoNegotiation mode"
3312 " (Sense).\n Using AutoNegotiation On\n");
3317 ** set the desired mode
3319 if (AutoSet
|| DupSet
) {
3320 pAC
->GIni
.GP
[0].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3324 ** c) Any Flowcontrol-parameter set?
3326 if (FlowCtrl_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3327 FlowCtrl_A
[pAC
->Index
] != NULL
) {
3328 if (strcmp(FlowCtrl_A
[pAC
->Index
],"") == 0) {
3329 IsFlowCtrlDefined
= SK_FALSE
;
3330 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"SymOrRem") == 0) {
3331 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3332 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"Sym")==0) {
3333 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3334 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"LocSend")==0) {
3335 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3336 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"None")==0) {
3337 FlowCtrl
= SK_FLOW_MODE_NONE
;
3339 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
3340 FlowCtrl_A
[pAC
->Index
]);
3341 IsFlowCtrlDefined
= SK_FALSE
;
3344 IsFlowCtrlDefined
= SK_FALSE
;
3347 if (IsFlowCtrlDefined
) {
3348 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3349 printk("sk98lin: Port A: FlowControl"
3350 " impossible without AutoNegotiation,"
3352 FlowCtrl
= SK_FLOW_MODE_NONE
;
3354 pAC
->GIni
.GP
[0].PFlowCtrlMode
= FlowCtrl
;
3358 ** d) What is with the RoleParameter?
3360 if (Role_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3361 Role_A
[pAC
->Index
] != NULL
) {
3362 if (strcmp(Role_A
[pAC
->Index
],"")==0) {
3363 IsRoleDefined
= SK_FALSE
;
3364 } else if (strcmp(Role_A
[pAC
->Index
],"Auto")==0) {
3365 MSMode
= SK_MS_MODE_AUTO
;
3366 } else if (strcmp(Role_A
[pAC
->Index
],"Master")==0) {
3367 MSMode
= SK_MS_MODE_MASTER
;
3368 } else if (strcmp(Role_A
[pAC
->Index
],"Slave")==0) {
3369 MSMode
= SK_MS_MODE_SLAVE
;
3371 printk("sk98lin: Illegal value \"%s\" for Role_A\n",
3372 Role_A
[pAC
->Index
]);
3373 IsRoleDefined
= SK_FALSE
;
3376 IsRoleDefined
= SK_FALSE
;
3379 if (IsRoleDefined
== SK_TRUE
) {
3380 pAC
->GIni
.GP
[0].PMSMode
= MSMode
;
3386 ** Parse any parameter settings for port B:
3387 ** a) any LinkSpeed stated?
3389 IsConTypeDefined
= SK_TRUE
;
3390 IsLinkSpeedDefined
= SK_TRUE
;
3391 IsFlowCtrlDefined
= SK_TRUE
;
3392 IsModeDefined
= SK_TRUE
;
3394 if (Speed_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3395 Speed_B
[pAC
->Index
] != NULL
) {
3396 if (strcmp(Speed_B
[pAC
->Index
],"")==0) {
3397 IsLinkSpeedDefined
= SK_FALSE
;
3398 } else if (strcmp(Speed_B
[pAC
->Index
],"Auto")==0) {
3399 LinkSpeed
= SK_LSPEED_AUTO
;
3400 } else if (strcmp(Speed_B
[pAC
->Index
],"10")==0) {
3401 LinkSpeed
= SK_LSPEED_10MBPS
;
3402 } else if (strcmp(Speed_B
[pAC
->Index
],"100")==0) {
3403 LinkSpeed
= SK_LSPEED_100MBPS
;
3404 } else if (strcmp(Speed_B
[pAC
->Index
],"1000")==0) {
3405 LinkSpeed
= SK_LSPEED_1000MBPS
;
3407 printk("sk98lin: Illegal value \"%s\" for Speed_B\n",
3408 Speed_B
[pAC
->Index
]);
3409 IsLinkSpeedDefined
= SK_FALSE
;
3412 IsLinkSpeedDefined
= SK_FALSE
;
3416 ** Check speed parameter:
3417 ** Only copper type adapter and GE V2 cards
3419 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3420 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3421 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3422 printk("sk98lin: Illegal value for Speed_B. "
3423 "Not a copper card or GE V2 card\n Using "
3425 LinkSpeed
= SK_LSPEED_1000MBPS
;
3429 ** Decide whether to set new config value if somethig valid has
3432 if (IsLinkSpeedDefined
) {
3433 pAC
->GIni
.GP
[1].PLinkSpeed
= LinkSpeed
;
3437 ** b) Any Autonegotiation and DuplexCapabilities set?
3438 ** Please note that both belong together...
3440 AutoNeg
= AN_SENS
; /* default: do auto Sense */
3442 if (AutoNeg_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3443 AutoNeg_B
[pAC
->Index
] != NULL
) {
3445 if (strcmp(AutoNeg_B
[pAC
->Index
],"")==0) {
3447 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"On")==0) {
3449 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Off")==0) {
3451 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Sense")==0) {
3454 printk("sk98lin: Illegal value \"%s\" for AutoNeg_B\n",
3455 AutoNeg_B
[pAC
->Index
]);
3459 DuplexCap
= DC_BOTH
;
3461 if (DupCap_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3462 DupCap_B
[pAC
->Index
] != NULL
) {
3464 if (strcmp(DupCap_B
[pAC
->Index
],"")==0) {
3466 } else if (strcmp(DupCap_B
[pAC
->Index
],"Both")==0) {
3467 DuplexCap
= DC_BOTH
;
3468 } else if (strcmp(DupCap_B
[pAC
->Index
],"Full")==0) {
3469 DuplexCap
= DC_FULL
;
3470 } else if (strcmp(DupCap_B
[pAC
->Index
],"Half")==0) {
3471 DuplexCap
= DC_HALF
;
3473 printk("sk98lin: Illegal value \"%s\" for DupCap_B\n",
3474 DupCap_B
[pAC
->Index
]);
3480 ** Check for illegal combinations
3482 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3483 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3484 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3485 (pAC
->ChipsetType
)) {
3486 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3487 " Using Full Duplex.\n");
3488 DuplexCap
= DC_FULL
;
3491 if (AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3492 printk("sk98lin, Port B: DuplexCapabilities"
3493 " ignored using Sense mode\n");
3496 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3497 printk("sk98lin: Port B: Illegal combination"
3498 " of values AutoNeg. and DuplexCap.\n Using "
3500 DuplexCap
= DC_FULL
;
3503 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3504 DuplexCap
= DC_FULL
;
3507 if (!AutoSet
&& DupSet
) {
3508 printk("sk98lin: Port B: Duplex setting not"
3509 " possible in\n default AutoNegotiation mode"
3510 " (Sense).\n Using AutoNegotiation On\n");
3515 ** set the desired mode
3517 if (AutoSet
|| DupSet
) {
3518 pAC
->GIni
.GP
[1].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3522 ** c) Any FlowCtrl parameter set?
3524 if (FlowCtrl_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3525 FlowCtrl_B
[pAC
->Index
] != NULL
) {
3526 if (strcmp(FlowCtrl_B
[pAC
->Index
],"") == 0) {
3527 IsFlowCtrlDefined
= SK_FALSE
;
3528 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"SymOrRem") == 0) {
3529 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3530 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"Sym")==0) {
3531 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3532 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"LocSend")==0) {
3533 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3534 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"None")==0) {
3535 FlowCtrl
= SK_FLOW_MODE_NONE
;
3537 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_B\n",
3538 FlowCtrl_B
[pAC
->Index
]);
3539 IsFlowCtrlDefined
= SK_FALSE
;
3542 IsFlowCtrlDefined
= SK_FALSE
;
3545 if (IsFlowCtrlDefined
) {
3546 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3547 printk("sk98lin: Port B: FlowControl"
3548 " impossible without AutoNegotiation,"
3550 FlowCtrl
= SK_FLOW_MODE_NONE
;
3552 pAC
->GIni
.GP
[1].PFlowCtrlMode
= FlowCtrl
;
3556 ** d) What is the RoleParameter?
3558 if (Role_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3559 Role_B
[pAC
->Index
] != NULL
) {
3560 if (strcmp(Role_B
[pAC
->Index
],"")==0) {
3561 IsRoleDefined
= SK_FALSE
;
3562 } else if (strcmp(Role_B
[pAC
->Index
],"Auto")==0) {
3563 MSMode
= SK_MS_MODE_AUTO
;
3564 } else if (strcmp(Role_B
[pAC
->Index
],"Master")==0) {
3565 MSMode
= SK_MS_MODE_MASTER
;
3566 } else if (strcmp(Role_B
[pAC
->Index
],"Slave")==0) {
3567 MSMode
= SK_MS_MODE_SLAVE
;
3569 printk("sk98lin: Illegal value \"%s\" for Role_B\n",
3570 Role_B
[pAC
->Index
]);
3571 IsRoleDefined
= SK_FALSE
;
3574 IsRoleDefined
= SK_FALSE
;
3577 if (IsRoleDefined
) {
3578 pAC
->GIni
.GP
[1].PMSMode
= MSMode
;
3582 ** Evaluate settings for both ports
3584 pAC
->ActivePort
= 0;
3585 if (PrefPort
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3586 PrefPort
[pAC
->Index
] != NULL
) {
3587 if (strcmp(PrefPort
[pAC
->Index
],"") == 0) { /* Auto */
3588 pAC
->ActivePort
= 0;
3589 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3590 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3591 } else if (strcmp(PrefPort
[pAC
->Index
],"A") == 0) {
3593 ** do not set ActivePort here, thus a port
3594 ** switch is issued after net up.
3597 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3598 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3599 } else if (strcmp(PrefPort
[pAC
->Index
],"B") == 0) {
3601 ** do not set ActivePort here, thus a port
3602 ** switch is issued after net up.
3604 if (pAC
->GIni
.GIMacsFound
== 1) {
3605 printk("sk98lin: Illegal value \"B\" for PrefPort.\n"
3606 " Port B not available on single port adapters.\n");
3608 pAC
->ActivePort
= 0;
3609 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3610 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3613 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3614 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3617 printk("sk98lin: Illegal value \"%s\" for PrefPort\n",
3618 PrefPort
[pAC
->Index
]);
3624 if (RlmtMode
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3625 RlmtMode
[pAC
->Index
] != NULL
) {
3626 if (strcmp(RlmtMode
[pAC
->Index
], "") == 0) {
3628 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLinkState") == 0) {
3629 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3630 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLocalPort") == 0) {
3631 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3632 SK_RLMT_CHECK_LOC_LINK
;
3633 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckSeg") == 0) {
3634 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3635 SK_RLMT_CHECK_LOC_LINK
|
3637 } else if ((strcmp(RlmtMode
[pAC
->Index
], "DualNet") == 0) &&
3638 (pAC
->GIni
.GIMacsFound
== 2)) {
3639 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3642 printk("sk98lin: Illegal value \"%s\" for"
3643 " RlmtMode, using default\n",
3644 RlmtMode
[pAC
->Index
]);
3652 ** Check the interrupt moderation parameters
3654 if (Moderation
[pAC
->Index
] != NULL
) {
3655 if (strcmp(Moderation
[pAC
->Index
], "") == 0) {
3656 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3657 } else if (strcmp(Moderation
[pAC
->Index
], "Static") == 0) {
3658 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_STATIC
;
3659 } else if (strcmp(Moderation
[pAC
->Index
], "Dynamic") == 0) {
3660 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_DYNAMIC
;
3661 } else if (strcmp(Moderation
[pAC
->Index
], "None") == 0) {
3662 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3664 printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
3665 " Disable interrupt moderation.\n",
3666 Moderation
[pAC
->Index
]);
3667 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3670 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3673 if (Stats
[pAC
->Index
] != NULL
) {
3674 if (strcmp(Stats
[pAC
->Index
], "Yes") == 0) {
3675 pAC
->DynIrqModInfo
.DisplayStats
= SK_TRUE
;
3677 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3680 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3683 if (ModerationMask
[pAC
->Index
] != NULL
) {
3684 if (strcmp(ModerationMask
[pAC
->Index
], "Rx") == 0) {
3685 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3686 } else if (strcmp(ModerationMask
[pAC
->Index
], "Tx") == 0) {
3687 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_ONLY
;
3688 } else if (strcmp(ModerationMask
[pAC
->Index
], "Sp") == 0) {
3689 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_ONLY
;
3690 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSp") == 0) {
3691 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3692 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRx") == 0) {
3693 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3694 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTx") == 0) {
3695 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3696 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRx") == 0) {
3697 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3698 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSp") == 0) {
3699 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3700 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTx") == 0) {
3701 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3702 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTxSp") == 0) {
3703 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3704 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSpTx") == 0) {
3705 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3706 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRxSp") == 0) {
3707 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3708 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSpRx") == 0) {
3709 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3710 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTxRx") == 0) {
3711 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3712 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRxTx") == 0) {
3713 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3714 } else { /* some rubbish */
3715 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3717 } else { /* operator has stated nothing */
3718 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3721 if (AutoSizing
[pAC
->Index
] != NULL
) {
3722 if (strcmp(AutoSizing
[pAC
->Index
], "On") == 0) {
3723 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3725 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3727 } else { /* operator has stated nothing */
3728 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3731 if (IntsPerSec
[pAC
->Index
] != 0) {
3732 if ((IntsPerSec
[pAC
->Index
]< C_INT_MOD_IPS_LOWER_RANGE
) ||
3733 (IntsPerSec
[pAC
->Index
] > C_INT_MOD_IPS_UPPER_RANGE
)) {
3734 printk("sk98lin: Illegal value \"%d\" for IntsPerSec. (Range: %d - %d)\n"
3735 " Using default value of %i.\n",
3736 IntsPerSec
[pAC
->Index
],
3737 C_INT_MOD_IPS_LOWER_RANGE
,
3738 C_INT_MOD_IPS_UPPER_RANGE
,
3739 C_INTS_PER_SEC_DEFAULT
);
3740 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3742 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= IntsPerSec
[pAC
->Index
];
3745 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3749 ** Evaluate upper and lower moderation threshold
3751 pAC
->DynIrqModInfo
.MaxModIntsPerSecUpperLimit
=
3752 pAC
->DynIrqModInfo
.MaxModIntsPerSec
+
3753 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3755 pAC
->DynIrqModInfo
.MaxModIntsPerSecLowerLimit
=
3756 pAC
->DynIrqModInfo
.MaxModIntsPerSec
-
3757 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3759 pAC
->DynIrqModInfo
.PrevTimeVal
= jiffies
; /* initial value */
3762 } /* GetConfiguration */
3765 /*****************************************************************************
3767 * ProductStr - return a adapter identification string from vpd
3770 * This function reads the product name string from the vpd area
3771 * and puts it the field pAC->DeviceString.
3775 static void ProductStr(
3776 SK_AC
*pAC
/* pointer to adapter context */
3779 int StrLen
= 80; /* length of the string, defined in SK_AC */
3780 char Keyword
[] = VPD_NAME
; /* vpd productname identifier */
3781 int ReturnCode
; /* return code from vpd_read */
3782 unsigned long Flags
;
3784 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3785 ReturnCode
= VpdRead(pAC
, pAC
->IoBase
, Keyword
, pAC
->DeviceStr
,
3787 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3788 if (ReturnCode
!= 0) {
3789 /* there was an error reading the vpd data */
3790 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ERROR
,
3791 ("Error reading VPD data: %d\n", ReturnCode
));
3792 pAC
->DeviceStr
[0] = '\0';
3796 /*****************************************************************************
3798 * StartDrvCleanupTimer - Start timer to check for descriptors which
3799 * might be placed in descriptor ring, but
3800 * havent been handled up to now
3803 * This function requests a HW-timer fo the Yukon card. The actions to
3804 * perform when this timer expires, are located in the SkDrvEvent().
3809 StartDrvCleanupTimer(SK_AC
*pAC
) {
3810 SK_EVPARA EventParam
; /* Event struct for timer event */
3812 SK_MEMSET((char *) &EventParam
, 0, sizeof(EventParam
));
3813 EventParam
.Para32
[0] = SK_DRV_RX_CLEANUP_TIMER
;
3814 SkTimerStart(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
,
3815 SK_DRV_RX_CLEANUP_TIMER_LENGTH
,
3816 SKGE_DRV
, SK_DRV_TIMER
, EventParam
);
3819 /*****************************************************************************
3821 * StopDrvCleanupTimer - Stop timer to check for descriptors
3824 * This function requests a HW-timer fo the Yukon card. The actions to
3825 * perform when this timer expires, are located in the SkDrvEvent().
3830 StopDrvCleanupTimer(SK_AC
*pAC
) {
3831 SkTimerStop(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
);
3832 SK_MEMSET((char *) &pAC
->DrvCleanupTimer
, 0, sizeof(SK_TIMER
));
3835 /****************************************************************************/
3836 /* functions for common modules *********************************************/
3837 /****************************************************************************/
3840 /*****************************************************************************
3842 * SkDrvAllocRlmtMbuf - allocate an RLMT mbuf
3845 * This routine returns an RLMT mbuf or NULL. The RLMT Mbuf structure
3846 * is embedded into a socket buff data area.
3852 * NULL or pointer to Mbuf.
3854 SK_MBUF
*SkDrvAllocRlmtMbuf(
3855 SK_AC
*pAC
, /* pointer to adapter context */
3856 SK_IOC IoC
, /* the IO-context */
3857 unsigned BufferSize
) /* size of the requested buffer */
3859 SK_MBUF
*pRlmtMbuf
; /* pointer to a new rlmt-mbuf structure */
3860 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
3862 pMsgBlock
= alloc_skb(BufferSize
+ sizeof(SK_MBUF
), GFP_ATOMIC
);
3863 if (pMsgBlock
== NULL
) {
3866 pRlmtMbuf
= (SK_MBUF
*) pMsgBlock
->data
;
3867 skb_reserve(pMsgBlock
, sizeof(SK_MBUF
));
3868 pRlmtMbuf
->pNext
= NULL
;
3869 pRlmtMbuf
->pOs
= pMsgBlock
;
3870 pRlmtMbuf
->pData
= pMsgBlock
->data
; /* Data buffer. */
3871 pRlmtMbuf
->Size
= BufferSize
; /* Data buffer size. */
3872 pRlmtMbuf
->Length
= 0; /* Length of packet (<= Size). */
3875 } /* SkDrvAllocRlmtMbuf */
3878 /*****************************************************************************
3880 * SkDrvFreeRlmtMbuf - free an RLMT mbuf
3883 * This routine frees one or more RLMT mbuf(s).
3891 void SkDrvFreeRlmtMbuf(
3892 SK_AC
*pAC
, /* pointer to adapter context */
3893 SK_IOC IoC
, /* the IO-context */
3894 SK_MBUF
*pMbuf
) /* size of the requested buffer */
3901 pNextMbuf
= pFreeMbuf
->pNext
;
3902 DEV_KFREE_SKB_ANY(pFreeMbuf
->pOs
);
3903 pFreeMbuf
= pNextMbuf
;
3904 } while ( pFreeMbuf
!= NULL
);
3905 } /* SkDrvFreeRlmtMbuf */
3908 /*****************************************************************************
3910 * SkOsGetTime - provide a time value
3913 * This routine provides a time value. The unit is 1/HZ (defined by Linux).
3914 * It is not used for absolute time, but only for time differences.
3920 SK_U64
SkOsGetTime(SK_AC
*pAC
)
3922 SK_U64 PrivateJiffies
;
3923 SkOsGetTimeCurrent(pAC
, &PrivateJiffies
);
3924 return PrivateJiffies
;
3928 /*****************************************************************************
3930 * SkPciReadCfgDWord - read a 32 bit value from pci config space
3933 * This routine reads a 32 bit value from the pci configuration
3937 * 0 - indicate everything worked ok.
3938 * != 0 - error indication
3940 int SkPciReadCfgDWord(
3941 SK_AC
*pAC
, /* Adapter Control structure pointer */
3942 int PciAddr
, /* PCI register address */
3943 SK_U32
*pVal
) /* pointer to store the read value */
3945 pci_read_config_dword(pAC
->PciDev
, PciAddr
, pVal
);
3947 } /* SkPciReadCfgDWord */
3950 /*****************************************************************************
3952 * SkPciReadCfgWord - read a 16 bit value from pci config space
3955 * This routine reads a 16 bit value from the pci configuration
3959 * 0 - indicate everything worked ok.
3960 * != 0 - error indication
3962 int SkPciReadCfgWord(
3963 SK_AC
*pAC
, /* Adapter Control structure pointer */
3964 int PciAddr
, /* PCI register address */
3965 SK_U16
*pVal
) /* pointer to store the read value */
3967 pci_read_config_word(pAC
->PciDev
, PciAddr
, pVal
);
3969 } /* SkPciReadCfgWord */
3972 /*****************************************************************************
3974 * SkPciReadCfgByte - read a 8 bit value from pci config space
3977 * This routine reads a 8 bit value from the pci configuration
3981 * 0 - indicate everything worked ok.
3982 * != 0 - error indication
3984 int SkPciReadCfgByte(
3985 SK_AC
*pAC
, /* Adapter Control structure pointer */
3986 int PciAddr
, /* PCI register address */
3987 SK_U8
*pVal
) /* pointer to store the read value */
3989 pci_read_config_byte(pAC
->PciDev
, PciAddr
, pVal
);
3991 } /* SkPciReadCfgByte */
3994 /*****************************************************************************
3996 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
3999 * This routine writes a 32 bit value to the pci configuration
4003 * 0 - indicate everything worked ok.
4004 * != 0 - error indication
4006 int SkPciWriteCfgDWord(
4007 SK_AC
*pAC
, /* Adapter Control structure pointer */
4008 int PciAddr
, /* PCI register address */
4009 SK_U32 Val
) /* pointer to store the read value */
4011 pci_write_config_dword(pAC
->PciDev
, PciAddr
, Val
);
4013 } /* SkPciWriteCfgDWord */
4016 /*****************************************************************************
4018 * SkPciWriteCfgWord - write a 16 bit value to pci config space
4021 * This routine writes a 16 bit value to the pci configuration
4022 * space. The flag PciConfigUp indicates whether the config space
4023 * is accesible or must be set up first.
4026 * 0 - indicate everything worked ok.
4027 * != 0 - error indication
4029 int SkPciWriteCfgWord(
4030 SK_AC
*pAC
, /* Adapter Control structure pointer */
4031 int PciAddr
, /* PCI register address */
4032 SK_U16 Val
) /* pointer to store the read value */
4034 pci_write_config_word(pAC
->PciDev
, PciAddr
, Val
);
4036 } /* SkPciWriteCfgWord */
4039 /*****************************************************************************
4041 * SkPciWriteCfgWord - write a 8 bit value to pci config space
4044 * This routine writes a 8 bit value to the pci configuration
4045 * space. The flag PciConfigUp indicates whether the config space
4046 * is accesible or must be set up first.
4049 * 0 - indicate everything worked ok.
4050 * != 0 - error indication
4052 int SkPciWriteCfgByte(
4053 SK_AC
*pAC
, /* Adapter Control structure pointer */
4054 int PciAddr
, /* PCI register address */
4055 SK_U8 Val
) /* pointer to store the read value */
4057 pci_write_config_byte(pAC
->PciDev
, PciAddr
, Val
);
4059 } /* SkPciWriteCfgByte */
4062 /*****************************************************************************
4064 * SkDrvEvent - handle driver events
4067 * This function handles events from all modules directed to the driver
4070 * Is called under protection of slow path lock.
4073 * 0 if everything ok
4078 SK_AC
*pAC
, /* pointer to adapter context */
4079 SK_IOC IoC
, /* io-context */
4080 SK_U32 Event
, /* event-id */
4081 SK_EVPARA Param
) /* event-parameter */
4083 SK_MBUF
*pRlmtMbuf
; /* pointer to a rlmt-mbuf structure */
4084 struct sk_buff
*pMsg
; /* pointer to a message block */
4085 int FromPort
; /* the port from which we switch away */
4086 int ToPort
; /* the port we switch to */
4087 SK_EVPARA NewPara
; /* parameter for further events */
4089 unsigned long Flags
;
4093 case SK_DRV_ADAP_FAIL
:
4094 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4095 ("ADAPTER FAIL EVENT\n"));
4096 printk("%s: Adapter failed.\n", pAC
->dev
[0]->name
);
4097 /* disable interrupts */
4098 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
4101 case SK_DRV_PORT_FAIL
:
4102 FromPort
= Param
.Para32
[0];
4103 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4104 ("PORT FAIL EVENT, Port: %d\n", FromPort
));
4105 if (FromPort
== 0) {
4106 printk("%s: Port A failed.\n", pAC
->dev
[0]->name
);
4108 printk("%s: Port B failed.\n", pAC
->dev
[1]->name
);
4112 case SK_DRV_PORT_RESET
: /* SK_U32 PortIdx */
4114 FromPort
= Param
.Para32
[0];
4115 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4116 ("PORT RESET EVENT, Port: %d ", FromPort
));
4117 NewPara
.Para64
= FromPort
;
4118 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4120 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4123 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_HARD_RST
);
4124 netif_carrier_off(pAC
->dev
[Param
.Para32
[0]]);
4125 spin_unlock_irqrestore(
4126 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4129 /* clear rx ring from received frames */
4130 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
);
4132 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4134 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4137 /* tschilling: Handling of return value inserted. */
4138 if (SkGeInitPort(pAC
, IoC
, FromPort
)) {
4139 if (FromPort
== 0) {
4140 printk("%s: SkGeInitPort A failed.\n", pAC
->dev
[0]->name
);
4142 printk("%s: SkGeInitPort B failed.\n", pAC
->dev
[1]->name
);
4145 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4146 PortReInitBmu(pAC
, FromPort
);
4147 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4148 ClearAndStartRx(pAC
, FromPort
);
4149 spin_unlock_irqrestore(
4150 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4153 case SK_DRV_NET_UP
: /* SK_U32 PortIdx */
4155 FromPort
= Param
.Para32
[0];
4156 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4157 ("NET UP EVENT, Port: %d ", Param
.Para32
[0]));
4159 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4161 if (DoPrintInterfaceChange
) {
4162 printk("%s: network connection up using"
4163 " port %c\n", pAC
->dev
[Param
.Para32
[0]]->name
, 'A'+Param
.Para32
[0]);
4165 /* tschilling: Values changed according to LinkSpeedUsed. */
4166 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
;
4167 if (Stat
== SK_LSPEED_STAT_10MBPS
) {
4168 printk(" speed: 10\n");
4169 } else if (Stat
== SK_LSPEED_STAT_100MBPS
) {
4170 printk(" speed: 100\n");
4171 } else if (Stat
== SK_LSPEED_STAT_1000MBPS
) {
4172 printk(" speed: 1000\n");
4174 printk(" speed: unknown\n");
4178 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkModeStatus
;
4179 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4180 Stat
== SK_LMODE_STAT_AUTOFULL
) {
4181 printk(" autonegotiation: yes\n");
4184 printk(" autonegotiation: no\n");
4186 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4187 Stat
== SK_LMODE_STAT_HALF
) {
4188 printk(" duplex mode: half\n");
4191 printk(" duplex mode: full\n");
4193 Stat
= pAC
->GIni
.GP
[FromPort
].PFlowCtrlStatus
;
4194 if (Stat
== SK_FLOW_STAT_REM_SEND
) {
4195 printk(" flowctrl: remote send\n");
4197 else if (Stat
== SK_FLOW_STAT_LOC_SEND
){
4198 printk(" flowctrl: local send\n");
4200 else if (Stat
== SK_FLOW_STAT_SYMMETRIC
){
4201 printk(" flowctrl: symmetric\n");
4204 printk(" flowctrl: none\n");
4207 /* tschilling: Check against CopperType now. */
4208 if ((pAC
->GIni
.GICopperType
== SK_TRUE
) &&
4209 (pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
==
4210 SK_LSPEED_STAT_1000MBPS
)) {
4211 Stat
= pAC
->GIni
.GP
[FromPort
].PMSStatus
;
4212 if (Stat
== SK_MS_STAT_MASTER
) {
4213 printk(" role: master\n");
4215 else if (Stat
== SK_MS_STAT_SLAVE
) {
4216 printk(" role: slave\n");
4219 printk(" role: ???\n");
4224 Display dim (dynamic interrupt moderation)
4227 if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_STATIC
)
4228 printk(" irq moderation: static (%d ints/sec)\n",
4229 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4230 else if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_DYNAMIC
)
4231 printk(" irq moderation: dynamic (%d ints/sec)\n",
4232 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4234 printk(" irq moderation: disabled\n");
4238 if (pAC
->ChipsetType
)
4239 #ifdef USE_SK_TX_CHECKSUM
4240 printk(" scatter-gather: enabled\n");
4242 printk(" tx-checksum: disabled\n");
4245 printk(" scatter-gather: disabled\n");
4247 printk(" scatter-gather: disabled\n");
4250 #ifndef USE_SK_RX_CHECKSUM
4251 printk(" rx-checksum: disabled\n");
4255 DoPrintInterfaceChange
= SK_TRUE
;
4258 if ((Param
.Para32
[0] != pAC
->ActivePort
) &&
4259 (pAC
->RlmtNets
== 1)) {
4260 NewPara
.Para32
[0] = pAC
->ActivePort
;
4261 NewPara
.Para32
[1] = Param
.Para32
[0];
4262 SkEventQueue(pAC
, SKGE_DRV
, SK_DRV_SWITCH_INTERN
,
4266 /* Inform the world that link protocol is up. */
4267 netif_carrier_on(pAC
->dev
[Param
.Para32
[0]]);
4270 case SK_DRV_NET_DOWN
: /* SK_U32 Reason */
4272 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4273 ("NET DOWN EVENT "));
4274 if (DoPrintInterfaceChange
) {
4275 printk("%s: network connection down\n",
4276 pAC
->dev
[Param
.Para32
[1]]->name
);
4278 DoPrintInterfaceChange
= SK_TRUE
;
4280 netif_carrier_off(pAC
->dev
[Param
.Para32
[1]]);
4282 case SK_DRV_SWITCH_HARD
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4283 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4284 ("PORT SWITCH HARD "));
4285 case SK_DRV_SWITCH_SOFT
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4287 printk("%s: switching to port %c\n", pAC
->dev
[0]->name
,
4288 'A'+Param
.Para32
[1]);
4289 case SK_DRV_SWITCH_INTERN
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4290 FromPort
= Param
.Para32
[0];
4291 ToPort
= Param
.Para32
[1];
4292 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4293 ("PORT SWITCH EVENT, From: %d To: %d (Pref %d) ",
4294 FromPort
, ToPort
, pAC
->Rlmt
.Net
[0].PrefPort
));
4295 NewPara
.Para64
= FromPort
;
4296 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4297 NewPara
.Para64
= ToPort
;
4298 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4300 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4302 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4303 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4304 SkGeStopPort(pAC
, IoC
, ToPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4305 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4306 spin_unlock_irqrestore(
4307 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4310 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
); /* clears rx ring */
4311 ReceiveIrq(pAC
, &pAC
->RxPort
[ToPort
], SK_FALSE
); /* clears rx ring */
4313 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4314 ClearTxRing(pAC
, &pAC
->TxPort
[ToPort
][TX_PRIO_LOW
]);
4316 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4318 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4319 pAC
->ActivePort
= ToPort
;
4323 /* tschilling: New common function with minimum size check. */
4325 if (pAC
->RlmtNets
== 2) {
4329 if (SkGeInitAssignRamToQueues(
4333 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4334 spin_unlock_irqrestore(
4335 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4337 printk("SkGeInitAssignRamToQueues failed.\n");
4341 /* tschilling: Handling of return values inserted. */
4342 if (SkGeInitPort(pAC
, IoC
, FromPort
) ||
4343 SkGeInitPort(pAC
, IoC
, ToPort
)) {
4344 printk("%s: SkGeInitPort failed.\n", pAC
->dev
[0]->name
);
4346 if (Event
== SK_DRV_SWITCH_SOFT
) {
4347 SkMacRxTxEnable(pAC
, IoC
, FromPort
);
4349 SkMacRxTxEnable(pAC
, IoC
, ToPort
);
4350 SkAddrSwap(pAC
, IoC
, FromPort
, ToPort
);
4351 SkAddrMcUpdate(pAC
, IoC
, FromPort
);
4352 SkAddrMcUpdate(pAC
, IoC
, ToPort
);
4353 PortReInitBmu(pAC
, FromPort
);
4354 PortReInitBmu(pAC
, ToPort
);
4355 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4356 SkGePollTxD(pAC
, IoC
, ToPort
, SK_TRUE
);
4357 ClearAndStartRx(pAC
, FromPort
);
4358 ClearAndStartRx(pAC
, ToPort
);
4359 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4360 spin_unlock_irqrestore(
4361 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4364 case SK_DRV_RLMT_SEND
: /* SK_MBUF *pMb */
4365 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4367 pRlmtMbuf
= (SK_MBUF
*) Param
.pParaPtr
;
4368 pMsg
= (struct sk_buff
*) pRlmtMbuf
->pOs
;
4369 skb_put(pMsg
, pRlmtMbuf
->Length
);
4370 if (XmitFrame(pAC
, &pAC
->TxPort
[pRlmtMbuf
->PortIdx
][TX_PRIO_LOW
],
4373 DEV_KFREE_SKB_ANY(pMsg
);
4376 if (Param
.Para32
[0] == SK_DRV_MODERATION_TIMER
) {
4378 ** expiration of the moderation timer implies that
4379 ** dynamic moderation is to be applied
4381 SkDimStartModerationTimer(pAC
);
4383 if (pAC
->DynIrqModInfo
.DisplayStats
) {
4384 SkDimDisplayModerationSettings(pAC
);
4386 } else if (Param
.Para32
[0] == SK_DRV_RX_CLEANUP_TIMER
) {
4388 ** check if we need to check for descriptors which
4389 ** haven't been handled the last millisecs
4391 StartDrvCleanupTimer(pAC
);
4392 if (pAC
->GIni
.GIMacsFound
== 2) {
4393 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_FALSE
);
4395 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_FALSE
);
4397 printk("Expiration of unknown timer\n");
4403 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4410 /*****************************************************************************
4412 * SkErrorLog - log errors
4415 * This function logs errors to the system buffer and to the console
4418 * 0 if everything ok
4431 case SK_ERRCL_OTHER
:
4432 strcpy(ClassStr
, "Other error");
4434 case SK_ERRCL_CONFIG
:
4435 strcpy(ClassStr
, "Configuration error");
4438 strcpy(ClassStr
, "Initialization error");
4440 case SK_ERRCL_NORES
:
4441 strcpy(ClassStr
, "Out of resources error");
4444 strcpy(ClassStr
, "internal Software error");
4447 strcpy(ClassStr
, "Hardware failure");
4450 strcpy(ClassStr
, "Communication error");
4453 printk(KERN_INFO
"%s: -- ERROR --\n Class: %s\n"
4454 " Nr: 0x%x\n Msg: %s\n", pAC
->dev
[0]->name
,
4455 ClassStr
, ErrNum
, pErrorMsg
);
4459 #ifdef SK_DIAG_SUPPORT
4461 /*****************************************************************************
4463 * SkDrvEnterDiagMode - handles DIAG attach request
4466 * Notify the kernel to NOT access the card any longer due to DIAG
4467 * Deinitialize the Card
4472 int SkDrvEnterDiagMode(
4473 SK_AC
*pAc
) /* pointer to adapter context */
4475 DEV_NET
*pNet
= netdev_priv(pAc
->dev
[0]);
4476 SK_AC
*pAC
= pNet
->pAC
;
4478 SK_MEMCPY(&(pAc
->PnmiBackup
), &(pAc
->PnmiStruct
),
4479 sizeof(SK_PNMI_STRUCT_DATA
));
4481 pAC
->DiagModeActive
= DIAG_ACTIVE
;
4482 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
4484 pAC
->WasIfUp
[0] = SK_TRUE
;
4485 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4486 DoPrintInterfaceChange
= SK_FALSE
;
4487 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
4489 pAC
->WasIfUp
[0] = SK_FALSE
;
4491 if (pNet
!= netdev_priv(pAC
->dev
[1])) {
4492 pNet
= netdev_priv(pAC
->dev
[1]);
4494 pAC
->WasIfUp
[1] = SK_TRUE
;
4495 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4496 DoPrintInterfaceChange
= SK_FALSE
;
4497 SkDrvDeInitAdapter(pAC
, 1); /* do SkGeClose */
4499 pAC
->WasIfUp
[1] = SK_FALSE
;
4502 pAC
->BoardLevel
= SK_INIT_DATA
;
4507 /*****************************************************************************
4509 * SkDrvLeaveDiagMode - handles DIAG detach request
4512 * Notify the kernel to may access the card again after use by DIAG
4513 * Initialize the Card
4518 int SkDrvLeaveDiagMode(
4519 SK_AC
*pAc
) /* pointer to adapter control context */
4521 SK_MEMCPY(&(pAc
->PnmiStruct
), &(pAc
->PnmiBackup
),
4522 sizeof(SK_PNMI_STRUCT_DATA
));
4523 pAc
->DiagModeActive
= DIAG_NOTACTIVE
;
4524 pAc
->Pnmi
.DiagAttached
= SK_DIAG_IDLE
;
4525 if (pAc
->WasIfUp
[0] == SK_TRUE
) {
4526 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4527 DoPrintInterfaceChange
= SK_FALSE
;
4528 SkDrvInitAdapter(pAc
, 0); /* first device */
4530 if (pAc
->WasIfUp
[1] == SK_TRUE
) {
4531 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4532 DoPrintInterfaceChange
= SK_FALSE
;
4533 SkDrvInitAdapter(pAc
, 1); /* second device */
4538 /*****************************************************************************
4540 * ParseDeviceNbrFromSlotName - Evaluate PCI device number
4543 * This function parses the PCI slot name information string and will
4544 * retrieve the devcie number out of it. The slot_name maintianed by
4545 * linux is in the form of '02:0a.0', whereas the first two characters
4546 * represent the bus number in hex (in the sample above this is
4547 * pci bus 0x02) and the next two characters the device number (0x0a).
4550 * SK_U32: The device number from the PCI slot name
4553 static SK_U32
ParseDeviceNbrFromSlotName(
4554 const char *SlotName
) /* pointer to pci slot name eg. '02:0a.0' */
4556 char *CurrCharPos
= (char *) SlotName
;
4557 int FirstNibble
= -1;
4558 int SecondNibble
= -1;
4561 while (*CurrCharPos
!= '\0') {
4562 if (*CurrCharPos
== ':') {
4563 while (*CurrCharPos
!= '.') {
4565 if ( (*CurrCharPos
>= '0') &&
4566 (*CurrCharPos
<= '9')) {
4567 if (FirstNibble
== -1) {
4568 /* dec. value for '0' */
4569 FirstNibble
= *CurrCharPos
- 48;
4571 SecondNibble
= *CurrCharPos
- 48;
4573 } else if ( (*CurrCharPos
>= 'a') &&
4574 (*CurrCharPos
<= 'f') ) {
4575 if (FirstNibble
== -1) {
4576 FirstNibble
= *CurrCharPos
- 87;
4578 SecondNibble
= *CurrCharPos
- 87;
4585 Result
= FirstNibble
;
4586 Result
= Result
<< 4; /* first nibble is higher one */
4587 Result
= Result
| SecondNibble
;
4589 CurrCharPos
++; /* next character */
4594 /****************************************************************************
4596 * SkDrvDeInitAdapter - deinitialize adapter (this function is only
4597 * called if Diag attaches to that card)
4600 * Close initialized adapter.
4604 * error code - on error
4606 static int SkDrvDeInitAdapter(
4607 SK_AC
*pAC
, /* pointer to adapter context */
4608 int devNbr
) /* what device is to be handled */
4610 struct SK_NET_DEVICE
*dev
;
4612 dev
= pAC
->dev
[devNbr
];
4614 /* On Linux 2.6 the network driver does NOT mess with reference
4615 ** counts. The driver MUST be able to be unloaded at any time
4616 ** due to the possibility of hotplug.
4618 if (SkGeClose(dev
) != 0) {
4623 } /* SkDrvDeInitAdapter() */
4625 /****************************************************************************
4627 * SkDrvInitAdapter - Initialize adapter (this function is only
4628 * called if Diag deattaches from that card)
4631 * Close initialized adapter.
4635 * error code - on error
4637 static int SkDrvInitAdapter(
4638 SK_AC
*pAC
, /* pointer to adapter context */
4639 int devNbr
) /* what device is to be handled */
4641 struct SK_NET_DEVICE
*dev
;
4643 dev
= pAC
->dev
[devNbr
];
4645 if (SkGeOpen(dev
) != 0) {
4650 ** Use correct MTU size and indicate to kernel TX queue can be started
4652 if (SkGeChangeMtu(dev
, dev
->mtu
) != 0) {
4657 } /* SkDrvInitAdapter */
4662 /****************************************************************************/
4663 /* "debug only" section *****************************************************/
4664 /****************************************************************************/
4667 /*****************************************************************************
4669 * DumpMsg - print a frame
4672 * This function prints frames to the system logfile/to the console.
4677 static void DumpMsg(struct sk_buff
*skb
, char *str
)
4682 printk("DumpMsg(): NULL-Message\n");
4686 if (skb
->data
== NULL
) {
4687 printk("DumpMsg(): Message empty\n");
4695 printk("--- Begin of message from %s , len %d (from %d) ----\n", str
, msglen
, skb
->len
);
4697 DumpData((char *)skb
->data
, msglen
);
4699 printk("------- End of message ---------\n");
4704 /*****************************************************************************
4706 * DumpData - print a data area
4709 * This function prints a area of data to the system logfile/to the
4715 static void DumpData(char *p
, int size
)
4719 char hex_buffer
[180];
4720 char asc_buffer
[180];
4721 char HEXCHAR
[] = "0123456789ABCDEF";
4727 for (i
=0; i
< size
; ) {
4728 if (*p
>= '0' && *p
<='z')
4729 asc_buffer
[addr
] = *p
;
4731 asc_buffer
[addr
] = '.';
4733 asc_buffer
[addr
] = 0;
4734 hex_buffer
[haddr
] = HEXCHAR
[(*p
& 0xf0) >> 4];
4736 hex_buffer
[haddr
] = HEXCHAR
[*p
& 0x0f];
4738 hex_buffer
[haddr
] = ' ';
4740 hex_buffer
[haddr
] = 0;
4744 printk("%s %s\n", hex_buffer
, asc_buffer
);
4752 /*****************************************************************************
4754 * DumpLong - print a data area as long values
4757 * This function prints a area of data to the system logfile/to the
4763 static void DumpLong(char *pc
, int size
)
4767 char hex_buffer
[180];
4768 char asc_buffer
[180];
4769 char HEXCHAR
[] = "0123456789ABCDEF";
4778 for (i
=0; i
< size
; ) {
4780 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 28) & 0xf];
4782 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 24) & 0xf];
4784 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 20) & 0xf];
4786 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 16) & 0xf];
4788 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 12) & 0xf];
4790 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 8) & 0xf];
4792 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 4) & 0xf];
4794 hex_buffer
[haddr
] = HEXCHAR
[l
& 0x0f];
4796 hex_buffer
[haddr
] = ' ';
4798 hex_buffer
[haddr
] = 0;
4802 printk("%4x %s\n", (i
-8)*4, hex_buffer
);
4806 printk("------------------------\n");
4811 static int __devinit
skge_probe_one(struct pci_dev
*pdev
,
4812 const struct pci_device_id
*ent
)
4815 DEV_NET
*pNet
= NULL
;
4816 struct net_device
*dev
= NULL
;
4817 static int boards_found
= 0;
4818 int error
= -ENODEV
;
4820 if (pci_enable_device(pdev
))
4823 /* Configure DMA attributes. */
4824 if (pci_set_dma_mask(pdev
, DMA_64BIT_MASK
) &&
4825 pci_set_dma_mask(pdev
, DMA_32BIT_MASK
))
4826 goto out_disable_device
;
4829 if ((dev
= alloc_etherdev(sizeof(DEV_NET
))) == NULL
) {
4830 printk(KERN_ERR
"Unable to allocate etherdev "
4832 goto out_disable_device
;
4835 pNet
= netdev_priv(dev
);
4836 pNet
->pAC
= kmalloc(sizeof(SK_AC
), GFP_KERNEL
);
4838 printk(KERN_ERR
"Unable to allocate adapter "
4840 goto out_free_netdev
;
4843 memset(pNet
->pAC
, 0, sizeof(SK_AC
));
4846 pAC
->PciDevId
= pdev
->device
;
4849 sprintf(pAC
->Name
, "SysKonnect SK-98xx");
4850 pAC
->CheckQueue
= SK_FALSE
;
4854 dev
->irq
= pdev
->irq
;
4855 error
= SkGeInitPCI(pAC
);
4857 printk(KERN_ERR
"sk98lin: PCI setup failed: %i\n", error
);
4858 goto out_free_netdev
;
4861 SET_MODULE_OWNER(dev
);
4862 dev
->open
= &SkGeOpen
;
4863 dev
->stop
= &SkGeClose
;
4864 dev
->hard_start_xmit
= &SkGeXmit
;
4865 dev
->get_stats
= &SkGeStats
;
4866 dev
->set_multicast_list
= &SkGeSetRxMode
;
4867 dev
->set_mac_address
= &SkGeSetMacAddr
;
4868 dev
->do_ioctl
= &SkGeIoctl
;
4869 dev
->change_mtu
= &SkGeChangeMtu
;
4870 #ifdef CONFIG_NET_POLL_CONTROLLER
4871 dev
->poll_controller
= &SkGePollController
;
4873 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4874 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4877 #ifdef USE_SK_TX_CHECKSUM
4878 if (pAC
->ChipsetType
) {
4879 /* Use only if yukon hardware */
4880 /* SK and ZEROCOPY - fly baby... */
4881 dev
->features
|= NETIF_F_SG
| NETIF_F_IP_CSUM
;
4886 pAC
->Index
= boards_found
++;
4888 if (SkGeBoardInit(dev
, pAC
))
4889 goto out_free_netdev
;
4891 /* Register net device */
4892 if (register_netdev(dev
)) {
4893 printk(KERN_ERR
"sk98lin: Could not register device.\n");
4894 goto out_free_resources
;
4897 /* Print adapter specific string from vpd */
4899 printk("%s: %s\n", dev
->name
, pAC
->DeviceStr
);
4901 /* Print configuration settings */
4902 printk(" PrefPort:%c RlmtMode:%s\n",
4903 'A' + pAC
->Rlmt
.Net
[0].Port
[pAC
->Rlmt
.Net
[0].PrefPort
]->PortNumber
,
4904 (pAC
->RlmtMode
==0) ? "Check Link State" :
4905 ((pAC
->RlmtMode
==1) ? "Check Link State" :
4906 ((pAC
->RlmtMode
==3) ? "Check Local Port" :
4907 ((pAC
->RlmtMode
==7) ? "Check Segmentation" :
4908 ((pAC
->RlmtMode
==17) ? "Dual Check Link State" :"Error")))));
4910 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
4912 memcpy(&dev
->dev_addr
, &pAC
->Addr
.Net
[0].CurrentMacAddress
, 6);
4913 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4915 SkGeProcCreate(dev
);
4922 /* More then one port found */
4923 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
4924 if ((dev
= alloc_etherdev(sizeof(DEV_NET
))) == 0) {
4925 printk(KERN_ERR
"Unable to allocate etherdev "
4931 pNet
= netdev_priv(dev
);
4938 dev
->open
= &SkGeOpen
;
4939 dev
->stop
= &SkGeClose
;
4940 dev
->hard_start_xmit
= &SkGeXmit
;
4941 dev
->get_stats
= &SkGeStats
;
4942 dev
->set_multicast_list
= &SkGeSetRxMode
;
4943 dev
->set_mac_address
= &SkGeSetMacAddr
;
4944 dev
->do_ioctl
= &SkGeIoctl
;
4945 dev
->change_mtu
= &SkGeChangeMtu
;
4946 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4947 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4950 #ifdef USE_SK_TX_CHECKSUM
4951 if (pAC
->ChipsetType
) {
4952 /* SG and ZEROCOPY - fly baby... */
4953 dev
->features
|= NETIF_F_SG
| NETIF_F_IP_CSUM
;
4958 if (register_netdev(dev
)) {
4959 printk(KERN_ERR
"sk98lin: Could not register device for seconf port.\n");
4961 pAC
->dev
[1] = pAC
->dev
[0];
4963 SkGeProcCreate(dev
);
4964 memcpy(&dev
->dev_addr
,
4965 &pAC
->Addr
.Net
[1].CurrentMacAddress
, 6);
4966 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4968 printk("%s: %s\n", dev
->name
, pAC
->DeviceStr
);
4969 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4973 /* Save the hardware revision */
4974 pAC
->HWRevision
= (((pAC
->GIni
.GIPciHwRev
>> 4) & 0x0F)*10) +
4975 (pAC
->GIni
.GIPciHwRev
& 0x0F);
4977 /* Set driver globals */
4978 pAC
->Pnmi
.pDriverFileName
= DRIVER_FILE_NAME
;
4979 pAC
->Pnmi
.pDriverReleaseDate
= DRIVER_REL_DATE
;
4981 memset(&pAC
->PnmiBackup
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
4982 memcpy(&pAC
->PnmiBackup
, &pAC
->PnmiStruct
, sizeof(SK_PNMI_STRUCT_DATA
));
4984 pci_set_drvdata(pdev
, dev
);
4992 pci_disable_device(pdev
);
4997 static void __devexit
skge_remove_one(struct pci_dev
*pdev
)
4999 struct net_device
*dev
= pci_get_drvdata(pdev
);
5000 DEV_NET
*pNet
= netdev_priv(dev
);
5001 SK_AC
*pAC
= pNet
->pAC
;
5002 struct net_device
*otherdev
= pAC
->dev
[1];
5004 SkGeProcRemove(dev
);
5005 unregister_netdev(dev
);
5006 if (otherdev
!= dev
)
5007 SkGeProcRemove(otherdev
);
5009 SkGeYellowLED(pAC
, pAC
->IoBase
, 0);
5011 if (pAC
->BoardLevel
== SK_INIT_RUN
) {
5013 unsigned long Flags
;
5015 /* board is still alive */
5016 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
5017 EvPara
.Para32
[0] = 0;
5018 EvPara
.Para32
[1] = -1;
5019 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
5020 EvPara
.Para32
[0] = 1;
5021 EvPara
.Para32
[1] = -1;
5022 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
5023 SkEventDispatcher(pAC
, pAC
->IoBase
);
5024 /* disable interrupts */
5025 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
5026 SkGeDeInit(pAC
, pAC
->IoBase
);
5027 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
5028 pAC
->BoardLevel
= SK_INIT_DATA
;
5029 /* We do NOT check here, if IRQ was pending, of course*/
5032 if (pAC
->BoardLevel
== SK_INIT_IO
) {
5033 /* board is still alive */
5034 SkGeDeInit(pAC
, pAC
->IoBase
);
5035 pAC
->BoardLevel
= SK_INIT_DATA
;
5040 if (otherdev
!= dev
)
5041 free_netdev(otherdev
);
5046 static int skge_suspend(struct pci_dev
*pdev
, pm_message_t state
)
5048 struct net_device
*dev
= pci_get_drvdata(pdev
);
5049 DEV_NET
*pNet
= netdev_priv(dev
);
5050 SK_AC
*pAC
= pNet
->pAC
;
5051 struct net_device
*otherdev
= pAC
->dev
[1];
5053 if (netif_running(dev
)) {
5054 netif_carrier_off(dev
);
5055 DoPrintInterfaceChange
= SK_FALSE
;
5056 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
5057 netif_device_detach(dev
);
5059 if (otherdev
!= dev
) {
5060 if (netif_running(otherdev
)) {
5061 netif_carrier_off(otherdev
);
5062 DoPrintInterfaceChange
= SK_FALSE
;
5063 SkDrvDeInitAdapter(pAC
, 1); /* performs SkGeClose */
5064 netif_device_detach(otherdev
);
5068 pci_save_state(pdev
);
5069 pci_enable_wake(pdev
, pci_choose_state(pdev
, state
), 0);
5070 if (pAC
->AllocFlag
& SK_ALLOC_IRQ
) {
5071 free_irq(dev
->irq
, dev
);
5073 pci_disable_device(pdev
);
5074 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
5079 static int skge_resume(struct pci_dev
*pdev
)
5081 struct net_device
*dev
= pci_get_drvdata(pdev
);
5082 DEV_NET
*pNet
= netdev_priv(dev
);
5083 SK_AC
*pAC
= pNet
->pAC
;
5084 struct net_device
*otherdev
= pAC
->dev
[1];
5087 pci_set_power_state(pdev
, PCI_D0
);
5088 pci_restore_state(pdev
);
5089 pci_enable_device(pdev
);
5090 pci_set_master(pdev
);
5091 if (pAC
->GIni
.GIMacsFound
== 2)
5092 ret
= request_irq(dev
->irq
, SkGeIsr
, SA_SHIRQ
, pAC
->Name
, dev
);
5094 ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, SA_SHIRQ
, pAC
->Name
, dev
);
5096 printk(KERN_WARNING
"sk98lin: unable to acquire IRQ %d\n", dev
->irq
);
5097 pAC
->AllocFlag
&= ~SK_ALLOC_IRQ
;
5099 pci_disable_device(pdev
);
5103 netif_device_attach(dev
);
5104 if (netif_running(dev
)) {
5105 DoPrintInterfaceChange
= SK_FALSE
;
5106 SkDrvInitAdapter(pAC
, 0); /* first device */
5108 if (otherdev
!= dev
) {
5109 netif_device_attach(otherdev
);
5110 if (netif_running(otherdev
)) {
5111 DoPrintInterfaceChange
= SK_FALSE
;
5112 SkDrvInitAdapter(pAC
, 1); /* second device */
5119 #define skge_suspend NULL
5120 #define skge_resume NULL
5123 static struct pci_device_id skge_pci_tbl
[] = {
5124 { PCI_VENDOR_ID_3COM
, 0x1700, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5125 { PCI_VENDOR_ID_3COM
, 0x80eb, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5126 { PCI_VENDOR_ID_SYSKONNECT
, 0x4300, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5127 { PCI_VENDOR_ID_SYSKONNECT
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5128 /* DLink card does not have valid VPD so this driver gags
5129 * { PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5131 { PCI_VENDOR_ID_MARVELL
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5132 { PCI_VENDOR_ID_MARVELL
, 0x5005, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5133 { PCI_VENDOR_ID_CNET
, 0x434e, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5134 { PCI_VENDOR_ID_LINKSYS
, 0x1032, PCI_ANY_ID
, 0x0015, },
5135 { PCI_VENDOR_ID_LINKSYS
, 0x1064, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5139 MODULE_DEVICE_TABLE(pci
, skge_pci_tbl
);
5141 static struct pci_driver skge_driver
= {
5143 .id_table
= skge_pci_tbl
,
5144 .probe
= skge_probe_one
,
5145 .remove
= __devexit_p(skge_remove_one
),
5146 .suspend
= skge_suspend
,
5147 .resume
= skge_resume
,
5150 static int __init
skge_init(void)
5154 pSkRootDir
= proc_mkdir(SKRootName
, NULL
);
5156 pSkRootDir
->owner
= THIS_MODULE
;
5158 error
= pci_register_driver(&skge_driver
);
5160 remove_proc_entry(SKRootName
, NULL
);
5164 static void __exit
skge_exit(void)
5166 pci_unregister_driver(&skge_driver
);
5167 remove_proc_entry(SKRootName
, NULL
);
5171 module_init(skge_init
);
5172 module_exit(skge_exit
);