1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.45 $
6 * Date: $Date: 2004/02/12 14:41:02 $
7 * Purpose: The main driver source module
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2002 SysKonnect GmbH.
14 * (C)Copyright 2002-2003 Marvell.
16 * Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet
19 * Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and
20 * SysKonnects GEnesis Solaris driver
21 * Author: Christoph Goos (cgoos@syskonnect.de)
22 * Mirko Lindner (mlindner@syskonnect.de)
24 * Address all question to: linux@syskonnect.de
26 * The technical manual for the adapters is available from SysKonnect's
27 * web pages: www.syskonnect.com
28 * Goto "Support" and search Knowledge Base for "manual".
30 * This program is free software; you can redistribute it and/or modify
31 * it under the terms of the GNU General Public License as published by
32 * the Free Software Foundation; either version 2 of the License, or
33 * (at your option) any later version.
35 * The information in this file is provided "AS IS" without warranty.
37 ******************************************************************************/
39 /******************************************************************************
41 * Possible compiler options (#define xxx / -Dxxx):
43 * debugging can be enable by changing SK_DEBUG_CHKMOD and
44 * SK_DEBUG_CHKCAT in makefile (described there).
46 ******************************************************************************/
48 /******************************************************************************
52 * This is the main module of the Linux GE driver.
54 * All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h
55 * are part of SysKonnect's COMMON MODULES for the SK-98xx adapters.
56 * Those are used for drivers on multiple OS', so some thing may seem
57 * unnecessary complicated on Linux. Please do not try to 'clean up'
58 * them without VERY good reasons, because this will make it more
59 * difficult to keep the Linux driver in synchronisation with the
62 * Include file hierarchy:
79 * <linux/etherdevice.h>
81 * those three depending on kernel version used:
106 ******************************************************************************/
108 #include "h/skversion.h"
110 #include <linux/in.h>
111 #include <linux/module.h>
112 #include <linux/moduleparam.h>
113 #include <linux/init.h>
114 #include <linux/dma-mapping.h>
115 #include <linux/ip.h>
117 #include "h/skdrv1st.h"
118 #include "h/skdrv2nd.h"
120 /*******************************************************************************
124 ******************************************************************************/
126 /* for debuging on x86 only */
127 /* #define BREAKPOINT() asm(" int $3"); */
129 /* use the transmit hw checksum driver functionality */
130 #define USE_SK_TX_CHECKSUM
132 /* use the receive hw checksum driver functionality */
133 #define USE_SK_RX_CHECKSUM
135 /* use the scatter-gather functionality with sendfile() */
138 /* use of a transmit complete interrupt */
139 #define USE_TX_COMPLETE
142 * threshold for copying small receive frames
143 * set to 0 to avoid copying, set to 9001 to copy all frames
145 #define SK_COPY_THRESHOLD 50
147 /* number of adapters that can be configured via command line params */
148 #define SK_MAX_CARD_PARAM 16
153 * use those defines for a compile-in version of the driver instead
154 * of command line parameters
156 // #define LINK_SPEED_A {"Auto", }
157 // #define LINK_SPEED_B {"Auto", }
158 // #define AUTO_NEG_A {"Sense", }
159 // #define AUTO_NEG_B {"Sense", }
160 // #define DUP_CAP_A {"Both", }
161 // #define DUP_CAP_B {"Both", }
162 // #define FLOW_CTRL_A {"SymOrRem", }
163 // #define FLOW_CTRL_B {"SymOrRem", }
164 // #define ROLE_A {"Auto", }
165 // #define ROLE_B {"Auto", }
166 // #define PREF_PORT {"A", }
167 // #define CON_TYPE {"Auto", }
168 // #define RLMT_MODE {"CheckLinkState", }
170 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
171 #define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
172 #define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
176 #define OEM_CONFIG_VALUE ( SK_ACT_LED_BLINK | \
177 SK_DUP_LED_NORMAL | \
181 /* Isr return value */
182 #define SkIsrRetVar irqreturn_t
183 #define SkIsrRetNone IRQ_NONE
184 #define SkIsrRetHandled IRQ_HANDLED
187 /*******************************************************************************
189 * Local Function Prototypes
191 ******************************************************************************/
193 static void FreeResources(struct SK_NET_DEVICE
*dev
);
194 static int SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
);
195 static SK_BOOL
BoardAllocMem(SK_AC
*pAC
);
196 static void BoardFreeMem(SK_AC
*pAC
);
197 static void BoardInitMem(SK_AC
*pAC
);
198 static void SetupRing(SK_AC
*, void*, uintptr_t, RXD
**, RXD
**, RXD
**, int*, SK_BOOL
);
199 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
, struct pt_regs
*ptregs
);
200 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
, struct pt_regs
*ptregs
);
201 static int SkGeOpen(struct SK_NET_DEVICE
*dev
);
202 static int SkGeClose(struct SK_NET_DEVICE
*dev
);
203 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
);
204 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
);
205 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
);
206 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
);
207 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
);
208 static void GetConfiguration(SK_AC
*);
209 static int XmitFrame(SK_AC
*, TX_PORT
*, struct sk_buff
*);
210 static void FreeTxDescriptors(SK_AC
*pAC
, TX_PORT
*);
211 static void FillRxRing(SK_AC
*, RX_PORT
*);
212 static SK_BOOL
FillRxDescriptor(SK_AC
*, RX_PORT
*);
213 static void ReceiveIrq(SK_AC
*, RX_PORT
*, SK_BOOL
);
214 static void ClearAndStartRx(SK_AC
*, int);
215 static void ClearTxIrq(SK_AC
*, int, int);
216 static void ClearRxRing(SK_AC
*, RX_PORT
*);
217 static void ClearTxRing(SK_AC
*, TX_PORT
*);
218 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int new_mtu
);
219 static void PortReInitBmu(SK_AC
*, int);
220 static int SkGeIocMib(DEV_NET
*, unsigned int, int);
221 static int SkGeInitPCI(SK_AC
*pAC
);
222 static void StartDrvCleanupTimer(SK_AC
*pAC
);
223 static void StopDrvCleanupTimer(SK_AC
*pAC
);
224 static int XmitFrameSG(SK_AC
*, TX_PORT
*, struct sk_buff
*);
226 #ifdef SK_DIAG_SUPPORT
227 static SK_U32
ParseDeviceNbrFromSlotName(const char *SlotName
);
228 static int SkDrvInitAdapter(SK_AC
*pAC
, int devNbr
);
229 static int SkDrvDeInitAdapter(SK_AC
*pAC
, int devNbr
);
232 /*******************************************************************************
234 * Extern Function Prototypes
236 ******************************************************************************/
237 extern void SkDimEnableModerationIfNeeded(SK_AC
*pAC
);
238 extern void SkDimDisplayModerationSettings(SK_AC
*pAC
);
239 extern void SkDimStartModerationTimer(SK_AC
*pAC
);
240 extern void SkDimModerate(SK_AC
*pAC
);
241 extern void SkGeBlinkTimer(unsigned long data
);
244 static void DumpMsg(struct sk_buff
*, char*);
245 static void DumpData(char*, int);
246 static void DumpLong(char*, int);
249 /* global variables *********************************************************/
250 static SK_BOOL DoPrintInterfaceChange
= SK_TRUE
;
251 extern struct ethtool_ops SkGeEthtoolOps
;
253 /* local variables **********************************************************/
254 static uintptr_t TxQueueAddr
[SK_MAX_MACS
][2] = {{0x680, 0x600},{0x780, 0x700}};
255 static uintptr_t RxQueueAddr
[SK_MAX_MACS
] = {0x400, 0x480};
257 /*****************************************************************************
259 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
262 * This routine writes a 32 bit value to the pci configuration
266 * 0 - indicate everything worked ok.
267 * != 0 - error indication
269 static inline int SkPciWriteCfgDWord(
270 SK_AC
*pAC
, /* Adapter Control structure pointer */
271 int PciAddr
, /* PCI register address */
272 SK_U32 Val
) /* pointer to store the read value */
274 pci_write_config_dword(pAC
->PciDev
, PciAddr
, Val
);
276 } /* SkPciWriteCfgDWord */
278 /*****************************************************************************
280 * SkGeInitPCI - Init the PCI resources
283 * This function initialize the PCI resources and IO
286 * 0 - indicate everything worked ok.
287 * != 0 - error indication
289 static __devinit
int SkGeInitPCI(SK_AC
*pAC
)
291 struct SK_NET_DEVICE
*dev
= pAC
->dev
[0];
292 struct pci_dev
*pdev
= pAC
->PciDev
;
295 dev
->mem_start
= pci_resource_start (pdev
, 0);
296 pci_set_master(pdev
);
298 retval
= pci_request_regions(pdev
, "sk98lin");
304 * On big endian machines, we use the adapter's aibility of
305 * reading the descriptors as big endian.
309 SkPciReadCfgDWord(pAC
, PCI_OUR_REG_2
, &our2
);
310 our2
|= PCI_REV_DESC
;
311 SkPciWriteCfgDWord(pAC
, PCI_OUR_REG_2
, our2
);
316 * Remap the regs into kernel space.
318 pAC
->IoBase
= ioremap_nocache(dev
->mem_start
, 0x4000);
327 pci_release_regions(pdev
);
333 /*****************************************************************************
335 * FreeResources - release resources allocated for adapter
338 * This function releases the IRQ, unmaps the IO and
339 * frees the desriptor ring.
344 static void FreeResources(struct SK_NET_DEVICE
*dev
)
350 pNet
= netdev_priv(dev
);
352 AllocFlag
= pAC
->AllocFlag
;
354 pci_release_regions(pAC
->PciDev
);
356 if (AllocFlag
& SK_ALLOC_IRQ
) {
357 free_irq(dev
->irq
, dev
);
360 iounmap(pAC
->IoBase
);
362 if (pAC
->pDescrMem
) {
366 } /* FreeResources */
368 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
369 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
370 MODULE_LICENSE("GPL");
373 static char *Speed_A
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
375 static char *Speed_A
[SK_MAX_CARD_PARAM
] = {"", };
379 static char *Speed_B
[SK_MAX_CARD_PARAM
] = LINK_SPEED
;
381 static char *Speed_B
[SK_MAX_CARD_PARAM
] = {"", };
385 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = AUTO_NEG_A
;
387 static char *AutoNeg_A
[SK_MAX_CARD_PARAM
] = {"", };
391 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = DUP_CAP_A
;
393 static char *DupCap_A
[SK_MAX_CARD_PARAM
] = {"", };
397 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_A
;
399 static char *FlowCtrl_A
[SK_MAX_CARD_PARAM
] = {"", };
403 static char *Role_A
[SK_MAX_CARD_PARAM
] = ROLE_A
;
405 static char *Role_A
[SK_MAX_CARD_PARAM
] = {"", };
409 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = AUTO_NEG_B
;
411 static char *AutoNeg_B
[SK_MAX_CARD_PARAM
] = {"", };
415 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = DUP_CAP_B
;
417 static char *DupCap_B
[SK_MAX_CARD_PARAM
] = {"", };
421 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = FLOW_CTRL_B
;
423 static char *FlowCtrl_B
[SK_MAX_CARD_PARAM
] = {"", };
427 static char *Role_B
[SK_MAX_CARD_PARAM
] = ROLE_B
;
429 static char *Role_B
[SK_MAX_CARD_PARAM
] = {"", };
433 static char *ConType
[SK_MAX_CARD_PARAM
] = CON_TYPE
;
435 static char *ConType
[SK_MAX_CARD_PARAM
] = {"", };
439 static char *PrefPort
[SK_MAX_CARD_PARAM
] = PREF_PORT
;
441 static char *PrefPort
[SK_MAX_CARD_PARAM
] = {"", };
445 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = RLMT_MODE
;
447 static char *RlmtMode
[SK_MAX_CARD_PARAM
] = {"", };
450 static int IntsPerSec
[SK_MAX_CARD_PARAM
];
451 static char *Moderation
[SK_MAX_CARD_PARAM
];
452 static char *ModerationMask
[SK_MAX_CARD_PARAM
];
453 static char *AutoSizing
[SK_MAX_CARD_PARAM
];
454 static char *Stats
[SK_MAX_CARD_PARAM
];
456 module_param_array(Speed_A
, charp
, NULL
, 0);
457 module_param_array(Speed_B
, charp
, NULL
, 0);
458 module_param_array(AutoNeg_A
, charp
, NULL
, 0);
459 module_param_array(AutoNeg_B
, charp
, NULL
, 0);
460 module_param_array(DupCap_A
, charp
, NULL
, 0);
461 module_param_array(DupCap_B
, charp
, NULL
, 0);
462 module_param_array(FlowCtrl_A
, charp
, NULL
, 0);
463 module_param_array(FlowCtrl_B
, charp
, NULL
, 0);
464 module_param_array(Role_A
, charp
, NULL
, 0);
465 module_param_array(Role_B
, charp
, NULL
, 0);
466 module_param_array(ConType
, charp
, NULL
, 0);
467 module_param_array(PrefPort
, charp
, NULL
, 0);
468 module_param_array(RlmtMode
, charp
, NULL
, 0);
469 /* used for interrupt moderation */
470 module_param_array(IntsPerSec
, int, NULL
, 0);
471 module_param_array(Moderation
, charp
, NULL
, 0);
472 module_param_array(Stats
, charp
, NULL
, 0);
473 module_param_array(ModerationMask
, charp
, NULL
, 0);
474 module_param_array(AutoSizing
, charp
, NULL
, 0);
476 /*****************************************************************************
478 * SkGeBoardInit - do level 0 and 1 initialization
481 * This function prepares the board hardware for running. The desriptor
482 * ring is set up, the IRQ is allocated and the configuration settings
486 * 0, if everything is ok
489 static int __devinit
SkGeBoardInit(struct SK_NET_DEVICE
*dev
, SK_AC
*pAC
)
493 char *DescrString
= "sk98lin: Driver for Linux"; /* this is given to PNMI */
494 char *VerStr
= VER_STRING
;
495 int Ret
; /* return code of request_irq */
498 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
499 ("IoBase: %08lX\n", (unsigned long)pAC
->IoBase
));
500 for (i
=0; i
<SK_MAX_MACS
; i
++) {
501 pAC
->TxPort
[i
][0].HwAddr
= pAC
->IoBase
+ TxQueueAddr
[i
][0];
502 pAC
->TxPort
[i
][0].PortIndex
= i
;
503 pAC
->RxPort
[i
].HwAddr
= pAC
->IoBase
+ RxQueueAddr
[i
];
504 pAC
->RxPort
[i
].PortIndex
= i
;
507 /* Initialize the mutexes */
508 for (i
=0; i
<SK_MAX_MACS
; i
++) {
509 spin_lock_init(&pAC
->TxPort
[i
][0].TxDesRingLock
);
510 spin_lock_init(&pAC
->RxPort
[i
].RxDesRingLock
);
512 spin_lock_init(&pAC
->SlowPathLock
);
514 /* setup phy_id blink timer */
515 pAC
->BlinkTimer
.function
= SkGeBlinkTimer
;
516 pAC
->BlinkTimer
.data
= (unsigned long) dev
;
517 init_timer(&pAC
->BlinkTimer
);
519 /* level 0 init common modules here */
521 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
522 /* Does a RESET on board ...*/
523 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
) != 0) {
524 printk("HWInit (0) failed.\n");
525 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
528 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
529 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
530 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
531 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
532 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_DATA
);
533 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_DATA
);
535 pAC
->BoardLevel
= SK_INIT_DATA
;
536 pAC
->RxBufSize
= ETH_BUF_SIZE
;
538 SK_PNMI_SET_DRIVER_DESCR(pAC
, DescrString
);
539 SK_PNMI_SET_DRIVER_VER(pAC
, VerStr
);
541 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
543 /* level 1 init common modules here (HW init) */
544 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
545 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
546 printk("sk98lin: HWInit (1) failed.\n");
547 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
550 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
551 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
552 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
553 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
554 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
555 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
557 /* Set chipset type support */
558 pAC
->ChipsetType
= 0;
559 if ((pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
) ||
560 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON_LITE
)) {
561 pAC
->ChipsetType
= 1;
564 GetConfiguration(pAC
);
565 if (pAC
->RlmtNets
== 2) {
566 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
569 pAC
->BoardLevel
= SK_INIT_IO
;
570 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
572 if (pAC
->GIni
.GIMacsFound
== 2) {
573 Ret
= request_irq(dev
->irq
, SkGeIsr
, SA_SHIRQ
, "sk98lin", dev
);
574 } else if (pAC
->GIni
.GIMacsFound
== 1) {
575 Ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, SA_SHIRQ
,
578 printk(KERN_WARNING
"sk98lin: Illegal number of ports: %d\n",
579 pAC
->GIni
.GIMacsFound
);
584 printk(KERN_WARNING
"sk98lin: Requested IRQ %d is busy.\n",
588 pAC
->AllocFlag
|= SK_ALLOC_IRQ
;
590 /* Alloc memory for this board (Mem for RxD/TxD) : */
591 if(!BoardAllocMem(pAC
)) {
592 printk("No memory for descriptor rings.\n");
597 /* tschilling: New common function with minimum size check. */
599 if (pAC
->RlmtNets
== 2) {
603 if (SkGeInitAssignRamToQueues(
608 printk("sk98lin: SkGeInitAssignRamToQueues failed.\n");
613 } /* SkGeBoardInit */
616 /*****************************************************************************
618 * BoardAllocMem - allocate the memory for the descriptor rings
621 * This function allocates the memory for all descriptor rings.
622 * Each ring is aligned for the desriptor alignment and no ring
623 * has a 4 GByte boundary in it (because the upper 32 bit must
624 * be constant for all descriptiors in one rings).
627 * SK_TRUE, if all memory could be allocated
630 static __devinit SK_BOOL
BoardAllocMem(SK_AC
*pAC
)
632 caddr_t pDescrMem
; /* pointer to descriptor memory area */
633 size_t AllocLength
; /* length of complete descriptor area */
634 int i
; /* loop counter */
635 unsigned long BusAddr
;
638 /* rings plus one for alignment (do not cross 4 GB boundary) */
639 /* RX_RING_SIZE is assumed bigger than TX_RING_SIZE */
640 #if (BITS_PER_LONG == 32)
641 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
643 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
647 pDescrMem
= pci_alloc_consistent(pAC
->PciDev
, AllocLength
,
650 if (pDescrMem
== NULL
) {
653 pAC
->pDescrMem
= pDescrMem
;
654 BusAddr
= (unsigned long) pAC
->pDescrMemDMA
;
656 /* Descriptors need 8 byte alignment, and this is ensured
657 * by pci_alloc_consistent.
659 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
660 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
661 ("TX%d/A: pDescrMem: %lX, PhysDescrMem: %lX\n",
662 i
, (unsigned long) pDescrMem
,
664 pAC
->TxPort
[i
][0].pTxDescrRing
= pDescrMem
;
665 pAC
->TxPort
[i
][0].VTxDescrRing
= BusAddr
;
666 pDescrMem
+= TX_RING_SIZE
;
667 BusAddr
+= TX_RING_SIZE
;
669 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
670 ("RX%d: pDescrMem: %lX, PhysDescrMem: %lX\n",
671 i
, (unsigned long) pDescrMem
,
672 (unsigned long)BusAddr
));
673 pAC
->RxPort
[i
].pRxDescrRing
= pDescrMem
;
674 pAC
->RxPort
[i
].VRxDescrRing
= BusAddr
;
675 pDescrMem
+= RX_RING_SIZE
;
676 BusAddr
+= RX_RING_SIZE
;
680 } /* BoardAllocMem */
683 /****************************************************************************
685 * BoardFreeMem - reverse of BoardAllocMem
688 * Free all memory allocated in BoardAllocMem: adapter context,
689 * descriptor rings, locks.
693 static void BoardFreeMem(
696 size_t AllocLength
; /* length of complete descriptor area */
698 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
700 #if (BITS_PER_LONG == 32)
701 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
+ 8;
703 AllocLength
= (RX_RING_SIZE
+ TX_RING_SIZE
) * pAC
->GIni
.GIMacsFound
707 pci_free_consistent(pAC
->PciDev
, AllocLength
,
708 pAC
->pDescrMem
, pAC
->pDescrMemDMA
);
709 pAC
->pDescrMem
= NULL
;
713 /*****************************************************************************
715 * BoardInitMem - initiate the descriptor rings
718 * This function sets the descriptor rings up in memory.
719 * The adapter is initialized with the descriptor start addresses.
723 static __devinit
void BoardInitMem(SK_AC
*pAC
)
725 int i
; /* loop counter */
726 int RxDescrSize
; /* the size of a rx descriptor rounded up to alignment*/
727 int TxDescrSize
; /* the size of a tx descriptor rounded up to alignment*/
729 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
732 RxDescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
733 pAC
->RxDescrPerRing
= RX_RING_SIZE
/ RxDescrSize
;
734 TxDescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) * DESCR_ALIGN
;
735 pAC
->TxDescrPerRing
= TX_RING_SIZE
/ RxDescrSize
;
737 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
740 pAC
->TxPort
[i
][0].pTxDescrRing
,
741 pAC
->TxPort
[i
][0].VTxDescrRing
,
742 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingHead
,
743 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingTail
,
744 (RXD
**)&pAC
->TxPort
[i
][0].pTxdRingPrev
,
745 &pAC
->TxPort
[i
][0].TxdRingFree
,
749 pAC
->RxPort
[i
].pRxDescrRing
,
750 pAC
->RxPort
[i
].VRxDescrRing
,
751 &pAC
->RxPort
[i
].pRxdRingHead
,
752 &pAC
->RxPort
[i
].pRxdRingTail
,
753 &pAC
->RxPort
[i
].pRxdRingPrev
,
754 &pAC
->RxPort
[i
].RxdRingFree
,
760 /*****************************************************************************
762 * SetupRing - create one descriptor ring
765 * This function creates one descriptor ring in the given memory area.
766 * The head, tail and number of free descriptors in the ring are set.
771 static void SetupRing(
773 void *pMemArea
, /* a pointer to the memory area for the ring */
774 uintptr_t VMemArea
, /* the virtual bus address of the memory area */
775 RXD
**ppRingHead
, /* address where the head should be written */
776 RXD
**ppRingTail
, /* address where the tail should be written */
777 RXD
**ppRingPrev
, /* address where the tail should be written */
778 int *pRingFree
, /* address where the # of free descr. goes */
779 SK_BOOL IsTx
) /* flag: is this a tx ring */
781 int i
; /* loop counter */
782 int DescrSize
; /* the size of a descriptor rounded up to alignment*/
783 int DescrNum
; /* number of descriptors per ring */
784 RXD
*pDescr
; /* pointer to a descriptor (receive or transmit) */
785 RXD
*pNextDescr
; /* pointer to the next descriptor */
786 RXD
*pPrevDescr
; /* pointer to the previous descriptor */
787 uintptr_t VNextDescr
; /* the virtual bus address of the next descriptor */
789 if (IsTx
== SK_TRUE
) {
790 DescrSize
= (((sizeof(TXD
) - 1) / DESCR_ALIGN
) + 1) *
792 DescrNum
= TX_RING_SIZE
/ DescrSize
;
794 DescrSize
= (((sizeof(RXD
) - 1) / DESCR_ALIGN
) + 1) *
796 DescrNum
= RX_RING_SIZE
/ DescrSize
;
799 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
,
800 ("Descriptor size: %d Descriptor Number: %d\n",
801 DescrSize
,DescrNum
));
803 pDescr
= (RXD
*) pMemArea
;
805 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
806 VNextDescr
= VMemArea
+ DescrSize
;
807 for(i
=0; i
<DescrNum
; i
++) {
808 /* set the pointers right */
809 pDescr
->VNextRxd
= VNextDescr
& 0xffffffffULL
;
810 pDescr
->pNextRxd
= pNextDescr
;
811 if (!IsTx
) pDescr
->TcpSumStarts
= ETH_HLEN
<< 16 | ETH_HLEN
;
813 /* advance one step */
816 pNextDescr
= (RXD
*) (((char*)pDescr
) + DescrSize
);
817 VNextDescr
+= DescrSize
;
819 pPrevDescr
->pNextRxd
= (RXD
*) pMemArea
;
820 pPrevDescr
->VNextRxd
= VMemArea
;
821 pDescr
= (RXD
*) pMemArea
;
822 *ppRingHead
= (RXD
*) pMemArea
;
823 *ppRingTail
= *ppRingHead
;
824 *ppRingPrev
= pPrevDescr
;
825 *pRingFree
= DescrNum
;
829 /*****************************************************************************
831 * PortReInitBmu - re-initiate the descriptor rings for one port
834 * This function reinitializes the descriptor rings of one port
835 * in memory. The port must be stopped before.
836 * The HW is initialized with the descriptor start addresses.
841 static void PortReInitBmu(
842 SK_AC
*pAC
, /* pointer to adapter context */
843 int PortIndex
) /* index of the port for which to re-init */
845 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
848 /* set address of first descriptor of ring in BMU */
849 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_L
,
850 (uint32_t)(((caddr_t
)
851 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
852 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
853 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) &
855 SK_OUT32(pAC
->IoBase
, TxQueueAddr
[PortIndex
][TX_PRIO_LOW
]+ Q_DA_H
,
856 (uint32_t)(((caddr_t
)
857 (pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxdRingHead
) -
858 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].pTxDescrRing
+
859 pAC
->TxPort
[PortIndex
][TX_PRIO_LOW
].VTxDescrRing
) >> 32));
860 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_L
,
861 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
862 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
863 pAC
->RxPort
[PortIndex
].VRxDescrRing
) & 0xFFFFFFFF));
864 SK_OUT32(pAC
->IoBase
, RxQueueAddr
[PortIndex
]+Q_DA_H
,
865 (uint32_t)(((caddr_t
)(pAC
->RxPort
[PortIndex
].pRxdRingHead
) -
866 pAC
->RxPort
[PortIndex
].pRxDescrRing
+
867 pAC
->RxPort
[PortIndex
].VRxDescrRing
) >> 32));
868 } /* PortReInitBmu */
871 /****************************************************************************
873 * SkGeIsr - handle adapter interrupts
876 * The interrupt routine is called when the network adapter
877 * generates an interrupt. It may also be called if another device
878 * shares this interrupt vector with the driver.
883 static SkIsrRetVar
SkGeIsr(int irq
, void *dev_id
, struct pt_regs
*ptregs
)
885 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
888 SK_U32 IntSrc
; /* interrupts source register contents */
890 pNet
= netdev_priv(dev
);
894 * Check and process if its our interrupt
896 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
901 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
902 #if 0 /* software irq currently not used */
903 if (IntSrc
& IS_IRQ_SW
) {
904 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
905 SK_DBGCAT_DRV_INT_SRC
,
909 if (IntSrc
& IS_R1_F
) {
910 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
911 SK_DBGCAT_DRV_INT_SRC
,
913 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
914 SK_PNMI_CNT_RX_INTR(pAC
, 0);
916 if (IntSrc
& IS_R2_F
) {
917 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
918 SK_DBGCAT_DRV_INT_SRC
,
920 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_TRUE
);
921 SK_PNMI_CNT_RX_INTR(pAC
, 1);
923 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
924 if (IntSrc
& IS_XA1_F
) {
925 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
926 SK_DBGCAT_DRV_INT_SRC
,
927 ("EOF AS TX1 IRQ\n"));
928 SK_PNMI_CNT_TX_INTR(pAC
, 0);
929 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
930 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
931 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
933 if (IntSrc
& IS_XA2_F
) {
934 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
935 SK_DBGCAT_DRV_INT_SRC
,
936 ("EOF AS TX2 IRQ\n"));
937 SK_PNMI_CNT_TX_INTR(pAC
, 1);
938 spin_lock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
939 FreeTxDescriptors(pAC
, &pAC
->TxPort
[1][TX_PRIO_LOW
]);
940 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_LOW
].TxDesRingLock
);
942 #if 0 /* only if sync. queues used */
943 if (IntSrc
& IS_XS1_F
) {
944 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
945 SK_DBGCAT_DRV_INT_SRC
,
946 ("EOF SY TX1 IRQ\n"));
947 SK_PNMI_CNT_TX_INTR(pAC
, 1);
948 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
949 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
950 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
951 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
953 if (IntSrc
& IS_XS2_F
) {
954 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
955 SK_DBGCAT_DRV_INT_SRC
,
956 ("EOF SY TX2 IRQ\n"));
957 SK_PNMI_CNT_TX_INTR(pAC
, 1);
958 spin_lock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
959 FreeTxDescriptors(pAC
, 1, TX_PRIO_HIGH
);
960 spin_unlock(&pAC
->TxPort
[1][TX_PRIO_HIGH
].TxDesRingLock
);
961 ClearTxIrq(pAC
, 1, TX_PRIO_HIGH
);
966 /* do all IO at once */
967 if (IntSrc
& IS_R1_F
)
968 ClearAndStartRx(pAC
, 0);
969 if (IntSrc
& IS_R2_F
)
970 ClearAndStartRx(pAC
, 1);
971 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
972 if (IntSrc
& IS_XA1_F
)
973 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
974 if (IntSrc
& IS_XA2_F
)
975 ClearTxIrq(pAC
, 1, TX_PRIO_LOW
);
977 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
978 } /* while (IntSrc & IRQ_MASK != 0) */
980 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
981 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
982 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
983 ("SPECIAL IRQ DP-Cards => %x\n", IntSrc
));
984 pAC
->CheckQueue
= SK_FALSE
;
985 spin_lock(&pAC
->SlowPathLock
);
986 if (IntSrc
& SPECIAL_IRQS
)
987 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
989 SkEventDispatcher(pAC
, pAC
->IoBase
);
990 spin_unlock(&pAC
->SlowPathLock
);
993 * do it all again is case we cleared an interrupt that
994 * came in after handling the ring (OUTs may be delayed
995 * in hardware buffers, but are through after IN)
997 * rroesler: has been commented out and shifted to
998 * SkGeDrvEvent(), because it is timer
1001 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1002 ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1005 if (pAC
->CheckQueue
) {
1006 pAC
->CheckQueue
= SK_FALSE
;
1007 spin_lock(&pAC
->SlowPathLock
);
1008 SkEventDispatcher(pAC
, pAC
->IoBase
);
1009 spin_unlock(&pAC
->SlowPathLock
);
1012 /* IRQ is processed - Enable IRQs again*/
1013 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1015 return SkIsrRetHandled
;
1019 /****************************************************************************
1021 * SkGeIsrOnePort - handle adapter interrupts for single port adapter
1024 * The interrupt routine is called when the network adapter
1025 * generates an interrupt. It may also be called if another device
1026 * shares this interrupt vector with the driver.
1027 * This is the same as above, but handles only one port.
1032 static SkIsrRetVar
SkGeIsrOnePort(int irq
, void *dev_id
, struct pt_regs
*ptregs
)
1034 struct SK_NET_DEVICE
*dev
= (struct SK_NET_DEVICE
*)dev_id
;
1037 SK_U32 IntSrc
; /* interrupts source register contents */
1039 pNet
= netdev_priv(dev
);
1043 * Check and process if its our interrupt
1045 SK_IN32(pAC
->IoBase
, B0_SP_ISRC
, &IntSrc
);
1047 return SkIsrRetNone
;
1050 while (((IntSrc
& IRQ_MASK
) & ~SPECIAL_IRQS
) != 0) {
1051 #if 0 /* software irq currently not used */
1052 if (IntSrc
& IS_IRQ_SW
) {
1053 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1054 SK_DBGCAT_DRV_INT_SRC
,
1055 ("Software IRQ\n"));
1058 if (IntSrc
& IS_R1_F
) {
1059 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1060 SK_DBGCAT_DRV_INT_SRC
,
1062 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_TRUE
);
1063 SK_PNMI_CNT_RX_INTR(pAC
, 0);
1065 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1066 if (IntSrc
& IS_XA1_F
) {
1067 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1068 SK_DBGCAT_DRV_INT_SRC
,
1069 ("EOF AS TX1 IRQ\n"));
1070 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1071 spin_lock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1072 FreeTxDescriptors(pAC
, &pAC
->TxPort
[0][TX_PRIO_LOW
]);
1073 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_LOW
].TxDesRingLock
);
1075 #if 0 /* only if sync. queues used */
1076 if (IntSrc
& IS_XS1_F
) {
1077 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1078 SK_DBGCAT_DRV_INT_SRC
,
1079 ("EOF SY TX1 IRQ\n"));
1080 SK_PNMI_CNT_TX_INTR(pAC
, 0);
1081 spin_lock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1082 FreeTxDescriptors(pAC
, 0, TX_PRIO_HIGH
);
1083 spin_unlock(&pAC
->TxPort
[0][TX_PRIO_HIGH
].TxDesRingLock
);
1084 ClearTxIrq(pAC
, 0, TX_PRIO_HIGH
);
1089 /* do all IO at once */
1090 if (IntSrc
& IS_R1_F
)
1091 ClearAndStartRx(pAC
, 0);
1092 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1093 if (IntSrc
& IS_XA1_F
)
1094 ClearTxIrq(pAC
, 0, TX_PRIO_LOW
);
1096 SK_IN32(pAC
->IoBase
, B0_ISRC
, &IntSrc
);
1097 } /* while (IntSrc & IRQ_MASK != 0) */
1099 IntSrc
&= pAC
->GIni
.GIValIrqMask
;
1100 if ((IntSrc
& SPECIAL_IRQS
) || pAC
->CheckQueue
) {
1101 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_INT_SRC
,
1102 ("SPECIAL IRQ SP-Cards => %x\n", IntSrc
));
1103 pAC
->CheckQueue
= SK_FALSE
;
1104 spin_lock(&pAC
->SlowPathLock
);
1105 if (IntSrc
& SPECIAL_IRQS
)
1106 SkGeSirqIsr(pAC
, pAC
->IoBase
, IntSrc
);
1108 SkEventDispatcher(pAC
, pAC
->IoBase
);
1109 spin_unlock(&pAC
->SlowPathLock
);
1112 * do it all again is case we cleared an interrupt that
1113 * came in after handling the ring (OUTs may be delayed
1114 * in hardware buffers, but are through after IN)
1116 * rroesler: has been commented out and shifted to
1117 * SkGeDrvEvent(), because it is timer
1120 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1123 /* IRQ is processed - Enable IRQs again*/
1124 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1126 return SkIsrRetHandled
;
1127 } /* SkGeIsrOnePort */
1129 #ifdef CONFIG_NET_POLL_CONTROLLER
1130 /****************************************************************************
1132 * SkGePollController - polling receive, for netconsole
1135 * Polling receive - used by netconsole and other diagnostic tools
1136 * to allow network i/o with interrupts disabled.
1140 static void SkGePollController(struct net_device
*dev
)
1142 disable_irq(dev
->irq
);
1143 SkGeIsr(dev
->irq
, dev
, NULL
);
1144 enable_irq(dev
->irq
);
1148 /****************************************************************************
1150 * SkGeOpen - handle start of initialized adapter
1153 * This function starts the initialized adapter.
1154 * The board level variable is set and the adapter is
1155 * brought to full functionality.
1156 * The device flags are set for operation.
1157 * Do all necessary level 2 initialization, enable interrupts and
1158 * give start command to RLMT.
1164 static int SkGeOpen(
1165 struct SK_NET_DEVICE
*dev
)
1169 unsigned long Flags
; /* for spin lock */
1171 SK_EVPARA EvPara
; /* an event parameter union */
1173 pNet
= netdev_priv(dev
);
1176 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1177 ("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC
));
1179 #ifdef SK_DIAG_SUPPORT
1180 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1181 if (pAC
->Pnmi
.DiagAttached
== SK_DIAG_RUNNING
) {
1182 return (-1); /* still in use by diag; deny actions */
1187 /* Set blink mode */
1188 if ((pAC
->PciDev
->vendor
== 0x1186) || (pAC
->PciDev
->vendor
== 0x11ab ))
1189 pAC
->GIni
.GILedBlinkCtrl
= OEM_CONFIG_VALUE
;
1191 if (pAC
->BoardLevel
== SK_INIT_DATA
) {
1192 /* level 1 init common modules here */
1193 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_IO
) != 0) {
1194 printk("%s: HWInit (1) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1197 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1198 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1199 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1200 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1201 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1202 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_IO
);
1203 pAC
->BoardLevel
= SK_INIT_IO
;
1206 if (pAC
->BoardLevel
!= SK_INIT_RUN
) {
1207 /* tschilling: Level 2 init modules here, check return value. */
1208 if (SkGeInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
) != 0) {
1209 printk("%s: HWInit (2) failed.\n", pAC
->dev
[pNet
->PortNr
]->name
);
1212 SkI2cInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1213 SkEventInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1214 SkPnmiInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1215 SkAddrInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1216 SkRlmtInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1217 SkTimerInit (pAC
, pAC
->IoBase
, SK_INIT_RUN
);
1218 pAC
->BoardLevel
= SK_INIT_RUN
;
1221 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1222 /* Enable transmit descriptor polling. */
1223 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
1224 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
1226 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
1228 StartDrvCleanupTimer(pAC
);
1229 SkDimEnableModerationIfNeeded(pAC
);
1230 SkDimDisplayModerationSettings(pAC
);
1232 pAC
->GIni
.GIValIrqMask
&= IRQ_MASK
;
1234 /* enable Interrupts */
1235 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
1236 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
1238 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1240 if ((pAC
->RlmtMode
!= 0) && (pAC
->MaxPorts
== 0)) {
1241 EvPara
.Para32
[0] = pAC
->RlmtNets
;
1242 EvPara
.Para32
[1] = -1;
1243 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
,
1245 EvPara
.Para32
[0] = pAC
->RlmtMode
;
1246 EvPara
.Para32
[1] = 0;
1247 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_MODE_CHANGE
,
1251 EvPara
.Para32
[0] = pNet
->NetNr
;
1252 EvPara
.Para32
[1] = -1;
1253 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
1254 SkEventDispatcher(pAC
, pAC
->IoBase
);
1255 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1260 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1261 ("SkGeOpen suceeded\n"));
1267 /****************************************************************************
1269 * SkGeClose - Stop initialized adapter
1272 * Close initialized adapter.
1276 * error code - on error
1278 static int SkGeClose(
1279 struct SK_NET_DEVICE
*dev
)
1285 unsigned long Flags
; /* for spin lock */
1290 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1291 ("SkGeClose: pAC=0x%lX ", (unsigned long)pAC
));
1293 pNet
= netdev_priv(dev
);
1296 #ifdef SK_DIAG_SUPPORT
1297 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
1298 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
1300 ** notify that the interface which has been closed
1301 ** by operator interaction must not be started up
1302 ** again when the DIAG has finished.
1304 newPtrNet
= netdev_priv(pAC
->dev
[0]);
1305 if (newPtrNet
== pNet
) {
1306 pAC
->WasIfUp
[0] = SK_FALSE
;
1308 pAC
->WasIfUp
[1] = SK_FALSE
;
1310 return 0; /* return to system everything is fine... */
1312 pAC
->DiagFlowCtrl
= SK_FALSE
;
1317 netif_stop_queue(dev
);
1319 if (pAC
->RlmtNets
== 1)
1320 PortIdx
= pAC
->ActivePort
;
1322 PortIdx
= pNet
->NetNr
;
1324 StopDrvCleanupTimer(pAC
);
1327 * Clear multicast table, promiscuous mode ....
1329 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
1330 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
1333 if (pAC
->MaxPorts
== 1) {
1334 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1335 /* disable interrupts */
1336 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1337 EvPara
.Para32
[0] = pNet
->NetNr
;
1338 EvPara
.Para32
[1] = -1;
1339 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1340 SkEventDispatcher(pAC
, pAC
->IoBase
);
1341 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
1342 /* stop the hardware */
1343 SkGeDeInit(pAC
, pAC
->IoBase
);
1344 pAC
->BoardLevel
= SK_INIT_DATA
;
1345 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1348 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
1349 EvPara
.Para32
[0] = pNet
->NetNr
;
1350 EvPara
.Para32
[1] = -1;
1351 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
1352 SkPnmiEvent(pAC
, pAC
->IoBase
, SK_PNMI_EVT_XMAC_RESET
, EvPara
);
1353 SkEventDispatcher(pAC
, pAC
->IoBase
);
1354 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
1357 spin_lock_irqsave(&pAC
->TxPort
[pNet
->PortNr
]
1358 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1359 SkGeStopPort(pAC
, pAC
->IoBase
, pNet
->PortNr
,
1360 SK_STOP_ALL
, SK_HARD_RST
);
1361 spin_unlock_irqrestore(&pAC
->TxPort
[pNet
->PortNr
]
1362 [TX_PRIO_LOW
].TxDesRingLock
, Flags
);
1365 if (pAC
->RlmtNets
== 1) {
1366 /* clear all descriptor rings */
1367 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
1368 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
1369 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
1370 ClearTxRing(pAC
, &pAC
->TxPort
[i
][TX_PRIO_LOW
]);
1373 /* clear port descriptor rings */
1374 ReceiveIrq(pAC
, &pAC
->RxPort
[pNet
->PortNr
], SK_TRUE
);
1375 ClearRxRing(pAC
, &pAC
->RxPort
[pNet
->PortNr
]);
1376 ClearTxRing(pAC
, &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
]);
1379 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
1380 ("SkGeClose: done "));
1382 SK_MEMSET(&(pAC
->PnmiBackup
), 0, sizeof(SK_PNMI_STRUCT_DATA
));
1383 SK_MEMCPY(&(pAC
->PnmiBackup
), &(pAC
->PnmiStruct
),
1384 sizeof(SK_PNMI_STRUCT_DATA
));
1392 /*****************************************************************************
1394 * SkGeXmit - Linux frame transmit function
1397 * The system calls this function to send frames onto the wire.
1398 * It puts the frame in the tx descriptor ring. If the ring is
1399 * full then, the 'tbusy' flag is set.
1402 * 0, if everything is ok
1404 * WARNING: returning 1 in 'tbusy' case caused system crashes (double
1405 * allocated skb's) !!!
1407 static int SkGeXmit(struct sk_buff
*skb
, struct SK_NET_DEVICE
*dev
)
1411 int Rc
; /* return code of XmitFrame */
1413 pNet
= netdev_priv(dev
);
1416 if ((!skb_shinfo(skb
)->nr_frags
) ||
1417 (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
)) {
1418 /* Don't activate scatter-gather and hardware checksum */
1420 if (pAC
->RlmtNets
== 2)
1423 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1428 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1431 /* scatter-gather and hardware TCP checksumming anabled*/
1432 if (pAC
->RlmtNets
== 2)
1435 &pAC
->TxPort
[pNet
->PortNr
][TX_PRIO_LOW
],
1440 &pAC
->TxPort
[pAC
->ActivePort
][TX_PRIO_LOW
],
1444 /* Transmitter out of resources? */
1446 netif_stop_queue(dev
);
1449 /* If not taken, give buffer ownership back to the
1455 dev
->trans_start
= jiffies
;
1460 /*****************************************************************************
1462 * XmitFrame - fill one socket buffer into the transmit ring
1465 * This function puts a message into the transmit descriptor ring
1466 * if there is a descriptors left.
1467 * Linux skb's consist of only one continuous buffer.
1468 * The first step locks the ring. It is held locked
1469 * all time to avoid problems with SWITCH_../PORT_RESET.
1470 * Then the descriptoris allocated.
1471 * The second part is linking the buffer to the descriptor.
1472 * At the very last, the Control field of the descriptor
1473 * is made valid for the BMU and a start TX command is given
1477 * > 0 - on succes: the number of bytes in the message
1478 * = 0 - on resource shortage: this frame sent or dropped, now
1479 * the ring is full ( -> set tbusy)
1480 * < 0 - on failure: other problems ( -> return failure to upper layers)
1482 static int XmitFrame(
1483 SK_AC
*pAC
, /* pointer to adapter context */
1484 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1485 struct sk_buff
*pMessage
) /* pointer to send-message */
1487 TXD
*pTxd
; /* the rxd to fill */
1489 unsigned long Flags
;
1491 int BytesSend
= pMessage
->len
;
1493 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_TX_PROGRESS
, ("X"));
1495 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1496 #ifndef USE_TX_COMPLETE
1497 FreeTxDescriptors(pAC
, pTxPort
);
1499 if (pTxPort
->TxdRingFree
== 0) {
1501 ** no enough free descriptors in ring at the moment.
1502 ** Maybe free'ing some old one help?
1504 FreeTxDescriptors(pAC
, pTxPort
);
1505 if (pTxPort
->TxdRingFree
== 0) {
1506 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1507 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1508 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1509 SK_DBGCAT_DRV_TX_PROGRESS
,
1510 ("XmitFrame failed\n"));
1512 ** the desired message can not be sent
1513 ** Because tbusy seems to be set, the message
1514 ** should not be freed here. It will be used
1515 ** by the scheduler of the ethernet handler
1522 ** If the passed socket buffer is of smaller MTU-size than 60,
1523 ** copy everything into new buffer and fill all bytes between
1524 ** the original packet end and the new packet end of 60 with 0x00.
1525 ** This is to resolve faulty padding by the HW with 0xaa bytes.
1527 if (BytesSend
< C_LEN_ETHERNET_MINSIZE
) {
1528 if ((pMessage
= skb_padto(pMessage
, C_LEN_ETHERNET_MINSIZE
)) == NULL
) {
1529 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1532 pMessage
->len
= C_LEN_ETHERNET_MINSIZE
;
1536 ** advance head counter behind descriptor needed for this frame,
1537 ** so that needed descriptor is reserved from that on. The next
1538 ** action will be to add the passed buffer to the TX-descriptor
1540 pTxd
= pTxPort
->pTxdRingHead
;
1541 pTxPort
->pTxdRingHead
= pTxd
->pNextTxd
;
1542 pTxPort
->TxdRingFree
--;
1545 DumpMsg(pMessage
, "XmitFrame");
1549 ** First step is to map the data to be sent via the adapter onto
1550 ** the DMA memory. Kernel 2.2 uses virt_to_bus(), but kernels 2.4
1551 ** and 2.6 need to use pci_map_page() for that mapping.
1553 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1554 virt_to_page(pMessage
->data
),
1555 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1558 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1559 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1560 pTxd
->pMBuf
= pMessage
;
1562 if (pMessage
->ip_summed
== CHECKSUM_HW
) {
1563 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1564 u16 offset
= hdrlen
+ pMessage
->csum
;
1566 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1567 (pAC
->GIni
.GIChipRev
== 0) &&
1568 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1569 pTxd
->TBControl
= BMU_TCP_CHECK
;
1571 pTxd
->TBControl
= BMU_UDP_CHECK
;
1574 pTxd
->TcpSumOfs
= 0;
1575 pTxd
->TcpSumSt
= hdrlen
;
1576 pTxd
->TcpSumWr
= offset
;
1578 pTxd
->TBControl
|= BMU_OWN
| BMU_STF
|
1580 #ifdef USE_TX_COMPLETE
1585 pTxd
->TBControl
= BMU_OWN
| BMU_STF
| BMU_CHECK
|
1587 #ifdef USE_TX_COMPLETE
1594 ** If previous descriptor already done, give TX start cmd
1596 pOldTxd
= xchg(&pTxPort
->pTxdRingPrev
, pTxd
);
1597 if ((pOldTxd
->TBControl
& BMU_OWN
) == 0) {
1598 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1602 ** after releasing the lock, the skb may immediately be free'd
1604 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1605 if (pTxPort
->TxdRingFree
!= 0) {
1613 /*****************************************************************************
1615 * XmitFrameSG - fill one socket buffer into the transmit ring
1616 * (use SG and TCP/UDP hardware checksumming)
1619 * This function puts a message into the transmit descriptor ring
1620 * if there is a descriptors left.
1623 * > 0 - on succes: the number of bytes in the message
1624 * = 0 - on resource shortage: this frame sent or dropped, now
1625 * the ring is full ( -> set tbusy)
1626 * < 0 - on failure: other problems ( -> return failure to upper layers)
1628 static int XmitFrameSG(
1629 SK_AC
*pAC
, /* pointer to adapter context */
1630 TX_PORT
*pTxPort
, /* pointer to struct of port to send to */
1631 struct sk_buff
*pMessage
) /* pointer to send-message */
1639 skb_frag_t
*sk_frag
;
1641 unsigned long Flags
;
1644 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
1645 #ifndef USE_TX_COMPLETE
1646 FreeTxDescriptors(pAC
, pTxPort
);
1648 if ((skb_shinfo(pMessage
)->nr_frags
+1) > pTxPort
->TxdRingFree
) {
1649 FreeTxDescriptors(pAC
, pTxPort
);
1650 if ((skb_shinfo(pMessage
)->nr_frags
+ 1) > pTxPort
->TxdRingFree
) {
1651 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1652 SK_PNMI_CNT_NO_TX_BUF(pAC
, pTxPort
->PortIndex
);
1653 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1654 SK_DBGCAT_DRV_TX_PROGRESS
,
1655 ("XmitFrameSG failed - Ring full\n"));
1656 /* this message can not be sent now */
1661 pTxd
= pTxPort
->pTxdRingHead
;
1667 ** Map the first fragment (header) into the DMA-space
1669 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1670 virt_to_page(pMessage
->data
),
1671 ((unsigned long) pMessage
->data
& ~PAGE_MASK
),
1672 skb_headlen(pMessage
),
1675 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1676 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1679 ** Does the HW need to evaluate checksum for TCP or UDP packets?
1681 if (pMessage
->ip_summed
== CHECKSUM_HW
) {
1682 u16 hdrlen
= pMessage
->h
.raw
- pMessage
->data
;
1683 u16 offset
= hdrlen
+ pMessage
->csum
;
1685 Control
= BMU_STFWD
;
1688 ** We have to use the opcode for tcp here, because the
1689 ** opcode for udp is not working in the hardware yet
1692 if ((pMessage
->h
.ipiph
->protocol
== IPPROTO_UDP
) &&
1693 (pAC
->GIni
.GIChipRev
== 0) &&
1694 (pAC
->GIni
.GIChipId
== CHIP_ID_YUKON
)) {
1695 Control
|= BMU_TCP_CHECK
;
1697 Control
|= BMU_UDP_CHECK
;
1700 pTxd
->TcpSumOfs
= 0;
1701 pTxd
->TcpSumSt
= hdrlen
;
1702 pTxd
->TcpSumWr
= offset
;
1704 Control
= BMU_CHECK
| BMU_SW
;
1706 pTxd
->TBControl
= BMU_STF
| Control
| skb_headlen(pMessage
);
1708 pTxd
= pTxd
->pNextTxd
;
1709 pTxPort
->TxdRingFree
--;
1710 BytesSend
+= skb_headlen(pMessage
);
1713 ** Browse over all SG fragments and map each of them into the DMA space
1715 for (CurrFrag
= 0; CurrFrag
< skb_shinfo(pMessage
)->nr_frags
; CurrFrag
++) {
1716 sk_frag
= &skb_shinfo(pMessage
)->frags
[CurrFrag
];
1718 ** we already have the proper value in entry
1720 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1722 sk_frag
->page_offset
,
1726 pTxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1727 pTxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1728 pTxd
->pMBuf
= pMessage
;
1730 pTxd
->TBControl
= Control
| BMU_OWN
| sk_frag
->size
;;
1733 ** Do we have the last fragment?
1735 if( (CurrFrag
+1) == skb_shinfo(pMessage
)->nr_frags
) {
1736 #ifdef USE_TX_COMPLETE
1737 pTxd
->TBControl
|= BMU_EOF
| BMU_IRQ_EOF
;
1739 pTxd
->TBControl
|= BMU_EOF
;
1741 pTxdFst
->TBControl
|= BMU_OWN
| BMU_SW
;
1744 pTxd
= pTxd
->pNextTxd
;
1745 pTxPort
->TxdRingFree
--;
1746 BytesSend
+= sk_frag
->size
;
1750 ** If previous descriptor already done, give TX start cmd
1752 if ((pTxPort
->pTxdRingPrev
->TBControl
& BMU_OWN
) == 0) {
1753 SK_OUT8(pTxPort
->HwAddr
, Q_CSR
, CSR_START
);
1756 pTxPort
->pTxdRingPrev
= pTxdLst
;
1757 pTxPort
->pTxdRingHead
= pTxd
;
1759 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
1761 if (pTxPort
->TxdRingFree
> 0) {
1768 /*****************************************************************************
1770 * FreeTxDescriptors - release descriptors from the descriptor ring
1773 * This function releases descriptors from a transmit ring if they
1774 * have been sent by the BMU.
1775 * If a descriptors is sent, it can be freed and the message can
1777 * The SOFTWARE controllable bit is used to prevent running around a
1778 * completely free ring for ever. If this bit is no set in the
1779 * frame (by XmitFrame), this frame has never been sent or is
1781 * The Tx descriptor ring lock must be held while calling this function !!!
1786 static void FreeTxDescriptors(
1787 SK_AC
*pAC
, /* pointer to the adapter context */
1788 TX_PORT
*pTxPort
) /* pointer to destination port structure */
1790 TXD
*pTxd
; /* pointer to the checked descriptor */
1791 TXD
*pNewTail
; /* pointer to 'end' of the ring */
1792 SK_U32 Control
; /* TBControl field of descriptor */
1793 SK_U64 PhysAddr
; /* address of DMA mapping */
1795 pNewTail
= pTxPort
->pTxdRingTail
;
1798 ** loop forever; exits if BMU_SW bit not set in start frame
1799 ** or BMU_OWN bit set in any frame
1802 Control
= pTxd
->TBControl
;
1803 if ((Control
& BMU_SW
) == 0) {
1805 ** software controllable bit is set in first
1806 ** fragment when given to BMU. Not set means that
1807 ** this fragment was never sent or is already
1808 ** freed ( -> ring completely free now).
1810 pTxPort
->pTxdRingTail
= pTxd
;
1811 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1814 if (Control
& BMU_OWN
) {
1815 pTxPort
->pTxdRingTail
= pTxd
;
1816 if (pTxPort
->TxdRingFree
> 0) {
1817 netif_wake_queue(pAC
->dev
[pTxPort
->PortIndex
]);
1823 ** release the DMA mapping, because until not unmapped
1824 ** this buffer is considered being under control of the
1827 PhysAddr
= ((SK_U64
) pTxd
->VDataHigh
) << (SK_U64
) 32;
1828 PhysAddr
|= (SK_U64
) pTxd
->VDataLow
;
1829 pci_unmap_page(pAC
->PciDev
, PhysAddr
,
1833 if (Control
& BMU_EOF
)
1834 DEV_KFREE_SKB_ANY(pTxd
->pMBuf
); /* free message */
1836 pTxPort
->TxdRingFree
++;
1837 pTxd
->TBControl
&= ~BMU_SW
;
1838 pTxd
= pTxd
->pNextTxd
; /* point behind fragment with EOF */
1839 } /* while(forever) */
1840 } /* FreeTxDescriptors */
1842 /*****************************************************************************
1844 * FillRxRing - fill the receive ring with valid descriptors
1847 * This function fills the receive ring descriptors with data
1848 * segments and makes them valid for the BMU.
1849 * The active ring is filled completely, if possible.
1850 * The non-active ring is filled only partial to save memory.
1852 * Description of rx ring structure:
1853 * head - points to the descriptor which will be used next by the BMU
1854 * tail - points to the next descriptor to give to the BMU
1858 static void FillRxRing(
1859 SK_AC
*pAC
, /* pointer to the adapter context */
1860 RX_PORT
*pRxPort
) /* ptr to port struct for which the ring
1863 unsigned long Flags
;
1865 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
1866 while (pRxPort
->RxdRingFree
> pRxPort
->RxFillLimit
) {
1867 if(!FillRxDescriptor(pAC
, pRxPort
))
1870 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
1874 /*****************************************************************************
1876 * FillRxDescriptor - fill one buffer into the receive ring
1879 * The function allocates a new receive buffer and
1880 * puts it into the next descriptor.
1883 * SK_TRUE - a buffer was added to the ring
1884 * SK_FALSE - a buffer could not be added
1886 static SK_BOOL
FillRxDescriptor(
1887 SK_AC
*pAC
, /* pointer to the adapter context struct */
1888 RX_PORT
*pRxPort
) /* ptr to port struct of ring to fill */
1890 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
1891 RXD
*pRxd
; /* the rxd to fill */
1892 SK_U16 Length
; /* data fragment length */
1893 SK_U64 PhysAddr
; /* physical address of a rx buffer */
1895 pMsgBlock
= alloc_skb(pAC
->RxBufSize
, GFP_ATOMIC
);
1896 if (pMsgBlock
== NULL
) {
1897 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
1898 SK_DBGCAT_DRV_ENTRY
,
1899 ("%s: Allocation of rx buffer failed !\n",
1900 pAC
->dev
[pRxPort
->PortIndex
]->name
));
1901 SK_PNMI_CNT_NO_RX_BUF(pAC
, pRxPort
->PortIndex
);
1904 skb_reserve(pMsgBlock
, 2); /* to align IP frames */
1905 /* skb allocated ok, so add buffer */
1906 pRxd
= pRxPort
->pRxdRingTail
;
1907 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1908 pRxPort
->RxdRingFree
--;
1909 Length
= pAC
->RxBufSize
;
1910 PhysAddr
= (SK_U64
) pci_map_page(pAC
->PciDev
,
1911 virt_to_page(pMsgBlock
->data
),
1912 ((unsigned long) pMsgBlock
->data
&
1915 PCI_DMA_FROMDEVICE
);
1917 pRxd
->VDataLow
= (SK_U32
) (PhysAddr
& 0xffffffff);
1918 pRxd
->VDataHigh
= (SK_U32
) (PhysAddr
>> 32);
1919 pRxd
->pMBuf
= pMsgBlock
;
1920 pRxd
->RBControl
= BMU_OWN
|
1927 } /* FillRxDescriptor */
1930 /*****************************************************************************
1932 * ReQueueRxBuffer - fill one buffer back into the receive ring
1935 * Fill a given buffer back into the rx ring. The buffer
1936 * has been previously allocated and aligned, and its phys.
1937 * address calculated, so this is no more necessary.
1941 static void ReQueueRxBuffer(
1942 SK_AC
*pAC
, /* pointer to the adapter context struct */
1943 RX_PORT
*pRxPort
, /* ptr to port struct of ring to fill */
1944 struct sk_buff
*pMsg
, /* pointer to the buffer */
1945 SK_U32 PhysHigh
, /* phys address high dword */
1946 SK_U32 PhysLow
) /* phys address low dword */
1948 RXD
*pRxd
; /* the rxd to fill */
1949 SK_U16 Length
; /* data fragment length */
1951 pRxd
= pRxPort
->pRxdRingTail
;
1952 pRxPort
->pRxdRingTail
= pRxd
->pNextRxd
;
1953 pRxPort
->RxdRingFree
--;
1954 Length
= pAC
->RxBufSize
;
1956 pRxd
->VDataLow
= PhysLow
;
1957 pRxd
->VDataHigh
= PhysHigh
;
1959 pRxd
->RBControl
= BMU_OWN
|
1965 } /* ReQueueRxBuffer */
1967 /*****************************************************************************
1969 * ReceiveIrq - handle a receive IRQ
1972 * This function is called when a receive IRQ is set.
1973 * It walks the receive descriptor ring and sends up all
1974 * frames that are complete.
1978 static void ReceiveIrq(
1979 SK_AC
*pAC
, /* pointer to adapter context */
1980 RX_PORT
*pRxPort
, /* pointer to receive port struct */
1981 SK_BOOL SlowPathLock
) /* indicates if SlowPathLock is needed */
1983 RXD
*pRxd
; /* pointer to receive descriptors */
1984 SK_U32 Control
; /* control field of descriptor */
1985 struct sk_buff
*pMsg
; /* pointer to message holding frame */
1986 struct sk_buff
*pNewMsg
; /* pointer to a new message for copying frame */
1987 int FrameLength
; /* total length of received frame */
1988 SK_MBUF
*pRlmtMbuf
; /* ptr to a buffer for giving a frame to rlmt */
1989 SK_EVPARA EvPara
; /* an event parameter union */
1990 unsigned long Flags
; /* for spin lock */
1991 int PortIndex
= pRxPort
->PortIndex
;
1992 unsigned int Offset
;
1993 unsigned int NumBytes
;
1994 unsigned int ForRlmt
;
1997 SK_BOOL IsBadFrame
; /* Bad frame */
2003 /* do forever; exit if BMU_OWN found */
2004 for ( pRxd
= pRxPort
->pRxdRingHead
;
2005 pRxPort
->RxdRingFree
< pAC
->RxDescrPerRing
;
2006 pRxd
= pRxd
->pNextRxd
,
2007 pRxPort
->pRxdRingHead
= pRxd
,
2008 pRxPort
->RxdRingFree
++) {
2011 * For a better understanding of this loop
2012 * Go through every descriptor beginning at the head
2013 * Please note: the ring might be completely received so the OWN bit
2014 * set is not a good crirteria to leave that loop.
2015 * Therefore the RingFree counter is used.
2016 * On entry of this loop pRxd is a pointer to the Rxd that needs
2017 * to be checked next.
2020 Control
= pRxd
->RBControl
;
2022 /* check if this descriptor is ready */
2023 if ((Control
& BMU_OWN
) != 0) {
2024 /* this descriptor is not yet ready */
2025 /* This is the usual end of the loop */
2026 /* We don't need to start the ring again */
2027 FillRxRing(pAC
, pRxPort
);
2030 pAC
->DynIrqModInfo
.NbrProcessedDescr
++;
2032 /* get length of frame and check it */
2033 FrameLength
= Control
& BMU_BBC
;
2034 if (FrameLength
> pAC
->RxBufSize
) {
2038 /* check for STF and EOF */
2039 if ((Control
& (BMU_STF
| BMU_EOF
)) != (BMU_STF
| BMU_EOF
)) {
2043 /* here we have a complete frame in the ring */
2046 FrameStat
= pRxd
->FrameStat
;
2048 /* check for frame length mismatch */
2049 #define XMR_FS_LEN_SHIFT 18
2050 #define GMR_FS_LEN_SHIFT 16
2051 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2052 if (FrameLength
!= (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)) {
2053 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2054 SK_DBGCAT_DRV_RX_PROGRESS
,
2055 ("skge: Frame length mismatch (%u/%u).\n",
2057 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2062 if (FrameLength
!= (SK_U32
) (FrameStat
>> GMR_FS_LEN_SHIFT
)) {
2063 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2064 SK_DBGCAT_DRV_RX_PROGRESS
,
2065 ("skge: Frame length mismatch (%u/%u).\n",
2067 (SK_U32
) (FrameStat
>> XMR_FS_LEN_SHIFT
)));
2073 if (pAC
->GIni
.GIChipId
== CHIP_ID_GENESIS
) {
2074 IsBc
= (FrameStat
& XMR_FS_BC
) != 0;
2075 IsMc
= (FrameStat
& XMR_FS_MC
) != 0;
2076 IsBadFrame
= (FrameStat
&
2077 (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0;
2079 IsBc
= (FrameStat
& GMR_FS_BC
) != 0;
2080 IsMc
= (FrameStat
& GMR_FS_MC
) != 0;
2081 IsBadFrame
= (((FrameStat
& GMR_FS_ANY_ERR
) != 0) ||
2082 ((FrameStat
& GMR_FS_RX_OK
) == 0));
2085 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2086 ("Received frame of length %d on port %d\n",
2087 FrameLength
, PortIndex
));
2088 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 0,
2089 ("Number of free rx descriptors: %d\n",
2090 pRxPort
->RxdRingFree
));
2091 /* DumpMsg(pMsg, "Rx"); */
2093 if ((Control
& BMU_STAT_VAL
) != BMU_STAT_VAL
|| (IsBadFrame
)) {
2095 (FrameStat
& (XMR_FS_ANY_ERR
| XMR_FS_2L_VLAN
)) != 0) {
2097 /* there is a receive error in this frame */
2098 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2099 SK_DBGCAT_DRV_RX_PROGRESS
,
2100 ("skge: Error in received frame, dropped!\n"
2101 "Control: %x\nRxStat: %x\n",
2102 Control
, FrameStat
));
2104 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2105 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2111 * if short frame then copy data to reduce memory waste
2113 if ((FrameLength
< SK_COPY_THRESHOLD
) &&
2114 ((pNewMsg
= alloc_skb(FrameLength
+2, GFP_ATOMIC
)) != NULL
)) {
2116 * Short frame detected and allocation successfull
2118 /* use new skb and copy data */
2119 skb_reserve(pNewMsg
, 2);
2120 skb_put(pNewMsg
, FrameLength
);
2121 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2122 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2124 pci_dma_sync_single_for_cpu(pAC
->PciDev
,
2125 (dma_addr_t
) PhysAddr
,
2127 PCI_DMA_FROMDEVICE
);
2128 memcpy(pNewMsg
->data
, pMsg
, FrameLength
);
2130 pci_dma_sync_single_for_device(pAC
->PciDev
,
2131 (dma_addr_t
) PhysAddr
,
2133 PCI_DMA_FROMDEVICE
);
2134 ReQueueRxBuffer(pAC
, pRxPort
, pMsg
,
2135 pRxd
->VDataHigh
, pRxd
->VDataLow
);
2142 * if large frame, or SKB allocation failed, pass
2143 * the SKB directly to the networking
2146 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2147 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2149 /* release the DMA mapping */
2150 pci_unmap_single(pAC
->PciDev
,
2153 PCI_DMA_FROMDEVICE
);
2155 /* set length in message */
2156 skb_put(pMsg
, FrameLength
);
2157 } /* frame > SK_COPY_TRESHOLD */
2159 #ifdef USE_SK_RX_CHECKSUM
2160 pMsg
->csum
= pRxd
->TcpSums
& 0xffff;
2161 pMsg
->ip_summed
= CHECKSUM_HW
;
2163 pMsg
->ip_summed
= CHECKSUM_NONE
;
2166 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("V"));
2167 ForRlmt
= SK_RLMT_RX_PROTOCOL
;
2169 IsBc
= (FrameStat
& XMR_FS_BC
)==XMR_FS_BC
;
2171 SK_RLMT_PRE_LOOKAHEAD(pAC
, PortIndex
, FrameLength
,
2172 IsBc
, &Offset
, &NumBytes
);
2173 if (NumBytes
!= 0) {
2175 IsMc
= (FrameStat
& XMR_FS_MC
)==XMR_FS_MC
;
2177 SK_RLMT_LOOKAHEAD(pAC
, PortIndex
,
2178 &pMsg
->data
[Offset
],
2179 IsBc
, IsMc
, &ForRlmt
);
2181 if (ForRlmt
== SK_RLMT_RX_PROTOCOL
) {
2182 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("W"));
2183 /* send up only frames from active port */
2184 if ((PortIndex
== pAC
->ActivePort
) ||
2185 (pAC
->RlmtNets
== 2)) {
2186 /* frame for upper layer */
2187 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, 1,("U"));
2189 DumpMsg(pMsg
, "Rx");
2191 SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC
,
2192 FrameLength
, pRxPort
->PortIndex
);
2194 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2195 pMsg
->protocol
= eth_type_trans(pMsg
,
2196 pAC
->dev
[pRxPort
->PortIndex
]);
2198 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2202 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2203 SK_DBGCAT_DRV_RX_PROGRESS
,
2205 DEV_KFREE_SKB(pMsg
);
2208 } /* if not for rlmt */
2210 /* packet for rlmt */
2211 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2212 SK_DBGCAT_DRV_RX_PROGRESS
, ("R"));
2213 pRlmtMbuf
= SkDrvAllocRlmtMbuf(pAC
,
2214 pAC
->IoBase
, FrameLength
);
2215 if (pRlmtMbuf
!= NULL
) {
2216 pRlmtMbuf
->pNext
= NULL
;
2217 pRlmtMbuf
->Length
= FrameLength
;
2218 pRlmtMbuf
->PortIdx
= PortIndex
;
2219 EvPara
.pParaPtr
= pRlmtMbuf
;
2220 memcpy((char*)(pRlmtMbuf
->pData
),
2221 (char*)(pMsg
->data
),
2224 /* SlowPathLock needed? */
2225 if (SlowPathLock
== SK_TRUE
) {
2226 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2227 SkEventQueue(pAC
, SKGE_RLMT
,
2228 SK_RLMT_PACKET_RECEIVED
,
2230 pAC
->CheckQueue
= SK_TRUE
;
2231 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2233 SkEventQueue(pAC
, SKGE_RLMT
,
2234 SK_RLMT_PACKET_RECEIVED
,
2236 pAC
->CheckQueue
= SK_TRUE
;
2239 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
,
2240 SK_DBGCAT_DRV_RX_PROGRESS
,
2243 if ((pAC
->dev
[pRxPort
->PortIndex
]->flags
&
2244 (IFF_PROMISC
| IFF_ALLMULTI
)) != 0 ||
2245 (ForRlmt
& SK_RLMT_RX_PROTOCOL
) ==
2246 SK_RLMT_RX_PROTOCOL
) {
2247 pMsg
->dev
= pAC
->dev
[pRxPort
->PortIndex
];
2248 pMsg
->protocol
= eth_type_trans(pMsg
,
2249 pAC
->dev
[pRxPort
->PortIndex
]);
2251 pAC
->dev
[pRxPort
->PortIndex
]->last_rx
= jiffies
;
2254 DEV_KFREE_SKB(pMsg
);
2257 } /* if packet for rlmt */
2258 } /* for ... scanning the RXD ring */
2260 /* RXD ring is empty -> fill and restart */
2261 FillRxRing(pAC
, pRxPort
);
2262 /* do not start if called from Close */
2263 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
2264 ClearAndStartRx(pAC
, PortIndex
);
2269 /* remove error frame */
2270 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ERROR
,
2271 ("Schrottdescriptor, length: 0x%x\n", FrameLength
));
2273 /* release the DMA mapping */
2275 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2276 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2277 pci_unmap_page(pAC
->PciDev
,
2280 PCI_DMA_FROMDEVICE
);
2281 DEV_KFREE_SKB_IRQ(pRxd
->pMBuf
);
2283 pRxPort
->RxdRingFree
++;
2284 pRxPort
->pRxdRingHead
= pRxd
->pNextRxd
;
2290 /*****************************************************************************
2292 * ClearAndStartRx - give a start receive command to BMU, clear IRQ
2295 * This function sends a start command and a clear interrupt
2296 * command for one receive queue to the BMU.
2301 static void ClearAndStartRx(
2302 SK_AC
*pAC
, /* pointer to the adapter context */
2303 int PortIndex
) /* index of the receive port (XMAC) */
2305 SK_OUT8(pAC
->IoBase
,
2306 RxQueueAddr
[PortIndex
]+Q_CSR
,
2307 CSR_START
| CSR_IRQ_CL_F
);
2308 } /* ClearAndStartRx */
2311 /*****************************************************************************
2313 * ClearTxIrq - give a clear transmit IRQ command to BMU
2316 * This function sends a clear tx IRQ command for one
2317 * transmit queue to the BMU.
2321 static void ClearTxIrq(
2322 SK_AC
*pAC
, /* pointer to the adapter context */
2323 int PortIndex
, /* index of the transmit port (XMAC) */
2324 int Prio
) /* priority or normal queue */
2326 SK_OUT8(pAC
->IoBase
,
2327 TxQueueAddr
[PortIndex
][Prio
]+Q_CSR
,
2332 /*****************************************************************************
2334 * ClearRxRing - remove all buffers from the receive ring
2337 * This function removes all receive buffers from the ring.
2338 * The receive BMU must be stopped before calling this function.
2342 static void ClearRxRing(
2343 SK_AC
*pAC
, /* pointer to adapter context */
2344 RX_PORT
*pRxPort
) /* pointer to rx port struct */
2346 RXD
*pRxd
; /* pointer to the current descriptor */
2347 unsigned long Flags
;
2350 if (pRxPort
->RxdRingFree
== pAC
->RxDescrPerRing
) {
2353 spin_lock_irqsave(&pRxPort
->RxDesRingLock
, Flags
);
2354 pRxd
= pRxPort
->pRxdRingHead
;
2356 if (pRxd
->pMBuf
!= NULL
) {
2358 PhysAddr
= ((SK_U64
) pRxd
->VDataHigh
) << (SK_U64
)32;
2359 PhysAddr
|= (SK_U64
) pRxd
->VDataLow
;
2360 pci_unmap_page(pAC
->PciDev
,
2363 PCI_DMA_FROMDEVICE
);
2364 DEV_KFREE_SKB(pRxd
->pMBuf
);
2367 pRxd
->RBControl
&= BMU_OWN
;
2368 pRxd
= pRxd
->pNextRxd
;
2369 pRxPort
->RxdRingFree
++;
2370 } while (pRxd
!= pRxPort
->pRxdRingTail
);
2371 pRxPort
->pRxdRingTail
= pRxPort
->pRxdRingHead
;
2372 spin_unlock_irqrestore(&pRxPort
->RxDesRingLock
, Flags
);
2375 /*****************************************************************************
2377 * ClearTxRing - remove all buffers from the transmit ring
2380 * This function removes all transmit buffers from the ring.
2381 * The transmit BMU must be stopped before calling this function
2382 * and transmitting at the upper level must be disabled.
2383 * The BMU own bit of all descriptors is cleared, the rest is
2384 * done by calling FreeTxDescriptors.
2388 static void ClearTxRing(
2389 SK_AC
*pAC
, /* pointer to adapter context */
2390 TX_PORT
*pTxPort
) /* pointer to tx prt struct */
2392 TXD
*pTxd
; /* pointer to the current descriptor */
2394 unsigned long Flags
;
2396 spin_lock_irqsave(&pTxPort
->TxDesRingLock
, Flags
);
2397 pTxd
= pTxPort
->pTxdRingHead
;
2398 for (i
=0; i
<pAC
->TxDescrPerRing
; i
++) {
2399 pTxd
->TBControl
&= ~BMU_OWN
;
2400 pTxd
= pTxd
->pNextTxd
;
2402 FreeTxDescriptors(pAC
, pTxPort
);
2403 spin_unlock_irqrestore(&pTxPort
->TxDesRingLock
, Flags
);
2406 /*****************************************************************************
2408 * SkGeSetMacAddr - Set the hardware MAC address
2411 * This function sets the MAC address used by the adapter.
2414 * 0, if everything is ok
2417 static int SkGeSetMacAddr(struct SK_NET_DEVICE
*dev
, void *p
)
2420 DEV_NET
*pNet
= netdev_priv(dev
);
2421 SK_AC
*pAC
= pNet
->pAC
;
2423 struct sockaddr
*addr
= p
;
2424 unsigned long Flags
;
2426 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2427 ("SkGeSetMacAddr starts now...\n"));
2428 if(netif_running(dev
))
2431 memcpy(dev
->dev_addr
, addr
->sa_data
,dev
->addr_len
);
2433 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2435 if (pAC
->RlmtNets
== 2)
2436 SkAddrOverride(pAC
, pAC
->IoBase
, pNet
->NetNr
,
2437 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2439 SkAddrOverride(pAC
, pAC
->IoBase
, pAC
->ActivePort
,
2440 (SK_MAC_ADDR
*)dev
->dev_addr
, SK_ADDR_VIRTUAL_ADDRESS
);
2444 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2446 } /* SkGeSetMacAddr */
2449 /*****************************************************************************
2451 * SkGeSetRxMode - set receive mode
2454 * This function sets the receive mode of an adapter. The adapter
2455 * supports promiscuous mode, allmulticast mode and a number of
2456 * multicast addresses. If more multicast addresses the available
2457 * are selected, a hash function in the hardware is used.
2460 * 0, if everything is ok
2463 static void SkGeSetRxMode(struct SK_NET_DEVICE
*dev
)
2469 struct dev_mc_list
*pMcList
;
2472 unsigned long Flags
;
2474 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2475 ("SkGeSetRxMode starts now... "));
2477 pNet
= netdev_priv(dev
);
2479 if (pAC
->RlmtNets
== 1)
2480 PortIdx
= pAC
->ActivePort
;
2482 PortIdx
= pNet
->NetNr
;
2484 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2485 if (dev
->flags
& IFF_PROMISC
) {
2486 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2487 ("PROMISCUOUS mode\n"));
2488 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2490 } else if (dev
->flags
& IFF_ALLMULTI
) {
2491 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2492 ("ALLMULTI mode\n"));
2493 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2494 SK_PROM_MODE_ALL_MC
);
2496 SkAddrPromiscuousChange(pAC
, pAC
->IoBase
, PortIdx
,
2498 SkAddrMcClear(pAC
, pAC
->IoBase
, PortIdx
, 0);
2500 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2501 ("Number of MC entries: %d ", dev
->mc_count
));
2503 pMcList
= dev
->mc_list
;
2504 for (i
=0; i
<dev
->mc_count
; i
++, pMcList
= pMcList
->next
) {
2505 SkAddrMcAdd(pAC
, pAC
->IoBase
, PortIdx
,
2506 (SK_MAC_ADDR
*)pMcList
->dmi_addr
, 0);
2507 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_MCA
,
2508 ("%02x:%02x:%02x:%02x:%02x:%02x\n",
2509 pMcList
->dmi_addr
[0],
2510 pMcList
->dmi_addr
[1],
2511 pMcList
->dmi_addr
[2],
2512 pMcList
->dmi_addr
[3],
2513 pMcList
->dmi_addr
[4],
2514 pMcList
->dmi_addr
[5]));
2516 SkAddrMcUpdate(pAC
, pAC
->IoBase
, PortIdx
);
2518 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2521 } /* SkGeSetRxMode */
2524 /*****************************************************************************
2526 * SkGeChangeMtu - set the MTU to another value
2529 * This function sets is called whenever the MTU size is changed
2530 * (ifconfig mtu xxx dev ethX). If the MTU is bigger than standard
2531 * ethernet MTU size, long frame support is activated.
2534 * 0, if everything is ok
2537 static int SkGeChangeMtu(struct SK_NET_DEVICE
*dev
, int NewMtu
)
2540 struct net_device
*pOtherDev
;
2542 unsigned long Flags
;
2546 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2547 ("SkGeChangeMtu starts now...\n"));
2549 pNet
= netdev_priv(dev
);
2552 if ((NewMtu
< 68) || (NewMtu
> SK_JUMBO_MTU
)) {
2556 if(pAC
->BoardLevel
!= SK_INIT_RUN
) {
2560 #ifdef SK_DIAG_SUPPORT
2561 if (pAC
->DiagModeActive
== DIAG_ACTIVE
) {
2562 if (pAC
->DiagFlowCtrl
== SK_FALSE
) {
2563 return -1; /* still in use, deny any actions of MTU */
2565 pAC
->DiagFlowCtrl
= SK_FALSE
;
2570 pOtherDev
= pAC
->dev
[1 - pNet
->NetNr
];
2572 if ( netif_running(pOtherDev
) && (pOtherDev
->mtu
> 1500)
2573 && (NewMtu
<= 1500))
2576 pAC
->RxBufSize
= NewMtu
+ 32;
2579 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2580 ("New MTU: %d\n", NewMtu
));
2583 ** Prevent any reconfiguration while changing the MTU
2584 ** by disabling any interrupts
2586 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
2587 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2590 ** Notify RLMT that any ports are to be stopped
2592 EvPara
.Para32
[0] = 0;
2593 EvPara
.Para32
[1] = -1;
2594 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2595 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2596 EvPara
.Para32
[0] = 1;
2597 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2599 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
2603 ** After calling the SkEventDispatcher(), RLMT is aware about
2604 ** the stopped ports -> configuration can take place!
2606 SkEventDispatcher(pAC
, pAC
->IoBase
);
2608 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2609 spin_lock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2610 netif_stop_queue(pAC
->dev
[i
]);
2615 ** Depending on the desired MTU size change, a different number of
2616 ** RX buffers need to be allocated
2618 if (NewMtu
> 1500) {
2620 ** Use less rx buffers
2622 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2623 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2624 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2625 (pAC
->RxDescrPerRing
/ 4);
2627 if (i
== pAC
->ActivePort
) {
2628 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2629 (pAC
->RxDescrPerRing
/ 4);
2631 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2632 (pAC
->RxDescrPerRing
/ 10);
2638 ** Use the normal amount of rx buffers
2640 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2641 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2642 pAC
->RxPort
[i
].RxFillLimit
= 1;
2644 if (i
== pAC
->ActivePort
) {
2645 pAC
->RxPort
[i
].RxFillLimit
= 1;
2647 pAC
->RxPort
[i
].RxFillLimit
= pAC
->RxDescrPerRing
-
2648 (pAC
->RxDescrPerRing
/ 4);
2654 SkGeDeInit(pAC
, pAC
->IoBase
);
2657 ** enable/disable hardware support for long frames
2659 if (NewMtu
> 1500) {
2660 // pAC->JumboActivated = SK_TRUE; /* is never set back !!! */
2661 pAC
->GIni
.GIPortUsage
= SK_JUMBO_LINK
;
2663 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2664 pAC
->GIni
.GIPortUsage
= SK_MUL_LINK
;
2666 pAC
->GIni
.GIPortUsage
= SK_RED_LINK
;
2670 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2671 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2672 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2673 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2674 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2675 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_IO
);
2676 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_IO
);
2680 ** Speed and others are set back to default in level 1 init!
2682 GetConfiguration(pAC
);
2684 SkGeInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2685 SkI2cInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2686 SkEventInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2687 SkPnmiInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2688 SkAddrInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2689 SkRlmtInit( pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2690 SkTimerInit(pAC
, pAC
->IoBase
, SK_INIT_RUN
);
2693 ** clear and reinit the rx rings here
2695 for (i
=0; i
<pAC
->GIni
.GIMacsFound
; i
++) {
2696 ReceiveIrq(pAC
, &pAC
->RxPort
[i
], SK_TRUE
);
2697 ClearRxRing(pAC
, &pAC
->RxPort
[i
]);
2698 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2701 ** Enable transmit descriptor polling
2703 SkGePollTxD(pAC
, pAC
->IoBase
, i
, SK_TRUE
);
2704 FillRxRing(pAC
, &pAC
->RxPort
[i
]);
2707 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
2708 SkDimEnableModerationIfNeeded(pAC
);
2709 SkDimDisplayModerationSettings(pAC
);
2711 netif_start_queue(pAC
->dev
[pNet
->PortNr
]);
2712 for (i
=pAC
->GIni
.GIMacsFound
-1; i
>=0; i
--) {
2713 spin_unlock(&pAC
->TxPort
[i
][TX_PRIO_LOW
].TxDesRingLock
);
2717 ** Enable Interrupts again
2719 SK_OUT32(pAC
->IoBase
, B0_IMSK
, pAC
->GIni
.GIValIrqMask
);
2720 SK_OUT32(pAC
->IoBase
, B0_HWE_IMSK
, IRQ_HWE_MASK
);
2722 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2723 SkEventDispatcher(pAC
, pAC
->IoBase
);
2726 ** Notify RLMT about the changing and restarting one (or more) ports
2728 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
2729 EvPara
.Para32
[0] = pAC
->RlmtNets
;
2730 EvPara
.Para32
[1] = -1;
2731 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_SET_NETS
, EvPara
);
2732 EvPara
.Para32
[0] = pNet
->PortNr
;
2733 EvPara
.Para32
[1] = -1;
2734 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2736 if (netif_running(pOtherDev
)) {
2737 DEV_NET
*pOtherNet
= netdev_priv(pOtherDev
);
2738 EvPara
.Para32
[0] = pOtherNet
->PortNr
;
2739 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2742 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_START
, EvPara
);
2745 SkEventDispatcher(pAC
, pAC
->IoBase
);
2746 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2749 ** While testing this driver with latest kernel 2.5 (2.5.70), it
2750 ** seems as if upper layers have a problem to handle a successful
2751 ** return value of '0'. If such a zero is returned, the complete
2752 ** system hangs for several minutes (!), which is in acceptable.
2754 ** Currently it is not clear, what the exact reason for this problem
2755 ** is. The implemented workaround for 2.5 is to return the desired
2756 ** new MTU size if all needed changes for the new MTU size where
2757 ** performed. In kernels 2.2 and 2.4, a zero value is returned,
2758 ** which indicates the successful change of the mtu-size.
2762 } /* SkGeChangeMtu */
2765 /*****************************************************************************
2767 * SkGeStats - return ethernet device statistics
2770 * This function return statistic data about the ethernet device
2771 * to the operating system.
2774 * pointer to the statistic structure.
2776 static struct net_device_stats
*SkGeStats(struct SK_NET_DEVICE
*dev
)
2778 DEV_NET
*pNet
= netdev_priv(dev
);
2779 SK_AC
*pAC
= pNet
->pAC
;
2780 SK_PNMI_STRUCT_DATA
*pPnmiStruct
; /* structure for all Pnmi-Data */
2781 SK_PNMI_STAT
*pPnmiStat
; /* pointer to virtual XMAC stat. data */
2782 SK_PNMI_CONF
*pPnmiConf
; /* pointer to virtual link config. */
2783 unsigned int Size
; /* size of pnmi struct */
2784 unsigned long Flags
; /* for spin lock */
2786 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2787 ("SkGeStats starts now...\n"));
2788 pPnmiStruct
= &pAC
->PnmiStruct
;
2790 #ifdef SK_DIAG_SUPPORT
2791 if ((pAC
->DiagModeActive
== DIAG_NOTACTIVE
) &&
2792 (pAC
->BoardLevel
== SK_INIT_RUN
)) {
2794 SK_MEMSET(pPnmiStruct
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
2795 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
2796 Size
= SK_PNMI_STRUCT_SIZE
;
2797 SkPnmiGetStruct(pAC
, pAC
->IoBase
, pPnmiStruct
, &Size
, pNet
->NetNr
);
2798 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
2799 #ifdef SK_DIAG_SUPPORT
2803 pPnmiStat
= &pPnmiStruct
->Stat
[0];
2804 pPnmiConf
= &pPnmiStruct
->Conf
[0];
2806 pAC
->stats
.rx_packets
= (SK_U32
) pPnmiStruct
->RxDeliveredCts
& 0xFFFFFFFF;
2807 pAC
->stats
.tx_packets
= (SK_U32
) pPnmiStat
->StatTxOkCts
& 0xFFFFFFFF;
2808 pAC
->stats
.rx_bytes
= (SK_U32
) pPnmiStruct
->RxOctetsDeliveredCts
;
2809 pAC
->stats
.tx_bytes
= (SK_U32
) pPnmiStat
->StatTxOctetsOkCts
;
2811 if (dev
->mtu
<= 1500) {
2812 pAC
->stats
.rx_errors
= (SK_U32
) pPnmiStruct
->InErrorsCts
& 0xFFFFFFFF;
2814 pAC
->stats
.rx_errors
= (SK_U32
) ((pPnmiStruct
->InErrorsCts
-
2815 pPnmiStat
->StatRxTooLongCts
) & 0xFFFFFFFF);
2819 if (pAC
->GIni
.GP
[0].PhyType
== SK_PHY_XMAC
&& pAC
->HWRevision
< 12)
2820 pAC
->stats
.rx_errors
= pAC
->stats
.rx_errors
- pPnmiStat
->StatRxShortsCts
;
2822 pAC
->stats
.tx_errors
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2823 pAC
->stats
.rx_dropped
= (SK_U32
) pPnmiStruct
->RxNoBufCts
& 0xFFFFFFFF;
2824 pAC
->stats
.tx_dropped
= (SK_U32
) pPnmiStruct
->TxNoBufCts
& 0xFFFFFFFF;
2825 pAC
->stats
.multicast
= (SK_U32
) pPnmiStat
->StatRxMulticastOkCts
& 0xFFFFFFFF;
2826 pAC
->stats
.collisions
= (SK_U32
) pPnmiStat
->StatTxSingleCollisionCts
& 0xFFFFFFFF;
2828 /* detailed rx_errors: */
2829 pAC
->stats
.rx_length_errors
= (SK_U32
) pPnmiStat
->StatRxRuntCts
& 0xFFFFFFFF;
2830 pAC
->stats
.rx_over_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2831 pAC
->stats
.rx_crc_errors
= (SK_U32
) pPnmiStat
->StatRxFcsCts
& 0xFFFFFFFF;
2832 pAC
->stats
.rx_frame_errors
= (SK_U32
) pPnmiStat
->StatRxFramingCts
& 0xFFFFFFFF;
2833 pAC
->stats
.rx_fifo_errors
= (SK_U32
) pPnmiStat
->StatRxFifoOverflowCts
& 0xFFFFFFFF;
2834 pAC
->stats
.rx_missed_errors
= (SK_U32
) pPnmiStat
->StatRxMissedCts
& 0xFFFFFFFF;
2836 /* detailed tx_errors */
2837 pAC
->stats
.tx_aborted_errors
= (SK_U32
) 0;
2838 pAC
->stats
.tx_carrier_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2839 pAC
->stats
.tx_fifo_errors
= (SK_U32
) pPnmiStat
->StatTxFifoUnderrunCts
& 0xFFFFFFFF;
2840 pAC
->stats
.tx_heartbeat_errors
= (SK_U32
) pPnmiStat
->StatTxCarrierCts
& 0xFFFFFFFF;
2841 pAC
->stats
.tx_window_errors
= (SK_U32
) 0;
2843 return(&pAC
->stats
);
2847 /*****************************************************************************
2849 * SkGeIoctl - IO-control function
2852 * This function is called if an ioctl is issued on the device.
2853 * There are three subfunction for reading, writing and test-writing
2854 * the private MIB data structure (useful for SysKonnect-internal tools).
2857 * 0, if everything is ok
2860 static int SkGeIoctl(struct SK_NET_DEVICE
*dev
, struct ifreq
*rq
, int cmd
)
2865 struct pci_dev
*pdev
= NULL
;
2867 unsigned int Err
= 0;
2870 unsigned int Length
= 0;
2871 int HeaderLength
= sizeof(SK_U32
) + sizeof(SK_U32
);
2873 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
2874 ("SkGeIoctl starts now...\n"));
2876 pNet
= netdev_priv(dev
);
2879 if(copy_from_user(&Ioctl
, rq
->ifr_data
, sizeof(SK_GE_IOCTL
))) {
2884 case SK_IOCTL_SETMIB
:
2885 case SK_IOCTL_PRESETMIB
:
2886 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2887 case SK_IOCTL_GETMIB
:
2888 if(copy_from_user(&pAC
->PnmiStruct
, Ioctl
.pData
,
2889 Ioctl
.Len
<sizeof(pAC
->PnmiStruct
)?
2890 Ioctl
.Len
: sizeof(pAC
->PnmiStruct
))) {
2893 Size
= SkGeIocMib(pNet
, Ioctl
.Len
, cmd
);
2894 if(copy_to_user(Ioctl
.pData
, &pAC
->PnmiStruct
,
2895 Ioctl
.Len
<Size
? Ioctl
.Len
: Size
)) {
2899 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2904 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2907 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2909 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2912 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2916 if ((Ret
= SkPnmiGenIoctl(pAC
, pAC
->IoBase
, pMemBuf
, &Length
, 0)) < 0) {
2920 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2925 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2930 kfree(pMemBuf
); /* cleanup everything */
2932 #ifdef SK_DIAG_SUPPORT
2934 if (!capable(CAP_NET_ADMIN
)) return -EPERM
;
2935 if (Ioctl
.Len
< (sizeof(pAC
->PnmiStruct
) + HeaderLength
)) {
2938 Length
= sizeof(pAC
->PnmiStruct
) + HeaderLength
;
2940 if (NULL
== (pMemBuf
= kmalloc(Length
, GFP_KERNEL
))) {
2943 if(copy_from_user(pMemBuf
, Ioctl
.pData
, Length
)) {
2948 Length
= 3 * sizeof(SK_U32
); /* Error, Bus and Device */
2950 ** While coding this new IOCTL interface, only a few lines of code
2951 ** are to to be added. Therefore no dedicated function has been
2952 ** added. If more functionality is added, a separate function
2953 ** should be used...
2955 * ((SK_U32
*)pMemBuf
) = 0;
2956 * ((SK_U32
*)pMemBuf
+ 1) = pdev
->bus
->number
;
2957 * ((SK_U32
*)pMemBuf
+ 2) = ParseDeviceNbrFromSlotName(pci_name(pdev
));
2958 if(copy_to_user(Ioctl
.pData
, pMemBuf
, Length
) ) {
2963 if(copy_to_user(rq
->ifr_data
, &Ioctl
, sizeof(SK_GE_IOCTL
))) {
2968 kfree(pMemBuf
); /* cleanup everything */
2980 /*****************************************************************************
2982 * SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message
2985 * This function reads/writes the MIB data using PNMI (Private Network
2986 * Management Interface).
2987 * The destination for the data must be provided with the
2988 * ioctl call and is given to the driver in the form of
2989 * a user space address.
2990 * Copying from the user-provided data area into kernel messages
2991 * and back is done by copy_from_user and copy_to_user calls in
2995 * returned size from PNMI call
2997 static int SkGeIocMib(
2998 DEV_NET
*pNet
, /* pointer to the adapter context */
2999 unsigned int Size
, /* length of ioctl data */
3000 int mode
) /* flag for set/preset */
3002 unsigned long Flags
; /* for spin lock */
3005 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3006 ("SkGeIocMib starts now...\n"));
3009 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3011 case SK_IOCTL_GETMIB
:
3012 SkPnmiGetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3015 case SK_IOCTL_PRESETMIB
:
3016 SkPnmiPreSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3019 case SK_IOCTL_SETMIB
:
3020 SkPnmiSetStruct(pAC
, pAC
->IoBase
, &pAC
->PnmiStruct
, &Size
,
3026 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3027 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_ENTRY
,
3028 ("MIB data access succeeded\n"));
3033 /*****************************************************************************
3035 * GetConfiguration - read configuration information
3038 * This function reads per-adapter configuration information from
3039 * the options provided on the command line.
3044 static void GetConfiguration(
3045 SK_AC
*pAC
) /* pointer to the adapter context structure */
3047 SK_I32 Port
; /* preferred port */
3050 int LinkSpeed
= SK_LSPEED_AUTO
; /* Link speed */
3051 int AutoNeg
= 1; /* autoneg off (0) or on (1) */
3052 int DuplexCap
= 0; /* 0=both,1=full,2=half */
3053 int FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
; /* FlowControl */
3054 int MSMode
= SK_MS_MODE_AUTO
; /* master/slave mode */
3056 SK_BOOL IsConTypeDefined
= SK_TRUE
;
3057 SK_BOOL IsLinkSpeedDefined
= SK_TRUE
;
3058 SK_BOOL IsFlowCtrlDefined
= SK_TRUE
;
3059 SK_BOOL IsRoleDefined
= SK_TRUE
;
3060 SK_BOOL IsModeDefined
= SK_TRUE
;
3062 * The two parameters AutoNeg. and DuplexCap. map to one configuration
3063 * parameter. The mapping is described by this table:
3064 * DuplexCap -> | both | full | half |
3066 * -----------------------------------------------------------------
3067 * Off | illegal | Full | Half |
3068 * -----------------------------------------------------------------
3069 * On | AutoBoth | AutoFull | AutoHalf |
3070 * -----------------------------------------------------------------
3071 * Sense | AutoSense | AutoSense | AutoSense |
3073 int Capabilities
[3][3] =
3074 { { -1, SK_LMODE_FULL
, SK_LMODE_HALF
},
3075 {SK_LMODE_AUTOBOTH
, SK_LMODE_AUTOFULL
, SK_LMODE_AUTOHALF
},
3076 {SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
, SK_LMODE_AUTOSENSE
} };
3084 #define M_CurrPort pAC->GIni.GP[Port]
3088 ** Set the default values first for both ports!
3090 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3091 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3092 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3093 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3094 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3098 ** Check merged parameter ConType. If it has not been used,
3099 ** verify any other parameter (e.g. AutoNeg) and use default values.
3101 ** Stating both ConType and other lowlevel link parameters is also
3102 ** possible. If this is the case, the passed ConType-parameter is
3103 ** overwritten by the lowlevel link parameter.
3105 ** The following settings are used for a merged ConType-parameter:
3107 ** ConType DupCap AutoNeg FlowCtrl Role Speed
3108 ** ------- ------ ------- -------- ---------- -----
3109 ** Auto Both On SymOrRem Auto Auto
3110 ** 100FD Full Off None <ignored> 100
3111 ** 100HD Half Off None <ignored> 100
3112 ** 10FD Full Off None <ignored> 10
3113 ** 10HD Half Off None <ignored> 10
3115 ** This ConType parameter is used for all ports of the adapter!
3117 if ( (ConType
!= NULL
) &&
3118 (pAC
->Index
< SK_MAX_CARD_PARAM
) &&
3119 (ConType
[pAC
->Index
] != NULL
) ) {
3121 /* Check chipset family */
3122 if ((!pAC
->ChipsetType
) &&
3123 (strcmp(ConType
[pAC
->Index
],"Auto")!=0) &&
3124 (strcmp(ConType
[pAC
->Index
],"")!=0)) {
3125 /* Set the speed parameter back */
3126 printk("sk98lin: Illegal value \"%s\" "
3129 ConType
[pAC
->Index
]);
3131 sprintf(ConType
[pAC
->Index
], "Auto");
3134 if (strcmp(ConType
[pAC
->Index
],"")==0) {
3135 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3136 } else if (strcmp(ConType
[pAC
->Index
],"Auto")==0) {
3137 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3138 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_ON
][DC_BOTH
];
3139 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_SYM_OR_REM
;
3140 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3141 M_CurrPort
.PLinkSpeed
= SK_LSPEED_AUTO
;
3143 } else if (strcmp(ConType
[pAC
->Index
],"100FD")==0) {
3144 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3145 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3146 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3147 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3148 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3150 } else if (strcmp(ConType
[pAC
->Index
],"100HD")==0) {
3151 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3152 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3153 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3154 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3155 M_CurrPort
.PLinkSpeed
= SK_LSPEED_100MBPS
;
3157 } else if (strcmp(ConType
[pAC
->Index
],"10FD")==0) {
3158 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3159 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_FULL
];
3160 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3161 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3162 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3164 } else if (strcmp(ConType
[pAC
->Index
],"10HD")==0) {
3165 for (Port
= 0; Port
< SK_MAX_MACS
; Port
++) {
3166 M_CurrPort
.PLinkModeConf
= Capabilities
[AN_OFF
][DC_HALF
];
3167 M_CurrPort
.PFlowCtrlMode
= SK_FLOW_MODE_NONE
;
3168 M_CurrPort
.PMSMode
= SK_MS_MODE_AUTO
;
3169 M_CurrPort
.PLinkSpeed
= SK_LSPEED_10MBPS
;
3172 printk("sk98lin: Illegal value \"%s\" for ConType\n",
3173 ConType
[pAC
->Index
]);
3174 IsConTypeDefined
= SK_FALSE
; /* Wrong ConType defined */
3177 IsConTypeDefined
= SK_FALSE
; /* No ConType defined */
3181 ** Parse any parameter settings for port A:
3182 ** a) any LinkSpeed stated?
3184 if (Speed_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3185 Speed_A
[pAC
->Index
] != NULL
) {
3186 if (strcmp(Speed_A
[pAC
->Index
],"")==0) {
3187 IsLinkSpeedDefined
= SK_FALSE
;
3188 } else if (strcmp(Speed_A
[pAC
->Index
],"Auto")==0) {
3189 LinkSpeed
= SK_LSPEED_AUTO
;
3190 } else if (strcmp(Speed_A
[pAC
->Index
],"10")==0) {
3191 LinkSpeed
= SK_LSPEED_10MBPS
;
3192 } else if (strcmp(Speed_A
[pAC
->Index
],"100")==0) {
3193 LinkSpeed
= SK_LSPEED_100MBPS
;
3194 } else if (strcmp(Speed_A
[pAC
->Index
],"1000")==0) {
3195 LinkSpeed
= SK_LSPEED_1000MBPS
;
3197 printk("sk98lin: Illegal value \"%s\" for Speed_A\n",
3198 Speed_A
[pAC
->Index
]);
3199 IsLinkSpeedDefined
= SK_FALSE
;
3202 IsLinkSpeedDefined
= SK_FALSE
;
3206 ** Check speed parameter:
3207 ** Only copper type adapter and GE V2 cards
3209 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3210 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3211 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3212 printk("sk98lin: Illegal value for Speed_A. "
3213 "Not a copper card or GE V2 card\n Using "
3215 LinkSpeed
= SK_LSPEED_1000MBPS
;
3219 ** Decide whether to set new config value if somethig valid has
3222 if (IsLinkSpeedDefined
) {
3223 pAC
->GIni
.GP
[0].PLinkSpeed
= LinkSpeed
;
3227 ** b) Any Autonegotiation and DuplexCapabilities set?
3228 ** Please note that both belong together...
3230 AutoNeg
= AN_ON
; /* tschilling: Default: Autonegotiation on! */
3232 if (AutoNeg_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3233 AutoNeg_A
[pAC
->Index
] != NULL
) {
3235 if (strcmp(AutoNeg_A
[pAC
->Index
],"")==0) {
3237 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"On")==0) {
3239 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Off")==0) {
3241 } else if (strcmp(AutoNeg_A
[pAC
->Index
],"Sense")==0) {
3244 printk("sk98lin: Illegal value \"%s\" for AutoNeg_A\n",
3245 AutoNeg_A
[pAC
->Index
]);
3249 DuplexCap
= DC_BOTH
;
3251 if (DupCap_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3252 DupCap_A
[pAC
->Index
] != NULL
) {
3254 if (strcmp(DupCap_A
[pAC
->Index
],"")==0) {
3256 } else if (strcmp(DupCap_A
[pAC
->Index
],"Both")==0) {
3257 DuplexCap
= DC_BOTH
;
3258 } else if (strcmp(DupCap_A
[pAC
->Index
],"Full")==0) {
3259 DuplexCap
= DC_FULL
;
3260 } else if (strcmp(DupCap_A
[pAC
->Index
],"Half")==0) {
3261 DuplexCap
= DC_HALF
;
3263 printk("sk98lin: Illegal value \"%s\" for DupCap_A\n",
3264 DupCap_A
[pAC
->Index
]);
3269 ** Check for illegal combinations
3271 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3272 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3273 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3274 (pAC
->ChipsetType
)) {
3275 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3276 " Using Full Duplex.\n");
3277 DuplexCap
= DC_FULL
;
3280 if ( AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3281 printk("sk98lin, Port A: DuplexCapabilities"
3282 " ignored using Sense mode\n");
3285 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3286 printk("sk98lin: Port A: Illegal combination"
3287 " of values AutoNeg. and DuplexCap.\n Using "
3289 DuplexCap
= DC_FULL
;
3292 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3293 DuplexCap
= DC_FULL
;
3296 if (!AutoSet
&& DupSet
) {
3297 printk("sk98lin: Port A: Duplex setting not"
3298 " possible in\n default AutoNegotiation mode"
3299 " (Sense).\n Using AutoNegotiation On\n");
3304 ** set the desired mode
3306 if (AutoSet
|| DupSet
) {
3307 pAC
->GIni
.GP
[0].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3311 ** c) Any Flowcontrol-parameter set?
3313 if (FlowCtrl_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3314 FlowCtrl_A
[pAC
->Index
] != NULL
) {
3315 if (strcmp(FlowCtrl_A
[pAC
->Index
],"") == 0) {
3316 IsFlowCtrlDefined
= SK_FALSE
;
3317 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"SymOrRem") == 0) {
3318 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3319 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"Sym")==0) {
3320 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3321 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"LocSend")==0) {
3322 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3323 } else if (strcmp(FlowCtrl_A
[pAC
->Index
],"None")==0) {
3324 FlowCtrl
= SK_FLOW_MODE_NONE
;
3326 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n",
3327 FlowCtrl_A
[pAC
->Index
]);
3328 IsFlowCtrlDefined
= SK_FALSE
;
3331 IsFlowCtrlDefined
= SK_FALSE
;
3334 if (IsFlowCtrlDefined
) {
3335 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3336 printk("sk98lin: Port A: FlowControl"
3337 " impossible without AutoNegotiation,"
3339 FlowCtrl
= SK_FLOW_MODE_NONE
;
3341 pAC
->GIni
.GP
[0].PFlowCtrlMode
= FlowCtrl
;
3345 ** d) What is with the RoleParameter?
3347 if (Role_A
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3348 Role_A
[pAC
->Index
] != NULL
) {
3349 if (strcmp(Role_A
[pAC
->Index
],"")==0) {
3350 IsRoleDefined
= SK_FALSE
;
3351 } else if (strcmp(Role_A
[pAC
->Index
],"Auto")==0) {
3352 MSMode
= SK_MS_MODE_AUTO
;
3353 } else if (strcmp(Role_A
[pAC
->Index
],"Master")==0) {
3354 MSMode
= SK_MS_MODE_MASTER
;
3355 } else if (strcmp(Role_A
[pAC
->Index
],"Slave")==0) {
3356 MSMode
= SK_MS_MODE_SLAVE
;
3358 printk("sk98lin: Illegal value \"%s\" for Role_A\n",
3359 Role_A
[pAC
->Index
]);
3360 IsRoleDefined
= SK_FALSE
;
3363 IsRoleDefined
= SK_FALSE
;
3366 if (IsRoleDefined
== SK_TRUE
) {
3367 pAC
->GIni
.GP
[0].PMSMode
= MSMode
;
3373 ** Parse any parameter settings for port B:
3374 ** a) any LinkSpeed stated?
3376 IsConTypeDefined
= SK_TRUE
;
3377 IsLinkSpeedDefined
= SK_TRUE
;
3378 IsFlowCtrlDefined
= SK_TRUE
;
3379 IsModeDefined
= SK_TRUE
;
3381 if (Speed_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3382 Speed_B
[pAC
->Index
] != NULL
) {
3383 if (strcmp(Speed_B
[pAC
->Index
],"")==0) {
3384 IsLinkSpeedDefined
= SK_FALSE
;
3385 } else if (strcmp(Speed_B
[pAC
->Index
],"Auto")==0) {
3386 LinkSpeed
= SK_LSPEED_AUTO
;
3387 } else if (strcmp(Speed_B
[pAC
->Index
],"10")==0) {
3388 LinkSpeed
= SK_LSPEED_10MBPS
;
3389 } else if (strcmp(Speed_B
[pAC
->Index
],"100")==0) {
3390 LinkSpeed
= SK_LSPEED_100MBPS
;
3391 } else if (strcmp(Speed_B
[pAC
->Index
],"1000")==0) {
3392 LinkSpeed
= SK_LSPEED_1000MBPS
;
3394 printk("sk98lin: Illegal value \"%s\" for Speed_B\n",
3395 Speed_B
[pAC
->Index
]);
3396 IsLinkSpeedDefined
= SK_FALSE
;
3399 IsLinkSpeedDefined
= SK_FALSE
;
3403 ** Check speed parameter:
3404 ** Only copper type adapter and GE V2 cards
3406 if (((!pAC
->ChipsetType
) || (pAC
->GIni
.GICopperType
!= SK_TRUE
)) &&
3407 ((LinkSpeed
!= SK_LSPEED_AUTO
) &&
3408 (LinkSpeed
!= SK_LSPEED_1000MBPS
))) {
3409 printk("sk98lin: Illegal value for Speed_B. "
3410 "Not a copper card or GE V2 card\n Using "
3412 LinkSpeed
= SK_LSPEED_1000MBPS
;
3416 ** Decide whether to set new config value if somethig valid has
3419 if (IsLinkSpeedDefined
) {
3420 pAC
->GIni
.GP
[1].PLinkSpeed
= LinkSpeed
;
3424 ** b) Any Autonegotiation and DuplexCapabilities set?
3425 ** Please note that both belong together...
3427 AutoNeg
= AN_SENS
; /* default: do auto Sense */
3429 if (AutoNeg_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3430 AutoNeg_B
[pAC
->Index
] != NULL
) {
3432 if (strcmp(AutoNeg_B
[pAC
->Index
],"")==0) {
3434 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"On")==0) {
3436 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Off")==0) {
3438 } else if (strcmp(AutoNeg_B
[pAC
->Index
],"Sense")==0) {
3441 printk("sk98lin: Illegal value \"%s\" for AutoNeg_B\n",
3442 AutoNeg_B
[pAC
->Index
]);
3446 DuplexCap
= DC_BOTH
;
3448 if (DupCap_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3449 DupCap_B
[pAC
->Index
] != NULL
) {
3451 if (strcmp(DupCap_B
[pAC
->Index
],"")==0) {
3453 } else if (strcmp(DupCap_B
[pAC
->Index
],"Both")==0) {
3454 DuplexCap
= DC_BOTH
;
3455 } else if (strcmp(DupCap_B
[pAC
->Index
],"Full")==0) {
3456 DuplexCap
= DC_FULL
;
3457 } else if (strcmp(DupCap_B
[pAC
->Index
],"Half")==0) {
3458 DuplexCap
= DC_HALF
;
3460 printk("sk98lin: Illegal value \"%s\" for DupCap_B\n",
3461 DupCap_B
[pAC
->Index
]);
3467 ** Check for illegal combinations
3469 if ((LinkSpeed
== SK_LSPEED_1000MBPS
) &&
3470 ((DuplexCap
== SK_LMODE_STAT_AUTOHALF
) ||
3471 (DuplexCap
== SK_LMODE_STAT_HALF
)) &&
3472 (pAC
->ChipsetType
)) {
3473 printk("sk98lin: Half Duplex not possible with Gigabit speed!\n"
3474 " Using Full Duplex.\n");
3475 DuplexCap
= DC_FULL
;
3478 if (AutoSet
&& AutoNeg
==AN_SENS
&& DupSet
) {
3479 printk("sk98lin, Port B: DuplexCapabilities"
3480 " ignored using Sense mode\n");
3483 if (AutoSet
&& AutoNeg
==AN_OFF
&& DupSet
&& DuplexCap
==DC_BOTH
){
3484 printk("sk98lin: Port B: Illegal combination"
3485 " of values AutoNeg. and DuplexCap.\n Using "
3487 DuplexCap
= DC_FULL
;
3490 if (AutoSet
&& AutoNeg
==AN_OFF
&& !DupSet
) {
3491 DuplexCap
= DC_FULL
;
3494 if (!AutoSet
&& DupSet
) {
3495 printk("sk98lin: Port B: Duplex setting not"
3496 " possible in\n default AutoNegotiation mode"
3497 " (Sense).\n Using AutoNegotiation On\n");
3502 ** set the desired mode
3504 if (AutoSet
|| DupSet
) {
3505 pAC
->GIni
.GP
[1].PLinkModeConf
= Capabilities
[AutoNeg
][DuplexCap
];
3509 ** c) Any FlowCtrl parameter set?
3511 if (FlowCtrl_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3512 FlowCtrl_B
[pAC
->Index
] != NULL
) {
3513 if (strcmp(FlowCtrl_B
[pAC
->Index
],"") == 0) {
3514 IsFlowCtrlDefined
= SK_FALSE
;
3515 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"SymOrRem") == 0) {
3516 FlowCtrl
= SK_FLOW_MODE_SYM_OR_REM
;
3517 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"Sym")==0) {
3518 FlowCtrl
= SK_FLOW_MODE_SYMMETRIC
;
3519 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"LocSend")==0) {
3520 FlowCtrl
= SK_FLOW_MODE_LOC_SEND
;
3521 } else if (strcmp(FlowCtrl_B
[pAC
->Index
],"None")==0) {
3522 FlowCtrl
= SK_FLOW_MODE_NONE
;
3524 printk("sk98lin: Illegal value \"%s\" for FlowCtrl_B\n",
3525 FlowCtrl_B
[pAC
->Index
]);
3526 IsFlowCtrlDefined
= SK_FALSE
;
3529 IsFlowCtrlDefined
= SK_FALSE
;
3532 if (IsFlowCtrlDefined
) {
3533 if ((AutoNeg
== AN_OFF
) && (FlowCtrl
!= SK_FLOW_MODE_NONE
)) {
3534 printk("sk98lin: Port B: FlowControl"
3535 " impossible without AutoNegotiation,"
3537 FlowCtrl
= SK_FLOW_MODE_NONE
;
3539 pAC
->GIni
.GP
[1].PFlowCtrlMode
= FlowCtrl
;
3543 ** d) What is the RoleParameter?
3545 if (Role_B
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3546 Role_B
[pAC
->Index
] != NULL
) {
3547 if (strcmp(Role_B
[pAC
->Index
],"")==0) {
3548 IsRoleDefined
= SK_FALSE
;
3549 } else if (strcmp(Role_B
[pAC
->Index
],"Auto")==0) {
3550 MSMode
= SK_MS_MODE_AUTO
;
3551 } else if (strcmp(Role_B
[pAC
->Index
],"Master")==0) {
3552 MSMode
= SK_MS_MODE_MASTER
;
3553 } else if (strcmp(Role_B
[pAC
->Index
],"Slave")==0) {
3554 MSMode
= SK_MS_MODE_SLAVE
;
3556 printk("sk98lin: Illegal value \"%s\" for Role_B\n",
3557 Role_B
[pAC
->Index
]);
3558 IsRoleDefined
= SK_FALSE
;
3561 IsRoleDefined
= SK_FALSE
;
3564 if (IsRoleDefined
) {
3565 pAC
->GIni
.GP
[1].PMSMode
= MSMode
;
3569 ** Evaluate settings for both ports
3571 pAC
->ActivePort
= 0;
3572 if (PrefPort
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3573 PrefPort
[pAC
->Index
] != NULL
) {
3574 if (strcmp(PrefPort
[pAC
->Index
],"") == 0) { /* Auto */
3575 pAC
->ActivePort
= 0;
3576 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3577 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3578 } else if (strcmp(PrefPort
[pAC
->Index
],"A") == 0) {
3580 ** do not set ActivePort here, thus a port
3581 ** switch is issued after net up.
3584 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3585 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3586 } else if (strcmp(PrefPort
[pAC
->Index
],"B") == 0) {
3588 ** do not set ActivePort here, thus a port
3589 ** switch is issued after net up.
3591 if (pAC
->GIni
.GIMacsFound
== 1) {
3592 printk("sk98lin: Illegal value \"B\" for PrefPort.\n"
3593 " Port B not available on single port adapters.\n");
3595 pAC
->ActivePort
= 0;
3596 pAC
->Rlmt
.Net
[0].Preference
= -1; /* auto */
3597 pAC
->Rlmt
.Net
[0].PrefPort
= 0;
3600 pAC
->Rlmt
.Net
[0].Preference
= Port
;
3601 pAC
->Rlmt
.Net
[0].PrefPort
= Port
;
3604 printk("sk98lin: Illegal value \"%s\" for PrefPort\n",
3605 PrefPort
[pAC
->Index
]);
3611 if (RlmtMode
!= NULL
&& pAC
->Index
<SK_MAX_CARD_PARAM
&&
3612 RlmtMode
[pAC
->Index
] != NULL
) {
3613 if (strcmp(RlmtMode
[pAC
->Index
], "") == 0) {
3615 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLinkState") == 0) {
3616 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3617 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckLocalPort") == 0) {
3618 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3619 SK_RLMT_CHECK_LOC_LINK
;
3620 } else if (strcmp(RlmtMode
[pAC
->Index
], "CheckSeg") == 0) {
3621 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
|
3622 SK_RLMT_CHECK_LOC_LINK
|
3624 } else if ((strcmp(RlmtMode
[pAC
->Index
], "DualNet") == 0) &&
3625 (pAC
->GIni
.GIMacsFound
== 2)) {
3626 pAC
->RlmtMode
= SK_RLMT_CHECK_LINK
;
3629 printk("sk98lin: Illegal value \"%s\" for"
3630 " RlmtMode, using default\n",
3631 RlmtMode
[pAC
->Index
]);
3639 ** Check the interrupt moderation parameters
3641 if (Moderation
[pAC
->Index
] != NULL
) {
3642 if (strcmp(Moderation
[pAC
->Index
], "") == 0) {
3643 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3644 } else if (strcmp(Moderation
[pAC
->Index
], "Static") == 0) {
3645 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_STATIC
;
3646 } else if (strcmp(Moderation
[pAC
->Index
], "Dynamic") == 0) {
3647 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_DYNAMIC
;
3648 } else if (strcmp(Moderation
[pAC
->Index
], "None") == 0) {
3649 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3651 printk("sk98lin: Illegal value \"%s\" for Moderation.\n"
3652 " Disable interrupt moderation.\n",
3653 Moderation
[pAC
->Index
]);
3654 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3657 pAC
->DynIrqModInfo
.IntModTypeSelect
= C_INT_MOD_NONE
;
3660 if (Stats
[pAC
->Index
] != NULL
) {
3661 if (strcmp(Stats
[pAC
->Index
], "Yes") == 0) {
3662 pAC
->DynIrqModInfo
.DisplayStats
= SK_TRUE
;
3664 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3667 pAC
->DynIrqModInfo
.DisplayStats
= SK_FALSE
;
3670 if (ModerationMask
[pAC
->Index
] != NULL
) {
3671 if (strcmp(ModerationMask
[pAC
->Index
], "Rx") == 0) {
3672 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3673 } else if (strcmp(ModerationMask
[pAC
->Index
], "Tx") == 0) {
3674 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_ONLY
;
3675 } else if (strcmp(ModerationMask
[pAC
->Index
], "Sp") == 0) {
3676 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_ONLY
;
3677 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSp") == 0) {
3678 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3679 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRx") == 0) {
3680 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_RX
;
3681 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTx") == 0) {
3682 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3683 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRx") == 0) {
3684 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3685 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSp") == 0) {
3686 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3687 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTx") == 0) {
3688 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_SP_TX
;
3689 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxTxSp") == 0) {
3690 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3691 } else if (strcmp(ModerationMask
[pAC
->Index
], "RxSpTx") == 0) {
3692 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3693 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxRxSp") == 0) {
3694 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3695 } else if (strcmp(ModerationMask
[pAC
->Index
], "TxSpRx") == 0) {
3696 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3697 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpTxRx") == 0) {
3698 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3699 } else if (strcmp(ModerationMask
[pAC
->Index
], "SpRxTx") == 0) {
3700 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_TX_SP
;
3701 } else { /* some rubbish */
3702 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_RX_ONLY
;
3704 } else { /* operator has stated nothing */
3705 pAC
->DynIrqModInfo
.MaskIrqModeration
= IRQ_MASK_TX_RX
;
3708 if (AutoSizing
[pAC
->Index
] != NULL
) {
3709 if (strcmp(AutoSizing
[pAC
->Index
], "On") == 0) {
3710 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3712 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3714 } else { /* operator has stated nothing */
3715 pAC
->DynIrqModInfo
.AutoSizing
= SK_FALSE
;
3718 if (IntsPerSec
[pAC
->Index
] != 0) {
3719 if ((IntsPerSec
[pAC
->Index
]< C_INT_MOD_IPS_LOWER_RANGE
) ||
3720 (IntsPerSec
[pAC
->Index
] > C_INT_MOD_IPS_UPPER_RANGE
)) {
3721 printk("sk98lin: Illegal value \"%d\" for IntsPerSec. (Range: %d - %d)\n"
3722 " Using default value of %i.\n",
3723 IntsPerSec
[pAC
->Index
],
3724 C_INT_MOD_IPS_LOWER_RANGE
,
3725 C_INT_MOD_IPS_UPPER_RANGE
,
3726 C_INTS_PER_SEC_DEFAULT
);
3727 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3729 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= IntsPerSec
[pAC
->Index
];
3732 pAC
->DynIrqModInfo
.MaxModIntsPerSec
= C_INTS_PER_SEC_DEFAULT
;
3736 ** Evaluate upper and lower moderation threshold
3738 pAC
->DynIrqModInfo
.MaxModIntsPerSecUpperLimit
=
3739 pAC
->DynIrqModInfo
.MaxModIntsPerSec
+
3740 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3742 pAC
->DynIrqModInfo
.MaxModIntsPerSecLowerLimit
=
3743 pAC
->DynIrqModInfo
.MaxModIntsPerSec
-
3744 (pAC
->DynIrqModInfo
.MaxModIntsPerSec
/ 2);
3746 pAC
->DynIrqModInfo
.PrevTimeVal
= jiffies
; /* initial value */
3749 } /* GetConfiguration */
3752 /*****************************************************************************
3754 * ProductStr - return a adapter identification string from vpd
3757 * This function reads the product name string from the vpd area
3758 * and puts it the field pAC->DeviceString.
3762 static inline int ProductStr(
3763 SK_AC
*pAC
, /* pointer to adapter context */
3764 char *DeviceStr
, /* result string */
3765 int StrLen
/* length of the string */
3768 char Keyword
[] = VPD_NAME
; /* vpd productname identifier */
3769 int ReturnCode
; /* return code from vpd_read */
3770 unsigned long Flags
;
3772 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
3773 ReturnCode
= VpdRead(pAC
, pAC
->IoBase
, Keyword
, DeviceStr
, &StrLen
);
3774 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
3779 /*****************************************************************************
3781 * StartDrvCleanupTimer - Start timer to check for descriptors which
3782 * might be placed in descriptor ring, but
3783 * havent been handled up to now
3786 * This function requests a HW-timer fo the Yukon card. The actions to
3787 * perform when this timer expires, are located in the SkDrvEvent().
3792 StartDrvCleanupTimer(SK_AC
*pAC
) {
3793 SK_EVPARA EventParam
; /* Event struct for timer event */
3795 SK_MEMSET((char *) &EventParam
, 0, sizeof(EventParam
));
3796 EventParam
.Para32
[0] = SK_DRV_RX_CLEANUP_TIMER
;
3797 SkTimerStart(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
,
3798 SK_DRV_RX_CLEANUP_TIMER_LENGTH
,
3799 SKGE_DRV
, SK_DRV_TIMER
, EventParam
);
3802 /*****************************************************************************
3804 * StopDrvCleanupTimer - Stop timer to check for descriptors
3807 * This function requests a HW-timer fo the Yukon card. The actions to
3808 * perform when this timer expires, are located in the SkDrvEvent().
3813 StopDrvCleanupTimer(SK_AC
*pAC
) {
3814 SkTimerStop(pAC
, pAC
->IoBase
, &pAC
->DrvCleanupTimer
);
3815 SK_MEMSET((char *) &pAC
->DrvCleanupTimer
, 0, sizeof(SK_TIMER
));
3818 /****************************************************************************/
3819 /* functions for common modules *********************************************/
3820 /****************************************************************************/
3823 /*****************************************************************************
3825 * SkDrvAllocRlmtMbuf - allocate an RLMT mbuf
3828 * This routine returns an RLMT mbuf or NULL. The RLMT Mbuf structure
3829 * is embedded into a socket buff data area.
3835 * NULL or pointer to Mbuf.
3837 SK_MBUF
*SkDrvAllocRlmtMbuf(
3838 SK_AC
*pAC
, /* pointer to adapter context */
3839 SK_IOC IoC
, /* the IO-context */
3840 unsigned BufferSize
) /* size of the requested buffer */
3842 SK_MBUF
*pRlmtMbuf
; /* pointer to a new rlmt-mbuf structure */
3843 struct sk_buff
*pMsgBlock
; /* pointer to a new message block */
3845 pMsgBlock
= alloc_skb(BufferSize
+ sizeof(SK_MBUF
), GFP_ATOMIC
);
3846 if (pMsgBlock
== NULL
) {
3849 pRlmtMbuf
= (SK_MBUF
*) pMsgBlock
->data
;
3850 skb_reserve(pMsgBlock
, sizeof(SK_MBUF
));
3851 pRlmtMbuf
->pNext
= NULL
;
3852 pRlmtMbuf
->pOs
= pMsgBlock
;
3853 pRlmtMbuf
->pData
= pMsgBlock
->data
; /* Data buffer. */
3854 pRlmtMbuf
->Size
= BufferSize
; /* Data buffer size. */
3855 pRlmtMbuf
->Length
= 0; /* Length of packet (<= Size). */
3858 } /* SkDrvAllocRlmtMbuf */
3861 /*****************************************************************************
3863 * SkDrvFreeRlmtMbuf - free an RLMT mbuf
3866 * This routine frees one or more RLMT mbuf(s).
3874 void SkDrvFreeRlmtMbuf(
3875 SK_AC
*pAC
, /* pointer to adapter context */
3876 SK_IOC IoC
, /* the IO-context */
3877 SK_MBUF
*pMbuf
) /* size of the requested buffer */
3884 pNextMbuf
= pFreeMbuf
->pNext
;
3885 DEV_KFREE_SKB_ANY(pFreeMbuf
->pOs
);
3886 pFreeMbuf
= pNextMbuf
;
3887 } while ( pFreeMbuf
!= NULL
);
3888 } /* SkDrvFreeRlmtMbuf */
3891 /*****************************************************************************
3893 * SkOsGetTime - provide a time value
3896 * This routine provides a time value. The unit is 1/HZ (defined by Linux).
3897 * It is not used for absolute time, but only for time differences.
3903 SK_U64
SkOsGetTime(SK_AC
*pAC
)
3905 SK_U64 PrivateJiffies
;
3906 SkOsGetTimeCurrent(pAC
, &PrivateJiffies
);
3907 return PrivateJiffies
;
3911 /*****************************************************************************
3913 * SkPciReadCfgDWord - read a 32 bit value from pci config space
3916 * This routine reads a 32 bit value from the pci configuration
3920 * 0 - indicate everything worked ok.
3921 * != 0 - error indication
3923 int SkPciReadCfgDWord(
3924 SK_AC
*pAC
, /* Adapter Control structure pointer */
3925 int PciAddr
, /* PCI register address */
3926 SK_U32
*pVal
) /* pointer to store the read value */
3928 pci_read_config_dword(pAC
->PciDev
, PciAddr
, pVal
);
3930 } /* SkPciReadCfgDWord */
3933 /*****************************************************************************
3935 * SkPciReadCfgWord - read a 16 bit value from pci config space
3938 * This routine reads a 16 bit value from the pci configuration
3942 * 0 - indicate everything worked ok.
3943 * != 0 - error indication
3945 int SkPciReadCfgWord(
3946 SK_AC
*pAC
, /* Adapter Control structure pointer */
3947 int PciAddr
, /* PCI register address */
3948 SK_U16
*pVal
) /* pointer to store the read value */
3950 pci_read_config_word(pAC
->PciDev
, PciAddr
, pVal
);
3952 } /* SkPciReadCfgWord */
3955 /*****************************************************************************
3957 * SkPciReadCfgByte - read a 8 bit value from pci config space
3960 * This routine reads a 8 bit value from the pci configuration
3964 * 0 - indicate everything worked ok.
3965 * != 0 - error indication
3967 int SkPciReadCfgByte(
3968 SK_AC
*pAC
, /* Adapter Control structure pointer */
3969 int PciAddr
, /* PCI register address */
3970 SK_U8
*pVal
) /* pointer to store the read value */
3972 pci_read_config_byte(pAC
->PciDev
, PciAddr
, pVal
);
3974 } /* SkPciReadCfgByte */
3977 /*****************************************************************************
3979 * SkPciWriteCfgWord - write a 16 bit value to pci config space
3982 * This routine writes a 16 bit value to the pci configuration
3983 * space. The flag PciConfigUp indicates whether the config space
3984 * is accesible or must be set up first.
3987 * 0 - indicate everything worked ok.
3988 * != 0 - error indication
3990 int SkPciWriteCfgWord(
3991 SK_AC
*pAC
, /* Adapter Control structure pointer */
3992 int PciAddr
, /* PCI register address */
3993 SK_U16 Val
) /* pointer to store the read value */
3995 pci_write_config_word(pAC
->PciDev
, PciAddr
, Val
);
3997 } /* SkPciWriteCfgWord */
4000 /*****************************************************************************
4002 * SkPciWriteCfgWord - write a 8 bit value to pci config space
4005 * This routine writes a 8 bit value to the pci configuration
4006 * space. The flag PciConfigUp indicates whether the config space
4007 * is accesible or must be set up first.
4010 * 0 - indicate everything worked ok.
4011 * != 0 - error indication
4013 int SkPciWriteCfgByte(
4014 SK_AC
*pAC
, /* Adapter Control structure pointer */
4015 int PciAddr
, /* PCI register address */
4016 SK_U8 Val
) /* pointer to store the read value */
4018 pci_write_config_byte(pAC
->PciDev
, PciAddr
, Val
);
4020 } /* SkPciWriteCfgByte */
4023 /*****************************************************************************
4025 * SkDrvEvent - handle driver events
4028 * This function handles events from all modules directed to the driver
4031 * Is called under protection of slow path lock.
4034 * 0 if everything ok
4039 SK_AC
*pAC
, /* pointer to adapter context */
4040 SK_IOC IoC
, /* io-context */
4041 SK_U32 Event
, /* event-id */
4042 SK_EVPARA Param
) /* event-parameter */
4044 SK_MBUF
*pRlmtMbuf
; /* pointer to a rlmt-mbuf structure */
4045 struct sk_buff
*pMsg
; /* pointer to a message block */
4046 int FromPort
; /* the port from which we switch away */
4047 int ToPort
; /* the port we switch to */
4048 SK_EVPARA NewPara
; /* parameter for further events */
4050 unsigned long Flags
;
4054 case SK_DRV_ADAP_FAIL
:
4055 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4056 ("ADAPTER FAIL EVENT\n"));
4057 printk("%s: Adapter failed.\n", pAC
->dev
[0]->name
);
4058 /* disable interrupts */
4059 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
4062 case SK_DRV_PORT_FAIL
:
4063 FromPort
= Param
.Para32
[0];
4064 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4065 ("PORT FAIL EVENT, Port: %d\n", FromPort
));
4066 if (FromPort
== 0) {
4067 printk("%s: Port A failed.\n", pAC
->dev
[0]->name
);
4069 printk("%s: Port B failed.\n", pAC
->dev
[1]->name
);
4073 case SK_DRV_PORT_RESET
: /* SK_U32 PortIdx */
4075 FromPort
= Param
.Para32
[0];
4076 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4077 ("PORT RESET EVENT, Port: %d ", FromPort
));
4078 NewPara
.Para64
= FromPort
;
4079 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4081 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4084 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_HARD_RST
);
4085 netif_carrier_off(pAC
->dev
[Param
.Para32
[0]]);
4086 spin_unlock_irqrestore(
4087 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4090 /* clear rx ring from received frames */
4091 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
);
4093 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4095 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4098 /* tschilling: Handling of return value inserted. */
4099 if (SkGeInitPort(pAC
, IoC
, FromPort
)) {
4100 if (FromPort
== 0) {
4101 printk("%s: SkGeInitPort A failed.\n", pAC
->dev
[0]->name
);
4103 printk("%s: SkGeInitPort B failed.\n", pAC
->dev
[1]->name
);
4106 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4107 PortReInitBmu(pAC
, FromPort
);
4108 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4109 ClearAndStartRx(pAC
, FromPort
);
4110 spin_unlock_irqrestore(
4111 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4114 case SK_DRV_NET_UP
: /* SK_U32 PortIdx */
4115 { struct net_device
*dev
= pAC
->dev
[Param
.Para32
[0]];
4117 FromPort
= Param
.Para32
[0];
4118 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4119 ("NET UP EVENT, Port: %d ", Param
.Para32
[0]));
4121 SkAddrMcUpdate(pAC
,IoC
, FromPort
);
4123 if (DoPrintInterfaceChange
) {
4124 printk("%s: network connection up using"
4125 " port %c\n", pAC
->dev
[Param
.Para32
[0]]->name
, 'A'+Param
.Para32
[0]);
4127 /* tschilling: Values changed according to LinkSpeedUsed. */
4128 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
;
4129 if (Stat
== SK_LSPEED_STAT_10MBPS
) {
4130 printk(" speed: 10\n");
4131 } else if (Stat
== SK_LSPEED_STAT_100MBPS
) {
4132 printk(" speed: 100\n");
4133 } else if (Stat
== SK_LSPEED_STAT_1000MBPS
) {
4134 printk(" speed: 1000\n");
4136 printk(" speed: unknown\n");
4140 Stat
= pAC
->GIni
.GP
[FromPort
].PLinkModeStatus
;
4141 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4142 Stat
== SK_LMODE_STAT_AUTOFULL
) {
4143 printk(" autonegotiation: yes\n");
4146 printk(" autonegotiation: no\n");
4148 if (Stat
== SK_LMODE_STAT_AUTOHALF
||
4149 Stat
== SK_LMODE_STAT_HALF
) {
4150 printk(" duplex mode: half\n");
4153 printk(" duplex mode: full\n");
4155 Stat
= pAC
->GIni
.GP
[FromPort
].PFlowCtrlStatus
;
4156 if (Stat
== SK_FLOW_STAT_REM_SEND
) {
4157 printk(" flowctrl: remote send\n");
4159 else if (Stat
== SK_FLOW_STAT_LOC_SEND
){
4160 printk(" flowctrl: local send\n");
4162 else if (Stat
== SK_FLOW_STAT_SYMMETRIC
){
4163 printk(" flowctrl: symmetric\n");
4166 printk(" flowctrl: none\n");
4169 /* tschilling: Check against CopperType now. */
4170 if ((pAC
->GIni
.GICopperType
== SK_TRUE
) &&
4171 (pAC
->GIni
.GP
[FromPort
].PLinkSpeedUsed
==
4172 SK_LSPEED_STAT_1000MBPS
)) {
4173 Stat
= pAC
->GIni
.GP
[FromPort
].PMSStatus
;
4174 if (Stat
== SK_MS_STAT_MASTER
) {
4175 printk(" role: master\n");
4177 else if (Stat
== SK_MS_STAT_SLAVE
) {
4178 printk(" role: slave\n");
4181 printk(" role: ???\n");
4186 Display dim (dynamic interrupt moderation)
4189 if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_STATIC
)
4190 printk(" irq moderation: static (%d ints/sec)\n",
4191 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4192 else if (pAC
->DynIrqModInfo
.IntModTypeSelect
== C_INT_MOD_DYNAMIC
)
4193 printk(" irq moderation: dynamic (%d ints/sec)\n",
4194 pAC
->DynIrqModInfo
.MaxModIntsPerSec
);
4196 printk(" irq moderation: disabled\n");
4199 printk(" scatter-gather: %s\n",
4200 (dev
->features
& NETIF_F_SG
) ? "enabled" : "disabled");
4201 printk(" tx-checksum: %s\n",
4202 (dev
->features
& NETIF_F_IP_CSUM
) ? "enabled" : "disabled");
4203 printk(" rx-checksum: %s\n",
4204 pAC
->RxPort
[Param
.Para32
[0]].RxCsum
? "enabled" : "disabled");
4207 DoPrintInterfaceChange
= SK_TRUE
;
4210 if ((Param
.Para32
[0] != pAC
->ActivePort
) &&
4211 (pAC
->RlmtNets
== 1)) {
4212 NewPara
.Para32
[0] = pAC
->ActivePort
;
4213 NewPara
.Para32
[1] = Param
.Para32
[0];
4214 SkEventQueue(pAC
, SKGE_DRV
, SK_DRV_SWITCH_INTERN
,
4218 /* Inform the world that link protocol is up. */
4219 netif_carrier_on(dev
);
4222 case SK_DRV_NET_DOWN
: /* SK_U32 Reason */
4224 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4225 ("NET DOWN EVENT "));
4226 if (DoPrintInterfaceChange
) {
4227 printk("%s: network connection down\n",
4228 pAC
->dev
[Param
.Para32
[1]]->name
);
4230 DoPrintInterfaceChange
= SK_TRUE
;
4232 netif_carrier_off(pAC
->dev
[Param
.Para32
[1]]);
4234 case SK_DRV_SWITCH_HARD
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4235 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4236 ("PORT SWITCH HARD "));
4237 case SK_DRV_SWITCH_SOFT
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4239 printk("%s: switching to port %c\n", pAC
->dev
[0]->name
,
4240 'A'+Param
.Para32
[1]);
4241 case SK_DRV_SWITCH_INTERN
: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4242 FromPort
= Param
.Para32
[0];
4243 ToPort
= Param
.Para32
[1];
4244 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4245 ("PORT SWITCH EVENT, From: %d To: %d (Pref %d) ",
4246 FromPort
, ToPort
, pAC
->Rlmt
.Net
[0].PrefPort
));
4247 NewPara
.Para64
= FromPort
;
4248 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4249 NewPara
.Para64
= ToPort
;
4250 SkPnmiEvent(pAC
, IoC
, SK_PNMI_EVT_XMAC_RESET
, NewPara
);
4252 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4254 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4255 SkGeStopPort(pAC
, IoC
, FromPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4256 SkGeStopPort(pAC
, IoC
, ToPort
, SK_STOP_ALL
, SK_SOFT_RST
);
4257 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4258 spin_unlock_irqrestore(
4259 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4262 ReceiveIrq(pAC
, &pAC
->RxPort
[FromPort
], SK_FALSE
); /* clears rx ring */
4263 ReceiveIrq(pAC
, &pAC
->RxPort
[ToPort
], SK_FALSE
); /* clears rx ring */
4265 ClearTxRing(pAC
, &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
]);
4266 ClearTxRing(pAC
, &pAC
->TxPort
[ToPort
][TX_PRIO_LOW
]);
4268 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4270 spin_lock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4271 pAC
->ActivePort
= ToPort
;
4275 /* tschilling: New common function with minimum size check. */
4277 if (pAC
->RlmtNets
== 2) {
4281 if (SkGeInitAssignRamToQueues(
4285 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4286 spin_unlock_irqrestore(
4287 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4289 printk("SkGeInitAssignRamToQueues failed.\n");
4293 /* tschilling: Handling of return values inserted. */
4294 if (SkGeInitPort(pAC
, IoC
, FromPort
) ||
4295 SkGeInitPort(pAC
, IoC
, ToPort
)) {
4296 printk("%s: SkGeInitPort failed.\n", pAC
->dev
[0]->name
);
4298 if (Event
== SK_DRV_SWITCH_SOFT
) {
4299 SkMacRxTxEnable(pAC
, IoC
, FromPort
);
4301 SkMacRxTxEnable(pAC
, IoC
, ToPort
);
4302 SkAddrSwap(pAC
, IoC
, FromPort
, ToPort
);
4303 SkAddrMcUpdate(pAC
, IoC
, FromPort
);
4304 SkAddrMcUpdate(pAC
, IoC
, ToPort
);
4305 PortReInitBmu(pAC
, FromPort
);
4306 PortReInitBmu(pAC
, ToPort
);
4307 SkGePollTxD(pAC
, IoC
, FromPort
, SK_TRUE
);
4308 SkGePollTxD(pAC
, IoC
, ToPort
, SK_TRUE
);
4309 ClearAndStartRx(pAC
, FromPort
);
4310 ClearAndStartRx(pAC
, ToPort
);
4311 spin_unlock(&pAC
->TxPort
[ToPort
][TX_PRIO_LOW
].TxDesRingLock
);
4312 spin_unlock_irqrestore(
4313 &pAC
->TxPort
[FromPort
][TX_PRIO_LOW
].TxDesRingLock
,
4316 case SK_DRV_RLMT_SEND
: /* SK_MBUF *pMb */
4317 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4319 pRlmtMbuf
= (SK_MBUF
*) Param
.pParaPtr
;
4320 pMsg
= (struct sk_buff
*) pRlmtMbuf
->pOs
;
4321 skb_put(pMsg
, pRlmtMbuf
->Length
);
4322 if (XmitFrame(pAC
, &pAC
->TxPort
[pRlmtMbuf
->PortIdx
][TX_PRIO_LOW
],
4325 DEV_KFREE_SKB_ANY(pMsg
);
4328 if (Param
.Para32
[0] == SK_DRV_MODERATION_TIMER
) {
4330 ** expiration of the moderation timer implies that
4331 ** dynamic moderation is to be applied
4333 SkDimStartModerationTimer(pAC
);
4335 if (pAC
->DynIrqModInfo
.DisplayStats
) {
4336 SkDimDisplayModerationSettings(pAC
);
4338 } else if (Param
.Para32
[0] == SK_DRV_RX_CLEANUP_TIMER
) {
4340 ** check if we need to check for descriptors which
4341 ** haven't been handled the last millisecs
4343 StartDrvCleanupTimer(pAC
);
4344 if (pAC
->GIni
.GIMacsFound
== 2) {
4345 ReceiveIrq(pAC
, &pAC
->RxPort
[1], SK_FALSE
);
4347 ReceiveIrq(pAC
, &pAC
->RxPort
[0], SK_FALSE
);
4349 printk("Expiration of unknown timer\n");
4355 SK_DBG_MSG(NULL
, SK_DBGMOD_DRV
, SK_DBGCAT_DRV_EVENT
,
4362 /*****************************************************************************
4364 * SkErrorLog - log errors
4367 * This function logs errors to the system buffer and to the console
4370 * 0 if everything ok
4383 case SK_ERRCL_OTHER
:
4384 strcpy(ClassStr
, "Other error");
4386 case SK_ERRCL_CONFIG
:
4387 strcpy(ClassStr
, "Configuration error");
4390 strcpy(ClassStr
, "Initialization error");
4392 case SK_ERRCL_NORES
:
4393 strcpy(ClassStr
, "Out of resources error");
4396 strcpy(ClassStr
, "internal Software error");
4399 strcpy(ClassStr
, "Hardware failure");
4402 strcpy(ClassStr
, "Communication error");
4405 printk(KERN_INFO
"%s: -- ERROR --\n Class: %s\n"
4406 " Nr: 0x%x\n Msg: %s\n", pAC
->dev
[0]->name
,
4407 ClassStr
, ErrNum
, pErrorMsg
);
4411 #ifdef SK_DIAG_SUPPORT
4413 /*****************************************************************************
4415 * SkDrvEnterDiagMode - handles DIAG attach request
4418 * Notify the kernel to NOT access the card any longer due to DIAG
4419 * Deinitialize the Card
4424 int SkDrvEnterDiagMode(
4425 SK_AC
*pAc
) /* pointer to adapter context */
4427 DEV_NET
*pNet
= netdev_priv(pAc
->dev
[0]);
4428 SK_AC
*pAC
= pNet
->pAC
;
4430 SK_MEMCPY(&(pAc
->PnmiBackup
), &(pAc
->PnmiStruct
),
4431 sizeof(SK_PNMI_STRUCT_DATA
));
4433 pAC
->DiagModeActive
= DIAG_ACTIVE
;
4434 if (pAC
->BoardLevel
> SK_INIT_DATA
) {
4435 if (netif_running(pAC
->dev
[0])) {
4436 pAC
->WasIfUp
[0] = SK_TRUE
;
4437 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4438 DoPrintInterfaceChange
= SK_FALSE
;
4439 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
4441 pAC
->WasIfUp
[0] = SK_FALSE
;
4443 if (pNet
!= netdev_priv(pAC
->dev
[1])) {
4444 pNet
= netdev_priv(pAC
->dev
[1]);
4445 if (netif_running(pAC
->dev
[1])) {
4446 pAC
->WasIfUp
[1] = SK_TRUE
;
4447 pAC
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4448 DoPrintInterfaceChange
= SK_FALSE
;
4449 SkDrvDeInitAdapter(pAC
, 1); /* do SkGeClose */
4451 pAC
->WasIfUp
[1] = SK_FALSE
;
4454 pAC
->BoardLevel
= SK_INIT_DATA
;
4459 /*****************************************************************************
4461 * SkDrvLeaveDiagMode - handles DIAG detach request
4464 * Notify the kernel to may access the card again after use by DIAG
4465 * Initialize the Card
4470 int SkDrvLeaveDiagMode(
4471 SK_AC
*pAc
) /* pointer to adapter control context */
4473 SK_MEMCPY(&(pAc
->PnmiStruct
), &(pAc
->PnmiBackup
),
4474 sizeof(SK_PNMI_STRUCT_DATA
));
4475 pAc
->DiagModeActive
= DIAG_NOTACTIVE
;
4476 pAc
->Pnmi
.DiagAttached
= SK_DIAG_IDLE
;
4477 if (pAc
->WasIfUp
[0] == SK_TRUE
) {
4478 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4479 DoPrintInterfaceChange
= SK_FALSE
;
4480 SkDrvInitAdapter(pAc
, 0); /* first device */
4482 if (pAc
->WasIfUp
[1] == SK_TRUE
) {
4483 pAc
->DiagFlowCtrl
= SK_TRUE
; /* for SkGeClose */
4484 DoPrintInterfaceChange
= SK_FALSE
;
4485 SkDrvInitAdapter(pAc
, 1); /* second device */
4490 /*****************************************************************************
4492 * ParseDeviceNbrFromSlotName - Evaluate PCI device number
4495 * This function parses the PCI slot name information string and will
4496 * retrieve the devcie number out of it. The slot_name maintianed by
4497 * linux is in the form of '02:0a.0', whereas the first two characters
4498 * represent the bus number in hex (in the sample above this is
4499 * pci bus 0x02) and the next two characters the device number (0x0a).
4502 * SK_U32: The device number from the PCI slot name
4505 static SK_U32
ParseDeviceNbrFromSlotName(
4506 const char *SlotName
) /* pointer to pci slot name eg. '02:0a.0' */
4508 char *CurrCharPos
= (char *) SlotName
;
4509 int FirstNibble
= -1;
4510 int SecondNibble
= -1;
4513 while (*CurrCharPos
!= '\0') {
4514 if (*CurrCharPos
== ':') {
4515 while (*CurrCharPos
!= '.') {
4517 if ( (*CurrCharPos
>= '0') &&
4518 (*CurrCharPos
<= '9')) {
4519 if (FirstNibble
== -1) {
4520 /* dec. value for '0' */
4521 FirstNibble
= *CurrCharPos
- 48;
4523 SecondNibble
= *CurrCharPos
- 48;
4525 } else if ( (*CurrCharPos
>= 'a') &&
4526 (*CurrCharPos
<= 'f') ) {
4527 if (FirstNibble
== -1) {
4528 FirstNibble
= *CurrCharPos
- 87;
4530 SecondNibble
= *CurrCharPos
- 87;
4537 Result
= FirstNibble
;
4538 Result
= Result
<< 4; /* first nibble is higher one */
4539 Result
= Result
| SecondNibble
;
4541 CurrCharPos
++; /* next character */
4546 /****************************************************************************
4548 * SkDrvDeInitAdapter - deinitialize adapter (this function is only
4549 * called if Diag attaches to that card)
4552 * Close initialized adapter.
4556 * error code - on error
4558 static int SkDrvDeInitAdapter(
4559 SK_AC
*pAC
, /* pointer to adapter context */
4560 int devNbr
) /* what device is to be handled */
4562 struct SK_NET_DEVICE
*dev
;
4564 dev
= pAC
->dev
[devNbr
];
4566 /* On Linux 2.6 the network driver does NOT mess with reference
4567 ** counts. The driver MUST be able to be unloaded at any time
4568 ** due to the possibility of hotplug.
4570 if (SkGeClose(dev
) != 0) {
4575 } /* SkDrvDeInitAdapter() */
4577 /****************************************************************************
4579 * SkDrvInitAdapter - Initialize adapter (this function is only
4580 * called if Diag deattaches from that card)
4583 * Close initialized adapter.
4587 * error code - on error
4589 static int SkDrvInitAdapter(
4590 SK_AC
*pAC
, /* pointer to adapter context */
4591 int devNbr
) /* what device is to be handled */
4593 struct SK_NET_DEVICE
*dev
;
4595 dev
= pAC
->dev
[devNbr
];
4597 if (SkGeOpen(dev
) != 0) {
4602 ** Use correct MTU size and indicate to kernel TX queue can be started
4604 if (SkGeChangeMtu(dev
, dev
->mtu
) != 0) {
4609 } /* SkDrvInitAdapter */
4614 /****************************************************************************/
4615 /* "debug only" section *****************************************************/
4616 /****************************************************************************/
4619 /*****************************************************************************
4621 * DumpMsg - print a frame
4624 * This function prints frames to the system logfile/to the console.
4629 static void DumpMsg(struct sk_buff
*skb
, char *str
)
4634 printk("DumpMsg(): NULL-Message\n");
4638 if (skb
->data
== NULL
) {
4639 printk("DumpMsg(): Message empty\n");
4647 printk("--- Begin of message from %s , len %d (from %d) ----\n", str
, msglen
, skb
->len
);
4649 DumpData((char *)skb
->data
, msglen
);
4651 printk("------- End of message ---------\n");
4656 /*****************************************************************************
4658 * DumpData - print a data area
4661 * This function prints a area of data to the system logfile/to the
4667 static void DumpData(char *p
, int size
)
4671 char hex_buffer
[180];
4672 char asc_buffer
[180];
4673 char HEXCHAR
[] = "0123456789ABCDEF";
4679 for (i
=0; i
< size
; ) {
4680 if (*p
>= '0' && *p
<='z')
4681 asc_buffer
[addr
] = *p
;
4683 asc_buffer
[addr
] = '.';
4685 asc_buffer
[addr
] = 0;
4686 hex_buffer
[haddr
] = HEXCHAR
[(*p
& 0xf0) >> 4];
4688 hex_buffer
[haddr
] = HEXCHAR
[*p
& 0x0f];
4690 hex_buffer
[haddr
] = ' ';
4692 hex_buffer
[haddr
] = 0;
4696 printk("%s %s\n", hex_buffer
, asc_buffer
);
4704 /*****************************************************************************
4706 * DumpLong - print a data area as long values
4709 * This function prints a area of data to the system logfile/to the
4715 static void DumpLong(char *pc
, int size
)
4719 char hex_buffer
[180];
4720 char asc_buffer
[180];
4721 char HEXCHAR
[] = "0123456789ABCDEF";
4730 for (i
=0; i
< size
; ) {
4732 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 28) & 0xf];
4734 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 24) & 0xf];
4736 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 20) & 0xf];
4738 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 16) & 0xf];
4740 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 12) & 0xf];
4742 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 8) & 0xf];
4744 hex_buffer
[haddr
] = HEXCHAR
[(l
>> 4) & 0xf];
4746 hex_buffer
[haddr
] = HEXCHAR
[l
& 0x0f];
4748 hex_buffer
[haddr
] = ' ';
4750 hex_buffer
[haddr
] = 0;
4754 printk("%4x %s\n", (i
-8)*4, hex_buffer
);
4758 printk("------------------------\n");
4763 static int __devinit
skge_probe_one(struct pci_dev
*pdev
,
4764 const struct pci_device_id
*ent
)
4767 DEV_NET
*pNet
= NULL
;
4768 struct net_device
*dev
= NULL
;
4769 static int boards_found
= 0;
4770 int error
= -ENODEV
;
4774 if (pci_enable_device(pdev
))
4777 /* Configure DMA attributes. */
4778 if (sizeof(dma_addr_t
) > sizeof(u32
) &&
4779 !(error
= pci_set_dma_mask(pdev
, DMA_64BIT_MASK
))) {
4781 error
= pci_set_consistent_dma_mask(pdev
, DMA_64BIT_MASK
);
4783 printk(KERN_ERR
"sk98lin %s unable to obtain 64 bit DMA "
4784 "for consistent allocations\n", pci_name(pdev
));
4785 goto out_disable_device
;
4788 error
= pci_set_dma_mask(pdev
, DMA_32BIT_MASK
);
4790 printk(KERN_ERR
"sk98lin %s no usable DMA configuration\n",
4792 goto out_disable_device
;
4797 dev
= alloc_etherdev(sizeof(DEV_NET
));
4799 printk(KERN_ERR
"sk98lin: unable to allocate etherdev "
4801 goto out_disable_device
;
4804 pNet
= netdev_priv(dev
);
4805 pNet
->pAC
= kzalloc(sizeof(SK_AC
), GFP_KERNEL
);
4807 printk(KERN_ERR
"sk98lin: unable to allocate adapter "
4809 goto out_free_netdev
;
4817 pAC
->CheckQueue
= SK_FALSE
;
4819 dev
->irq
= pdev
->irq
;
4821 error
= SkGeInitPCI(pAC
);
4823 printk(KERN_ERR
"sk98lin: PCI setup failed: %i\n", error
);
4824 goto out_free_netdev
;
4827 SET_MODULE_OWNER(dev
);
4828 dev
->open
= &SkGeOpen
;
4829 dev
->stop
= &SkGeClose
;
4830 dev
->hard_start_xmit
= &SkGeXmit
;
4831 dev
->get_stats
= &SkGeStats
;
4832 dev
->set_multicast_list
= &SkGeSetRxMode
;
4833 dev
->set_mac_address
= &SkGeSetMacAddr
;
4834 dev
->do_ioctl
= &SkGeIoctl
;
4835 dev
->change_mtu
= &SkGeChangeMtu
;
4836 #ifdef CONFIG_NET_POLL_CONTROLLER
4837 dev
->poll_controller
= &SkGePollController
;
4839 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4840 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4842 /* Use only if yukon hardware */
4843 if (pAC
->ChipsetType
) {
4844 #ifdef USE_SK_TX_CHECKSUM
4845 dev
->features
|= NETIF_F_IP_CSUM
;
4848 dev
->features
|= NETIF_F_SG
;
4850 #ifdef USE_SK_RX_CHECKSUM
4851 pAC
->RxPort
[0].RxCsum
= 1;
4856 dev
->features
|= NETIF_F_HIGHDMA
;
4858 pAC
->Index
= boards_found
++;
4860 error
= SkGeBoardInit(dev
, pAC
);
4862 goto out_free_netdev
;
4864 /* Read Adapter name from VPD */
4865 if (ProductStr(pAC
, DeviceStr
, sizeof(DeviceStr
)) != 0) {
4867 printk(KERN_ERR
"sk98lin: Could not read VPD data.\n");
4868 goto out_free_resources
;
4871 /* Register net device */
4872 error
= register_netdev(dev
);
4874 printk(KERN_ERR
"sk98lin: Could not register device.\n");
4875 goto out_free_resources
;
4878 /* Print adapter specific string from vpd */
4879 printk("%s: %s\n", dev
->name
, DeviceStr
);
4881 /* Print configuration settings */
4882 printk(" PrefPort:%c RlmtMode:%s\n",
4883 'A' + pAC
->Rlmt
.Net
[0].Port
[pAC
->Rlmt
.Net
[0].PrefPort
]->PortNumber
,
4884 (pAC
->RlmtMode
==0) ? "Check Link State" :
4885 ((pAC
->RlmtMode
==1) ? "Check Link State" :
4886 ((pAC
->RlmtMode
==3) ? "Check Local Port" :
4887 ((pAC
->RlmtMode
==7) ? "Check Segmentation" :
4888 ((pAC
->RlmtMode
==17) ? "Dual Check Link State" :"Error")))));
4890 SkGeYellowLED(pAC
, pAC
->IoBase
, 1);
4892 memcpy(&dev
->dev_addr
, &pAC
->Addr
.Net
[0].CurrentMacAddress
, 6);
4893 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4900 pci_set_drvdata(pdev
, dev
);
4902 /* More then one port found */
4903 if ((pAC
->GIni
.GIMacsFound
== 2 ) && (pAC
->RlmtNets
== 2)) {
4904 dev
= alloc_etherdev(sizeof(DEV_NET
));
4906 printk(KERN_ERR
"sk98lin: unable to allocate etherdev "
4911 pNet
= netdev_priv(dev
);
4916 dev
->open
= &SkGeOpen
;
4917 dev
->stop
= &SkGeClose
;
4918 dev
->hard_start_xmit
= &SkGeXmit
;
4919 dev
->get_stats
= &SkGeStats
;
4920 dev
->set_multicast_list
= &SkGeSetRxMode
;
4921 dev
->set_mac_address
= &SkGeSetMacAddr
;
4922 dev
->do_ioctl
= &SkGeIoctl
;
4923 dev
->change_mtu
= &SkGeChangeMtu
;
4924 SET_NETDEV_DEV(dev
, &pdev
->dev
);
4925 SET_ETHTOOL_OPS(dev
, &SkGeEthtoolOps
);
4927 if (pAC
->ChipsetType
) {
4928 #ifdef USE_SK_TX_CHECKSUM
4929 dev
->features
|= NETIF_F_IP_CSUM
;
4932 dev
->features
|= NETIF_F_SG
;
4934 #ifdef USE_SK_RX_CHECKSUM
4935 pAC
->RxPort
[1].RxCsum
= 1;
4940 dev
->features
|= NETIF_F_HIGHDMA
;
4942 error
= register_netdev(dev
);
4944 printk(KERN_ERR
"sk98lin: Could not register device"
4945 " for second port. (%d)\n", error
);
4951 memcpy(&dev
->dev_addr
,
4952 &pAC
->Addr
.Net
[1].CurrentMacAddress
, 6);
4953 memcpy(dev
->perm_addr
, dev
->dev_addr
, dev
->addr_len
);
4955 printk("%s: %s\n", dev
->name
, DeviceStr
);
4956 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
4961 /* Save the hardware revision */
4962 pAC
->HWRevision
= (((pAC
->GIni
.GIPciHwRev
>> 4) & 0x0F)*10) +
4963 (pAC
->GIni
.GIPciHwRev
& 0x0F);
4965 /* Set driver globals */
4966 pAC
->Pnmi
.pDriverFileName
= DRIVER_FILE_NAME
;
4967 pAC
->Pnmi
.pDriverReleaseDate
= DRIVER_REL_DATE
;
4969 memset(&pAC
->PnmiBackup
, 0, sizeof(SK_PNMI_STRUCT_DATA
));
4970 memcpy(&pAC
->PnmiBackup
, &pAC
->PnmiStruct
, sizeof(SK_PNMI_STRUCT_DATA
));
4979 pci_disable_device(pdev
);
4984 static void __devexit
skge_remove_one(struct pci_dev
*pdev
)
4986 struct net_device
*dev
= pci_get_drvdata(pdev
);
4987 DEV_NET
*pNet
= netdev_priv(dev
);
4988 SK_AC
*pAC
= pNet
->pAC
;
4989 struct net_device
*otherdev
= pAC
->dev
[1];
4991 unregister_netdev(dev
);
4993 SkGeYellowLED(pAC
, pAC
->IoBase
, 0);
4995 if (pAC
->BoardLevel
== SK_INIT_RUN
) {
4997 unsigned long Flags
;
4999 /* board is still alive */
5000 spin_lock_irqsave(&pAC
->SlowPathLock
, Flags
);
5001 EvPara
.Para32
[0] = 0;
5002 EvPara
.Para32
[1] = -1;
5003 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
5004 EvPara
.Para32
[0] = 1;
5005 EvPara
.Para32
[1] = -1;
5006 SkEventQueue(pAC
, SKGE_RLMT
, SK_RLMT_STOP
, EvPara
);
5007 SkEventDispatcher(pAC
, pAC
->IoBase
);
5008 /* disable interrupts */
5009 SK_OUT32(pAC
->IoBase
, B0_IMSK
, 0);
5010 SkGeDeInit(pAC
, pAC
->IoBase
);
5011 spin_unlock_irqrestore(&pAC
->SlowPathLock
, Flags
);
5012 pAC
->BoardLevel
= SK_INIT_DATA
;
5013 /* We do NOT check here, if IRQ was pending, of course*/
5016 if (pAC
->BoardLevel
== SK_INIT_IO
) {
5017 /* board is still alive */
5018 SkGeDeInit(pAC
, pAC
->IoBase
);
5019 pAC
->BoardLevel
= SK_INIT_DATA
;
5024 if (otherdev
!= dev
)
5025 free_netdev(otherdev
);
5030 static int skge_suspend(struct pci_dev
*pdev
, pm_message_t state
)
5032 struct net_device
*dev
= pci_get_drvdata(pdev
);
5033 DEV_NET
*pNet
= netdev_priv(dev
);
5034 SK_AC
*pAC
= pNet
->pAC
;
5035 struct net_device
*otherdev
= pAC
->dev
[1];
5037 if (netif_running(dev
)) {
5038 netif_carrier_off(dev
);
5039 DoPrintInterfaceChange
= SK_FALSE
;
5040 SkDrvDeInitAdapter(pAC
, 0); /* performs SkGeClose */
5041 netif_device_detach(dev
);
5043 if (otherdev
!= dev
) {
5044 if (netif_running(otherdev
)) {
5045 netif_carrier_off(otherdev
);
5046 DoPrintInterfaceChange
= SK_FALSE
;
5047 SkDrvDeInitAdapter(pAC
, 1); /* performs SkGeClose */
5048 netif_device_detach(otherdev
);
5052 pci_save_state(pdev
);
5053 pci_enable_wake(pdev
, pci_choose_state(pdev
, state
), 0);
5054 if (pAC
->AllocFlag
& SK_ALLOC_IRQ
) {
5055 free_irq(dev
->irq
, dev
);
5057 pci_disable_device(pdev
);
5058 pci_set_power_state(pdev
, pci_choose_state(pdev
, state
));
5063 static int skge_resume(struct pci_dev
*pdev
)
5065 struct net_device
*dev
= pci_get_drvdata(pdev
);
5066 DEV_NET
*pNet
= netdev_priv(dev
);
5067 SK_AC
*pAC
= pNet
->pAC
;
5068 struct net_device
*otherdev
= pAC
->dev
[1];
5071 pci_set_power_state(pdev
, PCI_D0
);
5072 pci_restore_state(pdev
);
5073 pci_enable_device(pdev
);
5074 pci_set_master(pdev
);
5075 if (pAC
->GIni
.GIMacsFound
== 2)
5076 ret
= request_irq(dev
->irq
, SkGeIsr
, SA_SHIRQ
, "sk98lin", dev
);
5078 ret
= request_irq(dev
->irq
, SkGeIsrOnePort
, SA_SHIRQ
, "sk98lin", dev
);
5080 printk(KERN_WARNING
"sk98lin: unable to acquire IRQ %d\n", dev
->irq
);
5081 pAC
->AllocFlag
&= ~SK_ALLOC_IRQ
;
5083 pci_disable_device(pdev
);
5087 netif_device_attach(dev
);
5088 if (netif_running(dev
)) {
5089 DoPrintInterfaceChange
= SK_FALSE
;
5090 SkDrvInitAdapter(pAC
, 0); /* first device */
5092 if (otherdev
!= dev
) {
5093 netif_device_attach(otherdev
);
5094 if (netif_running(otherdev
)) {
5095 DoPrintInterfaceChange
= SK_FALSE
;
5096 SkDrvInitAdapter(pAC
, 1); /* second device */
5103 #define skge_suspend NULL
5104 #define skge_resume NULL
5107 static struct pci_device_id skge_pci_tbl
[] = {
5108 { PCI_VENDOR_ID_3COM
, 0x1700, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5109 { PCI_VENDOR_ID_3COM
, 0x80eb, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5110 { PCI_VENDOR_ID_SYSKONNECT
, 0x4300, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5111 { PCI_VENDOR_ID_SYSKONNECT
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5112 /* DLink card does not have valid VPD so this driver gags
5113 * { PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
5115 { PCI_VENDOR_ID_MARVELL
, 0x4320, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5116 { PCI_VENDOR_ID_MARVELL
, 0x5005, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5117 { PCI_VENDOR_ID_CNET
, 0x434e, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5118 { PCI_VENDOR_ID_LINKSYS
, 0x1032, PCI_ANY_ID
, 0x0015, },
5119 { PCI_VENDOR_ID_LINKSYS
, 0x1064, PCI_ANY_ID
, PCI_ANY_ID
, 0, 0, 0 },
5123 MODULE_DEVICE_TABLE(pci
, skge_pci_tbl
);
5125 static struct pci_driver skge_driver
= {
5127 .id_table
= skge_pci_tbl
,
5128 .probe
= skge_probe_one
,
5129 .remove
= __devexit_p(skge_remove_one
),
5130 .suspend
= skge_suspend
,
5131 .resume
= skge_resume
,
5134 static int __init
skge_init(void)
5136 return pci_module_init(&skge_driver
);
5139 static void __exit
skge_exit(void)
5141 pci_unregister_driver(&skge_driver
);
5144 module_init(skge_init
);
5145 module_exit(skge_exit
);