1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.46 $
6 * Date: $Date: 2003/02/25 14:16:36 $
7 * Purpose: The main driver source module
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
15 * Driver for SysKonnect Gigabit Ethernet Server Adapters:
17 * SK-9871 (single link 1000Base-ZX)
18 * SK-9872 (dual link 1000Base-ZX)
19 * SK-9861 (single link 1000Base-SX, VF45 Volition Plug)
20 * SK-9862 (dual link 1000Base-SX, VF45 Volition Plug)
21 * SK-9841 (single link 1000Base-LX)
22 * SK-9842 (dual link 1000Base-LX)
23 * SK-9843 (single link 1000Base-SX)
24 * SK-9844 (dual link 1000Base-SX)
25 * SK-9821 (single link 1000Base-T)
26 * SK-9822 (dual link 1000Base-T)
27 * SK-9881 (single link 1000Base-SX V2 LC)
28 * SK-9871 (single link 1000Base-ZX V2)
29 * SK-9861 (single link 1000Base-SX V2, VF45 Volition Plug)
30 * SK-9841 (single link 1000Base-LX V2)
31 * SK-9843 (single link 1000Base-SX V2)
32 * SK-9821 (single link 1000Base-T V2)
34 * Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and
35 * SysKonnects GEnesis Solaris driver
36 * Author: Christoph Goos (cgoos@syskonnect.de)
37 * Mirko Lindner (mlindner@syskonnect.de)
39 * Address all question to: linux@syskonnect.de
41 * The technical manual for the adapters is available from SysKonnect's
42 * web pages: www.syskonnect.com
43 * Goto "Support" and search Knowledge Base for "manual".
45 * This program is free software; you can redistribute it and/or modify
46 * it under the terms of the GNU General Public License as published by
47 * the Free Software Foundation; either version 2 of the License, or
48 * (at your option) any later version.
50 * The information in this file is provided "AS IS" without warranty.
52 ******************************************************************************/
54 /******************************************************************************
59 * Revision 1.46 2003/02/25 14:16:36 mlindner
60 * Fix: Copyright statement
62 * Revision 1.45 2003/02/25 13:25:55 mlindner
63 * Add: Performance improvements
64 * Add: Support for various vendors
67 * Revision 1.44 2003/01/09 09:25:26 mlindner
68 * Fix: Remove useless init_module/cleanup_module forward declarations
70 * Revision 1.43 2002/11/29 08:42:41 mlindner
73 * Revision 1.42 2002/11/28 13:30:23 mlindner
74 * Add: New frame check
76 * Revision 1.41 2002/11/27 13:55:18 mlindner
77 * Fix: Drop wrong csum packets
78 * Fix: Initialize proc_entry after hw check
80 * Revision 1.40 2002/10/31 07:50:37 tschilli
81 * Function SkGeInitAssignRamToQueues() from common module inserted.
82 * Autonegotiation is set to ON for all adapters.
83 * LinkSpeedUsed is used in link up status report.
84 * Role parameter will show up for 1000 Mbps links only.
85 * GetConfiguration() inserted after init level 1 in SkGeChangeMtu().
86 * All return values of SkGeInit() and SkGeInitPort() are checked.
88 * Revision 1.39 2002/10/02 12:56:05 mlindner
89 * Add: Support for Yukon
90 * Add: Support for ZEROCOPY, scatter-gather and hw checksum
91 * Add: New transmit ring function (use SG and TCP/UDP hardware checksumming)
92 * Add: New init function
93 * Add: Speed check and setup
94 * Add: Merge source for kernel 2.2.x and 2.4.x
95 * Add: Opcode check for tcp
96 * Add: Frame length check
97 * Fix: Transmit complete interrupt
98 * Fix: Interrupt moderation
100 * Revision 1.29.2.13 2002/01/14 12:44:52 mlindner
103 * Revision 1.29.2.12 2001/12/07 12:06:18 mlindner
104 * Fix: malloc -> slab changes
106 * Revision 1.29.2.11 2001/12/06 15:19:20 mlindner
107 * Add: DMA attributes
108 * Fix: Module initialisation
109 * Fix: pci_map_single and pci_unmap_single replaced
111 * Revision 1.29.2.10 2001/12/06 09:56:50 mlindner
112 * Corrected some printk's
114 * Revision 1.29.2.9 2001/09/05 12:15:34 mlindner
116 * Fix: Counter Errors (Jumbo == to long errors)
117 * Fix: Changed pAC->PciDev declaration
118 * Fix: too short counters
120 * Revision 1.29.2.8 2001/06/25 12:10:44 mlindner
121 * fix: ReceiveIrq() changed.
123 * Revision 1.29.2.7 2001/06/25 08:07:05 mlindner
124 * fix: RLMT locking in ReceiveIrq() changed.
126 * Revision 1.29.2.6 2001/05/21 07:59:29 mlindner
127 * fix: MTU init problems
129 * Revision 1.29.2.5 2001/05/08 11:25:08 mlindner
130 * fix: removed VLAN error message
132 * Revision 1.29.2.4 2001/05/04 13:31:43 gklug
133 * fix: do not handle eth_copy on bad fragments received.
135 * Revision 1.29.2.3 2001/04/23 08:06:43 mlindner
136 * Fix: error handling
138 * Revision 1.29.2.2 2001/03/15 12:04:54 mlindner
139 * Fixed memory problem
141 * Revision 1.29.2.1 2001/03/12 16:41:44 mlindner
142 * add: procfs function
143 * add: dual-net function
145 * add: extended PNMI features
147 * Kernel 2.4.x specific:
148 * Revision 1.xx 2000/09/12 13:31:56 cgoos
149 * Fixed missign "dev=NULL in skge_probe.
150 * Added counting for jumbo frames (corrects error statistic).
151 * Removed VLAN tag check (enables VLAN support).
153 * Kernel 2.2.x specific:
154 * Revision 1.29 2000/02/21 13:31:56 cgoos
155 * Fixed "unused" warning for UltraSPARC change.
157 * Partially kernel 2.2.x specific:
158 * Revision 1.28 2000/02/21 10:32:36 cgoos
159 * Added fixes for UltraSPARC.
160 * Now printing RlmtMode and PrefPort setting at startup.
161 * Changed XmitFrame return value.
162 * Fixed rx checksum calculation for BIG ENDIAN systems.
163 * Fixed rx jumbo frames counted as ierrors.
166 * Revision 1.27 1999/11/25 09:06:28 cgoos
167 * Changed base_addr to unsigned long.
169 * Revision 1.26 1999/11/22 13:29:16 cgoos
170 * Changed license header to GPL.
171 * Changes for inclusion in linux kernel (2.2.13).
172 * Removed 2.0.x defines.
173 * Changed SkGeProbe to skge_probe.
174 * Added checks in SkGeIoctl.
176 * Revision 1.25 1999/10/07 14:47:52 cgoos
177 * Changed 984x to 98xx.
179 * Revision 1.24 1999/09/30 07:21:01 cgoos
180 * Removed SK_RLMT_SLOW_LOOKAHEAD option.
181 * Giving spanning tree packets also to OS now.
183 * Revision 1.23 1999/09/29 07:36:50 cgoos
184 * Changed assignment for IsBc/IsMc.
186 * Revision 1.22 1999/09/28 12:57:09 cgoos
187 * Added CheckQueue also to Single-Port-ISR.
189 * Revision 1.21 1999/09/28 12:42:41 cgoos
190 * Changed parameter strings for RlmtMode.
192 * Revision 1.20 1999/09/28 12:37:57 cgoos
193 * Added CheckQueue for fast delivery of RLMT frames.
195 * Revision 1.19 1999/09/16 07:57:25 cgoos
196 * Copperfield changes.
198 * Revision 1.18 1999/09/03 13:06:30 cgoos
199 * Fixed RlmtMode=CheckSeg bug: wrong DEV_KFREE_SKB in RLMT_SEND caused
200 * double allocated skb's.
201 * FrameStat in ReceiveIrq was accessed via wrong Rxd.
202 * Queue size for async. standby Tx queue was zero.
203 * FillRxLimit of 0 could cause problems with ReQueue, changed to 1.
204 * Removed debug output of checksum statistic.
206 * Revision 1.17 1999/08/11 13:55:27 cgoos
207 * Transmit descriptor polling was not reenabled after SkGePortInit.
209 * Revision 1.16 1999/07/27 15:17:29 cgoos
210 * Added some "\n" in output strings (removed while debuging...).
212 * Revision 1.15 1999/07/23 12:09:30 cgoos
213 * Performance optimization, rx checksumming, large frame support.
215 * Revision 1.14 1999/07/14 11:26:27 cgoos
216 * Removed Link LED settings (now in RLMT).
217 * Added status output at NET UP.
218 * Fixed SMP problems with Tx and SWITCH running in parallel.
219 * Fixed return code problem at RLMT_SEND event.
221 * Revision 1.13 1999/04/07 10:11:42 cgoos
222 * Fixed Single Port problems.
223 * Fixed Multi-Adapter problems.
224 * Always display startup string.
226 * Revision 1.12 1999/03/29 12:26:37 cgoos
227 * Reversed locking to fine granularity.
228 * Fixed skb double alloc problem (caused by incorrect xmit return code).
229 * Enhanced function descriptions.
231 * Revision 1.11 1999/03/15 13:10:51 cgoos
232 * Changed device identifier in output string to ethX.
234 * Revision 1.10 1999/03/15 12:12:34 cgoos
235 * Changed copyright notice.
237 * Revision 1.9 1999/03/15 12:10:17 cgoos
238 * Changed locking to one driver lock.
239 * Added check of SK_AC-size (for consistency with library).
241 * Revision 1.8 1999/03/08 11:44:02 cgoos
242 * Fixed missing dev->tbusy in SkGeXmit.
243 * Changed large frame (jumbo) buffer number.
244 * Added copying of short frames.
246 * Revision 1.7 1999/03/04 13:26:57 cgoos
247 * Fixed spinlock calls for SMP.
249 * Revision 1.6 1999/03/02 09:53:51 cgoos
250 * Added descriptor revertion for big endian machines.
252 * Revision 1.5 1999/03/01 08:50:59 cgoos
253 * Fixed SkGeChangeMtu.
254 * Fixed pci config space accesses.
256 * Revision 1.4 1999/02/18 15:48:44 cgoos
257 * Corrected some printk's.
259 * Revision 1.3 1999/02/18 12:45:55 cgoos
260 * Changed SK_MAX_CARD_PARAM to default 16
262 * Revision 1.2 1999/02/18 10:55:32 cgoos
263 * Removed SkGeDrvTimeStamp function.
264 * Printing "ethX:" before adapter type at adapter init.
267 * 10-Feb-1999 cg Created, based on Linux' acenic.c, 3c59x.c and
268 * SysKonnects GEnesis Solaris driver
270 ******************************************************************************/
272 /******************************************************************************
274 * Possible compiler options (#define xxx / -Dxxx):
276 * debugging can be enable by changing SK_DEBUG_CHKMOD and
277 * SK_DEBUG_CHKCAT in makefile (described there).
279 ******************************************************************************/
281 /******************************************************************************
285 * This is the main module of the Linux GE driver.
287 * All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h
288 * are part of SysKonnect's COMMON MODULES for the SK-98xx adapters.
289 * Those are used for drivers on multiple OS', so some thing may seem
290 * unnecessary complicated on Linux. Please do not try to 'clean up'
291 * them without VERY good reasons, because this will make it more
292 * difficult to keep the Linux driver in synchronisation with the
295 * Include file hierarchy:
307 * <linux/interrupt.h>
312 * <linux/netdevice.h>
313 * <linux/etherdevice.h>
315 * those three depending on kernel version used:
341 ******************************************************************************/
343 #include "h/skversion.h"
345 #include <linux/module.h>
346 #include <linux/init.h>
347 #include <linux/proc_fs.h>
349 #include "h/skdrv1st.h"
350 #include "h/skdrv2nd.h"
353 /* defines ******************************************************************/
354 /* for debuging on x86 only */
355 /* #define BREAKPOINT() asm(" int $3"); */
357 /* use the scatter-gather functionality with sendfile() */
362 /* use of a transmit complete interrupt */
363 #define USE_TX_COMPLETE
365 /* use interrupt moderation (for tx complete only) */
367 #define INTS_PER_SEC 1000
370 * threshold for copying small receive frames
371 * set to 0 to avoid copying, set to 9001 to copy all frames
373 #define SK_COPY_THRESHOLD 50
375 /* number of adapters that can be configured via command line params */
376 #define SK_MAX_CARD_PARAM 16
380 * use those defines for a compile-in version of the driver instead
381 * of command line parameters
383 // #define LINK_SPEED_A {"Auto", }
384 // #define LINK_SPEED_B {"Auto", }
385 // #define AUTO_NEG_A {"Sense", }
386 // #define AUTO_NEG_B {"Sense", }
387 // #define DUP_CAP_A {"Both", }
388 // #define DUP_CAP_B {"Both", }
389 // #define FLOW_CTRL_A {"SymOrRem", }
390 // #define FLOW_CTRL_B {"SymOrRem", }
391 // #define ROLE_A {"Auto", }
392 // #define ROLE_B {"Auto", }
393 // #define PREF_PORT {"A", }
394 // #define RLMT_MODE {"CheckLinkState", }
396 #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)
397 #define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)
398 #define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)
400 /* function prototypes ******************************************************/
401 static void FreeResources(struct SK_NET_DEVICE *dev);
402 static int SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC);
403 static SK_BOOL BoardAllocMem(SK_AC *pAC);
404 static void BoardFreeMem(SK_AC *pAC);
405 static void BoardInitMem(SK_AC *pAC);
406 static void SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**,
410 static void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
411 static void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
412 static int SkGeOpen(struct SK_NET_DEVICE *dev);
413 static int SkGeClose(struct SK_NET_DEVICE *dev);
414 static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);
415 static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p);
416 static void SkGeSetRxMode(struct SK_NET_DEVICE *dev);
417 static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);
418 static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd);
420 void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);
421 void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);
422 int SkGeOpen(struct SK_NET_DEVICE *dev);
423 int SkGeClose(struct SK_NET_DEVICE *dev);
424 int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);
426 static void GetConfiguration(SK_AC*);
427 static void ProductStr(SK_AC*);
428 static int XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*);
429 static void FreeTxDescriptors(SK_AC*pAC, TX_PORT*);
430 static void FillRxRing(SK_AC*, RX_PORT*);
431 static SK_BOOL FillRxDescriptor(SK_AC*, RX_PORT*);
433 static void ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL);
435 void ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL);
437 static void ClearAndStartRx(SK_AC*, int);
438 static void ClearTxIrq(SK_AC*, int, int);
439 static void ClearRxRing(SK_AC*, RX_PORT*);
440 static void ClearTxRing(SK_AC*, TX_PORT*);
442 static void SetQueueSizes(SK_AC *pAC);
444 static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu);
446 static void PortReInitBmu(SK_AC*, int);
448 static int SkGeIocMib(DEV_NET*, unsigned int, int);
449 static int XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*);
454 /* external Proc function */
455 extern int proc_read(
457 char **buffer_location,
464 static void DumpMsg(struct sk_buff*, char*);
465 static void DumpData(char*, int);
466 static void DumpLong(char*, int);
468 void dump_frag( SK_U8 *data, int length);
470 /* global variables *********************************************************/
472 static const char *BootString = BOOT_STRING;
474 struct SK_NET_DEVICE *SkGeRootDev = NULL;
475 static int probed __initdata = 0;
477 /* local variables **********************************************************/
478 static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}};
479 static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480};
482 /* local variables **********************************************************/
483 const char SK_Root_Dir_entry[8];
486 static struct proc_dir_entry *pSkRootDir;
490 static struct pci_device_id supported[] = {
491 {PCI_VENDOR_ID_3COM, 0x1700},
492 {PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE},
493 {PCI_VENDOR_ID_SYSKONNECT, PCI_DEVICE_ID_SYSKONNECT_GE_SA},
498 /*****************************************************************************
500 * skge_probe - find all SK-98xx adapters
503 * This function scans the PCI bus for SK-98xx adapters. Resources for
504 * each adapter are allocated and the adapter is brought into Init 1
508 * 0, if everything is ok
512 static int __init skge_probe (void)
514 int skge_probe (struct eth_device ** ret_dev)
518 int proc_root_initialized = 0;
520 int boards_found = 0;
522 int vendor_flag = SK_FALSE;
525 DEV_NET *pNet = NULL;
527 struct proc_dir_entry *pProcFile;
528 struct pci_dev *pdev = NULL;
529 unsigned long base_address;
533 struct SK_NET_DEVICE *dev = NULL;
535 SK_BOOL DeviceFound = SK_FALSE;
537 SK_BOOL BootStringCount = SK_FALSE;
546 if (!pci_present()) /* is PCI support present? */
550 while((pdev = pci_find_class(PCI_CLASS_NETWORK_ETHERNET << 8, pdev)))
552 while((devno = pci_find_devices (supported, boards_found)) >= 0)
561 SK_PCI_ISCOMPLIANT(vendor_flag, pdev);
566 /* if ((pdev->vendor != PCI_VENDOR_ID_SYSKONNECT) &&
567 ((pdev->device != PCI_DEVICE_ID_SYSKONNECT_GE) ||
568 (pdev->device != PCI_DEVICE_ID_SYSKONNECT_YU))){
573 /* Configure DMA attributes. */
574 if (pci_set_dma_mask(pdev, (u64) 0xffffffffffffffff) &&
575 pci_set_dma_mask(pdev, (u64) 0xffffffff))
581 if ((dev = init_etherdev(dev, sizeof(DEV_NET))) == NULL) {
582 printk(KERN_ERR "Unable to allocate etherdev "
587 dev = malloc (sizeof *dev);
588 memset(dev, 0, sizeof(*dev));
589 dev->priv = malloc(sizeof(DEV_NET));
592 if (dev->priv == NULL) {
593 printk(KERN_ERR "Unable to allocate adapter "
599 pNet->pAC = kmalloc(sizeof(SK_AC), GFP_KERNEL);
600 if (pNet->pAC == NULL){
602 printk(KERN_ERR "Unable to allocate adapter "
608 if (!BootStringCount) {
609 /* set display flag to TRUE so that */
610 /* we only display this string ONCE */
611 BootStringCount = SK_TRUE;
613 printk("%s\n", BootString);
617 memset(pNet->pAC, 0, sizeof(SK_AC));
621 pAC->PciDevId = pdev->device;
626 ret_dev[0] = pAC->dev[0] = dev;
627 ret_dev[1] = pAC->dev[1] = dev;
629 sprintf(pAC->Name, "SysKonnect SK-98xx");
630 pAC->CheckQueue = SK_FALSE;
635 dev->irq = pdev->irq;
637 dev->open = &SkGeOpen;
638 dev->stop = &SkGeClose;
639 dev->hard_start_xmit = &SkGeXmit;
640 dev->get_stats = &SkGeStats;
641 dev->set_multicast_list = &SkGeSetRxMode;
642 dev->set_mac_address = &SkGeSetMacAddr;
643 dev->do_ioctl = &SkGeIoctl;
644 dev->change_mtu = &SkGeChangeMtu;
645 dev->flags &= ~IFF_RUNNING;
649 if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
650 /* Use only if yukon hardware */
651 /* SK and ZEROCOPY - fly baby... */
652 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
661 pci_set_master(pdev);
663 pci_set_master(pdev);
664 base_address = pci_resource_start (pdev, 0);
666 pci_write_config_dword(devno,
668 PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER);
669 pci_read_config_dword (devno, PCI_BASE_ADDRESS_0,
675 * On big endian machines, we use the adapter's aibility of
676 * reading the descriptors as big endian.
680 SkPciReadCfgDWord(pAC, PCI_OUR_REG_2, &our2);
681 our2 |= PCI_REV_DESC;
682 SkPciWriteCfgDWord(pAC, PCI_OUR_REG_2, our2);
687 * Remap the regs into kernel space.
690 pAC->IoBase = (char*)ioremap(base_address, 0x4000);
692 pAC->IoBase = (char*)pci_mem_to_phys(devno, base_address);
696 printk(KERN_ERR "%s: Unable to map I/O register, "
697 "SK 98xx No. %i will be disabled.\n",
698 dev->name, boards_found);
703 pAC->Index = boards_found;
704 if (SkGeBoardInit(dev, pAC)) {
711 memcpy((caddr_t) &dev->dev_addr,
712 (caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
714 memcpy((caddr_t) &dev->enetaddr,
715 (caddr_t) &pAC->Addr.Net[0].CurrentMacAddress, 6);
719 /* First adapter... Create proc and print message */
721 DeviceFound = SK_TRUE;
722 SK_MEMCPY(&SK_Root_Dir_entry, BootString,
723 sizeof(SK_Root_Dir_entry) - 1);
725 /*Create proc (directory)*/
726 if(!proc_root_initialized) {
727 pSkRootDir = create_proc_entry(SK_Root_Dir_entry,
728 S_IFDIR | S_IWUSR | S_IRUGO | S_IXUGO, proc_net);
729 proc_root_initialized = 1;
732 pSkRootDir->owner = THIS_MODULE;
737 /* Create proc file */
738 pProcFile = create_proc_entry(dev->name,
739 S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
743 pProcFile->read_proc = proc_read;
744 pProcFile->write_proc = NULL;
745 pProcFile->nlink = 1;
746 pProcFile->size = sizeof(dev->name + 1);
747 pProcFile->data = (void *)pProcFile;
754 if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
755 /* SG and ZEROCOPY - fly baby... */
756 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
762 /* More then one port found */
763 if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) {
765 if ((dev = init_etherdev(NULL, sizeof(DEV_NET))) == 0) {
766 printk(KERN_ERR "Unable to allocate etherdev "
771 dev = malloc (sizeof *dev);
772 memset(dev, 0, sizeof(*dev));
773 dev->priv = malloc(sizeof(DEV_NET));
785 dev->open = &SkGeOpen;
786 dev->stop = &SkGeClose;
787 dev->hard_start_xmit = &SkGeXmit;
788 dev->get_stats = &SkGeStats;
789 dev->set_multicast_list = &SkGeSetRxMode;
790 dev->set_mac_address = &SkGeSetMacAddr;
791 dev->do_ioctl = &SkGeIoctl;
792 dev->change_mtu = &SkGeChangeMtu;
793 dev->flags &= ~IFF_RUNNING;
797 if (pAC->GIni.GIChipId == CHIP_ID_YUKON) {
798 /* SG and ZEROCOPY - fly baby... */
799 dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
804 pProcFile = create_proc_entry(dev->name,
805 S_IFREG | S_IXUSR | S_IWGRP | S_IROTH,
809 pProcFile->read_proc = proc_read;
810 pProcFile->write_proc = NULL;
811 pProcFile->nlink = 1;
812 pProcFile->size = sizeof(dev->name + 1);
813 pProcFile->data = (void *)pProcFile;
817 memcpy((caddr_t) &dev->dev_addr,
818 (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
820 memcpy((caddr_t) &dev->enetaddr,
821 (caddr_t) &pAC->Addr.Net[1].CurrentMacAddress, 6);
824 printk("%s: %s\n", dev->name, pAC->DeviceStr);
825 printk(" PrefPort:B RlmtMode:Dual Check Link State\n");
830 /* Save the hardware revision */
831 pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) +
832 (pAC->GIni.GIPciHwRev & 0x0F);
835 * This is bollocks, but we need to tell the net-init
836 * code that it shall go for the next device.
846 * If we're at this point we're going through skge_probe() for
847 * the first time. Return success (0) if we've initialized 1
848 * or more boards. Otherwise, return failure (-ENODEV).
855 /*****************************************************************************
857 * FreeResources - release resources allocated for adapter
860 * This function releases the IRQ, unmaps the IO and
861 * frees the desriptor ring.
866 static void FreeResources(struct SK_NET_DEVICE *dev)
873 pNet = (DEV_NET*) dev->priv;
875 AllocFlag = pAC->AllocFlag;
877 if (AllocFlag & SK_ALLOC_IRQ) {
878 free_irq(dev->irq, dev);
881 iounmap(pAC->IoBase);
884 if (pAC->pDescrMem) {
889 } /* FreeResources */
892 MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>");
893 MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver");
894 MODULE_LICENSE("GPL");
895 MODULE_PARM(Speed_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
896 MODULE_PARM(Speed_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
897 MODULE_PARM(AutoNeg_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
898 MODULE_PARM(AutoNeg_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
899 MODULE_PARM(DupCap_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
900 MODULE_PARM(DupCap_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
901 MODULE_PARM(FlowCtrl_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
902 MODULE_PARM(FlowCtrl_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
903 MODULE_PARM(Role_A, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
904 MODULE_PARM(Role_B, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
905 MODULE_PARM(PrefPort, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
906 MODULE_PARM(RlmtMode, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "s");
907 /* not used, just there because every driver should have them: */
908 MODULE_PARM(options, "1-" __MODULE_STRING(SK_MAX_CARD_PARAM) "i");
909 MODULE_PARM(debug, "i");
914 static char *Speed_A[SK_MAX_CARD_PARAM] = LINK_SPEED_A;
916 static char *Speed_A[SK_MAX_CARD_PARAM] = {"", };
920 static char *Speed_B[SK_MAX_CARD_PARAM] = LINK_SPEED_B;
922 static char *Speed_B[SK_MAX_CARD_PARAM] = {"", };
926 static char *AutoNeg_A[SK_MAX_CARD_PARAM] = AUTO_NEG_A;
928 static char *AutoNeg_A[SK_MAX_CARD_PARAM] = {"", };
932 static char *DupCap_A[SK_MAX_CARD_PARAM] = DUP_CAP_A;
934 static char *DupCap_A[SK_MAX_CARD_PARAM] = {"", };
938 static char *FlowCtrl_A[SK_MAX_CARD_PARAM] = FLOW_CTRL_A;
940 static char *FlowCtrl_A[SK_MAX_CARD_PARAM] = {"", };
944 static char *Role_A[SK_MAX_CARD_PARAM] = ROLE_A;
946 static char *Role_A[SK_MAX_CARD_PARAM] = {"", };
950 static char *AutoNeg_B[SK_MAX_CARD_PARAM] = AUTO_NEG_B;
952 static char *AutoNeg_B[SK_MAX_CARD_PARAM] = {"", };
956 static char *DupCap_B[SK_MAX_CARD_PARAM] = DUP_CAP_B;
958 static char *DupCap_B[SK_MAX_CARD_PARAM] = {"", };
962 static char *FlowCtrl_B[SK_MAX_CARD_PARAM] = FLOW_CTRL_B;
964 static char *FlowCtrl_B[SK_MAX_CARD_PARAM] = {"", };
968 static char *Role_B[SK_MAX_CARD_PARAM] = ROLE_B;
970 static char *Role_B[SK_MAX_CARD_PARAM] = {"", };
974 static char *PrefPort[SK_MAX_CARD_PARAM] = PREF_PORT;
976 static char *PrefPort[SK_MAX_CARD_PARAM] = {"", };
980 static char *RlmtMode[SK_MAX_CARD_PARAM] = RLMT_MODE;
982 static char *RlmtMode[SK_MAX_CARD_PARAM] = {"", };
986 static int debug = 0; /* not used */
987 static int options[SK_MAX_CARD_PARAM] = {0, }; /* not used */
990 /*****************************************************************************
992 * skge_init_module - module initialization function
995 * Very simple, only call skge_probe and return approriate result.
998 * 0, if everything is ok
1001 static int __init skge_init_module(void)
1006 /* just to avoid warnings ... */
1010 cards = skge_probe();
1012 printk("sk98lin: No adapter found.\n");
1014 return cards ? 0 : -ENODEV;
1015 } /* skge_init_module */
1018 /*****************************************************************************
1020 * skge_cleanup_module - module unload function
1023 * Disable adapter if it is still running, free resources,
1024 * free device struct.
1028 static void __exit skge_cleanup_module(void)
1032 struct SK_NET_DEVICE *next;
1033 unsigned long Flags;
1036 while (SkGeRootDev) {
1037 pNet = (DEV_NET*) SkGeRootDev->priv;
1041 netif_stop_queue(SkGeRootDev);
1042 SkGeYellowLED(pAC, pAC->IoBase, 0);
1044 if(pAC->BoardLevel == 2) {
1045 /* board is still alive */
1046 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1047 EvPara.Para32[0] = 0;
1048 EvPara.Para32[1] = -1;
1049 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
1050 EvPara.Para32[0] = 1;
1051 EvPara.Para32[1] = -1;
1052 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
1053 SkEventDispatcher(pAC, pAC->IoBase);
1054 /* disable interrupts */
1055 SK_OUT32(pAC->IoBase, B0_IMSK, 0);
1056 SkGeDeInit(pAC, pAC->IoBase);
1057 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1058 pAC->BoardLevel = 0;
1059 /* We do NOT check here, if IRQ was pending, of course*/
1062 if(pAC->BoardLevel == 1) {
1063 /* board is still alive */
1064 SkGeDeInit(pAC, pAC->IoBase);
1065 pAC->BoardLevel = 0;
1068 if ((pAC->GIni.GIMacsFound == 2) && pAC->RlmtNets == 2){
1069 unregister_netdev(pAC->dev[1]);
1073 FreeResources(SkGeRootDev);
1075 SkGeRootDev->get_stats = NULL;
1077 * otherwise unregister_netdev calls get_stats with
1078 * invalid IO ... :-(
1080 unregister_netdev(SkGeRootDev);
1086 /* clear proc-dir */
1087 remove_proc_entry(pSkRootDir->name, proc_net);
1089 } /* skge_cleanup_module */
1091 module_init(skge_init_module);
1092 module_exit(skge_cleanup_module);
1096 /*****************************************************************************
1098 * SkGeBoardInit - do level 0 and 1 initialization
1101 * This function prepares the board hardware for running. The desriptor
1102 * ring is set up, the IRQ is allocated and the configuration settings
1106 * 0, if everything is ok
1109 static int __init SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC)
1112 unsigned long Flags;
1113 char *DescrString = "sk98lin: Driver for Linux"; /* this is given to PNMI */
1114 char *VerStr = VER_STRING;
1116 int Ret; /* return code of request_irq */
1120 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1121 ("IoBase: %08lX\n", (unsigned long)pAC->IoBase));
1122 for (i=0; i<SK_MAX_MACS; i++) {
1123 pAC->TxPort[i][0].HwAddr = pAC->IoBase + TxQueueAddr[i][0];
1124 pAC->TxPort[i][0].PortIndex = i;
1125 pAC->RxPort[i].HwAddr = pAC->IoBase + RxQueueAddr[i];
1126 pAC->RxPort[i].PortIndex = i;
1129 /* Initialize the mutexes */
1130 for (i=0; i<SK_MAX_MACS; i++) {
1131 spin_lock_init(&pAC->TxPort[i][0].TxDesRingLock);
1132 spin_lock_init(&pAC->RxPort[i].RxDesRingLock);
1134 spin_lock_init(&pAC->SlowPathLock);
1136 /* level 0 init common modules here */
1138 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1139 /* Does a RESET on board ...*/
1140 if (SkGeInit(pAC, pAC->IoBase, 0) != 0) {
1141 printk("HWInit (0) failed.\n");
1142 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1145 SkI2cInit( pAC, pAC->IoBase, 0);
1146 SkEventInit(pAC, pAC->IoBase, 0);
1147 SkPnmiInit( pAC, pAC->IoBase, 0);
1148 SkAddrInit( pAC, pAC->IoBase, 0);
1149 SkRlmtInit( pAC, pAC->IoBase, 0);
1150 SkTimerInit(pAC, pAC->IoBase, 0);
1152 pAC->BoardLevel = 0;
1153 pAC->RxBufSize = ETH_BUF_SIZE;
1155 SK_PNMI_SET_DRIVER_DESCR(pAC, DescrString);
1156 SK_PNMI_SET_DRIVER_VER(pAC, VerStr);
1158 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1160 /* level 1 init common modules here (HW init) */
1161 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1162 if (SkGeInit(pAC, pAC->IoBase, 1) != 0) {
1163 printk("HWInit (1) failed.\n");
1164 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1167 SkI2cInit( pAC, pAC->IoBase, 1);
1168 SkEventInit(pAC, pAC->IoBase, 1);
1169 SkPnmiInit( pAC, pAC->IoBase, 1);
1170 SkAddrInit( pAC, pAC->IoBase, 1);
1171 SkRlmtInit( pAC, pAC->IoBase, 1);
1172 SkTimerInit(pAC, pAC->IoBase, 1);
1174 GetConfiguration(pAC);
1175 if (pAC->RlmtNets == 2) {
1176 pAC->GIni.GIPortUsage = SK_MUL_LINK;
1179 pAC->BoardLevel = 1;
1180 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1183 if (pAC->GIni.GIMacsFound == 2) {
1184 Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, pAC->Name, dev);
1185 } else if (pAC->GIni.GIMacsFound == 1) {
1186 Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ,
1189 printk(KERN_WARNING "%s: Illegal number of ports: %d\n",
1190 dev->name, pAC->GIni.GIMacsFound);
1195 printk(KERN_WARNING "%s: Requested IRQ %d is busy.\n",
1196 dev->name, dev->irq);
1200 pAC->AllocFlag |= SK_ALLOC_IRQ;
1202 /* Alloc memory for this board (Mem for RxD/TxD) : */
1203 if(!BoardAllocMem(pAC)) {
1204 printk("No memory for descriptor rings.\n");
1208 SkCsSetReceiveFlags(pAC,
1209 SKCS_PROTO_IP | SKCS_PROTO_TCP | SKCS_PROTO_UDP,
1210 &pAC->CsOfs1, &pAC->CsOfs2, 0);
1211 pAC->CsOfs = (pAC->CsOfs2 << 16) | pAC->CsOfs1;
1217 /* tschilling: New common function with minimum size check. */
1219 if (pAC->RlmtNets == 2) {
1223 if (SkGeInitAssignRamToQueues(
1228 printk("SkGeInitAssignRamToQueues failed.\n");
1233 /* Print adapter specific string from vpd */
1236 printk("%s: %s\n", dev->name, pAC->DeviceStr);
1238 /* Print configuration settings */
1239 printk(" PrefPort:%c RlmtMode:%s\n",
1240 'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber,
1241 (pAC->RlmtMode==0) ? "Check Link State" :
1242 ((pAC->RlmtMode==1) ? "Check Link State" :
1243 ((pAC->RlmtMode==3) ? "Check Local Port" :
1244 ((pAC->RlmtMode==7) ? "Check Segmentation" :
1245 ((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error")))));
1248 SkGeYellowLED(pAC, pAC->IoBase, 1);
1251 * Register the device here
1253 pAC->Next = SkGeRootDev;
1257 } /* SkGeBoardInit */
1260 /*****************************************************************************
1262 * BoardAllocMem - allocate the memory for the descriptor rings
1265 * This function allocates the memory for all descriptor rings.
1266 * Each ring is aligned for the desriptor alignment and no ring
1267 * has a 4 GByte boundary in it (because the upper 32 bit must
1268 * be constant for all descriptiors in one rings).
1271 * SK_TRUE, if all memory could be allocated
1274 static SK_BOOL BoardAllocMem(
1277 caddr_t pDescrMem; /* pointer to descriptor memory area */
1278 size_t AllocLength; /* length of complete descriptor area */
1279 int i; /* loop counter */
1280 unsigned long BusAddr;
1283 /* rings plus one for alignment (do not cross 4 GB boundary) */
1284 /* RX_RING_SIZE is assumed bigger than TX_RING_SIZE */
1285 #if (BITS_PER_LONG == 32)
1286 AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound + 8;
1288 AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound
1292 pDescrMem = pci_alloc_consistent(pAC->PciDev, AllocLength,
1293 &pAC->pDescrMemDMA);
1295 if (pDescrMem == NULL) {
1298 pAC->pDescrMem = pDescrMem;
1299 BusAddr = (unsigned long) pAC->pDescrMemDMA;
1301 /* Descriptors need 8 byte alignment, and this is ensured
1302 * by pci_alloc_consistent.
1304 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
1305 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1306 ("TX%d/A: pDescrMem: %lX, PhysDescrMem: %lX\n",
1307 i, (unsigned long) pDescrMem,
1309 pAC->TxPort[i][0].pTxDescrRing = pDescrMem;
1310 pAC->TxPort[i][0].VTxDescrRing = BusAddr;
1311 pDescrMem += TX_RING_SIZE;
1312 BusAddr += TX_RING_SIZE;
1314 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1315 ("RX%d: pDescrMem: %lX, PhysDescrMem: %lX\n",
1316 i, (unsigned long) pDescrMem,
1317 (unsigned long)BusAddr));
1318 pAC->RxPort[i].pRxDescrRing = pDescrMem;
1319 pAC->RxPort[i].VRxDescrRing = BusAddr;
1320 pDescrMem += RX_RING_SIZE;
1321 BusAddr += RX_RING_SIZE;
1325 } /* BoardAllocMem */
1328 /****************************************************************************
1330 * BoardFreeMem - reverse of BoardAllocMem
1333 * Free all memory allocated in BoardAllocMem: adapter context,
1334 * descriptor rings, locks.
1338 static void BoardFreeMem(
1341 size_t AllocLength; /* length of complete descriptor area */
1343 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1344 ("BoardFreeMem\n"));
1345 #if (BITS_PER_LONG == 32)
1346 AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound + 8;
1348 AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound
1352 pci_free_consistent(pAC->PciDev, AllocLength,
1353 pAC->pDescrMem, pAC->pDescrMemDMA);
1354 pAC->pDescrMem = NULL;
1355 } /* BoardFreeMem */
1358 /*****************************************************************************
1360 * BoardInitMem - initiate the descriptor rings
1363 * This function sets the descriptor rings up in memory.
1364 * The adapter is initialized with the descriptor start addresses.
1368 static void BoardInitMem(
1369 SK_AC *pAC) /* pointer to adapter context */
1371 int i; /* loop counter */
1372 int RxDescrSize; /* the size of a rx descriptor rounded up to alignment*/
1373 int TxDescrSize; /* the size of a tx descriptor rounded up to alignment*/
1375 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1376 ("BoardInitMem\n"));
1378 RxDescrSize = (((sizeof(RXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN;
1379 pAC->RxDescrPerRing = RX_RING_SIZE / RxDescrSize;
1380 TxDescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN;
1381 pAC->TxDescrPerRing = TX_RING_SIZE / RxDescrSize;
1383 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
1386 pAC->TxPort[i][0].pTxDescrRing,
1387 pAC->TxPort[i][0].VTxDescrRing,
1388 (RXD**)&pAC->TxPort[i][0].pTxdRingHead,
1389 (RXD**)&pAC->TxPort[i][0].pTxdRingTail,
1390 (RXD**)&pAC->TxPort[i][0].pTxdRingPrev,
1391 &pAC->TxPort[i][0].TxdRingFree,
1395 pAC->RxPort[i].pRxDescrRing,
1396 pAC->RxPort[i].VRxDescrRing,
1397 &pAC->RxPort[i].pRxdRingHead,
1398 &pAC->RxPort[i].pRxdRingTail,
1399 &pAC->RxPort[i].pRxdRingPrev,
1400 &pAC->RxPort[i].RxdRingFree,
1403 } /* BoardInitMem */
1406 /*****************************************************************************
1408 * SetupRing - create one descriptor ring
1411 * This function creates one descriptor ring in the given memory area.
1412 * The head, tail and number of free descriptors in the ring are set.
1417 static void SetupRing(
1419 void *pMemArea, /* a pointer to the memory area for the ring */
1420 uintptr_t VMemArea, /* the virtual bus address of the memory area */
1421 RXD **ppRingHead, /* address where the head should be written */
1422 RXD **ppRingTail, /* address where the tail should be written */
1423 RXD **ppRingPrev, /* address where the tail should be written */
1424 int *pRingFree, /* address where the # of free descr. goes */
1425 SK_BOOL IsTx) /* flag: is this a tx ring */
1427 int i; /* loop counter */
1428 int DescrSize; /* the size of a descriptor rounded up to alignment*/
1429 int DescrNum; /* number of descriptors per ring */
1430 RXD *pDescr; /* pointer to a descriptor (receive or transmit) */
1431 RXD *pNextDescr; /* pointer to the next descriptor */
1432 RXD *pPrevDescr; /* pointer to the previous descriptor */
1433 uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */
1435 if (IsTx == SK_TRUE) {
1436 DescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) *
1438 DescrNum = TX_RING_SIZE / DescrSize;
1440 DescrSize = (((sizeof(RXD) - 1) / DESCR_ALIGN) + 1) *
1442 DescrNum = RX_RING_SIZE / DescrSize;
1445 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
1446 ("Descriptor size: %d Descriptor Number: %d\n",
1447 DescrSize,DescrNum));
1449 pDescr = (RXD*) pMemArea;
1451 pNextDescr = (RXD*) (((char*)pDescr) + DescrSize);
1452 VNextDescr = VMemArea + DescrSize;
1453 for(i=0; i<DescrNum; i++) {
1454 /* set the pointers right */
1455 pDescr->VNextRxd = VNextDescr & 0xffffffffULL;
1456 pDescr->pNextRxd = pNextDescr;
1457 pDescr->TcpSumStarts = pAC->CsOfs;
1459 /* advance one step */
1460 pPrevDescr = pDescr;
1461 pDescr = pNextDescr;
1462 pNextDescr = (RXD*) (((char*)pDescr) + DescrSize);
1463 VNextDescr += DescrSize;
1465 pPrevDescr->pNextRxd = (RXD*) pMemArea;
1466 pPrevDescr->VNextRxd = VMemArea;
1467 pDescr = (RXD*) pMemArea;
1468 *ppRingHead = (RXD*) pMemArea;
1469 *ppRingTail = *ppRingHead;
1470 *ppRingPrev = pPrevDescr;
1471 *pRingFree = DescrNum;
1475 /*****************************************************************************
1477 * PortReInitBmu - re-initiate the descriptor rings for one port
1480 * This function reinitializes the descriptor rings of one port
1481 * in memory. The port must be stopped before.
1482 * The HW is initialized with the descriptor start addresses.
1487 static void PortReInitBmu(
1488 SK_AC *pAC, /* pointer to adapter context */
1489 int PortIndex) /* index of the port for which to re-init */
1491 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1492 ("PortReInitBmu "));
1494 /* set address of first descriptor of ring in BMU */
1495 SK_OUT32(pAC->IoBase, TxQueueAddr[PortIndex][TX_PRIO_LOW]+
1497 (uint32_t)(((caddr_t)
1498 (pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxdRingHead) -
1499 pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxDescrRing +
1500 pAC->TxPort[PortIndex][TX_PRIO_LOW].VTxDescrRing) &
1502 SK_OUT32(pAC->IoBase, TxQueueAddr[PortIndex][TX_PRIO_LOW]+
1504 (uint32_t)(((caddr_t)
1505 (pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxdRingHead) -
1506 pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxDescrRing +
1507 pAC->TxPort[PortIndex][TX_PRIO_LOW].VTxDescrRing) >> 32));
1508 SK_OUT32(pAC->IoBase, RxQueueAddr[PortIndex]+RX_Q_CUR_DESCR_LOW,
1509 (uint32_t)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) -
1510 pAC->RxPort[PortIndex].pRxDescrRing +
1511 pAC->RxPort[PortIndex].VRxDescrRing) & 0xFFFFFFFF));
1512 SK_OUT32(pAC->IoBase, RxQueueAddr[PortIndex]+RX_Q_DESCR_HIGH,
1513 (uint32_t)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) -
1514 pAC->RxPort[PortIndex].pRxDescrRing +
1515 pAC->RxPort[PortIndex].VRxDescrRing) >> 32));
1516 } /* PortReInitBmu */
1519 /****************************************************************************
1521 * SkGeIsr - handle adapter interrupts
1524 * The interrupt routine is called when the network adapter
1525 * generates an interrupt. It may also be called if another device
1526 * shares this interrupt vector with the driver.
1532 static void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
1534 void SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs)
1537 struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id;
1540 SK_U32 IntSrc; /* interrupts source register contents */
1542 pNet = (DEV_NET*) dev->priv;
1546 * Check and process if its our interrupt
1548 SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc);
1553 while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
1554 #if 0 /* software irq currently not used */
1555 if (IntSrc & IRQ_SW) {
1556 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1557 SK_DBGCAT_DRV_INT_SRC,
1558 ("Software IRQ\n"));
1561 if (IntSrc & IRQ_EOF_RX1) {
1562 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1563 SK_DBGCAT_DRV_INT_SRC,
1565 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1566 SK_PNMI_CNT_RX_INTR(pAC, 0);
1568 if (IntSrc & IRQ_EOF_RX2) {
1569 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1570 SK_DBGCAT_DRV_INT_SRC,
1572 ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1573 SK_PNMI_CNT_RX_INTR(pAC, 1);
1575 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1576 if (IntSrc & IRQ_EOF_AS_TX1) {
1577 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1578 SK_DBGCAT_DRV_INT_SRC,
1579 ("EOF AS TX1 IRQ\n"));
1580 SK_PNMI_CNT_TX_INTR(pAC, 0);
1581 spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1582 FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
1583 spin_unlock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1585 if (IntSrc & IRQ_EOF_AS_TX2) {
1586 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1587 SK_DBGCAT_DRV_INT_SRC,
1588 ("EOF AS TX2 IRQ\n"));
1589 SK_PNMI_CNT_TX_INTR(pAC, 1);
1590 spin_lock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock);
1591 FreeTxDescriptors(pAC, &pAC->TxPort[1][TX_PRIO_LOW]);
1592 spin_unlock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock);
1594 #if 0 /* only if sync. queues used */
1595 if (IntSrc & IRQ_EOF_SY_TX1) {
1596 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1597 SK_DBGCAT_DRV_INT_SRC,
1598 ("EOF SY TX1 IRQ\n"));
1599 SK_PNMI_CNT_TX_INTR(pAC, 1);
1600 spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1601 FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH);
1602 spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1603 ClearTxIrq(pAC, 0, TX_PRIO_HIGH);
1605 if (IntSrc & IRQ_EOF_SY_TX2) {
1606 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1607 SK_DBGCAT_DRV_INT_SRC,
1608 ("EOF SY TX2 IRQ\n"));
1609 SK_PNMI_CNT_TX_INTR(pAC, 1);
1610 spin_lock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock);
1611 FreeTxDescriptors(pAC, 1, TX_PRIO_HIGH);
1612 spin_unlock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock);
1613 ClearTxIrq(pAC, 1, TX_PRIO_HIGH);
1618 /* do all IO at once */
1619 if (IntSrc & IRQ_EOF_RX1)
1620 ClearAndStartRx(pAC, 0);
1621 if (IntSrc & IRQ_EOF_RX2)
1622 ClearAndStartRx(pAC, 1);
1623 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1624 if (IntSrc & IRQ_EOF_AS_TX1)
1625 ClearTxIrq(pAC, 0, TX_PRIO_LOW);
1626 if (IntSrc & IRQ_EOF_AS_TX2)
1627 ClearTxIrq(pAC, 1, TX_PRIO_LOW);
1629 SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc);
1630 } /* while (IntSrc & IRQ_MASK != 0) */
1632 if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) {
1633 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
1634 ("SPECIAL IRQ DP-Cards => %x\n", IntSrc));
1635 pAC->CheckQueue = SK_FALSE;
1636 spin_lock(&pAC->SlowPathLock);
1637 if (IntSrc & SPECIAL_IRQS)
1638 SkGeSirqIsr(pAC, pAC->IoBase, IntSrc);
1640 SkEventDispatcher(pAC, pAC->IoBase);
1641 spin_unlock(&pAC->SlowPathLock);
1644 * do it all again is case we cleared an interrupt that
1645 * came in after handling the ring (OUTs may be delayed
1646 * in hardware buffers, but are through after IN)
1649 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1650 ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE);
1652 if (pAC->CheckQueue) {
1653 pAC->CheckQueue = SK_FALSE;
1654 spin_lock(&pAC->SlowPathLock);
1655 SkEventDispatcher(pAC, pAC->IoBase);
1656 spin_unlock(&pAC->SlowPathLock);
1660 /* IRQ is processed - Enable IRQs again*/
1661 SK_OUT32(pAC->IoBase, B0_IMSK, IRQ_MASK);
1667 /****************************************************************************
1669 * SkGeIsrOnePort - handle adapter interrupts for single port adapter
1672 * The interrupt routine is called when the network adapter
1673 * generates an interrupt. It may also be called if another device
1674 * shares this interrupt vector with the driver.
1675 * This is the same as above, but handles only one port.
1681 static void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
1683 void SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs)
1686 struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id;
1689 SK_U32 IntSrc; /* interrupts source register contents */
1691 pNet = (DEV_NET*) dev->priv;
1695 * Check and process if its our interrupt
1697 SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc);
1702 while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) {
1703 #if 0 /* software irq currently not used */
1704 if (IntSrc & IRQ_SW) {
1705 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1706 SK_DBGCAT_DRV_INT_SRC,
1707 ("Software IRQ\n"));
1710 if (IntSrc & IRQ_EOF_RX1) {
1711 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1712 SK_DBGCAT_DRV_INT_SRC,
1714 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1715 SK_PNMI_CNT_RX_INTR(pAC, 0);
1717 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1718 if (IntSrc & IRQ_EOF_AS_TX1) {
1719 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1720 SK_DBGCAT_DRV_INT_SRC,
1721 ("EOF AS TX1 IRQ\n"));
1722 SK_PNMI_CNT_TX_INTR(pAC, 0);
1723 spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1724 FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]);
1725 spin_unlock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock);
1727 #if 0 /* only if sync. queues used */
1728 if (IntSrc & IRQ_EOF_SY_TX1) {
1729 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
1730 SK_DBGCAT_DRV_INT_SRC,
1731 ("EOF SY TX1 IRQ\n"));
1732 SK_PNMI_CNT_TX_INTR(pAC, 0);
1733 spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1734 FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH);
1735 spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock);
1736 ClearTxIrq(pAC, 0, TX_PRIO_HIGH);
1741 /* do all IO at once */
1742 if (IntSrc & IRQ_EOF_RX1)
1743 ClearAndStartRx(pAC, 0);
1744 #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */
1745 if (IntSrc & IRQ_EOF_AS_TX1)
1746 ClearTxIrq(pAC, 0, TX_PRIO_LOW);
1748 SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc);
1749 } /* while (IntSrc & IRQ_MASK != 0) */
1751 if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) {
1752 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC,
1753 ("SPECIAL IRQ SP-Cards => %x\n", IntSrc));
1754 pAC->CheckQueue = SK_FALSE;
1755 spin_lock(&pAC->SlowPathLock);
1756 if (IntSrc & SPECIAL_IRQS)
1757 SkGeSirqIsr(pAC, pAC->IoBase, IntSrc);
1759 SkEventDispatcher(pAC, pAC->IoBase);
1760 spin_unlock(&pAC->SlowPathLock);
1763 * do it all again is case we cleared an interrupt that
1764 * came in after handling the ring (OUTs may be delayed
1765 * in hardware buffers, but are through after IN)
1767 ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE);
1769 /* IRQ is processed - Enable IRQs again*/
1770 SK_OUT32(pAC->IoBase, B0_IMSK, IRQ_MASK);
1773 } /* SkGeIsrOnePort */
1776 /****************************************************************************
1778 * SkGeOpen - handle start of initialized adapter
1781 * This function starts the initialized adapter.
1782 * The board level variable is set and the adapter is
1783 * brought to full functionality.
1784 * The device flags are set for operation.
1785 * Do all necessary level 2 initialization, enable interrupts and
1786 * give start command to RLMT.
1793 static int SkGeOpen(
1797 struct SK_NET_DEVICE *dev)
1801 unsigned long Flags; /* for spin lock */
1803 SK_EVPARA EvPara; /* an event parameter union */
1805 pNet = (DEV_NET*) dev->priv;
1808 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1809 ("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC));
1811 if (pAC->BoardLevel == 0) {
1812 /* level 1 init common modules here */
1813 if (SkGeInit(pAC, pAC->IoBase, 1) != 0) {
1814 printk("%s: HWInit (1) failed.\n", pAC->dev[pNet->PortNr]->name);
1817 SkI2cInit (pAC, pAC->IoBase, 1);
1818 SkEventInit (pAC, pAC->IoBase, 1);
1819 SkPnmiInit (pAC, pAC->IoBase, 1);
1820 SkAddrInit (pAC, pAC->IoBase, 1);
1821 SkRlmtInit (pAC, pAC->IoBase, 1);
1822 SkTimerInit (pAC, pAC->IoBase, 1);
1823 pAC->BoardLevel = 1;
1826 if (pAC->BoardLevel != 2) {
1827 /* tschilling: Level 2 init modules here, check return value. */
1828 if (SkGeInit(pAC, pAC->IoBase, 2) != 0) {
1829 printk("%s: HWInit (2) failed.\n", pAC->dev[pNet->PortNr]->name);
1832 SkI2cInit (pAC, pAC->IoBase, 2);
1833 SkEventInit (pAC, pAC->IoBase, 2);
1834 SkPnmiInit (pAC, pAC->IoBase, 2);
1835 SkAddrInit (pAC, pAC->IoBase, 2);
1836 SkRlmtInit (pAC, pAC->IoBase, 2);
1837 SkTimerInit (pAC, pAC->IoBase, 2);
1838 pAC->BoardLevel = 2;
1841 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
1842 /* Enable transmit descriptor polling. */
1843 SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE);
1844 FillRxRing(pAC, &pAC->RxPort[i]);
1846 SkGeYellowLED(pAC, pAC->IoBase, 1);
1849 /* moderate only TX complete interrupts (these are not time critical) */
1850 #define IRQ_MOD_MASK (IRQ_EOF_AS_TX1 | IRQ_EOF_AS_TX2)
1852 unsigned long ModBase;
1853 ModBase = 53125000 / INTS_PER_SEC;
1854 SK_OUT32(pAC->IoBase, B2_IRQM_INI, ModBase);
1855 SK_OUT32(pAC->IoBase, B2_IRQM_MSK, IRQ_MOD_MASK);
1856 SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_START);
1860 /* enable Interrupts */
1861 SK_OUT32(pAC->IoBase, B0_IMSK, IRQ_MASK);
1862 SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK);
1864 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1866 if ((pAC->RlmtMode != 0) && (pAC->MaxPorts == 0)) {
1867 EvPara.Para32[0] = pAC->RlmtNets;
1868 EvPara.Para32[1] = -1;
1869 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS,
1871 EvPara.Para32[0] = pAC->RlmtMode;
1872 EvPara.Para32[1] = 0;
1873 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_MODE_CHANGE,
1877 EvPara.Para32[0] = pNet->NetNr;
1878 EvPara.Para32[1] = -1;
1879 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
1880 SkEventDispatcher(pAC, pAC->IoBase);
1881 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1888 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1889 ("SkGeOpen suceeded\n"));
1895 /****************************************************************************
1897 * SkGeClose - Stop initialized adapter
1900 * Close initialized adapter.
1904 * error code - on error
1907 static int SkGeClose(
1911 struct SK_NET_DEVICE *dev)
1916 unsigned long Flags; /* for spin lock */
1921 netif_stop_queue(dev);
1922 pNet = (DEV_NET*) dev->priv;
1925 if (pAC->RlmtNets == 1)
1926 PortIdx = pAC->ActivePort;
1928 PortIdx = pNet->NetNr;
1930 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1931 ("SkGeClose: pAC=0x%lX ", (unsigned long)pAC));
1934 * Clear multicast table, promiscuous mode ....
1936 SkAddrMcClear(pAC, pAC->IoBase, PortIdx, 0);
1937 SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx,
1940 if (pAC->MaxPorts == 1) {
1941 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1942 /* disable interrupts */
1943 SK_OUT32(pAC->IoBase, B0_IMSK, 0);
1944 EvPara.Para32[0] = pNet->NetNr;
1945 EvPara.Para32[1] = -1;
1946 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
1947 SkEventDispatcher(pAC, pAC->IoBase);
1948 SK_OUT32(pAC->IoBase, B0_IMSK, 0);
1949 /* stop the hardware */
1950 SkGeDeInit(pAC, pAC->IoBase);
1951 pAC->BoardLevel = 0;
1952 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1955 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
1956 EvPara.Para32[0] = pNet->NetNr;
1957 EvPara.Para32[1] = -1;
1958 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
1959 SkEventDispatcher(pAC, pAC->IoBase);
1960 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
1963 spin_lock_irqsave(&pAC->TxPort[pNet->PortNr]
1964 [TX_PRIO_LOW].TxDesRingLock, Flags);
1965 SkGeStopPort(pAC, pAC->IoBase, pNet->PortNr,
1966 SK_STOP_ALL, SK_HARD_RST);
1967 spin_unlock_irqrestore(&pAC->TxPort[pNet->PortNr]
1968 [TX_PRIO_LOW].TxDesRingLock, Flags);
1971 if (pAC->RlmtNets == 1) {
1972 /* clear all descriptor rings */
1973 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
1974 ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE);
1975 ClearRxRing(pAC, &pAC->RxPort[i]);
1976 ClearTxRing(pAC, &pAC->TxPort[i][TX_PRIO_LOW]);
1979 /* clear port descriptor rings */
1980 ReceiveIrq(pAC, &pAC->RxPort[pNet->PortNr], SK_TRUE);
1981 ClearRxRing(pAC, &pAC->RxPort[pNet->PortNr]);
1982 ClearTxRing(pAC, &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW]);
1985 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
1986 ("SkGeClose: done "));
1996 /*****************************************************************************
1998 * SkGeXmit - Linux frame transmit function
2001 * The system calls this function to send frames onto the wire.
2002 * It puts the frame in the tx descriptor ring. If the ring is
2003 * full then, the 'tbusy' flag is set.
2006 * 0, if everything is ok
2008 * WARNING: returning 1 in 'tbusy' case caused system crashes (double
2009 * allocated skb's) !!!
2012 static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev)
2014 int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev)
2019 int Rc; /* return code of XmitFrame */
2021 pNet = (DEV_NET*) dev->priv;
2025 if ((!skb_shinfo(skb)->nr_frags) ||
2029 (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) {
2030 /* Don't activate scatter-gather and hardware checksum */
2032 if (pAC->RlmtNets == 2)
2035 &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW],
2040 &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW],
2044 /* scatter-gather and hardware TCP checksumming anabled*/
2045 if (pAC->RlmtNets == 2)
2048 &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW],
2053 &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW],
2058 /* Transmitter out of resources? */
2060 netif_stop_queue(dev);
2063 /* If not taken, give buffer ownership back to the
2070 dev->trans_start = jiffies;
2076 /*****************************************************************************
2078 * XmitFrame - fill one socket buffer into the transmit ring
2081 * This function puts a message into the transmit descriptor ring
2082 * if there is a descriptors left.
2083 * Linux skb's consist of only one continuous buffer.
2084 * The first step locks the ring. It is held locked
2085 * all time to avoid problems with SWITCH_../PORT_RESET.
2086 * Then the descriptoris allocated.
2087 * The second part is linking the buffer to the descriptor.
2088 * At the very last, the Control field of the descriptor
2089 * is made valid for the BMU and a start TX command is given
2093 * > 0 - on succes: the number of bytes in the message
2094 * = 0 - on resource shortage: this frame sent or dropped, now
2095 * the ring is full ( -> set tbusy)
2096 * < 0 - on failure: other problems ( -> return failure to upper layers)
2098 static int XmitFrame(
2099 SK_AC *pAC, /* pointer to adapter context */
2100 TX_PORT *pTxPort, /* pointer to struct of port to send to */
2101 struct sk_buff *pMessage) /* pointer to send-message */
2103 TXD *pTxd; /* the rxd to fill */
2104 unsigned long Flags;
2108 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
2111 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
2112 #ifndef USE_TX_COMPLETE
2113 FreeTxDescriptors(pAC, pTxPort);
2115 if (pTxPort->TxdRingFree == 0) {
2116 /* no enough free descriptors in ring at the moment */
2117 FreeTxDescriptors(pAC, pTxPort);
2118 if (pTxPort->TxdRingFree == 0) {
2119 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
2120 SK_PNMI_CNT_NO_TX_BUF(pAC, pTxPort->PortIndex);
2121 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2122 SK_DBGCAT_DRV_TX_PROGRESS,
2123 ("XmitFrame failed\n"));
2124 /* this message can not be sent now */
2125 /* Because tbusy seems to be set, the message should not be freed here */
2126 /* It will be used by the scheduler of the ethernet handler */
2130 /* advance head counter behind descriptor needed for this frame */
2131 pTxd = pTxPort->pTxdRingHead;
2132 pTxPort->pTxdRingHead = pTxd->pNextTxd;
2133 pTxPort->TxdRingFree--;
2134 /* the needed descriptor is reserved now */
2137 * everything allocated ok, so add buffer to descriptor
2141 DumpMsg(pMessage, "XmitFrame");
2144 /* set up descriptor and CONTROL dword */
2146 PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
2147 virt_to_page(pMessage->data),
2148 ((unsigned long) pMessage->data &
2153 PhysAddr = (SK_U64) pci_phys_to_mem(pAC->PciDev, (u32) pMessage->data);
2155 pTxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff);
2156 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
2157 pTxd->pMBuf = pMessage;
2158 pTxd->TBControl = TX_CTRL_OWN_BMU | TX_CTRL_STF |
2159 TX_CTRL_CHECK_DEFAULT | TX_CTRL_SOFTWARE |
2160 #ifdef USE_TX_COMPLETE
2161 TX_CTRL_EOF | TX_CTRL_EOF_IRQ | pMessage->len;
2163 TX_CTRL_EOF | pMessage->len;
2166 if ((pTxPort->pTxdRingPrev->TBControl & TX_CTRL_OWN_BMU) == 0) {
2167 /* previous descriptor already done, so give tx start cmd */
2168 /* StartTx(pAC, pTxPort->HwAddr); */
2169 SK_OUT8(pTxPort->HwAddr, TX_Q_CTRL, TX_Q_CTRL_START);
2171 pTxPort->pTxdRingPrev = pTxd;
2174 BytesSend = pMessage->len;
2175 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
2176 /* after releasing the lock, the skb may be immidiately freed */
2177 if (pTxPort->TxdRingFree != 0)
2184 /*****************************************************************************
2186 * XmitFrameSG - fill one socket buffer into the transmit ring
2187 * (use SG and TCP/UDP hardware checksumming)
2190 * This function puts a message into the transmit descriptor ring
2191 * if there is a descriptors left.
2194 * > 0 - on succes: the number of bytes in the message
2195 * = 0 - on resource shortage: this frame sent or dropped, now
2196 * the ring is full ( -> set tbusy)
2197 * < 0 - on failure: other problems ( -> return failure to upper layers)
2200 static int XmitFrameSG(
2201 SK_AC *pAC, /* pointer to adapter context */
2202 TX_PORT *pTxPort, /* pointer to struct of port to send to */
2203 struct sk_buff *pMessage) /* pointer to send-message */
2210 skb_frag_t *sk_frag;
2215 unsigned long Flags;
2217 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
2218 #ifndef USE_TX_COMPLETE
2219 FreeTxDescriptors(pAC, pTxPort);
2221 if ((skb_shinfo(pMessage)->nr_frags +1) > pTxPort->TxdRingFree) {
2222 FreeTxDescriptors(pAC, pTxPort);
2223 if ((skb_shinfo(pMessage)->nr_frags + 1) > pTxPort->TxdRingFree) {
2224 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
2225 SK_PNMI_CNT_NO_TX_BUF(pAC, pTxPort->PortIndex);
2226 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2227 SK_DBGCAT_DRV_TX_PROGRESS,
2228 ("XmitFrameSG failed - Ring full\n"));
2229 /* this message can not be sent now */
2235 pTxd = pTxPort->pTxdRingHead;
2241 /* map first fragment (header) */
2242 PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
2243 virt_to_page(pMessage->data),
2244 ((unsigned long) pMessage->data & ~PAGE_MASK),
2245 skb_headlen(pMessage),
2248 pTxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff);
2249 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
2252 if (pMessage->ip_summed == CHECKSUM_HW) {
2253 pTxd->TBControl = TX_CTRL_STF |
2255 skb_headlen(pMessage);
2257 /* We have to use the opcode for tcp here because the opcode for
2258 udp is not working in the hardware yet (revision 2.0)*/
2259 protocol = ((SK_U8)pMessage->data[23] & 0xf);
2260 if ((protocol == 17) && (pAC->GIni.GIChipRev != 0))
2261 pTxd->TBControl |= BMU_UDP_CHECK;
2263 pTxd->TBControl |= BMU_TCP_CHECK ;
2265 hlength = ((SK_U8)pMessage->data[14] & 0xf) * 4;
2266 pTxd->TcpSumOfs = 0; /* PH-Checksum already claculated */
2267 pTxd->TcpSumSt = 14+hlength+16;
2268 pTxd->TcpSumWr = 14+hlength;
2271 pTxd->TBControl = TX_CTRL_CHECK_DEFAULT |
2274 skb_headlen(pMessage);
2277 pTxd = pTxd->pNextTxd;
2278 pTxPort->TxdRingFree--;
2279 BytesSend += skb_headlen(pMessage);
2282 /* Map SG fragments */
2283 for (i = 0; i < skb_shinfo(pMessage)->nr_frags; i++) {
2284 sk_frag = &skb_shinfo(pMessage)->frags[i];
2286 /* we already have the proper value in entry */
2287 PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
2289 sk_frag->page_offset,
2293 pTxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff);
2294 pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
2295 pTxd->pMBuf = pMessage;
2298 if (pMessage->ip_summed == CHECKSUM_HW) {
2299 pTxd->TBControl = TX_CTRL_OWN_BMU |
2303 /* We have to use the opcode for tcp here because the opcode for
2304 udp is not working in the hardware yet (revision 2.0)*/
2305 if ((protocol == 17) && (pAC->GIni.GIChipRev != 0))
2306 pTxd->TBControl |= BMU_UDP_CHECK ;
2308 pTxd->TBControl |= BMU_TCP_CHECK ;
2311 pTxd->TBControl = TX_CTRL_CHECK_DEFAULT |
2317 if( (i+1) == skb_shinfo(pMessage)->nr_frags ) {
2318 #ifdef USE_TX_COMPLETE
2319 pTxd->TBControl |= TX_CTRL_EOF |
2323 pTxd->TBControl |= TX_CTRL_EOF |
2326 pTxdFst->TBControl |= TX_CTRL_OWN_BMU |
2330 pTxd->TBControl |= sk_frag->size;
2333 pTxd = pTxd->pNextTxd;
2334 pTxPort->TxdRingFree--;
2335 BytesSend += sk_frag->size;
2338 if ((pTxPort->pTxdRingPrev->TBControl & TX_CTRL_OWN_BMU) == 0) {
2339 /* previous descriptor already done, so give tx start cmd */
2340 /* StartTx(pAC, pTxPort->HwAddr); */
2341 SK_OUT8(pTxPort->HwAddr, TX_Q_CTRL, TX_Q_CTRL_START);
2344 pTxPort->pTxdRingPrev = pTxdLst;
2345 pTxPort->pTxdRingHead = pTxd;
2347 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
2349 if (pTxPort->TxdRingFree > 0)
2357 void dump_frag( SK_U8 *data, int length)
2361 printk("Length: %d\n", length);
2362 for( i=0; i < length; i++ ) {
2363 printk(" %02x", (SK_U8)*(data + i) );
2372 /*****************************************************************************
2374 * FreeTxDescriptors - release descriptors from the descriptor ring
2377 * This function releases descriptors from a transmit ring if they
2378 * have been sent by the BMU.
2379 * If a descriptors is sent, it can be freed and the message can
2381 * The SOFTWARE controllable bit is used to prevent running around a
2382 * completely free ring for ever. If this bit is no set in the
2383 * frame (by XmitFrame), this frame has never been sent or is
2385 * The Tx descriptor ring lock must be held while calling this function !!!
2390 static void FreeTxDescriptors(
2391 SK_AC *pAC, /* pointer to the adapter context */
2392 TX_PORT *pTxPort) /* pointer to destination port structure */
2394 TXD *pTxd; /* pointer to the checked descriptor */
2395 TXD *pNewTail; /* pointer to 'end' of the ring */
2396 SK_U32 Control; /* TBControl field of descriptor */
2397 SK_U64 PhysAddr; /* address of DMA mapping */
2399 pNewTail = pTxPort->pTxdRingTail;
2402 * loop forever; exits if TX_CTRL_SOFTWARE bit not set in start frame
2403 * or TX_CTRL_OWN_BMU bit set in any frame
2406 Control = pTxd->TBControl;
2407 if ((Control & TX_CTRL_SOFTWARE) == 0) {
2409 * software controllable bit is set in first
2410 * fragment when given to BMU. Not set means that
2411 * this fragment was never sent or is already
2412 * freed ( -> ring completely free now).
2414 pTxPort->pTxdRingTail = pTxd;
2415 netif_wake_queue(pAC->dev[pTxPort->PortIndex]);
2418 if (Control & TX_CTRL_OWN_BMU) {
2419 pTxPort->pTxdRingTail = pTxd;
2420 if (pTxPort->TxdRingFree > 0) {
2421 netif_wake_queue(pAC->dev[pTxPort->PortIndex]);
2426 /* release the DMA mapping */
2427 PhysAddr = ((SK_U64) pTxd->VDataHigh) << (SK_U64) 32;
2428 PhysAddr |= (SK_U64) pTxd->VDataLow;
2429 pci_unmap_page(pAC->PciDev, PhysAddr,
2433 if (Control & TX_CTRL_EOF)
2434 DEV_KFREE_SKB_ANY(pTxd->pMBuf); /* free message */
2436 pTxPort->TxdRingFree++;
2437 pTxd->TBControl &= ~TX_CTRL_SOFTWARE;
2438 pTxd = pTxd->pNextTxd; /* point behind fragment with EOF */
2439 } /* while(forever) */
2440 } /* FreeTxDescriptors */
2442 /*****************************************************************************
2444 * FillRxRing - fill the receive ring with valid descriptors
2447 * This function fills the receive ring descriptors with data
2448 * segments and makes them valid for the BMU.
2449 * The active ring is filled completely, if possible.
2450 * The non-active ring is filled only partial to save memory.
2452 * Description of rx ring structure:
2453 * head - points to the descriptor which will be used next by the BMU
2454 * tail - points to the next descriptor to give to the BMU
2458 static void FillRxRing(
2459 SK_AC *pAC, /* pointer to the adapter context */
2460 RX_PORT *pRxPort) /* ptr to port struct for which the ring
2463 unsigned long Flags;
2465 spin_lock_irqsave(&pRxPort->RxDesRingLock, Flags);
2466 while (pRxPort->RxdRingFree > pRxPort->RxFillLimit) {
2467 if(!FillRxDescriptor(pAC, pRxPort))
2470 spin_unlock_irqrestore(&pRxPort->RxDesRingLock, Flags);
2474 /*****************************************************************************
2476 * FillRxDescriptor - fill one buffer into the receive ring
2479 * The function allocates a new receive buffer and
2480 * puts it into the next descriptor.
2483 * SK_TRUE - a buffer was added to the ring
2484 * SK_FALSE - a buffer could not be added
2486 static SK_BOOL FillRxDescriptor(
2487 SK_AC *pAC, /* pointer to the adapter context struct */
2488 RX_PORT *pRxPort) /* ptr to port struct of ring to fill */
2490 struct sk_buff *pMsgBlock; /* pointer to a new message block */
2491 RXD *pRxd; /* the rxd to fill */
2492 SK_U16 Length; /* data fragment length */
2493 SK_U64 PhysAddr; /* physical address of a rx buffer */
2495 pMsgBlock = alloc_skb(pAC->RxBufSize, GFP_ATOMIC);
2496 if (pMsgBlock == NULL) {
2497 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2498 SK_DBGCAT_DRV_ENTRY,
2499 ("%s: Allocation of rx buffer failed !\n",
2500 pAC->dev[pRxPort->PortIndex]->name));
2501 SK_PNMI_CNT_NO_RX_BUF(pAC, pRxPort->PortIndex);
2504 skb_reserve(pMsgBlock, 2); /* to align IP frames */
2505 /* skb allocated ok, so add buffer */
2506 pRxd = pRxPort->pRxdRingTail;
2507 pRxPort->pRxdRingTail = pRxd->pNextRxd;
2508 pRxPort->RxdRingFree--;
2509 Length = pAC->RxBufSize;
2511 PhysAddr = (SK_U64) pci_map_page(pAC->PciDev,
2512 virt_to_page(pMsgBlock->data),
2513 ((unsigned long) pMsgBlock->data &
2516 PCI_DMA_FROMDEVICE);
2518 PhysAddr = (SK_U64) pci_phys_to_mem(pAC->PciDev, (u32)pMsgBlock->data);
2520 pRxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff);
2521 pRxd->VDataHigh = (SK_U32) (PhysAddr >> 32);
2522 pRxd->pMBuf = pMsgBlock;
2523 pRxd->RBControl = RX_CTRL_OWN_BMU | RX_CTRL_STF |
2524 RX_CTRL_EOF_IRQ | RX_CTRL_CHECK_CSUM | Length;
2527 } /* FillRxDescriptor */
2530 /*****************************************************************************
2532 * ReQueueRxBuffer - fill one buffer back into the receive ring
2535 * Fill a given buffer back into the rx ring. The buffer
2536 * has been previously allocated and aligned, and its phys.
2537 * address calculated, so this is no more necessary.
2541 static void ReQueueRxBuffer(
2542 SK_AC *pAC, /* pointer to the adapter context struct */
2543 RX_PORT *pRxPort, /* ptr to port struct of ring to fill */
2544 struct sk_buff *pMsg, /* pointer to the buffer */
2545 SK_U32 PhysHigh, /* phys address high dword */
2546 SK_U32 PhysLow) /* phys address low dword */
2548 RXD *pRxd; /* the rxd to fill */
2549 SK_U16 Length; /* data fragment length */
2551 pRxd = pRxPort->pRxdRingTail;
2552 pRxPort->pRxdRingTail = pRxd->pNextRxd;
2553 pRxPort->RxdRingFree--;
2554 Length = pAC->RxBufSize;
2555 pRxd->VDataLow = PhysLow;
2556 pRxd->VDataHigh = PhysHigh;
2558 pRxd->RBControl = RX_CTRL_OWN_BMU | RX_CTRL_STF |
2559 RX_CTRL_EOF_IRQ | RX_CTRL_CHECK_CSUM | Length;
2561 } /* ReQueueRxBuffer */
2564 /*****************************************************************************
2566 * ReceiveIrq - handle a receive IRQ
2569 * This function is called when a receive IRQ is set.
2570 * It walks the receive descriptor ring and sends up all
2571 * frames that are complete.
2576 static void ReceiveIrq(
2580 SK_AC *pAC, /* pointer to adapter context */
2581 RX_PORT *pRxPort, /* pointer to receive port struct */
2582 SK_BOOL SlowPathLock) /* indicates if SlowPathLock is needed */
2584 RXD *pRxd; /* pointer to receive descriptors */
2585 SK_U32 Control; /* control field of descriptor */
2586 struct sk_buff *pMsg; /* pointer to message holding frame */
2587 struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */
2588 int FrameLength; /* total length of received frame */
2589 SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */
2590 SK_EVPARA EvPara; /* an event parameter union */
2591 unsigned long Flags; /* for spin lock */
2592 int PortIndex = pRxPort->PortIndex;
2593 unsigned int Offset;
2594 unsigned int NumBytes;
2595 unsigned int ForRlmt;
2598 SK_BOOL IsBadFrame; /* Bad frame */
2601 unsigned short Csum1;
2602 unsigned short Csum2;
2603 unsigned short Type;
2610 /* do forever; exit if RX_CTRL_OWN_BMU found */
2611 for ( pRxd = pRxPort->pRxdRingHead ;
2612 pRxPort->RxdRingFree < pAC->RxDescrPerRing ;
2613 pRxd = pRxd->pNextRxd,
2614 pRxPort->pRxdRingHead = pRxd,
2615 pRxPort->RxdRingFree ++) {
2618 * For a better understanding of this loop
2619 * Go through every descriptor beginning at the head
2620 * Please note: the ring might be completely received so the OWN bit
2621 * set is not a good crirteria to leave that loop.
2622 * Therefore the RingFree counter is used.
2623 * On entry of this loop pRxd is a pointer to the Rxd that needs
2624 * to be checked next.
2627 Control = pRxd->RBControl;
2629 /* check if this descriptor is ready */
2630 if ((Control & RX_CTRL_OWN_BMU) != 0) {
2631 /* this descriptor is not yet ready */
2632 /* This is the usual end of the loop */
2633 /* We don't need to start the ring again */
2634 FillRxRing(pAC, pRxPort);
2638 /* get length of frame and check it */
2639 FrameLength = Control & RX_CTRL_LEN_MASK;
2640 if (FrameLength > pAC->RxBufSize) {
2644 /* check for STF and EOF */
2645 if ((Control & (RX_CTRL_STF | RX_CTRL_EOF)) !=
2646 (RX_CTRL_STF | RX_CTRL_EOF)) {
2650 /* here we have a complete frame in the ring */
2653 FrameStat = pRxd->FrameStat;
2655 /* check for frame length mismatch */
2656 #define XMR_FS_LEN_SHIFT 18
2657 #define GMR_FS_LEN_SHIFT 16
2658 if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
2659 if (FrameLength != (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)) {
2660 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2661 SK_DBGCAT_DRV_RX_PROGRESS,
2662 ("skge: Frame length mismatch (%u/%u).\n",
2664 (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)));
2669 if (FrameLength != (SK_U32) (FrameStat >> GMR_FS_LEN_SHIFT)) {
2670 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2671 SK_DBGCAT_DRV_RX_PROGRESS,
2672 ("skge: Frame length mismatch (%u/%u).\n",
2674 (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)));
2680 if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) {
2681 IsBc = (FrameStat & XMR_FS_BC) != 0;
2682 IsMc = (FrameStat & XMR_FS_MC) != 0;
2683 IsBadFrame = (FrameStat &
2684 (XMR_FS_ANY_ERR | XMR_FS_2L_VLAN)) != 0;
2686 IsBc = (FrameStat & GMR_FS_BC) != 0;
2687 IsMc = (FrameStat & GMR_FS_MC) != 0;
2688 IsBadFrame = (((FrameStat & GMR_FS_ANY_ERR) != 0) ||
2689 ((FrameStat & GMR_FS_RX_OK) == 0));
2692 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 0,
2693 ("Received frame of length %d on port %d\n",
2694 FrameLength, PortIndex));
2695 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 0,
2696 ("Number of free rx descriptors: %d\n",
2697 pRxPort->RxdRingFree));
2698 /* DumpMsg(pMsg, "Rx"); */
2700 if ((Control & RX_CTRL_STAT_VALID) != RX_CTRL_STAT_VALID ||
2703 (FrameStat & (XMR_FS_ANY_ERR | XMR_FS_2L_VLAN)) != 0) {
2705 /* there is a receive error in this frame */
2706 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2707 SK_DBGCAT_DRV_RX_PROGRESS,
2708 ("skge: Error in received frame, dropped!\n"
2709 "Control: %x\nRxStat: %x\n",
2710 Control, FrameStat));
2712 PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
2713 PhysAddr |= (SK_U64) pRxd->VDataLow;
2714 pci_dma_sync_single(pAC->PciDev,
2715 (dma_addr_t) PhysAddr,
2717 PCI_DMA_FROMDEVICE);
2718 ReQueueRxBuffer(pAC, pRxPort, pMsg,
2719 pRxd->VDataHigh, pRxd->VDataLow);
2725 * if short frame then copy data to reduce memory waste
2727 if ((FrameLength < SK_COPY_THRESHOLD) &&
2728 ((pNewMsg = alloc_skb(FrameLength+2, GFP_ATOMIC)) != NULL)) {
2730 * Short frame detected and allocation successfull
2732 /* use new skb and copy data */
2733 skb_reserve(pNewMsg, 2);
2734 skb_put(pNewMsg, FrameLength);
2735 PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
2736 PhysAddr |= (SK_U64) pRxd->VDataLow;
2738 pci_dma_sync_single(pAC->PciDev,
2739 (dma_addr_t) PhysAddr,
2741 PCI_DMA_FROMDEVICE);
2742 eth_copy_and_sum(pNewMsg, pMsg->data,
2744 ReQueueRxBuffer(pAC, pRxPort, pMsg,
2745 pRxd->VDataHigh, pRxd->VDataLow);
2751 * if large frame, or SKB allocation failed, pass
2752 * the SKB directly to the networking
2755 PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
2756 PhysAddr |= (SK_U64) pRxd->VDataLow;
2758 /* release the DMA mapping */
2759 pci_unmap_single(pAC->PciDev,
2762 PCI_DMA_FROMDEVICE);
2764 /* set length in message */
2765 skb_put(pMsg, FrameLength);
2766 /* hardware checksum */
2767 Type = ntohs(*((short*)&pMsg->data[12]));
2768 if (Type == 0x800) {
2769 Csum1=le16_to_cpu(pRxd->TcpSums & 0xffff);
2770 Csum2=le16_to_cpu((pRxd->TcpSums >> 16) & 0xffff);
2772 if ((((Csum1 & 0xfffe) && (Csum2 & 0xfffe)) &&
2773 (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) ||
2774 (pAC->GIni.GIChipId == CHIP_ID_YUKON)) {
2775 Result = SkCsGetReceiveInfo(pAC,
2777 Csum1, Csum2, pRxPort->PortIndex);
2779 SKCS_STATUS_IP_FRAGMENT ||
2781 SKCS_STATUS_IP_CSUM_OK ||
2783 SKCS_STATUS_TCP_CSUM_OK ||
2785 SKCS_STATUS_UDP_CSUM_OK) {
2787 CHECKSUM_UNNECESSARY;
2789 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2790 SK_DBGCAT_DRV_RX_PROGRESS,
2791 ("skge: CRC error. Frame dropped!\n"));
2794 }/* checksumControl calculation valid */
2797 } /* frame > SK_COPY_TRESHOLD */
2799 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V"));
2800 ForRlmt = SK_RLMT_RX_PROTOCOL;
2802 IsBc = (FrameStat & XMR_FS_BC)==XMR_FS_BC;
2804 SK_RLMT_PRE_LOOKAHEAD(pAC, PortIndex, FrameLength,
2805 IsBc, &Offset, &NumBytes);
2806 if (NumBytes != 0) {
2808 IsMc = (FrameStat & XMR_FS_MC)==XMR_FS_MC;
2810 SK_RLMT_LOOKAHEAD(pAC, PortIndex,
2811 &pMsg->data[Offset],
2812 IsBc, IsMc, &ForRlmt);
2814 if (ForRlmt == SK_RLMT_RX_PROTOCOL) {
2815 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("W"));
2816 /* send up only frames from active port */
2817 if ((PortIndex == pAC->ActivePort) ||
2818 (pAC->RlmtNets == 2)) {
2819 /* frame for upper layer */
2820 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("U"));
2822 DumpMsg(pMsg, "Rx");
2824 SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC,
2825 FrameLength, pRxPort->PortIndex);
2828 pMsg->dev = pAC->dev[pRxPort->PortIndex];
2829 pMsg->protocol = eth_type_trans(pMsg,
2830 pAC->dev[pRxPort->PortIndex]);
2832 pAC->dev[pRxPort->PortIndex]->last_rx = jiffies;
2834 NetReceive(pMsg->data, pMsg->len);
2835 dev_kfree_skb_any(pMsg);
2840 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2841 SK_DBGCAT_DRV_RX_PROGRESS,
2843 DEV_KFREE_SKB(pMsg);
2846 } /* if not for rlmt */
2848 /* packet for rlmt */
2849 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2850 SK_DBGCAT_DRV_RX_PROGRESS, ("R"));
2851 pRlmtMbuf = SkDrvAllocRlmtMbuf(pAC,
2852 pAC->IoBase, FrameLength);
2853 if (pRlmtMbuf != NULL) {
2854 pRlmtMbuf->pNext = NULL;
2855 pRlmtMbuf->Length = FrameLength;
2856 pRlmtMbuf->PortIdx = PortIndex;
2857 EvPara.pParaPtr = pRlmtMbuf;
2858 memcpy((char*)(pRlmtMbuf->pData),
2859 (char*)(pMsg->data),
2862 /* SlowPathLock needed? */
2863 if (SlowPathLock == SK_TRUE) {
2864 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
2865 SkEventQueue(pAC, SKGE_RLMT,
2866 SK_RLMT_PACKET_RECEIVED,
2868 pAC->CheckQueue = SK_TRUE;
2869 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
2871 SkEventQueue(pAC, SKGE_RLMT,
2872 SK_RLMT_PACKET_RECEIVED,
2874 pAC->CheckQueue = SK_TRUE;
2877 SK_DBG_MSG(NULL, SK_DBGMOD_DRV,
2878 SK_DBGCAT_DRV_RX_PROGRESS,
2882 if ((pAC->dev[pRxPort->PortIndex]->flags &
2883 (IFF_PROMISC | IFF_ALLMULTI)) != 0 ||
2884 (ForRlmt & SK_RLMT_RX_PROTOCOL) ==
2885 SK_RLMT_RX_PROTOCOL) {
2886 pMsg->dev = pAC->dev[pRxPort->PortIndex];
2887 pMsg->protocol = eth_type_trans(pMsg,
2888 pAC->dev[pRxPort->PortIndex]);
2890 pAC->dev[pRxPort->PortIndex]->last_rx = jiffies;
2897 DEV_KFREE_SKB(pMsg);
2900 } /* if packet for rlmt */
2901 } /* for ... scanning the RXD ring */
2903 /* RXD ring is empty -> fill and restart */
2904 FillRxRing(pAC, pRxPort);
2905 /* do not start if called from Close */
2906 if (pAC->BoardLevel > 0) {
2907 ClearAndStartRx(pAC, PortIndex);
2912 /* remove error frame */
2913 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR,
2914 ("Schrottdescriptor, length: 0x%x\n", FrameLength));
2916 /* release the DMA mapping */
2918 PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
2919 PhysAddr |= (SK_U64) pRxd->VDataLow;
2920 pci_unmap_page(pAC->PciDev,
2923 PCI_DMA_FROMDEVICE);
2924 DEV_KFREE_SKB_IRQ(pRxd->pMBuf);
2926 pRxPort->RxdRingFree++;
2927 pRxPort->pRxdRingHead = pRxd->pNextRxd;
2933 /*****************************************************************************
2935 * ClearAndStartRx - give a start receive command to BMU, clear IRQ
2938 * This function sends a start command and a clear interrupt
2939 * command for one receive queue to the BMU.
2944 static void ClearAndStartRx(
2945 SK_AC *pAC, /* pointer to the adapter context */
2946 int PortIndex) /* index of the receive port (XMAC) */
2948 SK_OUT8(pAC->IoBase, RxQueueAddr[PortIndex]+RX_Q_CTRL,
2949 RX_Q_CTRL_START | RX_Q_CTRL_CLR_I_EOF);
2950 } /* ClearAndStartRx */
2953 /*****************************************************************************
2955 * ClearTxIrq - give a clear transmit IRQ command to BMU
2958 * This function sends a clear tx IRQ command for one
2959 * transmit queue to the BMU.
2963 static void ClearTxIrq(
2964 SK_AC *pAC, /* pointer to the adapter context */
2965 int PortIndex, /* index of the transmit port (XMAC) */
2966 int Prio) /* priority or normal queue */
2968 SK_OUT8(pAC->IoBase, TxQueueAddr[PortIndex][Prio]+TX_Q_CTRL,
2969 TX_Q_CTRL_CLR_I_EOF);
2973 /*****************************************************************************
2975 * ClearRxRing - remove all buffers from the receive ring
2978 * This function removes all receive buffers from the ring.
2979 * The receive BMU must be stopped before calling this function.
2983 static void ClearRxRing(
2984 SK_AC *pAC, /* pointer to adapter context */
2985 RX_PORT *pRxPort) /* pointer to rx port struct */
2987 RXD *pRxd; /* pointer to the current descriptor */
2988 unsigned long Flags;
2991 if (pRxPort->RxdRingFree == pAC->RxDescrPerRing) {
2994 spin_lock_irqsave(&pRxPort->RxDesRingLock, Flags);
2995 pRxd = pRxPort->pRxdRingHead;
2997 if (pRxd->pMBuf != NULL) {
2999 PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32;
3000 PhysAddr |= (SK_U64) pRxd->VDataLow;
3001 pci_unmap_page(pAC->PciDev,
3004 PCI_DMA_FROMDEVICE);
3005 DEV_KFREE_SKB(pRxd->pMBuf);
3008 pRxd->RBControl &= RX_CTRL_OWN_BMU;
3009 pRxd = pRxd->pNextRxd;
3010 pRxPort->RxdRingFree++;
3011 } while (pRxd != pRxPort->pRxdRingTail);
3012 pRxPort->pRxdRingTail = pRxPort->pRxdRingHead;
3013 spin_unlock_irqrestore(&pRxPort->RxDesRingLock, Flags);
3017 /*****************************************************************************
3019 * ClearTxRing - remove all buffers from the transmit ring
3022 * This function removes all transmit buffers from the ring.
3023 * The transmit BMU must be stopped before calling this function
3024 * and transmitting at the upper level must be disabled.
3025 * The BMU own bit of all descriptors is cleared, the rest is
3026 * done by calling FreeTxDescriptors.
3030 static void ClearTxRing(
3031 SK_AC *pAC, /* pointer to adapter context */
3032 TX_PORT *pTxPort) /* pointer to tx prt struct */
3034 TXD *pTxd; /* pointer to the current descriptor */
3036 unsigned long Flags;
3038 spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags);
3039 pTxd = pTxPort->pTxdRingHead;
3040 for (i=0; i<pAC->TxDescrPerRing; i++) {
3041 pTxd->TBControl &= ~TX_CTRL_OWN_BMU;
3042 pTxd = pTxd->pNextTxd;
3044 FreeTxDescriptors(pAC, pTxPort);
3045 spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags);
3050 /*****************************************************************************
3052 * SetQueueSizes - configure the sizes of rx and tx queues
3055 * This function assigns the sizes for active and passive port
3056 * to the appropriate HWinit structure variables.
3057 * The passive port(s) get standard values, all remaining RAM
3058 * is given to the active port.
3059 * The queue sizes are in kbyte and must be multiple of 8.
3060 * The limits for the number of buffers filled into the rx rings
3061 * is also set in this routine.
3066 static void SetQueueSizes(
3067 SK_AC *pAC) /* pointer to the adapter context */
3069 int StandbyRam; /* adapter RAM used for a standby port */
3070 int RemainingRam; /* adapter RAM available for the active port */
3071 int RxRam; /* RAM used for the active port receive queue */
3072 int i; /* loop counter */
3074 if (pAC->RlmtNets == 1) {
3075 StandbyRam = SK_RLMT_STANDBY_QRXSIZE + SK_RLMT_STANDBY_QXASIZE +
3076 SK_RLMT_STANDBY_QXSSIZE;
3077 RemainingRam = pAC->GIni.GIRamSize -
3078 (pAC->GIni.GIMacsFound-1) * StandbyRam;
3079 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3080 pAC->GIni.GP[i].PRxQSize = SK_RLMT_STANDBY_QRXSIZE;
3081 pAC->GIni.GP[i].PXSQSize = SK_RLMT_STANDBY_QXSSIZE;
3082 pAC->GIni.GP[i].PXAQSize = SK_RLMT_STANDBY_QXASIZE;
3084 RxRam = (RemainingRam * 8 / 10) & ~7;
3085 pAC->GIni.GP[pAC->ActivePort].PRxQSize = RxRam;
3086 pAC->GIni.GP[pAC->ActivePort].PXSQSize = 0;
3087 pAC->GIni.GP[pAC->ActivePort].PXAQSize =
3088 (RemainingRam - RxRam) & ~7;
3089 pAC->RxQueueSize = RxRam;
3090 pAC->TxSQueueSize = 0;
3091 pAC->TxAQueueSize = (RemainingRam - RxRam) & ~7;
3092 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3093 ("queue sizes settings - rx:%d txA:%d txS:%d\n",
3094 pAC->RxQueueSize,pAC->TxAQueueSize, pAC->TxSQueueSize));
3096 RemainingRam = pAC->GIni.GIRamSize/pAC->GIni.GIMacsFound;
3097 RxRam = (RemainingRam * 8 / 10) & ~7;
3098 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3099 pAC->GIni.GP[i].PRxQSize = RxRam;
3100 pAC->GIni.GP[i].PXSQSize = 0;
3101 pAC->GIni.GP[i].PXAQSize = (RemainingRam - RxRam) & ~7;
3104 pAC->RxQueueSize = RxRam;
3105 pAC->TxSQueueSize = 0;
3106 pAC->TxAQueueSize = (RemainingRam - RxRam) & ~7;
3108 for (i=0; i<SK_MAX_MACS; i++) {
3109 pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing;
3112 if (pAC->RlmtNets == 2) {
3113 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3114 pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing - 100;
3117 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3118 pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing - 100;
3121 * Do not set the Limit to 0, because this could cause
3122 * wrap around with ReQueue'ed buffers (a buffer could
3123 * be requeued in the same position, made accessable to
3124 * the hardware, and the hardware could change its
3127 pAC->RxPort[pAC->ActivePort].RxFillLimit = 1;
3131 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3132 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS,
3133 ("i: %d, RxQSize: %d, PXSQsize: %d, PXAQSize: %d\n",
3135 pAC->GIni.GP[i].PRxQSize,
3136 pAC->GIni.GP[i].PXSQSize,
3137 pAC->GIni.GP[i].PXAQSize));
3140 } /* SetQueueSizes */
3143 /*****************************************************************************
3145 * SkGeSetMacAddr - Set the hardware MAC address
3148 * This function sets the MAC address used by the adapter.
3151 * 0, if everything is ok
3154 static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p)
3157 DEV_NET *pNet = (DEV_NET*) dev->priv;
3158 SK_AC *pAC = pNet->pAC;
3160 struct sockaddr *addr = p;
3161 unsigned long Flags;
3163 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3164 ("SkGeSetMacAddr starts now...\n"));
3165 if(netif_running(dev))
3168 memcpy(dev->dev_addr, addr->sa_data,dev->addr_len);
3170 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3172 if (pAC->RlmtNets == 2)
3173 SkAddrOverride(pAC, pAC->IoBase, pNet->NetNr,
3174 (SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS);
3176 SkAddrOverride(pAC, pAC->IoBase, pAC->ActivePort,
3177 (SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS);
3181 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3183 } /* SkGeSetMacAddr */
3187 /*****************************************************************************
3189 * SkGeSetRxMode - set receive mode
3192 * This function sets the receive mode of an adapter. The adapter
3193 * supports promiscuous mode, allmulticast mode and a number of
3194 * multicast addresses. If more multicast addresses the available
3195 * are selected, a hash function in the hardware is used.
3198 * 0, if everything is ok
3202 static void SkGeSetRxMode(struct SK_NET_DEVICE *dev)
3208 struct dev_mc_list *pMcList;
3211 unsigned long Flags;
3213 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3214 ("SkGeSetRxMode starts now... "));
3216 pNet = (DEV_NET*) dev->priv;
3218 if (pAC->RlmtNets == 1)
3219 PortIdx = pAC->ActivePort;
3221 PortIdx = pNet->NetNr;
3223 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3224 if (dev->flags & IFF_PROMISC) {
3225 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3226 ("PROMISCUOUS mode\n"));
3227 SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx,
3229 } else if (dev->flags & IFF_ALLMULTI) {
3230 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3231 ("ALLMULTI mode\n"));
3232 SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx,
3233 SK_PROM_MODE_ALL_MC);
3235 SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx,
3237 SkAddrMcClear(pAC, pAC->IoBase, PortIdx, 0);
3239 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3240 ("Number of MC entries: %d ", dev->mc_count));
3242 pMcList = dev->mc_list;
3243 for (i=0; i<dev->mc_count; i++, pMcList = pMcList->next) {
3244 SkAddrMcAdd(pAC, pAC->IoBase, PortIdx,
3245 (SK_MAC_ADDR*)pMcList->dmi_addr, 0);
3246 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MCA,
3247 ("%02x:%02x:%02x:%02x:%02x:%02x\n",
3248 pMcList->dmi_addr[0],
3249 pMcList->dmi_addr[1],
3250 pMcList->dmi_addr[2],
3251 pMcList->dmi_addr[3],
3252 pMcList->dmi_addr[4],
3253 pMcList->dmi_addr[5]));
3255 SkAddrMcUpdate(pAC, pAC->IoBase, PortIdx);
3257 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3260 } /* SkGeSetRxMode */
3263 /*****************************************************************************
3265 * SkGeChangeMtu - set the MTU to another value
3268 * This function sets is called whenever the MTU size is changed
3269 * (ifconfig mtu xxx dev ethX). If the MTU is bigger than standard
3270 * ethernet MTU size, long frame support is activated.
3273 * 0, if everything is ok
3276 static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu)
3281 unsigned long Flags;
3285 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3286 ("SkGeChangeMtu starts now...\n"));
3288 pNet = (DEV_NET*) dev->priv;
3291 if ((NewMtu < 68) || (NewMtu > SK_JUMBO_MTU)) {
3295 if(pAC->BoardLevel != 2) {
3300 pOtherNet = (DEV_NET*)pAC->dev[1 - pNet->NetNr]->priv;
3301 if ((pOtherNet->Mtu > 1500) && (NewMtu <= 1500) && (pOtherNet->Up==1)) {
3305 EvPara.Para32[0] = pNet->NetNr;
3306 EvPara.Para32[1] = -1;
3308 pAC->RxBufSize = NewMtu + 32;
3311 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3312 ("New MTU: %d\n", NewMtu));
3314 /* prevent reconfiguration while changing the MTU */
3316 /* disable interrupts */
3317 SK_OUT32(pAC->IoBase, B0_IMSK, 0);
3318 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3320 /* Found more than one port */
3321 if ((pAC->GIni.GIMacsFound == 2 ) &&
3322 (pAC->RlmtNets == 2)) {
3323 /* Stop both ports */
3324 EvPara.Para32[0] = 0;
3325 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
3326 EvPara.Para32[0] = 1;
3327 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
3329 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara);
3332 SkEventDispatcher(pAC, pAC->IoBase);
3334 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3336 &pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock, Flags);
3337 netif_stop_queue(pAC->dev[i]);
3342 * adjust number of rx buffers allocated
3344 if (NewMtu > 1500) {
3345 /* use less rx buffers */
3346 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3347 /* Found more than one port */
3348 if ((pAC->GIni.GIMacsFound == 2 ) &&
3349 (pAC->RlmtNets == 2)) {
3350 pAC->RxPort[i].RxFillLimit =
3351 pAC->RxDescrPerRing - 100;
3353 if (i == pAC->ActivePort)
3354 pAC->RxPort[i].RxFillLimit =
3355 pAC->RxDescrPerRing - 100;
3357 pAC->RxPort[i].RxFillLimit =
3358 pAC->RxDescrPerRing - 10;
3363 /* use normal amount of rx buffers */
3364 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3365 /* Found more than one port */
3366 if ((pAC->GIni.GIMacsFound == 2 ) &&
3367 (pAC->RlmtNets == 2)) {
3368 pAC->RxPort[i].RxFillLimit = 1;
3370 if (i == pAC->ActivePort)
3371 pAC->RxPort[i].RxFillLimit = 1;
3373 pAC->RxPort[i].RxFillLimit =
3374 pAC->RxDescrPerRing - 100;
3379 SkGeDeInit(pAC, pAC->IoBase);
3382 * enable/disable hardware support for long frames
3384 if (NewMtu > 1500) {
3385 // pAC->JumboActivated = SK_TRUE; /* is never set back !!! */
3386 pAC->GIni.GIPortUsage = SK_JUMBO_LINK;
3389 if ((pAC->GIni.GIMacsFound == 2 ) &&
3390 (pAC->RlmtNets == 2)) {
3391 pAC->GIni.GIPortUsage = SK_MUL_LINK;
3393 pAC->GIni.GIPortUsage = SK_RED_LINK;
3397 SkGeInit( pAC, pAC->IoBase, 1);
3398 SkI2cInit( pAC, pAC->IoBase, 1);
3399 SkEventInit(pAC, pAC->IoBase, 1);
3400 SkPnmiInit( pAC, pAC->IoBase, 1);
3401 SkAddrInit( pAC, pAC->IoBase, 1);
3402 SkRlmtInit( pAC, pAC->IoBase, 1);
3403 SkTimerInit(pAC, pAC->IoBase, 1);
3407 * Speed and others are set back to default in level 1 init!
3409 GetConfiguration(pAC);
3411 SkGeInit( pAC, pAC->IoBase, 2);
3412 SkI2cInit( pAC, pAC->IoBase, 2);
3413 SkEventInit(pAC, pAC->IoBase, 2);
3414 SkPnmiInit( pAC, pAC->IoBase, 2);
3415 SkAddrInit( pAC, pAC->IoBase, 2);
3416 SkRlmtInit( pAC, pAC->IoBase, 2);
3417 SkTimerInit(pAC, pAC->IoBase, 2);
3420 * clear and reinit the rx rings here
3422 for (i=0; i<pAC->GIni.GIMacsFound; i++) {
3423 ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE);
3424 ClearRxRing(pAC, &pAC->RxPort[i]);
3425 FillRxRing(pAC, &pAC->RxPort[i]);
3427 /* Enable transmit descriptor polling. */
3428 SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE);
3429 FillRxRing(pAC, &pAC->RxPort[i]);
3432 SkGeYellowLED(pAC, pAC->IoBase, 1);
3436 unsigned long ModBase;
3437 ModBase = 53125000 / INTS_PER_SEC;
3438 SK_OUT32(pAC->IoBase, B2_IRQM_INI, ModBase);
3439 SK_OUT32(pAC->IoBase, B2_IRQM_MSK, IRQ_MOD_MASK);
3440 SK_OUT32(pAC->IoBase, B2_IRQM_CTRL, TIM_START);
3444 netif_start_queue(pAC->dev[pNet->PortNr]);
3445 for (i=pAC->GIni.GIMacsFound-1; i>=0; i--) {
3446 spin_unlock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock);
3449 /* enable Interrupts */
3450 SK_OUT32(pAC->IoBase, B0_IMSK, IRQ_MASK);
3451 SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK);
3453 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
3454 SkEventDispatcher(pAC, pAC->IoBase);
3456 /* Found more than one port */
3457 if ((pAC->GIni.GIMacsFound == 2 ) &&
3458 (pAC->RlmtNets == 2)) {
3459 /* Start both ports */
3460 EvPara.Para32[0] = pAC->RlmtNets;
3461 EvPara.Para32[1] = -1;
3462 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS,
3466 EvPara.Para32[1] = -1;
3467 EvPara.Para32[0] = pNet->PortNr;
3468 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
3470 if (pOtherNet->Up) {
3471 EvPara.Para32[0] = pOtherNet->PortNr;
3472 SkEventQueue(pAC, SKGE_RLMT,
3473 SK_RLMT_START, EvPara);
3476 SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara);
3479 SkEventDispatcher(pAC, pAC->IoBase);
3480 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3483 } /* SkGeChangeMtu */
3486 /*****************************************************************************
3488 * SkGeStats - return ethernet device statistics
3491 * This function return statistic data about the ethernet device
3492 * to the operating system.
3495 * pointer to the statistic structure.
3497 static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev)
3499 DEV_NET *pNet = (DEV_NET*) dev->priv;
3500 SK_AC *pAC = pNet->pAC;
3501 SK_PNMI_STRUCT_DATA *pPnmiStruct; /* structure for all Pnmi-Data */
3502 SK_PNMI_STAT *pPnmiStat; /* pointer to virtual XMAC stat. data */
3503 SK_PNMI_CONF *pPnmiConf; /* pointer to virtual link config. */
3504 unsigned int Size; /* size of pnmi struct */
3505 unsigned long Flags; /* for spin lock */
3507 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3508 ("SkGeStats starts now...\n"));
3509 pPnmiStruct = &pAC->PnmiStruct;
3510 memset(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA));
3511 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3512 Size = SK_PNMI_STRUCT_SIZE;
3513 SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr);
3514 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3515 pPnmiStat = &pPnmiStruct->Stat[0];
3516 pPnmiConf = &pPnmiStruct->Conf[0];
3518 pAC->stats.rx_packets = (SK_U32) pPnmiStruct->RxDeliveredCts & 0xFFFFFFFF;
3519 pAC->stats.tx_packets = (SK_U32) pPnmiStat->StatTxOkCts & 0xFFFFFFFF;
3520 pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts;
3521 pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts;
3523 if (pNet->Mtu <= 1500) {
3524 pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF;
3526 pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts -
3527 pPnmiStat->StatRxTooLongCts) & 0xFFFFFFFF);
3531 if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && pAC->HWRevision < 12)
3532 pAC->stats.rx_errors = pAC->stats.rx_errors - pPnmiStat->StatRxShortsCts;
3534 pAC->stats.tx_errors = (SK_U32) pPnmiStat->StatTxSingleCollisionCts & 0xFFFFFFFF;
3535 pAC->stats.rx_dropped = (SK_U32) pPnmiStruct->RxNoBufCts & 0xFFFFFFFF;
3536 pAC->stats.tx_dropped = (SK_U32) pPnmiStruct->TxNoBufCts & 0xFFFFFFFF;
3537 pAC->stats.multicast = (SK_U32) pPnmiStat->StatRxMulticastOkCts & 0xFFFFFFFF;
3538 pAC->stats.collisions = (SK_U32) pPnmiStat->StatTxSingleCollisionCts & 0xFFFFFFFF;
3540 /* detailed rx_errors: */
3541 pAC->stats.rx_length_errors = (SK_U32) pPnmiStat->StatRxRuntCts & 0xFFFFFFFF;
3542 pAC->stats.rx_over_errors = (SK_U32) pPnmiStat->StatRxFifoOverflowCts & 0xFFFFFFFF;
3543 pAC->stats.rx_crc_errors = (SK_U32) pPnmiStat->StatRxFcsCts & 0xFFFFFFFF;
3544 pAC->stats.rx_frame_errors = (SK_U32) pPnmiStat->StatRxFramingCts & 0xFFFFFFFF;
3545 pAC->stats.rx_fifo_errors = (SK_U32) pPnmiStat->StatRxFifoOverflowCts & 0xFFFFFFFF;
3546 pAC->stats.rx_missed_errors = (SK_U32) pPnmiStat->StatRxMissedCts & 0xFFFFFFFF;
3548 /* detailed tx_errors */
3549 pAC->stats.tx_aborted_errors = (SK_U32) 0;
3550 pAC->stats.tx_carrier_errors = (SK_U32) pPnmiStat->StatTxCarrierCts & 0xFFFFFFFF;
3551 pAC->stats.tx_fifo_errors = (SK_U32) pPnmiStat->StatTxFifoUnderrunCts & 0xFFFFFFFF;
3552 pAC->stats.tx_heartbeat_errors = (SK_U32) pPnmiStat->StatTxCarrierCts & 0xFFFFFFFF;
3553 pAC->stats.tx_window_errors = (SK_U32) 0;
3555 return(&pAC->stats);
3559 /*****************************************************************************
3561 * SkGeIoctl - IO-control function
3564 * This function is called if an ioctl is issued on the device.
3565 * There are three subfunction for reading, writing and test-writing
3566 * the private MIB data structure (usefull for SysKonnect-internal tools).
3569 * 0, if everything is ok
3572 static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd)
3578 unsigned int Err = 0;
3581 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3582 ("SkGeIoctl starts now...\n"));
3584 pNet = (DEV_NET*) dev->priv;
3587 if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) {
3592 case SK_IOCTL_SETMIB:
3593 case SK_IOCTL_PRESETMIB:
3594 if (!capable(CAP_NET_ADMIN)) return -EPERM;
3595 case SK_IOCTL_GETMIB:
3596 if(copy_from_user(&pAC->PnmiStruct, Ioctl.pData,
3597 Ioctl.Len<sizeof(pAC->PnmiStruct)?
3598 Ioctl.Len : sizeof(pAC->PnmiStruct))) {
3601 Size = SkGeIocMib(pNet, Ioctl.Len, cmd);
3602 if(copy_to_user(Ioctl.pData, &pAC->PnmiStruct,
3603 Ioctl.Len<Size? Ioctl.Len : Size)) {
3607 if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) {
3618 /*****************************************************************************
3620 * SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message
3623 * This function reads/writes the MIB data using PNMI (Private Network
3624 * Management Interface).
3625 * The destination for the data must be provided with the
3626 * ioctl call and is given to the driver in the form of
3627 * a user space address.
3628 * Copying from the user-provided data area into kernel messages
3629 * and back is done by copy_from_user and copy_to_user calls in
3633 * returned size from PNMI call
3635 static int SkGeIocMib(
3636 DEV_NET *pNet, /* pointer to the adapter context */
3637 unsigned int Size, /* length of ioctl data */
3638 int mode) /* flag for set/preset */
3640 unsigned long Flags; /* for spin lock */
3643 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3644 ("SkGeIocMib starts now...\n"));
3647 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
3649 case SK_IOCTL_GETMIB:
3650 SkPnmiGetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size,
3653 case SK_IOCTL_PRESETMIB:
3654 SkPnmiPreSetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size,
3657 case SK_IOCTL_SETMIB:
3658 SkPnmiSetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size,
3664 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
3665 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY,
3666 ("MIB data access succeeded\n"));
3672 /*****************************************************************************
3674 * GetConfiguration - read configuration information
3677 * This function reads per-adapter configuration information from
3678 * the options provided on the command line.
3683 static void GetConfiguration(
3684 SK_AC *pAC) /* pointer to the adapter context structure */
3686 SK_I32 Port; /* preferred port */
3687 int LinkSpeed; /* Link speed */
3688 int AutoNeg; /* auto negotiation off (0) or on (1) */
3689 int DuplexCap; /* duplex capabilities (0=both, 1=full, 2=half */
3690 int MSMode; /* master / slave mode selection */
3694 * The two parameters AutoNeg. and DuplexCap. map to one configuration
3695 * parameter. The mapping is described by this table:
3696 * DuplexCap -> | both | full | half |
3698 * -----------------------------------------------------------------
3699 * Off | illegal | Full | Half |
3700 * -----------------------------------------------------------------
3701 * On | AutoBoth | AutoFull | AutoHalf |
3702 * -----------------------------------------------------------------
3703 * Sense | AutoSense | AutoSense | AutoSense |
3705 int Capabilities[3][3] =
3706 { { -1, SK_LMODE_FULL, SK_LMODE_HALF},
3707 {SK_LMODE_AUTOBOTH, SK_LMODE_AUTOFULL, SK_LMODE_AUTOHALF},
3708 {SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE} };
3716 /* settings for port A */
3717 /* settings link speed */
3718 LinkSpeed = SK_LSPEED_AUTO; /* default: do auto select */
3719 if (Speed_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3720 Speed_A[pAC->Index] != NULL) {
3721 if (strcmp(Speed_A[pAC->Index],"")==0) {
3722 LinkSpeed = SK_LSPEED_AUTO;
3724 else if (strcmp(Speed_A[pAC->Index],"Auto")==0) {
3725 LinkSpeed = SK_LSPEED_AUTO;
3727 else if (strcmp(Speed_A[pAC->Index],"10")==0) {
3728 LinkSpeed = SK_LSPEED_10MBPS;
3730 else if (strcmp(Speed_A[pAC->Index],"100")==0) {
3731 LinkSpeed = SK_LSPEED_100MBPS;
3733 else if (strcmp(Speed_A[pAC->Index],"1000")==0) {
3734 LinkSpeed = SK_LSPEED_1000MBPS;
3736 else printk("%s: Illegal value for Speed_A\n",
3740 /* Check speed parameter */
3741 /* Only copper type adapter and GE V2 cards */
3742 if (((pAC->GIni.GIChipId != CHIP_ID_YUKON) ||
3743 (pAC->GIni.GICopperType != SK_TRUE)) &&
3744 ((LinkSpeed != SK_LSPEED_AUTO) &&
3745 (LinkSpeed != SK_LSPEED_1000MBPS))) {
3746 printk("%s: Illegal value for Speed_A. "
3747 "Not a copper card or GE V2 card\n Using "
3748 "speed 1000\n", pAC->dev[0]->name);
3749 LinkSpeed = SK_LSPEED_1000MBPS;
3751 pAC->GIni.GP[0].PLinkSpeed = LinkSpeed;
3753 /* Autonegotiation */
3754 AutoNeg = AN_ON; /* tschilling: Default: Autonegotiation on! */
3756 if (AutoNeg_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3757 AutoNeg_A[pAC->Index] != NULL) {
3759 if (strcmp(AutoNeg_A[pAC->Index],"")==0) {
3762 else if (strcmp(AutoNeg_A[pAC->Index],"On")==0) {
3765 else if (strcmp(AutoNeg_A[pAC->Index],"Off")==0) {
3768 else if (strcmp(AutoNeg_A[pAC->Index],"Sense")==0) {
3771 else printk("%s: Illegal value for AutoNeg_A\n",
3775 DuplexCap = DC_BOTH;
3777 if (DupCap_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3778 DupCap_A[pAC->Index] != NULL) {
3780 if (strcmp(DupCap_A[pAC->Index],"")==0) {
3783 else if (strcmp(DupCap_A[pAC->Index],"Both")==0) {
3784 DuplexCap = DC_BOTH;
3786 else if (strcmp(DupCap_A[pAC->Index],"Full")==0) {
3787 DuplexCap = DC_FULL;
3789 else if (strcmp(DupCap_A[pAC->Index],"Half")==0) {
3790 DuplexCap = DC_HALF;
3792 else printk("%s: Illegal value for DupCap_A\n",
3796 /* check for illegal combinations */
3797 if (AutoSet && AutoNeg==AN_SENS && DupSet) {
3798 printk("%s, Port A: DuplexCapabilities"
3799 " ignored using Sense mode\n", pAC->dev[0]->name);
3801 if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){
3802 printk("%s, Port A: Illegal combination"
3803 " of values AutoNeg. and DuplexCap.\n Using "
3804 "Full Duplex\n", pAC->dev[0]->name);
3806 DuplexCap = DC_FULL;
3808 if (AutoSet && AutoNeg==AN_OFF && !DupSet) {
3809 DuplexCap = DC_FULL;
3812 if (!AutoSet && DupSet) {
3813 printk("%s, Port A: Duplex setting not"
3814 " possible in\n default AutoNegotiation mode"
3815 " (Sense).\n Using AutoNegotiation On\n",
3820 /* set the desired mode */
3821 pAC->GIni.GP[0].PLinkModeConf =
3822 Capabilities[AutoNeg][DuplexCap];
3824 pAC->GIni.GP[0].PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM;
3825 if (FlowCtrl_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3826 FlowCtrl_A[pAC->Index] != NULL) {
3827 if (strcmp(FlowCtrl_A[pAC->Index],"") == 0) {
3829 else if (strcmp(FlowCtrl_A[pAC->Index],"SymOrRem") == 0) {
3830 pAC->GIni.GP[0].PFlowCtrlMode =
3831 SK_FLOW_MODE_SYM_OR_REM;
3833 else if (strcmp(FlowCtrl_A[pAC->Index],"Sym")==0) {
3834 pAC->GIni.GP[0].PFlowCtrlMode =
3835 SK_FLOW_MODE_SYMMETRIC;
3837 else if (strcmp(FlowCtrl_A[pAC->Index],"LocSend")==0) {
3838 pAC->GIni.GP[0].PFlowCtrlMode =
3839 SK_FLOW_MODE_LOC_SEND;
3841 else if (strcmp(FlowCtrl_A[pAC->Index],"None")==0) {
3842 pAC->GIni.GP[0].PFlowCtrlMode =
3845 else printk("Illegal value for FlowCtrl_A\n");
3847 if (AutoNeg==AN_OFF && pAC->GIni.GP[0].PFlowCtrlMode!=
3848 SK_FLOW_MODE_NONE) {
3849 printk("%s, Port A: FlowControl"
3850 " impossible without AutoNegotiation,"
3851 " disabled\n", pAC->dev[0]->name);
3852 pAC->GIni.GP[0].PFlowCtrlMode = SK_FLOW_MODE_NONE;
3855 MSMode = SK_MS_MODE_AUTO; /* default: do auto select */
3856 if (Role_A != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3857 Role_A[pAC->Index] != NULL) {
3858 if (strcmp(Role_A[pAC->Index],"")==0) {
3860 else if (strcmp(Role_A[pAC->Index],"Auto")==0) {
3861 MSMode = SK_MS_MODE_AUTO;
3863 else if (strcmp(Role_A[pAC->Index],"Master")==0) {
3864 MSMode = SK_MS_MODE_MASTER;
3866 else if (strcmp(Role_A[pAC->Index],"Slave")==0) {
3867 MSMode = SK_MS_MODE_SLAVE;
3869 else printk("%s: Illegal value for Role_A\n",
3872 pAC->GIni.GP[0].PMSMode = MSMode;
3875 /* settings for port B */
3876 /* settings link speed */
3877 LinkSpeed = SK_LSPEED_AUTO; /* default: do auto select */
3878 if (Speed_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3879 Speed_B[pAC->Index] != NULL) {
3880 if (strcmp(Speed_B[pAC->Index],"")==0) {
3881 LinkSpeed = SK_LSPEED_AUTO;
3883 else if (strcmp(Speed_B[pAC->Index],"Auto")==0) {
3884 LinkSpeed = SK_LSPEED_AUTO;
3886 else if (strcmp(Speed_B[pAC->Index],"10")==0) {
3887 LinkSpeed = SK_LSPEED_10MBPS;
3889 else if (strcmp(Speed_B[pAC->Index],"100")==0) {
3890 LinkSpeed = SK_LSPEED_100MBPS;
3892 else if (strcmp(Speed_B[pAC->Index],"1000")==0) {
3893 LinkSpeed = SK_LSPEED_1000MBPS;
3895 else printk("%s: Illegal value for Speed_B\n",
3899 /* Check speed parameter */
3900 /* Only copper type adapter and GE V2 cards */
3901 if (((pAC->GIni.GIChipId != CHIP_ID_YUKON) ||
3902 (pAC->GIni.GICopperType != SK_TRUE)) &&
3903 ((LinkSpeed != SK_LSPEED_AUTO) &&
3904 (LinkSpeed != SK_LSPEED_1000MBPS))) {
3905 printk("%s: Illegal value for Speed_B. "
3906 "Not a copper card or GE V2 card\n Using "
3907 "speed 1000\n", pAC->dev[1]->name);
3908 LinkSpeed = SK_LSPEED_1000MBPS;
3910 pAC->GIni.GP[1].PLinkSpeed = LinkSpeed;
3912 /* Auto negotiation */
3913 AutoNeg = AN_SENS; /* default: do auto Sense */
3915 if (AutoNeg_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3916 AutoNeg_B[pAC->Index] != NULL) {
3918 if (strcmp(AutoNeg_B[pAC->Index],"")==0) {
3921 else if (strcmp(AutoNeg_B[pAC->Index],"On")==0) {
3924 else if (strcmp(AutoNeg_B[pAC->Index],"Off")==0) {
3927 else if (strcmp(AutoNeg_B[pAC->Index],"Sense")==0) {
3930 else printk("Illegal value for AutoNeg_B\n");
3933 DuplexCap = DC_BOTH;
3935 if (DupCap_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3936 DupCap_B[pAC->Index] != NULL) {
3938 if (strcmp(DupCap_B[pAC->Index],"")==0) {
3941 else if (strcmp(DupCap_B[pAC->Index],"Both")==0) {
3942 DuplexCap = DC_BOTH;
3944 else if (strcmp(DupCap_B[pAC->Index],"Full")==0) {
3945 DuplexCap = DC_FULL;
3947 else if (strcmp(DupCap_B[pAC->Index],"Half")==0) {
3948 DuplexCap = DC_HALF;
3950 else printk("Illegal value for DupCap_B\n");
3953 /* check for illegal combinations */
3954 if (AutoSet && AutoNeg==AN_SENS && DupSet) {
3955 printk("%s, Port B: DuplexCapabilities"
3956 " ignored using Sense mode\n", pAC->dev[1]->name);
3958 if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){
3959 printk("%s, Port B: Illegal combination"
3960 " of values AutoNeg. and DuplexCap.\n Using "
3961 "Full Duplex\n", pAC->dev[1]->name);
3963 DuplexCap = DC_FULL;
3965 if (AutoSet && AutoNeg==AN_OFF && !DupSet) {
3966 DuplexCap = DC_FULL;
3969 if (!AutoSet && DupSet) {
3970 printk("%s, Port B: Duplex setting not"
3971 " possible in\n default AutoNegotiation mode"
3972 " (Sense).\n Using AutoNegotiation On\n",
3977 /* set the desired mode */
3978 pAC->GIni.GP[1].PLinkModeConf =
3979 Capabilities[AutoNeg][DuplexCap];
3981 pAC->GIni.GP[1].PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM;
3982 if (FlowCtrl_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
3983 FlowCtrl_B[pAC->Index] != NULL) {
3984 if (strcmp(FlowCtrl_B[pAC->Index],"") == 0) {
3986 else if (strcmp(FlowCtrl_B[pAC->Index],"SymOrRem") == 0) {
3987 pAC->GIni.GP[1].PFlowCtrlMode =
3988 SK_FLOW_MODE_SYM_OR_REM;
3990 else if (strcmp(FlowCtrl_B[pAC->Index],"Sym")==0) {
3991 pAC->GIni.GP[1].PFlowCtrlMode =
3992 SK_FLOW_MODE_SYMMETRIC;
3994 else if (strcmp(FlowCtrl_B[pAC->Index],"LocSend")==0) {
3995 pAC->GIni.GP[1].PFlowCtrlMode =
3996 SK_FLOW_MODE_LOC_SEND;
3998 else if (strcmp(FlowCtrl_B[pAC->Index],"None")==0) {
3999 pAC->GIni.GP[1].PFlowCtrlMode =
4002 else printk("Illegal value for FlowCtrl_B\n");
4004 if (AutoNeg==AN_OFF && pAC->GIni.GP[1].PFlowCtrlMode!=
4005 SK_FLOW_MODE_NONE) {
4006 printk("%s, Port B: FlowControl"
4007 " impossible without AutoNegotiation,"
4008 " disabled\n", pAC->dev[1]->name);
4009 pAC->GIni.GP[1].PFlowCtrlMode = SK_FLOW_MODE_NONE;
4012 MSMode = SK_MS_MODE_AUTO; /* default: do auto select */
4013 if (Role_B != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
4014 Role_B[pAC->Index] != NULL) {
4015 if (strcmp(Role_B[pAC->Index],"")==0) {
4017 else if (strcmp(Role_B[pAC->Index],"Auto")==0) {
4018 MSMode = SK_MS_MODE_AUTO;
4020 else if (strcmp(Role_B[pAC->Index],"Master")==0) {
4021 MSMode = SK_MS_MODE_MASTER;
4023 else if (strcmp(Role_B[pAC->Index],"Slave")==0) {
4024 MSMode = SK_MS_MODE_SLAVE;
4026 else printk("%s: Illegal value for Role_B\n",
4029 pAC->GIni.GP[1].PMSMode = MSMode;
4032 /* settings for both ports */
4033 pAC->ActivePort = 0;
4034 if (PrefPort != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
4035 PrefPort[pAC->Index] != NULL) {
4036 if (strcmp(PrefPort[pAC->Index],"") == 0) { /* Auto */
4037 pAC->ActivePort = 0;
4038 pAC->Rlmt.Net[0].Preference = -1; /* auto */
4039 pAC->Rlmt.Net[0].PrefPort = 0;
4041 else if (strcmp(PrefPort[pAC->Index],"A") == 0) {
4043 * do not set ActivePort here, thus a port
4044 * switch is issued after net up.
4047 pAC->Rlmt.Net[0].Preference = Port;
4048 pAC->Rlmt.Net[0].PrefPort = Port;
4050 else if (strcmp(PrefPort[pAC->Index],"B") == 0) {
4052 * do not set ActivePort here, thus a port
4053 * switch is issued after net up.
4056 pAC->Rlmt.Net[0].Preference = Port;
4057 pAC->Rlmt.Net[0].PrefPort = Port;
4059 else printk("%s: Illegal value for PrefPort\n",
4065 if (RlmtMode != NULL && pAC->Index<SK_MAX_CARD_PARAM &&
4066 RlmtMode[pAC->Index] != NULL) {
4067 if (strcmp(RlmtMode[pAC->Index], "") == 0) {
4070 else if (strcmp(RlmtMode[pAC->Index], "CheckLinkState") == 0) {
4071 pAC->RlmtMode = SK_RLMT_CHECK_LINK;
4073 else if (strcmp(RlmtMode[pAC->Index], "CheckLocalPort") == 0) {
4074 pAC->RlmtMode = SK_RLMT_CHECK_LINK |
4075 SK_RLMT_CHECK_LOC_LINK;
4077 else if (strcmp(RlmtMode[pAC->Index], "CheckSeg") == 0) {
4078 pAC->RlmtMode = SK_RLMT_CHECK_LINK |
4079 SK_RLMT_CHECK_LOC_LINK |
4082 else if ((strcmp(RlmtMode[pAC->Index], "DualNet") == 0) &&
4083 (pAC->GIni.GIMacsFound == 2)) {
4084 pAC->RlmtMode = SK_RLMT_CHECK_LINK;
4088 printk("%s: Illegal value for"
4089 " RlmtMode, using default\n", pAC->dev[0]->name);
4096 } /* GetConfiguration */
4099 /*****************************************************************************
4101 * ProductStr - return a adapter identification string from vpd
4104 * This function reads the product name string from the vpd area
4105 * and puts it the field pAC->DeviceString.
4109 static void ProductStr(
4110 SK_AC *pAC /* pointer to adapter context */
4113 int StrLen = 80; /* length of the string, defined in SK_AC */
4114 char Keyword[] = VPD_NAME; /* vpd productname identifier */
4115 int ReturnCode; /* return code from vpd_read */
4116 unsigned long Flags;
4118 spin_lock_irqsave(&pAC->SlowPathLock, Flags);
4119 ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, pAC->DeviceStr,
4121 spin_unlock_irqrestore(&pAC->SlowPathLock, Flags);
4122 if (ReturnCode != 0) {
4123 /* there was an error reading the vpd data */
4124 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR,
4125 ("Error reading VPD data: %d\n", ReturnCode));
4126 pAC->DeviceStr[0] = '\0';
4133 /****************************************************************************/
4134 /* functions for common modules *********************************************/
4135 /****************************************************************************/
4138 /*****************************************************************************
4140 * SkDrvAllocRlmtMbuf - allocate an RLMT mbuf
4143 * This routine returns an RLMT mbuf or NULL. The RLMT Mbuf structure
4144 * is embedded into a socket buff data area.
4150 * NULL or pointer to Mbuf.
4152 SK_MBUF *SkDrvAllocRlmtMbuf(
4153 SK_AC *pAC, /* pointer to adapter context */
4154 SK_IOC IoC, /* the IO-context */
4155 unsigned BufferSize) /* size of the requested buffer */
4157 SK_MBUF *pRlmtMbuf; /* pointer to a new rlmt-mbuf structure */
4158 struct sk_buff *pMsgBlock; /* pointer to a new message block */
4160 pMsgBlock = alloc_skb(BufferSize + sizeof(SK_MBUF), GFP_ATOMIC);
4161 if (pMsgBlock == NULL) {
4164 pRlmtMbuf = (SK_MBUF*) pMsgBlock->data;
4165 skb_reserve(pMsgBlock, sizeof(SK_MBUF));
4166 pRlmtMbuf->pNext = NULL;
4167 pRlmtMbuf->pOs = pMsgBlock;
4168 pRlmtMbuf->pData = pMsgBlock->data; /* Data buffer. */
4169 pRlmtMbuf->Size = BufferSize; /* Data buffer size. */
4170 pRlmtMbuf->Length = 0; /* Length of packet (<= Size). */
4173 } /* SkDrvAllocRlmtMbuf */
4176 /*****************************************************************************
4178 * SkDrvFreeRlmtMbuf - free an RLMT mbuf
4181 * This routine frees one or more RLMT mbuf(s).
4189 void SkDrvFreeRlmtMbuf(
4190 SK_AC *pAC, /* pointer to adapter context */
4191 SK_IOC IoC, /* the IO-context */
4192 SK_MBUF *pMbuf) /* size of the requested buffer */
4199 pNextMbuf = pFreeMbuf->pNext;
4200 DEV_KFREE_SKB_ANY(pFreeMbuf->pOs);
4201 pFreeMbuf = pNextMbuf;
4202 } while ( pFreeMbuf != NULL );
4203 } /* SkDrvFreeRlmtMbuf */
4206 /*****************************************************************************
4208 * SkOsGetTime - provide a time value
4211 * This routine provides a time value. The unit is 1/HZ (defined by Linux).
4212 * It is not used for absolute time, but only for time differences.
4218 SK_U64 SkOsGetTime(SK_AC *pAC)
4223 return get_timer(0);
4228 /*****************************************************************************
4230 * SkPciReadCfgDWord - read a 32 bit value from pci config space
4233 * This routine reads a 32 bit value from the pci configuration
4237 * 0 - indicate everything worked ok.
4238 * != 0 - error indication
4240 int SkPciReadCfgDWord(
4241 SK_AC *pAC, /* Adapter Control structure pointer */
4242 int PciAddr, /* PCI register address */
4243 SK_U32 *pVal) /* pointer to store the read value */
4245 pci_read_config_dword(pAC->PciDev, PciAddr, pVal);
4247 } /* SkPciReadCfgDWord */
4250 /*****************************************************************************
4252 * SkPciReadCfgWord - read a 16 bit value from pci config space
4255 * This routine reads a 16 bit value from the pci configuration
4259 * 0 - indicate everything worked ok.
4260 * != 0 - error indication
4262 int SkPciReadCfgWord(
4263 SK_AC *pAC, /* Adapter Control structure pointer */
4264 int PciAddr, /* PCI register address */
4265 SK_U16 *pVal) /* pointer to store the read value */
4267 pci_read_config_word(pAC->PciDev, PciAddr, pVal);
4269 } /* SkPciReadCfgWord */
4272 /*****************************************************************************
4274 * SkPciReadCfgByte - read a 8 bit value from pci config space
4277 * This routine reads a 8 bit value from the pci configuration
4281 * 0 - indicate everything worked ok.
4282 * != 0 - error indication
4284 int SkPciReadCfgByte(
4285 SK_AC *pAC, /* Adapter Control structure pointer */
4286 int PciAddr, /* PCI register address */
4287 SK_U8 *pVal) /* pointer to store the read value */
4289 pci_read_config_byte(pAC->PciDev, PciAddr, pVal);
4291 } /* SkPciReadCfgByte */
4294 /*****************************************************************************
4296 * SkPciWriteCfgDWord - write a 32 bit value to pci config space
4299 * This routine writes a 32 bit value to the pci configuration
4303 * 0 - indicate everything worked ok.
4304 * != 0 - error indication
4306 int SkPciWriteCfgDWord(
4307 SK_AC *pAC, /* Adapter Control structure pointer */
4308 int PciAddr, /* PCI register address */
4309 SK_U32 Val) /* pointer to store the read value */
4311 pci_write_config_dword(pAC->PciDev, PciAddr, Val);
4313 } /* SkPciWriteCfgDWord */
4316 /*****************************************************************************
4318 * SkPciWriteCfgWord - write a 16 bit value to pci config space
4321 * This routine writes a 16 bit value to the pci configuration
4322 * space. The flag PciConfigUp indicates whether the config space
4323 * is accesible or must be set up first.
4326 * 0 - indicate everything worked ok.
4327 * != 0 - error indication
4329 int SkPciWriteCfgWord(
4330 SK_AC *pAC, /* Adapter Control structure pointer */
4331 int PciAddr, /* PCI register address */
4332 SK_U16 Val) /* pointer to store the read value */
4334 pci_write_config_word(pAC->PciDev, PciAddr, Val);
4336 } /* SkPciWriteCfgWord */
4339 /*****************************************************************************
4341 * SkPciWriteCfgWord - write a 8 bit value to pci config space
4344 * This routine writes a 8 bit value to the pci configuration
4345 * space. The flag PciConfigUp indicates whether the config space
4346 * is accesible or must be set up first.
4349 * 0 - indicate everything worked ok.
4350 * != 0 - error indication
4352 int SkPciWriteCfgByte(
4353 SK_AC *pAC, /* Adapter Control structure pointer */
4354 int PciAddr, /* PCI register address */
4355 SK_U8 Val) /* pointer to store the read value */
4357 pci_write_config_byte(pAC->PciDev, PciAddr, Val);
4359 } /* SkPciWriteCfgByte */
4362 /*****************************************************************************
4364 * SkDrvEvent - handle driver events
4367 * This function handles events from all modules directed to the driver
4370 * Is called under protection of slow path lock.
4373 * 0 if everything ok
4378 SK_AC *pAC, /* pointer to adapter context */
4379 SK_IOC IoC, /* io-context */
4380 SK_U32 Event, /* event-id */
4381 SK_EVPARA Param) /* event-parameter */
4383 SK_MBUF *pRlmtMbuf; /* pointer to a rlmt-mbuf structure */
4384 struct sk_buff *pMsg; /* pointer to a message block */
4385 int FromPort; /* the port from which we switch away */
4386 int ToPort; /* the port we switch to */
4387 SK_EVPARA NewPara; /* parameter for further events */
4391 unsigned long Flags;
4395 case SK_DRV_ADAP_FAIL:
4396 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4397 ("ADAPTER FAIL EVENT\n"));
4398 printk("%s: Adapter failed.\n", pAC->dev[0]->name);
4399 /* disable interrupts */
4400 SK_OUT32(pAC->IoBase, B0_IMSK, 0);
4403 case SK_DRV_PORT_FAIL:
4404 FromPort = Param.Para32[0];
4405 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4406 ("PORT FAIL EVENT, Port: %d\n", FromPort));
4407 if (FromPort == 0) {
4408 printk("%s: Port A failed.\n", pAC->dev[0]->name);
4410 printk("%s: Port B failed.\n", pAC->dev[1]->name);
4414 case SK_DRV_PORT_RESET: /* SK_U32 PortIdx */
4416 FromPort = Param.Para32[0];
4417 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4418 ("PORT RESET EVENT, Port: %d ", FromPort));
4419 NewPara.Para64 = FromPort;
4420 SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara);
4422 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4424 SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_HARD_RST);
4426 pAC->dev[Param.Para32[0]]->flags &= ~IFF_RUNNING;
4428 spin_unlock_irqrestore(
4429 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4432 /* clear rx ring from received frames */
4433 ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE);
4435 ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
4437 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4440 /* tschilling: Handling of return value inserted. */
4441 if (SkGeInitPort(pAC, IoC, FromPort)) {
4442 if (FromPort == 0) {
4443 printk("%s: SkGeInitPort A failed.\n", pAC->dev[0]->name);
4445 printk("%s: SkGeInitPort B failed.\n", pAC->dev[1]->name);
4448 SkAddrMcUpdate(pAC,IoC, FromPort);
4449 PortReInitBmu(pAC, FromPort);
4450 SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
4451 ClearAndStartRx(pAC, FromPort);
4452 spin_unlock_irqrestore(
4453 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4456 case SK_DRV_NET_UP: /* SK_U32 PortIdx */
4458 FromPort = Param.Para32[0];
4459 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4460 ("NET UP EVENT, Port: %d ", Param.Para32[0]));
4462 printk("%s: network connection up using"
4463 " port %c\n", pAC->dev[Param.Para32[0]]->name, 'A'+Param.Para32[0]);
4465 /* tschilling: Values changed according to LinkSpeedUsed. */
4466 Stat = pAC->GIni.GP[FromPort].PLinkSpeedUsed;
4467 if (Stat == SK_LSPEED_STAT_10MBPS) {
4468 printk(" speed: 10\n");
4469 } else if (Stat == SK_LSPEED_STAT_100MBPS) {
4470 printk(" speed: 100\n");
4471 } else if (Stat == SK_LSPEED_STAT_1000MBPS) {
4472 printk(" speed: 1000\n");
4474 printk(" speed: unknown\n");
4477 Stat = pAC->GIni.GP[FromPort].PLinkModeStatus;
4478 if (Stat == SK_LMODE_STAT_AUTOHALF ||
4479 Stat == SK_LMODE_STAT_AUTOFULL) {
4480 printk(" autonegotiation: yes\n");
4483 printk(" autonegotiation: no\n");
4485 if (Stat == SK_LMODE_STAT_AUTOHALF ||
4486 Stat == SK_LMODE_STAT_HALF) {
4487 printk(" duplex mode: half\n");
4490 printk(" duplex mode: full\n");
4492 Stat = pAC->GIni.GP[FromPort].PFlowCtrlStatus;
4493 if (Stat == SK_FLOW_STAT_REM_SEND ) {
4494 printk(" flowctrl: remote send\n");
4496 else if (Stat == SK_FLOW_STAT_LOC_SEND ){
4497 printk(" flowctrl: local send\n");
4499 else if (Stat == SK_FLOW_STAT_SYMMETRIC ){
4500 printk(" flowctrl: symmetric\n");
4503 printk(" flowctrl: none\n");
4506 /* tschilling: Check against CopperType now. */
4507 if ((pAC->GIni.GICopperType == SK_TRUE) &&
4508 (pAC->GIni.GP[FromPort].PLinkSpeedUsed ==
4509 SK_LSPEED_STAT_1000MBPS)) {
4510 Stat = pAC->GIni.GP[FromPort].PMSStatus;
4511 if (Stat == SK_MS_STAT_MASTER ) {
4512 printk(" role: master\n");
4514 else if (Stat == SK_MS_STAT_SLAVE ) {
4515 printk(" role: slave\n");
4518 printk(" role: ???\n");
4523 if (pAC->GIni.GIChipId == CHIP_ID_YUKON)
4524 printk(" scatter-gather: enabled\n");
4526 printk(" scatter-gather: disabled\n");
4529 printk(" scatter-gather: disabled\n");
4531 #endif /* SK98_INFO */
4533 if ((Param.Para32[0] != pAC->ActivePort) &&
4534 (pAC->RlmtNets == 1)) {
4535 NewPara.Para32[0] = pAC->ActivePort;
4536 NewPara.Para32[1] = Param.Para32[0];
4537 SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_INTERN,
4541 /* Inform the world that link protocol is up. */
4543 pAC->dev[Param.Para32[0]]->flags |= IFF_RUNNING;
4547 case SK_DRV_NET_DOWN: /* SK_U32 Reason */
4549 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4550 ("NET DOWN EVENT "));
4552 printk("%s: network connection down\n", pAC->dev[Param.Para32[1]]->name);
4555 pAC->dev[Param.Para32[1]]->flags &= ~IFF_RUNNING;
4558 case SK_DRV_SWITCH_HARD: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4559 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4560 ("PORT SWITCH HARD "));
4561 case SK_DRV_SWITCH_SOFT: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4563 printk("%s: switching to port %c\n", pAC->dev[0]->name,
4564 'A'+Param.Para32[1]);
4565 case SK_DRV_SWITCH_INTERN: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */
4566 FromPort = Param.Para32[0];
4567 ToPort = Param.Para32[1];
4568 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4569 ("PORT SWITCH EVENT, From: %d To: %d (Pref %d) ",
4570 FromPort, ToPort, pAC->Rlmt.Net[0].PrefPort));
4571 NewPara.Para64 = FromPort;
4572 SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara);
4573 NewPara.Para64 = ToPort;
4574 SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara);
4576 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4579 &pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock, Flags);
4580 SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST);
4581 SkGeStopPort(pAC, IoC, ToPort, SK_STOP_ALL, SK_SOFT_RST);
4582 spin_unlock_irqrestore(
4583 &pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock, Flags);
4584 spin_unlock_irqrestore(
4585 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4588 ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE); /* clears rx ring */
4589 ReceiveIrq(pAC, &pAC->RxPort[ToPort], SK_FALSE); /* clears rx ring */
4591 ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]);
4592 ClearTxRing(pAC, &pAC->TxPort[ToPort][TX_PRIO_LOW]);
4594 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4597 &pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock, Flags);
4598 pAC->ActivePort = ToPort;
4602 /* tschilling: New common function with minimum size check. */
4604 if (pAC->RlmtNets == 2) {
4608 if (SkGeInitAssignRamToQueues(
4612 spin_unlock_irqrestore(
4613 &pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock, Flags);
4614 spin_unlock_irqrestore(
4615 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4617 printk("SkGeInitAssignRamToQueues failed.\n");
4621 /* tschilling: Handling of return values inserted. */
4622 if (SkGeInitPort(pAC, IoC, FromPort) ||
4623 SkGeInitPort(pAC, IoC, ToPort)) {
4624 printk("%s: SkGeInitPort failed.\n", pAC->dev[0]->name);
4626 if (Event == SK_DRV_SWITCH_SOFT) {
4627 SkMacRxTxEnable(pAC, IoC, FromPort);
4629 SkMacRxTxEnable(pAC, IoC, ToPort);
4630 SkAddrSwap(pAC, IoC, FromPort, ToPort);
4631 SkAddrMcUpdate(pAC, IoC, FromPort);
4632 SkAddrMcUpdate(pAC, IoC, ToPort);
4633 PortReInitBmu(pAC, FromPort);
4634 PortReInitBmu(pAC, ToPort);
4635 SkGePollTxD(pAC, IoC, FromPort, SK_TRUE);
4636 SkGePollTxD(pAC, IoC, ToPort, SK_TRUE);
4637 ClearAndStartRx(pAC, FromPort);
4638 ClearAndStartRx(pAC, ToPort);
4639 spin_unlock_irqrestore(
4640 &pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock, Flags);
4641 spin_unlock_irqrestore(
4642 &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock,
4645 case SK_DRV_RLMT_SEND: /* SK_MBUF *pMb */
4646 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4648 pRlmtMbuf = (SK_MBUF*) Param.pParaPtr;
4649 pMsg = (struct sk_buff*) pRlmtMbuf->pOs;
4650 skb_put(pMsg, pRlmtMbuf->Length);
4651 if (XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW],
4654 DEV_KFREE_SKB_ANY(pMsg);
4659 SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT,
4666 /*****************************************************************************
4668 * SkErrorLog - log errors
4671 * This function logs errors to the system buffer and to the console
4674 * 0 if everything ok
4687 case SK_ERRCL_OTHER:
4688 strcpy(ClassStr, "Other error");
4690 case SK_ERRCL_CONFIG:
4691 strcpy(ClassStr, "Configuration error");
4694 strcpy(ClassStr, "Initialization error");
4696 case SK_ERRCL_NORES:
4697 strcpy(ClassStr, "Out of resources error");
4700 strcpy(ClassStr, "internal Software error");
4703 strcpy(ClassStr, "Hardware failure");
4706 strcpy(ClassStr, "Communication error");
4709 printk(KERN_INFO "%s: -- ERROR --\n Class: %s\n"
4710 " Nr: 0x%x\n Msg: %s\n", pAC->dev[0]->name,
4711 ClassStr, ErrNum, pErrorMsg);
4716 /****************************************************************************/
4717 /* "debug only" section *****************************************************/
4718 /****************************************************************************/
4721 /*****************************************************************************
4723 * DumpMsg - print a frame
4726 * This function prints frames to the system logfile/to the console.
4731 static void DumpMsg(struct sk_buff *skb, char *str)
4736 printk("DumpMsg(): NULL-Message\n");
4740 if (skb->data == NULL) {
4741 printk("DumpMsg(): Message empty\n");
4749 printk("--- Begin of message from %s , len %d (from %d) ----\n", str, msglen, skb->len);
4751 DumpData((char *)skb->data, msglen);
4753 printk("------- End of message ---------\n");
4758 /*****************************************************************************
4760 * DumpData - print a data area
4763 * This function prints a area of data to the system logfile/to the
4769 static void DumpData(char *p, int size)
4773 char hex_buffer[180];
4774 char asc_buffer[180];
4775 char HEXCHAR[] = "0123456789ABCDEF";
4781 for (i=0; i < size; ) {
4782 if (*p >= '0' && *p <='z')
4783 asc_buffer[addr] = *p;
4785 asc_buffer[addr] = '.';
4787 asc_buffer[addr] = 0;
4788 hex_buffer[haddr] = HEXCHAR[(*p & 0xf0) >> 4];
4790 hex_buffer[haddr] = HEXCHAR[*p & 0x0f];
4792 hex_buffer[haddr] = ' ';
4794 hex_buffer[haddr] = 0;
4798 printk("%s %s\n", hex_buffer, asc_buffer);
4806 /*****************************************************************************
4808 * DumpLong - print a data area as long values
4811 * This function prints a area of data to the system logfile/to the
4817 static void DumpLong(char *pc, int size)
4821 char hex_buffer[180];
4822 char asc_buffer[180];
4823 char HEXCHAR[] = "0123456789ABCDEF";
4832 for (i=0; i < size; ) {
4834 hex_buffer[haddr] = HEXCHAR[(l >> 28) & 0xf];
4836 hex_buffer[haddr] = HEXCHAR[(l >> 24) & 0xf];
4838 hex_buffer[haddr] = HEXCHAR[(l >> 20) & 0xf];
4840 hex_buffer[haddr] = HEXCHAR[(l >> 16) & 0xf];
4842 hex_buffer[haddr] = HEXCHAR[(l >> 12) & 0xf];
4844 hex_buffer[haddr] = HEXCHAR[(l >> 8) & 0xf];
4846 hex_buffer[haddr] = HEXCHAR[(l >> 4) & 0xf];
4848 hex_buffer[haddr] = HEXCHAR[l & 0x0f];
4850 hex_buffer[haddr] = ' ';
4852 hex_buffer[haddr] = 0;
4856 printk("%4x %s\n", (i-8)*4, hex_buffer);
4860 printk("------------------------\n");
4867 * compile-command: "make"