]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Name: skge.c | |
4 | * Project: GEnesis, PCI Gigabit Ethernet Adapter | |
5 | * Version: $Revision: 1.45 $ | |
6 | * Date: $Date: 2004/02/12 14:41:02 $ | |
7 | * Purpose: The main driver source module | |
8 | * | |
9 | ******************************************************************************/ | |
10 | ||
11 | /****************************************************************************** | |
12 | * | |
13 | * (C)Copyright 1998-2002 SysKonnect GmbH. | |
14 | * (C)Copyright 2002-2003 Marvell. | |
15 | * | |
16 | * Driver for Marvell Yukon chipset and SysKonnect Gigabit Ethernet | |
17 | * Server Adapters. | |
18 | * | |
19 | * Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and | |
20 | * SysKonnects GEnesis Solaris driver | |
21 | * Author: Christoph Goos (cgoos@syskonnect.de) | |
22 | * Mirko Lindner (mlindner@syskonnect.de) | |
23 | * | |
24 | * Address all question to: linux@syskonnect.de | |
25 | * | |
26 | * The technical manual for the adapters is available from SysKonnect's | |
27 | * web pages: www.syskonnect.com | |
28 | * Goto "Support" and search Knowledge Base for "manual". | |
29 | * | |
30 | * This program is free software; you can redistribute it and/or modify | |
31 | * it under the terms of the GNU General Public License as published by | |
32 | * the Free Software Foundation; either version 2 of the License, or | |
33 | * (at your option) any later version. | |
34 | * | |
35 | * The information in this file is provided "AS IS" without warranty. | |
36 | * | |
37 | ******************************************************************************/ | |
38 | ||
39 | /****************************************************************************** | |
40 | * | |
41 | * Possible compiler options (#define xxx / -Dxxx): | |
42 | * | |
43 | * debugging can be enable by changing SK_DEBUG_CHKMOD and | |
44 | * SK_DEBUG_CHKCAT in makefile (described there). | |
45 | * | |
46 | ******************************************************************************/ | |
47 | ||
48 | /****************************************************************************** | |
49 | * | |
50 | * Description: | |
51 | * | |
52 | * This is the main module of the Linux GE driver. | |
53 | * | |
54 | * All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h | |
55 | * are part of SysKonnect's COMMON MODULES for the SK-98xx adapters. | |
56 | * Those are used for drivers on multiple OS', so some thing may seem | |
57 | * unnecessary complicated on Linux. Please do not try to 'clean up' | |
58 | * them without VERY good reasons, because this will make it more | |
59 | * difficult to keep the Linux driver in synchronisation with the | |
60 | * other versions. | |
61 | * | |
62 | * Include file hierarchy: | |
63 | * | |
64 | * <linux/module.h> | |
65 | * | |
66 | * "h/skdrv1st.h" | |
67 | * <linux/types.h> | |
68 | * <linux/kernel.h> | |
69 | * <linux/string.h> | |
70 | * <linux/errno.h> | |
71 | * <linux/ioport.h> | |
72 | * <linux/slab.h> | |
73 | * <linux/interrupt.h> | |
74 | * <linux/pci.h> | |
75 | * <linux/bitops.h> | |
76 | * <asm/byteorder.h> | |
77 | * <asm/io.h> | |
78 | * <linux/netdevice.h> | |
79 | * <linux/etherdevice.h> | |
80 | * <linux/skbuff.h> | |
81 | * those three depending on kernel version used: | |
82 | * <linux/bios32.h> | |
83 | * <linux/init.h> | |
84 | * <asm/uaccess.h> | |
85 | * <net/checksum.h> | |
86 | * | |
87 | * "h/skerror.h" | |
88 | * "h/skdebug.h" | |
89 | * "h/sktypes.h" | |
90 | * "h/lm80.h" | |
91 | * "h/xmac_ii.h" | |
92 | * | |
93 | * "h/skdrv2nd.h" | |
94 | * "h/skqueue.h" | |
95 | * "h/skgehwt.h" | |
96 | * "h/sktimer.h" | |
97 | * "h/ski2c.h" | |
98 | * "h/skgepnmi.h" | |
99 | * "h/skvpd.h" | |
100 | * "h/skgehw.h" | |
101 | * "h/skgeinit.h" | |
102 | * "h/skaddr.h" | |
103 | * "h/skgesirq.h" | |
1da177e4 LT |
104 | * "h/skrlmt.h" |
105 | * | |
106 | ******************************************************************************/ | |
107 | ||
108 | #include "h/skversion.h" | |
109 | ||
14c85021 | 110 | #include <linux/in.h> |
1da177e4 LT |
111 | #include <linux/module.h> |
112 | #include <linux/moduleparam.h> | |
113 | #include <linux/init.h> | |
1e7f0bd8 | 114 | #include <linux/dma-mapping.h> |
596f86a8 | 115 | #include <linux/ip.h> |
1da177e4 LT |
116 | |
117 | #include "h/skdrv1st.h" | |
118 | #include "h/skdrv2nd.h" | |
119 | ||
120 | /******************************************************************************* | |
121 | * | |
122 | * Defines | |
123 | * | |
124 | ******************************************************************************/ | |
125 | ||
126 | /* for debuging on x86 only */ | |
127 | /* #define BREAKPOINT() asm(" int $3"); */ | |
128 | ||
129 | /* use the transmit hw checksum driver functionality */ | |
130 | #define USE_SK_TX_CHECKSUM | |
131 | ||
132 | /* use the receive hw checksum driver functionality */ | |
133 | #define USE_SK_RX_CHECKSUM | |
134 | ||
135 | /* use the scatter-gather functionality with sendfile() */ | |
136 | #define SK_ZEROCOPY | |
137 | ||
138 | /* use of a transmit complete interrupt */ | |
139 | #define USE_TX_COMPLETE | |
140 | ||
141 | /* | |
142 | * threshold for copying small receive frames | |
143 | * set to 0 to avoid copying, set to 9001 to copy all frames | |
144 | */ | |
145 | #define SK_COPY_THRESHOLD 50 | |
146 | ||
147 | /* number of adapters that can be configured via command line params */ | |
148 | #define SK_MAX_CARD_PARAM 16 | |
149 | ||
150 | ||
151 | ||
152 | /* | |
153 | * use those defines for a compile-in version of the driver instead | |
154 | * of command line parameters | |
155 | */ | |
156 | // #define LINK_SPEED_A {"Auto", } | |
157 | // #define LINK_SPEED_B {"Auto", } | |
158 | // #define AUTO_NEG_A {"Sense", } | |
159 | // #define AUTO_NEG_B {"Sense", } | |
160 | // #define DUP_CAP_A {"Both", } | |
161 | // #define DUP_CAP_B {"Both", } | |
162 | // #define FLOW_CTRL_A {"SymOrRem", } | |
163 | // #define FLOW_CTRL_B {"SymOrRem", } | |
164 | // #define ROLE_A {"Auto", } | |
165 | // #define ROLE_B {"Auto", } | |
166 | // #define PREF_PORT {"A", } | |
167 | // #define CON_TYPE {"Auto", } | |
168 | // #define RLMT_MODE {"CheckLinkState", } | |
169 | ||
170 | #define DEV_KFREE_SKB(skb) dev_kfree_skb(skb) | |
171 | #define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb) | |
172 | #define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb) | |
173 | ||
174 | ||
175 | /* Set blink mode*/ | |
176 | #define OEM_CONFIG_VALUE ( SK_ACT_LED_BLINK | \ | |
177 | SK_DUP_LED_NORMAL | \ | |
178 | SK_LED_LINK100_ON) | |
179 | ||
180 | ||
181 | /* Isr return value */ | |
182 | #define SkIsrRetVar irqreturn_t | |
183 | #define SkIsrRetNone IRQ_NONE | |
184 | #define SkIsrRetHandled IRQ_HANDLED | |
185 | ||
186 | ||
187 | /******************************************************************************* | |
188 | * | |
189 | * Local Function Prototypes | |
190 | * | |
191 | ******************************************************************************/ | |
192 | ||
193 | static void FreeResources(struct SK_NET_DEVICE *dev); | |
194 | static int SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC); | |
195 | static SK_BOOL BoardAllocMem(SK_AC *pAC); | |
196 | static void BoardFreeMem(SK_AC *pAC); | |
197 | static void BoardInitMem(SK_AC *pAC); | |
198 | static void SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**, int*, SK_BOOL); | |
199 | static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs); | |
200 | static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs); | |
201 | static int SkGeOpen(struct SK_NET_DEVICE *dev); | |
202 | static int SkGeClose(struct SK_NET_DEVICE *dev); | |
203 | static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev); | |
204 | static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p); | |
205 | static void SkGeSetRxMode(struct SK_NET_DEVICE *dev); | |
206 | static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev); | |
207 | static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd); | |
208 | static void GetConfiguration(SK_AC*); | |
1da177e4 LT |
209 | static int XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*); |
210 | static void FreeTxDescriptors(SK_AC*pAC, TX_PORT*); | |
211 | static void FillRxRing(SK_AC*, RX_PORT*); | |
212 | static SK_BOOL FillRxDescriptor(SK_AC*, RX_PORT*); | |
213 | static void ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL); | |
214 | static void ClearAndStartRx(SK_AC*, int); | |
215 | static void ClearTxIrq(SK_AC*, int, int); | |
216 | static void ClearRxRing(SK_AC*, RX_PORT*); | |
217 | static void ClearTxRing(SK_AC*, TX_PORT*); | |
218 | static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu); | |
219 | static void PortReInitBmu(SK_AC*, int); | |
220 | static int SkGeIocMib(DEV_NET*, unsigned int, int); | |
221 | static int SkGeInitPCI(SK_AC *pAC); | |
222 | static void StartDrvCleanupTimer(SK_AC *pAC); | |
223 | static void StopDrvCleanupTimer(SK_AC *pAC); | |
224 | static int XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*); | |
225 | ||
226 | #ifdef SK_DIAG_SUPPORT | |
227 | static SK_U32 ParseDeviceNbrFromSlotName(const char *SlotName); | |
228 | static int SkDrvInitAdapter(SK_AC *pAC, int devNbr); | |
229 | static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr); | |
230 | #endif | |
231 | ||
232 | /******************************************************************************* | |
233 | * | |
234 | * Extern Function Prototypes | |
235 | * | |
236 | ******************************************************************************/ | |
1da177e4 LT |
237 | extern void SkDimEnableModerationIfNeeded(SK_AC *pAC); |
238 | extern void SkDimDisplayModerationSettings(SK_AC *pAC); | |
239 | extern void SkDimStartModerationTimer(SK_AC *pAC); | |
240 | extern void SkDimModerate(SK_AC *pAC); | |
241 | extern void SkGeBlinkTimer(unsigned long data); | |
242 | ||
243 | #ifdef DEBUG | |
244 | static void DumpMsg(struct sk_buff*, char*); | |
245 | static void DumpData(char*, int); | |
246 | static void DumpLong(char*, int); | |
247 | #endif | |
248 | ||
249 | /* global variables *********************************************************/ | |
250 | static SK_BOOL DoPrintInterfaceChange = SK_TRUE; | |
251 | extern struct ethtool_ops SkGeEthtoolOps; | |
252 | ||
253 | /* local variables **********************************************************/ | |
254 | static uintptr_t TxQueueAddr[SK_MAX_MACS][2] = {{0x680, 0x600},{0x780, 0x700}}; | |
255 | static uintptr_t RxQueueAddr[SK_MAX_MACS] = {0x400, 0x480}; | |
256 | ||
c8ebd3a3 AB |
257 | /***************************************************************************** |
258 | * | |
259 | * SkPciWriteCfgDWord - write a 32 bit value to pci config space | |
260 | * | |
261 | * Description: | |
262 | * This routine writes a 32 bit value to the pci configuration | |
263 | * space. | |
264 | * | |
265 | * Returns: | |
266 | * 0 - indicate everything worked ok. | |
267 | * != 0 - error indication | |
268 | */ | |
269 | static inline int SkPciWriteCfgDWord( | |
270 | SK_AC *pAC, /* Adapter Control structure pointer */ | |
271 | int PciAddr, /* PCI register address */ | |
272 | SK_U32 Val) /* pointer to store the read value */ | |
273 | { | |
274 | pci_write_config_dword(pAC->PciDev, PciAddr, Val); | |
275 | return(0); | |
276 | } /* SkPciWriteCfgDWord */ | |
277 | ||
1da177e4 LT |
278 | /***************************************************************************** |
279 | * | |
280 | * SkGeInitPCI - Init the PCI resources | |
281 | * | |
282 | * Description: | |
283 | * This function initialize the PCI resources and IO | |
284 | * | |
17fa6e2f SH |
285 | * Returns: |
286 | * 0 - indicate everything worked ok. | |
287 | * != 0 - error indication | |
1da177e4 | 288 | */ |
17fa6e2f | 289 | static __devinit int SkGeInitPCI(SK_AC *pAC) |
1da177e4 LT |
290 | { |
291 | struct SK_NET_DEVICE *dev = pAC->dev[0]; | |
292 | struct pci_dev *pdev = pAC->PciDev; | |
293 | int retval; | |
294 | ||
1da177e4 LT |
295 | dev->mem_start = pci_resource_start (pdev, 0); |
296 | pci_set_master(pdev); | |
297 | ||
df22b8aa SH |
298 | retval = pci_request_regions(pdev, "sk98lin"); |
299 | if (retval) | |
300 | goto out; | |
1da177e4 LT |
301 | |
302 | #ifdef SK_BIG_ENDIAN | |
303 | /* | |
304 | * On big endian machines, we use the adapter's aibility of | |
305 | * reading the descriptors as big endian. | |
306 | */ | |
307 | { | |
308 | SK_U32 our2; | |
309 | SkPciReadCfgDWord(pAC, PCI_OUR_REG_2, &our2); | |
310 | our2 |= PCI_REV_DESC; | |
311 | SkPciWriteCfgDWord(pAC, PCI_OUR_REG_2, our2); | |
312 | } | |
313 | #endif | |
314 | ||
315 | /* | |
316 | * Remap the regs into kernel space. | |
317 | */ | |
318 | pAC->IoBase = ioremap_nocache(dev->mem_start, 0x4000); | |
df22b8aa SH |
319 | if (!pAC->IoBase) { |
320 | retval = -EIO; | |
1da177e4 LT |
321 | goto out_release; |
322 | } | |
323 | ||
324 | return 0; | |
325 | ||
326 | out_release: | |
327 | pci_release_regions(pdev); | |
df22b8aa | 328 | out: |
1da177e4 LT |
329 | return retval; |
330 | } | |
331 | ||
332 | ||
333 | /***************************************************************************** | |
334 | * | |
335 | * FreeResources - release resources allocated for adapter | |
336 | * | |
337 | * Description: | |
338 | * This function releases the IRQ, unmaps the IO and | |
339 | * frees the desriptor ring. | |
340 | * | |
341 | * Returns: N/A | |
342 | * | |
343 | */ | |
344 | static void FreeResources(struct SK_NET_DEVICE *dev) | |
345 | { | |
346 | SK_U32 AllocFlag; | |
347 | DEV_NET *pNet; | |
348 | SK_AC *pAC; | |
349 | ||
350 | pNet = netdev_priv(dev); | |
351 | pAC = pNet->pAC; | |
352 | AllocFlag = pAC->AllocFlag; | |
353 | if (pAC->PciDev) { | |
354 | pci_release_regions(pAC->PciDev); | |
355 | } | |
356 | if (AllocFlag & SK_ALLOC_IRQ) { | |
357 | free_irq(dev->irq, dev); | |
358 | } | |
359 | if (pAC->IoBase) { | |
360 | iounmap(pAC->IoBase); | |
361 | } | |
362 | if (pAC->pDescrMem) { | |
363 | BoardFreeMem(pAC); | |
364 | } | |
365 | ||
366 | } /* FreeResources */ | |
367 | ||
368 | MODULE_AUTHOR("Mirko Lindner <mlindner@syskonnect.de>"); | |
369 | MODULE_DESCRIPTION("SysKonnect SK-NET Gigabit Ethernet SK-98xx driver"); | |
370 | MODULE_LICENSE("GPL"); | |
371 | ||
372 | #ifdef LINK_SPEED_A | |
373 | static char *Speed_A[SK_MAX_CARD_PARAM] = LINK_SPEED; | |
374 | #else | |
375 | static char *Speed_A[SK_MAX_CARD_PARAM] = {"", }; | |
376 | #endif | |
377 | ||
378 | #ifdef LINK_SPEED_B | |
379 | static char *Speed_B[SK_MAX_CARD_PARAM] = LINK_SPEED; | |
380 | #else | |
381 | static char *Speed_B[SK_MAX_CARD_PARAM] = {"", }; | |
382 | #endif | |
383 | ||
384 | #ifdef AUTO_NEG_A | |
385 | static char *AutoNeg_A[SK_MAX_CARD_PARAM] = AUTO_NEG_A; | |
386 | #else | |
387 | static char *AutoNeg_A[SK_MAX_CARD_PARAM] = {"", }; | |
388 | #endif | |
389 | ||
390 | #ifdef DUP_CAP_A | |
391 | static char *DupCap_A[SK_MAX_CARD_PARAM] = DUP_CAP_A; | |
392 | #else | |
393 | static char *DupCap_A[SK_MAX_CARD_PARAM] = {"", }; | |
394 | #endif | |
395 | ||
396 | #ifdef FLOW_CTRL_A | |
397 | static char *FlowCtrl_A[SK_MAX_CARD_PARAM] = FLOW_CTRL_A; | |
398 | #else | |
399 | static char *FlowCtrl_A[SK_MAX_CARD_PARAM] = {"", }; | |
400 | #endif | |
401 | ||
402 | #ifdef ROLE_A | |
403 | static char *Role_A[SK_MAX_CARD_PARAM] = ROLE_A; | |
404 | #else | |
405 | static char *Role_A[SK_MAX_CARD_PARAM] = {"", }; | |
406 | #endif | |
407 | ||
408 | #ifdef AUTO_NEG_B | |
409 | static char *AutoNeg_B[SK_MAX_CARD_PARAM] = AUTO_NEG_B; | |
410 | #else | |
411 | static char *AutoNeg_B[SK_MAX_CARD_PARAM] = {"", }; | |
412 | #endif | |
413 | ||
414 | #ifdef DUP_CAP_B | |
415 | static char *DupCap_B[SK_MAX_CARD_PARAM] = DUP_CAP_B; | |
416 | #else | |
417 | static char *DupCap_B[SK_MAX_CARD_PARAM] = {"", }; | |
418 | #endif | |
419 | ||
420 | #ifdef FLOW_CTRL_B | |
421 | static char *FlowCtrl_B[SK_MAX_CARD_PARAM] = FLOW_CTRL_B; | |
422 | #else | |
423 | static char *FlowCtrl_B[SK_MAX_CARD_PARAM] = {"", }; | |
424 | #endif | |
425 | ||
426 | #ifdef ROLE_B | |
427 | static char *Role_B[SK_MAX_CARD_PARAM] = ROLE_B; | |
428 | #else | |
429 | static char *Role_B[SK_MAX_CARD_PARAM] = {"", }; | |
430 | #endif | |
431 | ||
432 | #ifdef CON_TYPE | |
433 | static char *ConType[SK_MAX_CARD_PARAM] = CON_TYPE; | |
434 | #else | |
435 | static char *ConType[SK_MAX_CARD_PARAM] = {"", }; | |
436 | #endif | |
437 | ||
438 | #ifdef PREF_PORT | |
439 | static char *PrefPort[SK_MAX_CARD_PARAM] = PREF_PORT; | |
440 | #else | |
441 | static char *PrefPort[SK_MAX_CARD_PARAM] = {"", }; | |
442 | #endif | |
443 | ||
444 | #ifdef RLMT_MODE | |
445 | static char *RlmtMode[SK_MAX_CARD_PARAM] = RLMT_MODE; | |
446 | #else | |
447 | static char *RlmtMode[SK_MAX_CARD_PARAM] = {"", }; | |
448 | #endif | |
449 | ||
450 | static int IntsPerSec[SK_MAX_CARD_PARAM]; | |
451 | static char *Moderation[SK_MAX_CARD_PARAM]; | |
452 | static char *ModerationMask[SK_MAX_CARD_PARAM]; | |
453 | static char *AutoSizing[SK_MAX_CARD_PARAM]; | |
454 | static char *Stats[SK_MAX_CARD_PARAM]; | |
455 | ||
456 | module_param_array(Speed_A, charp, NULL, 0); | |
457 | module_param_array(Speed_B, charp, NULL, 0); | |
458 | module_param_array(AutoNeg_A, charp, NULL, 0); | |
459 | module_param_array(AutoNeg_B, charp, NULL, 0); | |
460 | module_param_array(DupCap_A, charp, NULL, 0); | |
461 | module_param_array(DupCap_B, charp, NULL, 0); | |
462 | module_param_array(FlowCtrl_A, charp, NULL, 0); | |
463 | module_param_array(FlowCtrl_B, charp, NULL, 0); | |
464 | module_param_array(Role_A, charp, NULL, 0); | |
465 | module_param_array(Role_B, charp, NULL, 0); | |
466 | module_param_array(ConType, charp, NULL, 0); | |
467 | module_param_array(PrefPort, charp, NULL, 0); | |
468 | module_param_array(RlmtMode, charp, NULL, 0); | |
469 | /* used for interrupt moderation */ | |
470 | module_param_array(IntsPerSec, int, NULL, 0); | |
471 | module_param_array(Moderation, charp, NULL, 0); | |
472 | module_param_array(Stats, charp, NULL, 0); | |
473 | module_param_array(ModerationMask, charp, NULL, 0); | |
474 | module_param_array(AutoSizing, charp, NULL, 0); | |
475 | ||
476 | /***************************************************************************** | |
477 | * | |
478 | * SkGeBoardInit - do level 0 and 1 initialization | |
479 | * | |
480 | * Description: | |
481 | * This function prepares the board hardware for running. The desriptor | |
482 | * ring is set up, the IRQ is allocated and the configuration settings | |
483 | * are examined. | |
484 | * | |
485 | * Returns: | |
486 | * 0, if everything is ok | |
487 | * !=0, on error | |
488 | */ | |
17fa6e2f | 489 | static int __devinit SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC) |
1da177e4 LT |
490 | { |
491 | short i; | |
492 | unsigned long Flags; | |
493 | char *DescrString = "sk98lin: Driver for Linux"; /* this is given to PNMI */ | |
494 | char *VerStr = VER_STRING; | |
495 | int Ret; /* return code of request_irq */ | |
496 | SK_BOOL DualNet; | |
497 | ||
498 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
499 | ("IoBase: %08lX\n", (unsigned long)pAC->IoBase)); | |
500 | for (i=0; i<SK_MAX_MACS; i++) { | |
501 | pAC->TxPort[i][0].HwAddr = pAC->IoBase + TxQueueAddr[i][0]; | |
502 | pAC->TxPort[i][0].PortIndex = i; | |
503 | pAC->RxPort[i].HwAddr = pAC->IoBase + RxQueueAddr[i]; | |
504 | pAC->RxPort[i].PortIndex = i; | |
505 | } | |
506 | ||
507 | /* Initialize the mutexes */ | |
508 | for (i=0; i<SK_MAX_MACS; i++) { | |
509 | spin_lock_init(&pAC->TxPort[i][0].TxDesRingLock); | |
510 | spin_lock_init(&pAC->RxPort[i].RxDesRingLock); | |
511 | } | |
512 | spin_lock_init(&pAC->SlowPathLock); | |
513 | ||
514 | /* setup phy_id blink timer */ | |
515 | pAC->BlinkTimer.function = SkGeBlinkTimer; | |
516 | pAC->BlinkTimer.data = (unsigned long) dev; | |
517 | init_timer(&pAC->BlinkTimer); | |
518 | ||
519 | /* level 0 init common modules here */ | |
520 | ||
521 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
522 | /* Does a RESET on board ...*/ | |
523 | if (SkGeInit(pAC, pAC->IoBase, SK_INIT_DATA) != 0) { | |
524 | printk("HWInit (0) failed.\n"); | |
525 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
16287557 | 526 | return -EIO; |
1da177e4 LT |
527 | } |
528 | SkI2cInit( pAC, pAC->IoBase, SK_INIT_DATA); | |
529 | SkEventInit(pAC, pAC->IoBase, SK_INIT_DATA); | |
530 | SkPnmiInit( pAC, pAC->IoBase, SK_INIT_DATA); | |
531 | SkAddrInit( pAC, pAC->IoBase, SK_INIT_DATA); | |
532 | SkRlmtInit( pAC, pAC->IoBase, SK_INIT_DATA); | |
533 | SkTimerInit(pAC, pAC->IoBase, SK_INIT_DATA); | |
534 | ||
535 | pAC->BoardLevel = SK_INIT_DATA; | |
536 | pAC->RxBufSize = ETH_BUF_SIZE; | |
537 | ||
538 | SK_PNMI_SET_DRIVER_DESCR(pAC, DescrString); | |
539 | SK_PNMI_SET_DRIVER_VER(pAC, VerStr); | |
540 | ||
541 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
542 | ||
543 | /* level 1 init common modules here (HW init) */ | |
544 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
545 | if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) { | |
546 | printk("sk98lin: HWInit (1) failed.\n"); | |
547 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
16287557 | 548 | return -EIO; |
1da177e4 LT |
549 | } |
550 | SkI2cInit( pAC, pAC->IoBase, SK_INIT_IO); | |
551 | SkEventInit(pAC, pAC->IoBase, SK_INIT_IO); | |
552 | SkPnmiInit( pAC, pAC->IoBase, SK_INIT_IO); | |
553 | SkAddrInit( pAC, pAC->IoBase, SK_INIT_IO); | |
554 | SkRlmtInit( pAC, pAC->IoBase, SK_INIT_IO); | |
555 | SkTimerInit(pAC, pAC->IoBase, SK_INIT_IO); | |
556 | ||
557 | /* Set chipset type support */ | |
558 | pAC->ChipsetType = 0; | |
559 | if ((pAC->GIni.GIChipId == CHIP_ID_YUKON) || | |
560 | (pAC->GIni.GIChipId == CHIP_ID_YUKON_LITE)) { | |
561 | pAC->ChipsetType = 1; | |
562 | } | |
563 | ||
564 | GetConfiguration(pAC); | |
565 | if (pAC->RlmtNets == 2) { | |
566 | pAC->GIni.GIPortUsage = SK_MUL_LINK; | |
567 | } | |
568 | ||
569 | pAC->BoardLevel = SK_INIT_IO; | |
570 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
571 | ||
572 | if (pAC->GIni.GIMacsFound == 2) { | |
8f7a17d1 | 573 | Ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev); |
1da177e4 LT |
574 | } else if (pAC->GIni.GIMacsFound == 1) { |
575 | Ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, | |
8f7a17d1 | 576 | "sk98lin", dev); |
1da177e4 LT |
577 | } else { |
578 | printk(KERN_WARNING "sk98lin: Illegal number of ports: %d\n", | |
579 | pAC->GIni.GIMacsFound); | |
16287557 | 580 | return -EIO; |
1da177e4 LT |
581 | } |
582 | ||
583 | if (Ret) { | |
584 | printk(KERN_WARNING "sk98lin: Requested IRQ %d is busy.\n", | |
585 | dev->irq); | |
16287557 | 586 | return Ret; |
1da177e4 LT |
587 | } |
588 | pAC->AllocFlag |= SK_ALLOC_IRQ; | |
589 | ||
590 | /* Alloc memory for this board (Mem for RxD/TxD) : */ | |
591 | if(!BoardAllocMem(pAC)) { | |
592 | printk("No memory for descriptor rings.\n"); | |
16287557 | 593 | return -ENOMEM; |
1da177e4 LT |
594 | } |
595 | ||
1da177e4 LT |
596 | BoardInitMem(pAC); |
597 | /* tschilling: New common function with minimum size check. */ | |
598 | DualNet = SK_FALSE; | |
599 | if (pAC->RlmtNets == 2) { | |
600 | DualNet = SK_TRUE; | |
601 | } | |
602 | ||
603 | if (SkGeInitAssignRamToQueues( | |
604 | pAC, | |
605 | pAC->ActivePort, | |
606 | DualNet)) { | |
607 | BoardFreeMem(pAC); | |
608 | printk("sk98lin: SkGeInitAssignRamToQueues failed.\n"); | |
16287557 | 609 | return -EIO; |
1da177e4 LT |
610 | } |
611 | ||
612 | return (0); | |
613 | } /* SkGeBoardInit */ | |
614 | ||
615 | ||
616 | /***************************************************************************** | |
617 | * | |
618 | * BoardAllocMem - allocate the memory for the descriptor rings | |
619 | * | |
620 | * Description: | |
621 | * This function allocates the memory for all descriptor rings. | |
622 | * Each ring is aligned for the desriptor alignment and no ring | |
623 | * has a 4 GByte boundary in it (because the upper 32 bit must | |
624 | * be constant for all descriptiors in one rings). | |
625 | * | |
626 | * Returns: | |
627 | * SK_TRUE, if all memory could be allocated | |
628 | * SK_FALSE, if not | |
629 | */ | |
17fa6e2f | 630 | static __devinit SK_BOOL BoardAllocMem(SK_AC *pAC) |
1da177e4 LT |
631 | { |
632 | caddr_t pDescrMem; /* pointer to descriptor memory area */ | |
633 | size_t AllocLength; /* length of complete descriptor area */ | |
634 | int i; /* loop counter */ | |
635 | unsigned long BusAddr; | |
636 | ||
637 | ||
638 | /* rings plus one for alignment (do not cross 4 GB boundary) */ | |
639 | /* RX_RING_SIZE is assumed bigger than TX_RING_SIZE */ | |
640 | #if (BITS_PER_LONG == 32) | |
641 | AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound + 8; | |
642 | #else | |
643 | AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound | |
644 | + RX_RING_SIZE + 8; | |
645 | #endif | |
646 | ||
647 | pDescrMem = pci_alloc_consistent(pAC->PciDev, AllocLength, | |
648 | &pAC->pDescrMemDMA); | |
649 | ||
650 | if (pDescrMem == NULL) { | |
651 | return (SK_FALSE); | |
652 | } | |
653 | pAC->pDescrMem = pDescrMem; | |
654 | BusAddr = (unsigned long) pAC->pDescrMemDMA; | |
655 | ||
656 | /* Descriptors need 8 byte alignment, and this is ensured | |
657 | * by pci_alloc_consistent. | |
658 | */ | |
659 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
660 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, | |
661 | ("TX%d/A: pDescrMem: %lX, PhysDescrMem: %lX\n", | |
662 | i, (unsigned long) pDescrMem, | |
663 | BusAddr)); | |
664 | pAC->TxPort[i][0].pTxDescrRing = pDescrMem; | |
665 | pAC->TxPort[i][0].VTxDescrRing = BusAddr; | |
666 | pDescrMem += TX_RING_SIZE; | |
667 | BusAddr += TX_RING_SIZE; | |
668 | ||
669 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, | |
670 | ("RX%d: pDescrMem: %lX, PhysDescrMem: %lX\n", | |
671 | i, (unsigned long) pDescrMem, | |
672 | (unsigned long)BusAddr)); | |
673 | pAC->RxPort[i].pRxDescrRing = pDescrMem; | |
674 | pAC->RxPort[i].VRxDescrRing = BusAddr; | |
675 | pDescrMem += RX_RING_SIZE; | |
676 | BusAddr += RX_RING_SIZE; | |
677 | } /* for */ | |
678 | ||
679 | return (SK_TRUE); | |
680 | } /* BoardAllocMem */ | |
681 | ||
682 | ||
683 | /**************************************************************************** | |
684 | * | |
685 | * BoardFreeMem - reverse of BoardAllocMem | |
686 | * | |
687 | * Description: | |
688 | * Free all memory allocated in BoardAllocMem: adapter context, | |
689 | * descriptor rings, locks. | |
690 | * | |
691 | * Returns: N/A | |
692 | */ | |
693 | static void BoardFreeMem( | |
694 | SK_AC *pAC) | |
695 | { | |
696 | size_t AllocLength; /* length of complete descriptor area */ | |
697 | ||
698 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
699 | ("BoardFreeMem\n")); | |
700 | #if (BITS_PER_LONG == 32) | |
701 | AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound + 8; | |
702 | #else | |
703 | AllocLength = (RX_RING_SIZE + TX_RING_SIZE) * pAC->GIni.GIMacsFound | |
704 | + RX_RING_SIZE + 8; | |
705 | #endif | |
706 | ||
707 | pci_free_consistent(pAC->PciDev, AllocLength, | |
708 | pAC->pDescrMem, pAC->pDescrMemDMA); | |
709 | pAC->pDescrMem = NULL; | |
710 | } /* BoardFreeMem */ | |
711 | ||
712 | ||
713 | /***************************************************************************** | |
714 | * | |
715 | * BoardInitMem - initiate the descriptor rings | |
716 | * | |
717 | * Description: | |
718 | * This function sets the descriptor rings up in memory. | |
719 | * The adapter is initialized with the descriptor start addresses. | |
720 | * | |
721 | * Returns: N/A | |
722 | */ | |
17fa6e2f | 723 | static __devinit void BoardInitMem(SK_AC *pAC) |
1da177e4 LT |
724 | { |
725 | int i; /* loop counter */ | |
726 | int RxDescrSize; /* the size of a rx descriptor rounded up to alignment*/ | |
727 | int TxDescrSize; /* the size of a tx descriptor rounded up to alignment*/ | |
728 | ||
729 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
730 | ("BoardInitMem\n")); | |
731 | ||
732 | RxDescrSize = (((sizeof(RXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN; | |
733 | pAC->RxDescrPerRing = RX_RING_SIZE / RxDescrSize; | |
734 | TxDescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) * DESCR_ALIGN; | |
735 | pAC->TxDescrPerRing = TX_RING_SIZE / RxDescrSize; | |
736 | ||
737 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
738 | SetupRing( | |
739 | pAC, | |
740 | pAC->TxPort[i][0].pTxDescrRing, | |
741 | pAC->TxPort[i][0].VTxDescrRing, | |
742 | (RXD**)&pAC->TxPort[i][0].pTxdRingHead, | |
743 | (RXD**)&pAC->TxPort[i][0].pTxdRingTail, | |
744 | (RXD**)&pAC->TxPort[i][0].pTxdRingPrev, | |
745 | &pAC->TxPort[i][0].TxdRingFree, | |
746 | SK_TRUE); | |
747 | SetupRing( | |
748 | pAC, | |
749 | pAC->RxPort[i].pRxDescrRing, | |
750 | pAC->RxPort[i].VRxDescrRing, | |
751 | &pAC->RxPort[i].pRxdRingHead, | |
752 | &pAC->RxPort[i].pRxdRingTail, | |
753 | &pAC->RxPort[i].pRxdRingPrev, | |
754 | &pAC->RxPort[i].RxdRingFree, | |
755 | SK_FALSE); | |
756 | } | |
757 | } /* BoardInitMem */ | |
758 | ||
759 | ||
760 | /***************************************************************************** | |
761 | * | |
762 | * SetupRing - create one descriptor ring | |
763 | * | |
764 | * Description: | |
765 | * This function creates one descriptor ring in the given memory area. | |
766 | * The head, tail and number of free descriptors in the ring are set. | |
767 | * | |
768 | * Returns: | |
769 | * none | |
770 | */ | |
771 | static void SetupRing( | |
772 | SK_AC *pAC, | |
773 | void *pMemArea, /* a pointer to the memory area for the ring */ | |
774 | uintptr_t VMemArea, /* the virtual bus address of the memory area */ | |
775 | RXD **ppRingHead, /* address where the head should be written */ | |
776 | RXD **ppRingTail, /* address where the tail should be written */ | |
777 | RXD **ppRingPrev, /* address where the tail should be written */ | |
778 | int *pRingFree, /* address where the # of free descr. goes */ | |
779 | SK_BOOL IsTx) /* flag: is this a tx ring */ | |
780 | { | |
781 | int i; /* loop counter */ | |
782 | int DescrSize; /* the size of a descriptor rounded up to alignment*/ | |
783 | int DescrNum; /* number of descriptors per ring */ | |
784 | RXD *pDescr; /* pointer to a descriptor (receive or transmit) */ | |
785 | RXD *pNextDescr; /* pointer to the next descriptor */ | |
786 | RXD *pPrevDescr; /* pointer to the previous descriptor */ | |
787 | uintptr_t VNextDescr; /* the virtual bus address of the next descriptor */ | |
788 | ||
789 | if (IsTx == SK_TRUE) { | |
790 | DescrSize = (((sizeof(TXD) - 1) / DESCR_ALIGN) + 1) * | |
791 | DESCR_ALIGN; | |
792 | DescrNum = TX_RING_SIZE / DescrSize; | |
793 | } else { | |
794 | DescrSize = (((sizeof(RXD) - 1) / DESCR_ALIGN) + 1) * | |
795 | DESCR_ALIGN; | |
796 | DescrNum = RX_RING_SIZE / DescrSize; | |
797 | } | |
798 | ||
799 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, | |
800 | ("Descriptor size: %d Descriptor Number: %d\n", | |
801 | DescrSize,DescrNum)); | |
802 | ||
803 | pDescr = (RXD*) pMemArea; | |
804 | pPrevDescr = NULL; | |
805 | pNextDescr = (RXD*) (((char*)pDescr) + DescrSize); | |
806 | VNextDescr = VMemArea + DescrSize; | |
807 | for(i=0; i<DescrNum; i++) { | |
808 | /* set the pointers right */ | |
809 | pDescr->VNextRxd = VNextDescr & 0xffffffffULL; | |
810 | pDescr->pNextRxd = pNextDescr; | |
92f268e0 | 811 | if (!IsTx) pDescr->TcpSumStarts = ETH_HLEN << 16 | ETH_HLEN; |
1da177e4 LT |
812 | |
813 | /* advance one step */ | |
814 | pPrevDescr = pDescr; | |
815 | pDescr = pNextDescr; | |
816 | pNextDescr = (RXD*) (((char*)pDescr) + DescrSize); | |
817 | VNextDescr += DescrSize; | |
818 | } | |
819 | pPrevDescr->pNextRxd = (RXD*) pMemArea; | |
820 | pPrevDescr->VNextRxd = VMemArea; | |
821 | pDescr = (RXD*) pMemArea; | |
822 | *ppRingHead = (RXD*) pMemArea; | |
823 | *ppRingTail = *ppRingHead; | |
824 | *ppRingPrev = pPrevDescr; | |
825 | *pRingFree = DescrNum; | |
826 | } /* SetupRing */ | |
827 | ||
828 | ||
829 | /***************************************************************************** | |
830 | * | |
831 | * PortReInitBmu - re-initiate the descriptor rings for one port | |
832 | * | |
833 | * Description: | |
834 | * This function reinitializes the descriptor rings of one port | |
835 | * in memory. The port must be stopped before. | |
836 | * The HW is initialized with the descriptor start addresses. | |
837 | * | |
838 | * Returns: | |
839 | * none | |
840 | */ | |
841 | static void PortReInitBmu( | |
842 | SK_AC *pAC, /* pointer to adapter context */ | |
843 | int PortIndex) /* index of the port for which to re-init */ | |
844 | { | |
845 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
846 | ("PortReInitBmu ")); | |
847 | ||
848 | /* set address of first descriptor of ring in BMU */ | |
849 | SK_OUT32(pAC->IoBase, TxQueueAddr[PortIndex][TX_PRIO_LOW]+ Q_DA_L, | |
850 | (uint32_t)(((caddr_t) | |
851 | (pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxdRingHead) - | |
852 | pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxDescrRing + | |
853 | pAC->TxPort[PortIndex][TX_PRIO_LOW].VTxDescrRing) & | |
854 | 0xFFFFFFFF)); | |
855 | SK_OUT32(pAC->IoBase, TxQueueAddr[PortIndex][TX_PRIO_LOW]+ Q_DA_H, | |
856 | (uint32_t)(((caddr_t) | |
857 | (pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxdRingHead) - | |
858 | pAC->TxPort[PortIndex][TX_PRIO_LOW].pTxDescrRing + | |
859 | pAC->TxPort[PortIndex][TX_PRIO_LOW].VTxDescrRing) >> 32)); | |
860 | SK_OUT32(pAC->IoBase, RxQueueAddr[PortIndex]+Q_DA_L, | |
861 | (uint32_t)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) - | |
862 | pAC->RxPort[PortIndex].pRxDescrRing + | |
863 | pAC->RxPort[PortIndex].VRxDescrRing) & 0xFFFFFFFF)); | |
864 | SK_OUT32(pAC->IoBase, RxQueueAddr[PortIndex]+Q_DA_H, | |
865 | (uint32_t)(((caddr_t)(pAC->RxPort[PortIndex].pRxdRingHead) - | |
866 | pAC->RxPort[PortIndex].pRxDescrRing + | |
867 | pAC->RxPort[PortIndex].VRxDescrRing) >> 32)); | |
868 | } /* PortReInitBmu */ | |
869 | ||
870 | ||
871 | /**************************************************************************** | |
872 | * | |
873 | * SkGeIsr - handle adapter interrupts | |
874 | * | |
875 | * Description: | |
876 | * The interrupt routine is called when the network adapter | |
877 | * generates an interrupt. It may also be called if another device | |
878 | * shares this interrupt vector with the driver. | |
879 | * | |
880 | * Returns: N/A | |
881 | * | |
882 | */ | |
883 | static SkIsrRetVar SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs) | |
884 | { | |
885 | struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id; | |
886 | DEV_NET *pNet; | |
887 | SK_AC *pAC; | |
888 | SK_U32 IntSrc; /* interrupts source register contents */ | |
889 | ||
890 | pNet = netdev_priv(dev); | |
891 | pAC = pNet->pAC; | |
892 | ||
893 | /* | |
894 | * Check and process if its our interrupt | |
895 | */ | |
896 | SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc); | |
897 | if (IntSrc == 0) { | |
898 | return SkIsrRetNone; | |
899 | } | |
900 | ||
901 | while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) { | |
902 | #if 0 /* software irq currently not used */ | |
903 | if (IntSrc & IS_IRQ_SW) { | |
904 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
905 | SK_DBGCAT_DRV_INT_SRC, | |
906 | ("Software IRQ\n")); | |
907 | } | |
908 | #endif | |
909 | if (IntSrc & IS_R1_F) { | |
910 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
911 | SK_DBGCAT_DRV_INT_SRC, | |
912 | ("EOF RX1 IRQ\n")); | |
913 | ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE); | |
914 | SK_PNMI_CNT_RX_INTR(pAC, 0); | |
915 | } | |
916 | if (IntSrc & IS_R2_F) { | |
917 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
918 | SK_DBGCAT_DRV_INT_SRC, | |
919 | ("EOF RX2 IRQ\n")); | |
920 | ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE); | |
921 | SK_PNMI_CNT_RX_INTR(pAC, 1); | |
922 | } | |
923 | #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */ | |
924 | if (IntSrc & IS_XA1_F) { | |
925 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
926 | SK_DBGCAT_DRV_INT_SRC, | |
927 | ("EOF AS TX1 IRQ\n")); | |
928 | SK_PNMI_CNT_TX_INTR(pAC, 0); | |
929 | spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock); | |
930 | FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]); | |
931 | spin_unlock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock); | |
932 | } | |
933 | if (IntSrc & IS_XA2_F) { | |
934 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
935 | SK_DBGCAT_DRV_INT_SRC, | |
936 | ("EOF AS TX2 IRQ\n")); | |
937 | SK_PNMI_CNT_TX_INTR(pAC, 1); | |
938 | spin_lock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock); | |
939 | FreeTxDescriptors(pAC, &pAC->TxPort[1][TX_PRIO_LOW]); | |
940 | spin_unlock(&pAC->TxPort[1][TX_PRIO_LOW].TxDesRingLock); | |
941 | } | |
942 | #if 0 /* only if sync. queues used */ | |
943 | if (IntSrc & IS_XS1_F) { | |
944 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
945 | SK_DBGCAT_DRV_INT_SRC, | |
946 | ("EOF SY TX1 IRQ\n")); | |
947 | SK_PNMI_CNT_TX_INTR(pAC, 1); | |
948 | spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock); | |
949 | FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH); | |
950 | spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock); | |
951 | ClearTxIrq(pAC, 0, TX_PRIO_HIGH); | |
952 | } | |
953 | if (IntSrc & IS_XS2_F) { | |
954 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
955 | SK_DBGCAT_DRV_INT_SRC, | |
956 | ("EOF SY TX2 IRQ\n")); | |
957 | SK_PNMI_CNT_TX_INTR(pAC, 1); | |
958 | spin_lock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock); | |
959 | FreeTxDescriptors(pAC, 1, TX_PRIO_HIGH); | |
960 | spin_unlock(&pAC->TxPort[1][TX_PRIO_HIGH].TxDesRingLock); | |
961 | ClearTxIrq(pAC, 1, TX_PRIO_HIGH); | |
962 | } | |
963 | #endif | |
964 | #endif | |
965 | ||
966 | /* do all IO at once */ | |
967 | if (IntSrc & IS_R1_F) | |
968 | ClearAndStartRx(pAC, 0); | |
969 | if (IntSrc & IS_R2_F) | |
970 | ClearAndStartRx(pAC, 1); | |
971 | #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */ | |
972 | if (IntSrc & IS_XA1_F) | |
973 | ClearTxIrq(pAC, 0, TX_PRIO_LOW); | |
974 | if (IntSrc & IS_XA2_F) | |
975 | ClearTxIrq(pAC, 1, TX_PRIO_LOW); | |
976 | #endif | |
977 | SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc); | |
978 | } /* while (IntSrc & IRQ_MASK != 0) */ | |
979 | ||
980 | IntSrc &= pAC->GIni.GIValIrqMask; | |
981 | if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) { | |
982 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC, | |
983 | ("SPECIAL IRQ DP-Cards => %x\n", IntSrc)); | |
984 | pAC->CheckQueue = SK_FALSE; | |
985 | spin_lock(&pAC->SlowPathLock); | |
986 | if (IntSrc & SPECIAL_IRQS) | |
987 | SkGeSirqIsr(pAC, pAC->IoBase, IntSrc); | |
988 | ||
989 | SkEventDispatcher(pAC, pAC->IoBase); | |
990 | spin_unlock(&pAC->SlowPathLock); | |
991 | } | |
992 | /* | |
993 | * do it all again is case we cleared an interrupt that | |
994 | * came in after handling the ring (OUTs may be delayed | |
995 | * in hardware buffers, but are through after IN) | |
996 | * | |
997 | * rroesler: has been commented out and shifted to | |
998 | * SkGeDrvEvent(), because it is timer | |
999 | * guarded now | |
1000 | * | |
1001 | ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE); | |
1002 | ReceiveIrq(pAC, &pAC->RxPort[1], SK_TRUE); | |
1003 | */ | |
1004 | ||
1005 | if (pAC->CheckQueue) { | |
1006 | pAC->CheckQueue = SK_FALSE; | |
1007 | spin_lock(&pAC->SlowPathLock); | |
1008 | SkEventDispatcher(pAC, pAC->IoBase); | |
1009 | spin_unlock(&pAC->SlowPathLock); | |
1010 | } | |
1011 | ||
1012 | /* IRQ is processed - Enable IRQs again*/ | |
1013 | SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask); | |
1014 | ||
1015 | return SkIsrRetHandled; | |
1016 | } /* SkGeIsr */ | |
1017 | ||
1018 | ||
1019 | /**************************************************************************** | |
1020 | * | |
1021 | * SkGeIsrOnePort - handle adapter interrupts for single port adapter | |
1022 | * | |
1023 | * Description: | |
1024 | * The interrupt routine is called when the network adapter | |
1025 | * generates an interrupt. It may also be called if another device | |
1026 | * shares this interrupt vector with the driver. | |
1027 | * This is the same as above, but handles only one port. | |
1028 | * | |
1029 | * Returns: N/A | |
1030 | * | |
1031 | */ | |
1032 | static SkIsrRetVar SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs) | |
1033 | { | |
1034 | struct SK_NET_DEVICE *dev = (struct SK_NET_DEVICE *)dev_id; | |
1035 | DEV_NET *pNet; | |
1036 | SK_AC *pAC; | |
1037 | SK_U32 IntSrc; /* interrupts source register contents */ | |
1038 | ||
1039 | pNet = netdev_priv(dev); | |
1040 | pAC = pNet->pAC; | |
1041 | ||
1042 | /* | |
1043 | * Check and process if its our interrupt | |
1044 | */ | |
1045 | SK_IN32(pAC->IoBase, B0_SP_ISRC, &IntSrc); | |
1046 | if (IntSrc == 0) { | |
1047 | return SkIsrRetNone; | |
1048 | } | |
1049 | ||
1050 | while (((IntSrc & IRQ_MASK) & ~SPECIAL_IRQS) != 0) { | |
1051 | #if 0 /* software irq currently not used */ | |
1052 | if (IntSrc & IS_IRQ_SW) { | |
1053 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1054 | SK_DBGCAT_DRV_INT_SRC, | |
1055 | ("Software IRQ\n")); | |
1056 | } | |
1057 | #endif | |
1058 | if (IntSrc & IS_R1_F) { | |
1059 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1060 | SK_DBGCAT_DRV_INT_SRC, | |
1061 | ("EOF RX1 IRQ\n")); | |
1062 | ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE); | |
1063 | SK_PNMI_CNT_RX_INTR(pAC, 0); | |
1064 | } | |
1065 | #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */ | |
1066 | if (IntSrc & IS_XA1_F) { | |
1067 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1068 | SK_DBGCAT_DRV_INT_SRC, | |
1069 | ("EOF AS TX1 IRQ\n")); | |
1070 | SK_PNMI_CNT_TX_INTR(pAC, 0); | |
1071 | spin_lock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock); | |
1072 | FreeTxDescriptors(pAC, &pAC->TxPort[0][TX_PRIO_LOW]); | |
1073 | spin_unlock(&pAC->TxPort[0][TX_PRIO_LOW].TxDesRingLock); | |
1074 | } | |
1075 | #if 0 /* only if sync. queues used */ | |
1076 | if (IntSrc & IS_XS1_F) { | |
1077 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1078 | SK_DBGCAT_DRV_INT_SRC, | |
1079 | ("EOF SY TX1 IRQ\n")); | |
1080 | SK_PNMI_CNT_TX_INTR(pAC, 0); | |
1081 | spin_lock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock); | |
1082 | FreeTxDescriptors(pAC, 0, TX_PRIO_HIGH); | |
1083 | spin_unlock(&pAC->TxPort[0][TX_PRIO_HIGH].TxDesRingLock); | |
1084 | ClearTxIrq(pAC, 0, TX_PRIO_HIGH); | |
1085 | } | |
1086 | #endif | |
1087 | #endif | |
1088 | ||
1089 | /* do all IO at once */ | |
1090 | if (IntSrc & IS_R1_F) | |
1091 | ClearAndStartRx(pAC, 0); | |
1092 | #ifdef USE_TX_COMPLETE /* only if tx complete interrupt used */ | |
1093 | if (IntSrc & IS_XA1_F) | |
1094 | ClearTxIrq(pAC, 0, TX_PRIO_LOW); | |
1095 | #endif | |
1096 | SK_IN32(pAC->IoBase, B0_ISRC, &IntSrc); | |
1097 | } /* while (IntSrc & IRQ_MASK != 0) */ | |
1098 | ||
1099 | IntSrc &= pAC->GIni.GIValIrqMask; | |
1100 | if ((IntSrc & SPECIAL_IRQS) || pAC->CheckQueue) { | |
1101 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_INT_SRC, | |
1102 | ("SPECIAL IRQ SP-Cards => %x\n", IntSrc)); | |
1103 | pAC->CheckQueue = SK_FALSE; | |
1104 | spin_lock(&pAC->SlowPathLock); | |
1105 | if (IntSrc & SPECIAL_IRQS) | |
1106 | SkGeSirqIsr(pAC, pAC->IoBase, IntSrc); | |
1107 | ||
1108 | SkEventDispatcher(pAC, pAC->IoBase); | |
1109 | spin_unlock(&pAC->SlowPathLock); | |
1110 | } | |
1111 | /* | |
1112 | * do it all again is case we cleared an interrupt that | |
1113 | * came in after handling the ring (OUTs may be delayed | |
1114 | * in hardware buffers, but are through after IN) | |
1115 | * | |
1116 | * rroesler: has been commented out and shifted to | |
1117 | * SkGeDrvEvent(), because it is timer | |
1118 | * guarded now | |
1119 | * | |
1120 | ReceiveIrq(pAC, &pAC->RxPort[0], SK_TRUE); | |
1121 | */ | |
1122 | ||
1123 | /* IRQ is processed - Enable IRQs again*/ | |
1124 | SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask); | |
1125 | ||
1126 | return SkIsrRetHandled; | |
1127 | } /* SkGeIsrOnePort */ | |
1128 | ||
1129 | #ifdef CONFIG_NET_POLL_CONTROLLER | |
1130 | /**************************************************************************** | |
1131 | * | |
1132 | * SkGePollController - polling receive, for netconsole | |
1133 | * | |
1134 | * Description: | |
1135 | * Polling receive - used by netconsole and other diagnostic tools | |
1136 | * to allow network i/o with interrupts disabled. | |
1137 | * | |
1138 | * Returns: N/A | |
1139 | */ | |
1140 | static void SkGePollController(struct net_device *dev) | |
1141 | { | |
1142 | disable_irq(dev->irq); | |
1143 | SkGeIsr(dev->irq, dev, NULL); | |
1144 | enable_irq(dev->irq); | |
1145 | } | |
1146 | #endif | |
1147 | ||
1148 | /**************************************************************************** | |
1149 | * | |
1150 | * SkGeOpen - handle start of initialized adapter | |
1151 | * | |
1152 | * Description: | |
1153 | * This function starts the initialized adapter. | |
1154 | * The board level variable is set and the adapter is | |
1155 | * brought to full functionality. | |
1156 | * The device flags are set for operation. | |
1157 | * Do all necessary level 2 initialization, enable interrupts and | |
1158 | * give start command to RLMT. | |
1159 | * | |
1160 | * Returns: | |
1161 | * 0 on success | |
1162 | * != 0 on error | |
1163 | */ | |
1164 | static int SkGeOpen( | |
1165 | struct SK_NET_DEVICE *dev) | |
1166 | { | |
1167 | DEV_NET *pNet; | |
1168 | SK_AC *pAC; | |
1169 | unsigned long Flags; /* for spin lock */ | |
1170 | int i; | |
1171 | SK_EVPARA EvPara; /* an event parameter union */ | |
1172 | ||
1173 | pNet = netdev_priv(dev); | |
1174 | pAC = pNet->pAC; | |
1175 | ||
1176 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
1177 | ("SkGeOpen: pAC=0x%lX:\n", (unsigned long)pAC)); | |
1178 | ||
1179 | #ifdef SK_DIAG_SUPPORT | |
1180 | if (pAC->DiagModeActive == DIAG_ACTIVE) { | |
1181 | if (pAC->Pnmi.DiagAttached == SK_DIAG_RUNNING) { | |
1182 | return (-1); /* still in use by diag; deny actions */ | |
1183 | } | |
1184 | } | |
1185 | #endif | |
1186 | ||
1187 | /* Set blink mode */ | |
1188 | if ((pAC->PciDev->vendor == 0x1186) || (pAC->PciDev->vendor == 0x11ab )) | |
1189 | pAC->GIni.GILedBlinkCtrl = OEM_CONFIG_VALUE; | |
1190 | ||
1191 | if (pAC->BoardLevel == SK_INIT_DATA) { | |
1192 | /* level 1 init common modules here */ | |
1193 | if (SkGeInit(pAC, pAC->IoBase, SK_INIT_IO) != 0) { | |
1194 | printk("%s: HWInit (1) failed.\n", pAC->dev[pNet->PortNr]->name); | |
1195 | return (-1); | |
1196 | } | |
1197 | SkI2cInit (pAC, pAC->IoBase, SK_INIT_IO); | |
1198 | SkEventInit (pAC, pAC->IoBase, SK_INIT_IO); | |
1199 | SkPnmiInit (pAC, pAC->IoBase, SK_INIT_IO); | |
1200 | SkAddrInit (pAC, pAC->IoBase, SK_INIT_IO); | |
1201 | SkRlmtInit (pAC, pAC->IoBase, SK_INIT_IO); | |
1202 | SkTimerInit (pAC, pAC->IoBase, SK_INIT_IO); | |
1203 | pAC->BoardLevel = SK_INIT_IO; | |
1204 | } | |
1205 | ||
1206 | if (pAC->BoardLevel != SK_INIT_RUN) { | |
1207 | /* tschilling: Level 2 init modules here, check return value. */ | |
1208 | if (SkGeInit(pAC, pAC->IoBase, SK_INIT_RUN) != 0) { | |
1209 | printk("%s: HWInit (2) failed.\n", pAC->dev[pNet->PortNr]->name); | |
1210 | return (-1); | |
1211 | } | |
1212 | SkI2cInit (pAC, pAC->IoBase, SK_INIT_RUN); | |
1213 | SkEventInit (pAC, pAC->IoBase, SK_INIT_RUN); | |
1214 | SkPnmiInit (pAC, pAC->IoBase, SK_INIT_RUN); | |
1215 | SkAddrInit (pAC, pAC->IoBase, SK_INIT_RUN); | |
1216 | SkRlmtInit (pAC, pAC->IoBase, SK_INIT_RUN); | |
1217 | SkTimerInit (pAC, pAC->IoBase, SK_INIT_RUN); | |
1218 | pAC->BoardLevel = SK_INIT_RUN; | |
1219 | } | |
1220 | ||
1221 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
1222 | /* Enable transmit descriptor polling. */ | |
1223 | SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE); | |
1224 | FillRxRing(pAC, &pAC->RxPort[i]); | |
1225 | } | |
1226 | SkGeYellowLED(pAC, pAC->IoBase, 1); | |
1227 | ||
1228 | StartDrvCleanupTimer(pAC); | |
1229 | SkDimEnableModerationIfNeeded(pAC); | |
1230 | SkDimDisplayModerationSettings(pAC); | |
1231 | ||
1232 | pAC->GIni.GIValIrqMask &= IRQ_MASK; | |
1233 | ||
1234 | /* enable Interrupts */ | |
1235 | SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask); | |
1236 | SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK); | |
1237 | ||
1238 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
1239 | ||
1240 | if ((pAC->RlmtMode != 0) && (pAC->MaxPorts == 0)) { | |
1241 | EvPara.Para32[0] = pAC->RlmtNets; | |
1242 | EvPara.Para32[1] = -1; | |
1243 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS, | |
1244 | EvPara); | |
1245 | EvPara.Para32[0] = pAC->RlmtMode; | |
1246 | EvPara.Para32[1] = 0; | |
1247 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_MODE_CHANGE, | |
1248 | EvPara); | |
1249 | } | |
1250 | ||
1251 | EvPara.Para32[0] = pNet->NetNr; | |
1252 | EvPara.Para32[1] = -1; | |
1253 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); | |
1254 | SkEventDispatcher(pAC, pAC->IoBase); | |
1255 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
1256 | ||
1257 | pAC->MaxPorts++; | |
1da177e4 LT |
1258 | |
1259 | ||
1260 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
1261 | ("SkGeOpen suceeded\n")); | |
1262 | ||
1263 | return (0); | |
1264 | } /* SkGeOpen */ | |
1265 | ||
1266 | ||
1267 | /**************************************************************************** | |
1268 | * | |
1269 | * SkGeClose - Stop initialized adapter | |
1270 | * | |
1271 | * Description: | |
1272 | * Close initialized adapter. | |
1273 | * | |
1274 | * Returns: | |
1275 | * 0 - on success | |
1276 | * error code - on error | |
1277 | */ | |
1278 | static int SkGeClose( | |
1279 | struct SK_NET_DEVICE *dev) | |
1280 | { | |
1281 | DEV_NET *pNet; | |
1282 | DEV_NET *newPtrNet; | |
1283 | SK_AC *pAC; | |
1284 | ||
1285 | unsigned long Flags; /* for spin lock */ | |
1286 | int i; | |
1287 | int PortIdx; | |
1288 | SK_EVPARA EvPara; | |
1289 | ||
1290 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
1291 | ("SkGeClose: pAC=0x%lX ", (unsigned long)pAC)); | |
1292 | ||
1293 | pNet = netdev_priv(dev); | |
1294 | pAC = pNet->pAC; | |
1295 | ||
1296 | #ifdef SK_DIAG_SUPPORT | |
1297 | if (pAC->DiagModeActive == DIAG_ACTIVE) { | |
1298 | if (pAC->DiagFlowCtrl == SK_FALSE) { | |
1299 | /* | |
1300 | ** notify that the interface which has been closed | |
1301 | ** by operator interaction must not be started up | |
1302 | ** again when the DIAG has finished. | |
1303 | */ | |
1304 | newPtrNet = netdev_priv(pAC->dev[0]); | |
1305 | if (newPtrNet == pNet) { | |
1306 | pAC->WasIfUp[0] = SK_FALSE; | |
1307 | } else { | |
1308 | pAC->WasIfUp[1] = SK_FALSE; | |
1309 | } | |
1310 | return 0; /* return to system everything is fine... */ | |
1311 | } else { | |
1312 | pAC->DiagFlowCtrl = SK_FALSE; | |
1313 | } | |
1314 | } | |
1315 | #endif | |
1316 | ||
1317 | netif_stop_queue(dev); | |
1318 | ||
1319 | if (pAC->RlmtNets == 1) | |
1320 | PortIdx = pAC->ActivePort; | |
1321 | else | |
1322 | PortIdx = pNet->NetNr; | |
1323 | ||
1324 | StopDrvCleanupTimer(pAC); | |
1325 | ||
1326 | /* | |
1327 | * Clear multicast table, promiscuous mode .... | |
1328 | */ | |
1329 | SkAddrMcClear(pAC, pAC->IoBase, PortIdx, 0); | |
1330 | SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx, | |
1331 | SK_PROM_MODE_NONE); | |
1332 | ||
1333 | if (pAC->MaxPorts == 1) { | |
1334 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
1335 | /* disable interrupts */ | |
1336 | SK_OUT32(pAC->IoBase, B0_IMSK, 0); | |
1337 | EvPara.Para32[0] = pNet->NetNr; | |
1338 | EvPara.Para32[1] = -1; | |
1339 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
1340 | SkEventDispatcher(pAC, pAC->IoBase); | |
1341 | SK_OUT32(pAC->IoBase, B0_IMSK, 0); | |
1342 | /* stop the hardware */ | |
1343 | SkGeDeInit(pAC, pAC->IoBase); | |
1344 | pAC->BoardLevel = SK_INIT_DATA; | |
1345 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
1346 | } else { | |
1347 | ||
1348 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
1349 | EvPara.Para32[0] = pNet->NetNr; | |
1350 | EvPara.Para32[1] = -1; | |
1351 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
1352 | SkPnmiEvent(pAC, pAC->IoBase, SK_PNMI_EVT_XMAC_RESET, EvPara); | |
1353 | SkEventDispatcher(pAC, pAC->IoBase); | |
1354 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
1355 | ||
1356 | /* Stop port */ | |
1357 | spin_lock_irqsave(&pAC->TxPort[pNet->PortNr] | |
1358 | [TX_PRIO_LOW].TxDesRingLock, Flags); | |
1359 | SkGeStopPort(pAC, pAC->IoBase, pNet->PortNr, | |
1360 | SK_STOP_ALL, SK_HARD_RST); | |
1361 | spin_unlock_irqrestore(&pAC->TxPort[pNet->PortNr] | |
1362 | [TX_PRIO_LOW].TxDesRingLock, Flags); | |
1363 | } | |
1364 | ||
1365 | if (pAC->RlmtNets == 1) { | |
1366 | /* clear all descriptor rings */ | |
1367 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
1368 | ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE); | |
1369 | ClearRxRing(pAC, &pAC->RxPort[i]); | |
1370 | ClearTxRing(pAC, &pAC->TxPort[i][TX_PRIO_LOW]); | |
1371 | } | |
1372 | } else { | |
1373 | /* clear port descriptor rings */ | |
1374 | ReceiveIrq(pAC, &pAC->RxPort[pNet->PortNr], SK_TRUE); | |
1375 | ClearRxRing(pAC, &pAC->RxPort[pNet->PortNr]); | |
1376 | ClearTxRing(pAC, &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW]); | |
1377 | } | |
1378 | ||
1379 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
1380 | ("SkGeClose: done ")); | |
1381 | ||
1382 | SK_MEMSET(&(pAC->PnmiBackup), 0, sizeof(SK_PNMI_STRUCT_DATA)); | |
1383 | SK_MEMCPY(&(pAC->PnmiBackup), &(pAC->PnmiStruct), | |
1384 | sizeof(SK_PNMI_STRUCT_DATA)); | |
1385 | ||
1386 | pAC->MaxPorts--; | |
1da177e4 LT |
1387 | |
1388 | return (0); | |
1389 | } /* SkGeClose */ | |
1390 | ||
1391 | ||
1392 | /***************************************************************************** | |
1393 | * | |
1394 | * SkGeXmit - Linux frame transmit function | |
1395 | * | |
1396 | * Description: | |
1397 | * The system calls this function to send frames onto the wire. | |
1398 | * It puts the frame in the tx descriptor ring. If the ring is | |
1399 | * full then, the 'tbusy' flag is set. | |
1400 | * | |
1401 | * Returns: | |
1402 | * 0, if everything is ok | |
1403 | * !=0, on error | |
1404 | * WARNING: returning 1 in 'tbusy' case caused system crashes (double | |
1405 | * allocated skb's) !!! | |
1406 | */ | |
1407 | static int SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev) | |
1408 | { | |
1409 | DEV_NET *pNet; | |
1410 | SK_AC *pAC; | |
1411 | int Rc; /* return code of XmitFrame */ | |
1412 | ||
1413 | pNet = netdev_priv(dev); | |
1414 | pAC = pNet->pAC; | |
1415 | ||
1416 | if ((!skb_shinfo(skb)->nr_frags) || | |
1417 | (pAC->GIni.GIChipId == CHIP_ID_GENESIS)) { | |
1418 | /* Don't activate scatter-gather and hardware checksum */ | |
1419 | ||
1420 | if (pAC->RlmtNets == 2) | |
1421 | Rc = XmitFrame( | |
1422 | pAC, | |
1423 | &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW], | |
1424 | skb); | |
1425 | else | |
1426 | Rc = XmitFrame( | |
1427 | pAC, | |
1428 | &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW], | |
1429 | skb); | |
1430 | } else { | |
1431 | /* scatter-gather and hardware TCP checksumming anabled*/ | |
1432 | if (pAC->RlmtNets == 2) | |
1433 | Rc = XmitFrameSG( | |
1434 | pAC, | |
1435 | &pAC->TxPort[pNet->PortNr][TX_PRIO_LOW], | |
1436 | skb); | |
1437 | else | |
1438 | Rc = XmitFrameSG( | |
1439 | pAC, | |
1440 | &pAC->TxPort[pAC->ActivePort][TX_PRIO_LOW], | |
1441 | skb); | |
1442 | } | |
1443 | ||
1444 | /* Transmitter out of resources? */ | |
1445 | if (Rc <= 0) { | |
1446 | netif_stop_queue(dev); | |
1447 | } | |
1448 | ||
1449 | /* If not taken, give buffer ownership back to the | |
1450 | * queueing layer. | |
1451 | */ | |
1452 | if (Rc < 0) | |
1453 | return (1); | |
1454 | ||
1455 | dev->trans_start = jiffies; | |
1456 | return (0); | |
1457 | } /* SkGeXmit */ | |
1458 | ||
1459 | ||
1460 | /***************************************************************************** | |
1461 | * | |
1462 | * XmitFrame - fill one socket buffer into the transmit ring | |
1463 | * | |
1464 | * Description: | |
1465 | * This function puts a message into the transmit descriptor ring | |
1466 | * if there is a descriptors left. | |
1467 | * Linux skb's consist of only one continuous buffer. | |
1468 | * The first step locks the ring. It is held locked | |
1469 | * all time to avoid problems with SWITCH_../PORT_RESET. | |
1470 | * Then the descriptoris allocated. | |
1471 | * The second part is linking the buffer to the descriptor. | |
1472 | * At the very last, the Control field of the descriptor | |
1473 | * is made valid for the BMU and a start TX command is given | |
1474 | * if necessary. | |
1475 | * | |
1476 | * Returns: | |
1477 | * > 0 - on succes: the number of bytes in the message | |
1478 | * = 0 - on resource shortage: this frame sent or dropped, now | |
1479 | * the ring is full ( -> set tbusy) | |
1480 | * < 0 - on failure: other problems ( -> return failure to upper layers) | |
1481 | */ | |
1482 | static int XmitFrame( | |
1483 | SK_AC *pAC, /* pointer to adapter context */ | |
1484 | TX_PORT *pTxPort, /* pointer to struct of port to send to */ | |
1485 | struct sk_buff *pMessage) /* pointer to send-message */ | |
1486 | { | |
1487 | TXD *pTxd; /* the rxd to fill */ | |
1488 | TXD *pOldTxd; | |
1489 | unsigned long Flags; | |
1490 | SK_U64 PhysAddr; | |
1da177e4 LT |
1491 | int BytesSend = pMessage->len; |
1492 | ||
1493 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_TX_PROGRESS, ("X")); | |
1494 | ||
1495 | spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); | |
1496 | #ifndef USE_TX_COMPLETE | |
1497 | FreeTxDescriptors(pAC, pTxPort); | |
1498 | #endif | |
1499 | if (pTxPort->TxdRingFree == 0) { | |
1500 | /* | |
1501 | ** no enough free descriptors in ring at the moment. | |
1502 | ** Maybe free'ing some old one help? | |
1503 | */ | |
1504 | FreeTxDescriptors(pAC, pTxPort); | |
1505 | if (pTxPort->TxdRingFree == 0) { | |
1506 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | |
1507 | SK_PNMI_CNT_NO_TX_BUF(pAC, pTxPort->PortIndex); | |
1508 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1509 | SK_DBGCAT_DRV_TX_PROGRESS, | |
1510 | ("XmitFrame failed\n")); | |
1511 | /* | |
1512 | ** the desired message can not be sent | |
1513 | ** Because tbusy seems to be set, the message | |
1514 | ** should not be freed here. It will be used | |
1515 | ** by the scheduler of the ethernet handler | |
1516 | */ | |
1517 | return (-1); | |
1518 | } | |
1519 | } | |
1520 | ||
1521 | /* | |
1522 | ** If the passed socket buffer is of smaller MTU-size than 60, | |
1523 | ** copy everything into new buffer and fill all bytes between | |
1524 | ** the original packet end and the new packet end of 60 with 0x00. | |
1525 | ** This is to resolve faulty padding by the HW with 0xaa bytes. | |
1526 | */ | |
1527 | if (BytesSend < C_LEN_ETHERNET_MINSIZE) { | |
1528 | if ((pMessage = skb_padto(pMessage, C_LEN_ETHERNET_MINSIZE)) == NULL) { | |
1529 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | |
1530 | return 0; | |
1531 | } | |
1532 | pMessage->len = C_LEN_ETHERNET_MINSIZE; | |
1533 | } | |
1534 | ||
1535 | /* | |
1536 | ** advance head counter behind descriptor needed for this frame, | |
1537 | ** so that needed descriptor is reserved from that on. The next | |
1538 | ** action will be to add the passed buffer to the TX-descriptor | |
1539 | */ | |
1540 | pTxd = pTxPort->pTxdRingHead; | |
1541 | pTxPort->pTxdRingHead = pTxd->pNextTxd; | |
1542 | pTxPort->TxdRingFree--; | |
1543 | ||
1544 | #ifdef SK_DUMP_TX | |
1545 | DumpMsg(pMessage, "XmitFrame"); | |
1546 | #endif | |
1547 | ||
1548 | /* | |
1549 | ** First step is to map the data to be sent via the adapter onto | |
1550 | ** the DMA memory. Kernel 2.2 uses virt_to_bus(), but kernels 2.4 | |
1551 | ** and 2.6 need to use pci_map_page() for that mapping. | |
1552 | */ | |
1553 | PhysAddr = (SK_U64) pci_map_page(pAC->PciDev, | |
1554 | virt_to_page(pMessage->data), | |
1555 | ((unsigned long) pMessage->data & ~PAGE_MASK), | |
1556 | pMessage->len, | |
1557 | PCI_DMA_TODEVICE); | |
1558 | pTxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff); | |
1559 | pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); | |
1560 | pTxd->pMBuf = pMessage; | |
1561 | ||
1562 | if (pMessage->ip_summed == CHECKSUM_HW) { | |
596f86a8 SH |
1563 | u16 hdrlen = pMessage->h.raw - pMessage->data; |
1564 | u16 offset = hdrlen + pMessage->csum; | |
1565 | ||
1566 | if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) && | |
1da177e4 LT |
1567 | (pAC->GIni.GIChipRev == 0) && |
1568 | (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { | |
1569 | pTxd->TBControl = BMU_TCP_CHECK; | |
1570 | } else { | |
1571 | pTxd->TBControl = BMU_UDP_CHECK; | |
1572 | } | |
1573 | ||
596f86a8 SH |
1574 | pTxd->TcpSumOfs = 0; |
1575 | pTxd->TcpSumSt = hdrlen; | |
1576 | pTxd->TcpSumWr = offset; | |
1da177e4 LT |
1577 | |
1578 | pTxd->TBControl |= BMU_OWN | BMU_STF | | |
1579 | BMU_SW | BMU_EOF | | |
1580 | #ifdef USE_TX_COMPLETE | |
1581 | BMU_IRQ_EOF | | |
1582 | #endif | |
1583 | pMessage->len; | |
1584 | } else { | |
1585 | pTxd->TBControl = BMU_OWN | BMU_STF | BMU_CHECK | | |
1586 | BMU_SW | BMU_EOF | | |
1587 | #ifdef USE_TX_COMPLETE | |
1588 | BMU_IRQ_EOF | | |
1589 | #endif | |
1590 | pMessage->len; | |
1591 | } | |
1592 | ||
1593 | /* | |
1594 | ** If previous descriptor already done, give TX start cmd | |
1595 | */ | |
1596 | pOldTxd = xchg(&pTxPort->pTxdRingPrev, pTxd); | |
1597 | if ((pOldTxd->TBControl & BMU_OWN) == 0) { | |
1598 | SK_OUT8(pTxPort->HwAddr, Q_CSR, CSR_START); | |
1599 | } | |
1600 | ||
1601 | /* | |
1602 | ** after releasing the lock, the skb may immediately be free'd | |
1603 | */ | |
1604 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | |
1605 | if (pTxPort->TxdRingFree != 0) { | |
1606 | return (BytesSend); | |
1607 | } else { | |
1608 | return (0); | |
1609 | } | |
1610 | ||
1611 | } /* XmitFrame */ | |
1612 | ||
1613 | /***************************************************************************** | |
1614 | * | |
1615 | * XmitFrameSG - fill one socket buffer into the transmit ring | |
1616 | * (use SG and TCP/UDP hardware checksumming) | |
1617 | * | |
1618 | * Description: | |
1619 | * This function puts a message into the transmit descriptor ring | |
1620 | * if there is a descriptors left. | |
1621 | * | |
1622 | * Returns: | |
1623 | * > 0 - on succes: the number of bytes in the message | |
1624 | * = 0 - on resource shortage: this frame sent or dropped, now | |
1625 | * the ring is full ( -> set tbusy) | |
1626 | * < 0 - on failure: other problems ( -> return failure to upper layers) | |
1627 | */ | |
1628 | static int XmitFrameSG( | |
1629 | SK_AC *pAC, /* pointer to adapter context */ | |
1630 | TX_PORT *pTxPort, /* pointer to struct of port to send to */ | |
1631 | struct sk_buff *pMessage) /* pointer to send-message */ | |
1632 | { | |
1633 | ||
1634 | TXD *pTxd; | |
1635 | TXD *pTxdFst; | |
1636 | TXD *pTxdLst; | |
1637 | int CurrFrag; | |
1638 | int BytesSend; | |
1da177e4 LT |
1639 | skb_frag_t *sk_frag; |
1640 | SK_U64 PhysAddr; | |
1641 | unsigned long Flags; | |
596f86a8 | 1642 | SK_U32 Control; |
1da177e4 LT |
1643 | |
1644 | spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); | |
1645 | #ifndef USE_TX_COMPLETE | |
1646 | FreeTxDescriptors(pAC, pTxPort); | |
1647 | #endif | |
1648 | if ((skb_shinfo(pMessage)->nr_frags +1) > pTxPort->TxdRingFree) { | |
1649 | FreeTxDescriptors(pAC, pTxPort); | |
1650 | if ((skb_shinfo(pMessage)->nr_frags + 1) > pTxPort->TxdRingFree) { | |
1651 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | |
1652 | SK_PNMI_CNT_NO_TX_BUF(pAC, pTxPort->PortIndex); | |
1653 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1654 | SK_DBGCAT_DRV_TX_PROGRESS, | |
1655 | ("XmitFrameSG failed - Ring full\n")); | |
1656 | /* this message can not be sent now */ | |
1657 | return(-1); | |
1658 | } | |
1659 | } | |
1660 | ||
1661 | pTxd = pTxPort->pTxdRingHead; | |
1662 | pTxdFst = pTxd; | |
1663 | pTxdLst = pTxd; | |
1664 | BytesSend = 0; | |
1da177e4 LT |
1665 | |
1666 | /* | |
1667 | ** Map the first fragment (header) into the DMA-space | |
1668 | */ | |
1669 | PhysAddr = (SK_U64) pci_map_page(pAC->PciDev, | |
1670 | virt_to_page(pMessage->data), | |
1671 | ((unsigned long) pMessage->data & ~PAGE_MASK), | |
1672 | skb_headlen(pMessage), | |
1673 | PCI_DMA_TODEVICE); | |
1674 | ||
1675 | pTxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff); | |
1676 | pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); | |
1677 | ||
1678 | /* | |
1679 | ** Does the HW need to evaluate checksum for TCP or UDP packets? | |
1680 | */ | |
1681 | if (pMessage->ip_summed == CHECKSUM_HW) { | |
596f86a8 SH |
1682 | u16 hdrlen = pMessage->h.raw - pMessage->data; |
1683 | u16 offset = hdrlen + pMessage->csum; | |
1684 | ||
1685 | Control = BMU_STFWD; | |
1686 | ||
1da177e4 LT |
1687 | /* |
1688 | ** We have to use the opcode for tcp here, because the | |
1689 | ** opcode for udp is not working in the hardware yet | |
1690 | ** (Revision 2.0) | |
1691 | */ | |
596f86a8 | 1692 | if ((pMessage->h.ipiph->protocol == IPPROTO_UDP ) && |
1da177e4 LT |
1693 | (pAC->GIni.GIChipRev == 0) && |
1694 | (pAC->GIni.GIChipId == CHIP_ID_YUKON)) { | |
596f86a8 | 1695 | Control |= BMU_TCP_CHECK; |
1da177e4 | 1696 | } else { |
596f86a8 | 1697 | Control |= BMU_UDP_CHECK; |
1da177e4 LT |
1698 | } |
1699 | ||
596f86a8 SH |
1700 | pTxd->TcpSumOfs = 0; |
1701 | pTxd->TcpSumSt = hdrlen; | |
1702 | pTxd->TcpSumWr = offset; | |
1703 | } else | |
1704 | Control = BMU_CHECK | BMU_SW; | |
1705 | ||
1706 | pTxd->TBControl = BMU_STF | Control | skb_headlen(pMessage); | |
1da177e4 LT |
1707 | |
1708 | pTxd = pTxd->pNextTxd; | |
1709 | pTxPort->TxdRingFree--; | |
1710 | BytesSend += skb_headlen(pMessage); | |
1711 | ||
1712 | /* | |
1713 | ** Browse over all SG fragments and map each of them into the DMA space | |
1714 | */ | |
1715 | for (CurrFrag = 0; CurrFrag < skb_shinfo(pMessage)->nr_frags; CurrFrag++) { | |
1716 | sk_frag = &skb_shinfo(pMessage)->frags[CurrFrag]; | |
1717 | /* | |
1718 | ** we already have the proper value in entry | |
1719 | */ | |
1720 | PhysAddr = (SK_U64) pci_map_page(pAC->PciDev, | |
1721 | sk_frag->page, | |
1722 | sk_frag->page_offset, | |
1723 | sk_frag->size, | |
1724 | PCI_DMA_TODEVICE); | |
1725 | ||
1726 | pTxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff); | |
1727 | pTxd->VDataHigh = (SK_U32) (PhysAddr >> 32); | |
1728 | pTxd->pMBuf = pMessage; | |
1729 | ||
596f86a8 | 1730 | pTxd->TBControl = Control | BMU_OWN | sk_frag->size;; |
1da177e4 LT |
1731 | |
1732 | /* | |
1733 | ** Do we have the last fragment? | |
1734 | */ | |
1735 | if( (CurrFrag+1) == skb_shinfo(pMessage)->nr_frags ) { | |
1736 | #ifdef USE_TX_COMPLETE | |
596f86a8 | 1737 | pTxd->TBControl |= BMU_EOF | BMU_IRQ_EOF; |
1da177e4 | 1738 | #else |
596f86a8 | 1739 | pTxd->TBControl |= BMU_EOF; |
1da177e4 LT |
1740 | #endif |
1741 | pTxdFst->TBControl |= BMU_OWN | BMU_SW; | |
1da177e4 LT |
1742 | } |
1743 | pTxdLst = pTxd; | |
1744 | pTxd = pTxd->pNextTxd; | |
1745 | pTxPort->TxdRingFree--; | |
1746 | BytesSend += sk_frag->size; | |
1747 | } | |
1748 | ||
1749 | /* | |
1750 | ** If previous descriptor already done, give TX start cmd | |
1751 | */ | |
1752 | if ((pTxPort->pTxdRingPrev->TBControl & BMU_OWN) == 0) { | |
1753 | SK_OUT8(pTxPort->HwAddr, Q_CSR, CSR_START); | |
1754 | } | |
1755 | ||
1756 | pTxPort->pTxdRingPrev = pTxdLst; | |
1757 | pTxPort->pTxdRingHead = pTxd; | |
1758 | ||
1759 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | |
1760 | ||
1761 | if (pTxPort->TxdRingFree > 0) { | |
1762 | return (BytesSend); | |
1763 | } else { | |
1764 | return (0); | |
1765 | } | |
1766 | } | |
1767 | ||
1768 | /***************************************************************************** | |
1769 | * | |
1770 | * FreeTxDescriptors - release descriptors from the descriptor ring | |
1771 | * | |
1772 | * Description: | |
1773 | * This function releases descriptors from a transmit ring if they | |
1774 | * have been sent by the BMU. | |
1775 | * If a descriptors is sent, it can be freed and the message can | |
1776 | * be freed, too. | |
1777 | * The SOFTWARE controllable bit is used to prevent running around a | |
1778 | * completely free ring for ever. If this bit is no set in the | |
1779 | * frame (by XmitFrame), this frame has never been sent or is | |
1780 | * already freed. | |
1781 | * The Tx descriptor ring lock must be held while calling this function !!! | |
1782 | * | |
1783 | * Returns: | |
1784 | * none | |
1785 | */ | |
1786 | static void FreeTxDescriptors( | |
1787 | SK_AC *pAC, /* pointer to the adapter context */ | |
1788 | TX_PORT *pTxPort) /* pointer to destination port structure */ | |
1789 | { | |
1790 | TXD *pTxd; /* pointer to the checked descriptor */ | |
1791 | TXD *pNewTail; /* pointer to 'end' of the ring */ | |
1792 | SK_U32 Control; /* TBControl field of descriptor */ | |
1793 | SK_U64 PhysAddr; /* address of DMA mapping */ | |
1794 | ||
1795 | pNewTail = pTxPort->pTxdRingTail; | |
1796 | pTxd = pNewTail; | |
1797 | /* | |
1798 | ** loop forever; exits if BMU_SW bit not set in start frame | |
1799 | ** or BMU_OWN bit set in any frame | |
1800 | */ | |
1801 | while (1) { | |
1802 | Control = pTxd->TBControl; | |
1803 | if ((Control & BMU_SW) == 0) { | |
1804 | /* | |
1805 | ** software controllable bit is set in first | |
1806 | ** fragment when given to BMU. Not set means that | |
1807 | ** this fragment was never sent or is already | |
1808 | ** freed ( -> ring completely free now). | |
1809 | */ | |
1810 | pTxPort->pTxdRingTail = pTxd; | |
1811 | netif_wake_queue(pAC->dev[pTxPort->PortIndex]); | |
1812 | return; | |
1813 | } | |
1814 | if (Control & BMU_OWN) { | |
1815 | pTxPort->pTxdRingTail = pTxd; | |
1816 | if (pTxPort->TxdRingFree > 0) { | |
1817 | netif_wake_queue(pAC->dev[pTxPort->PortIndex]); | |
1818 | } | |
1819 | return; | |
1820 | } | |
1821 | ||
1822 | /* | |
1823 | ** release the DMA mapping, because until not unmapped | |
1824 | ** this buffer is considered being under control of the | |
1825 | ** adapter card! | |
1826 | */ | |
1827 | PhysAddr = ((SK_U64) pTxd->VDataHigh) << (SK_U64) 32; | |
1828 | PhysAddr |= (SK_U64) pTxd->VDataLow; | |
1829 | pci_unmap_page(pAC->PciDev, PhysAddr, | |
1830 | pTxd->pMBuf->len, | |
1831 | PCI_DMA_TODEVICE); | |
1832 | ||
1833 | if (Control & BMU_EOF) | |
1834 | DEV_KFREE_SKB_ANY(pTxd->pMBuf); /* free message */ | |
1835 | ||
1836 | pTxPort->TxdRingFree++; | |
1837 | pTxd->TBControl &= ~BMU_SW; | |
1838 | pTxd = pTxd->pNextTxd; /* point behind fragment with EOF */ | |
1839 | } /* while(forever) */ | |
1840 | } /* FreeTxDescriptors */ | |
1841 | ||
1842 | /***************************************************************************** | |
1843 | * | |
1844 | * FillRxRing - fill the receive ring with valid descriptors | |
1845 | * | |
1846 | * Description: | |
1847 | * This function fills the receive ring descriptors with data | |
1848 | * segments and makes them valid for the BMU. | |
1849 | * The active ring is filled completely, if possible. | |
1850 | * The non-active ring is filled only partial to save memory. | |
1851 | * | |
1852 | * Description of rx ring structure: | |
1853 | * head - points to the descriptor which will be used next by the BMU | |
1854 | * tail - points to the next descriptor to give to the BMU | |
1855 | * | |
1856 | * Returns: N/A | |
1857 | */ | |
1858 | static void FillRxRing( | |
1859 | SK_AC *pAC, /* pointer to the adapter context */ | |
1860 | RX_PORT *pRxPort) /* ptr to port struct for which the ring | |
1861 | should be filled */ | |
1862 | { | |
1863 | unsigned long Flags; | |
1864 | ||
1865 | spin_lock_irqsave(&pRxPort->RxDesRingLock, Flags); | |
1866 | while (pRxPort->RxdRingFree > pRxPort->RxFillLimit) { | |
1867 | if(!FillRxDescriptor(pAC, pRxPort)) | |
1868 | break; | |
1869 | } | |
1870 | spin_unlock_irqrestore(&pRxPort->RxDesRingLock, Flags); | |
1871 | } /* FillRxRing */ | |
1872 | ||
1873 | ||
1874 | /***************************************************************************** | |
1875 | * | |
1876 | * FillRxDescriptor - fill one buffer into the receive ring | |
1877 | * | |
1878 | * Description: | |
1879 | * The function allocates a new receive buffer and | |
1880 | * puts it into the next descriptor. | |
1881 | * | |
1882 | * Returns: | |
1883 | * SK_TRUE - a buffer was added to the ring | |
1884 | * SK_FALSE - a buffer could not be added | |
1885 | */ | |
1886 | static SK_BOOL FillRxDescriptor( | |
1887 | SK_AC *pAC, /* pointer to the adapter context struct */ | |
1888 | RX_PORT *pRxPort) /* ptr to port struct of ring to fill */ | |
1889 | { | |
1890 | struct sk_buff *pMsgBlock; /* pointer to a new message block */ | |
1891 | RXD *pRxd; /* the rxd to fill */ | |
1892 | SK_U16 Length; /* data fragment length */ | |
1893 | SK_U64 PhysAddr; /* physical address of a rx buffer */ | |
1894 | ||
1895 | pMsgBlock = alloc_skb(pAC->RxBufSize, GFP_ATOMIC); | |
1896 | if (pMsgBlock == NULL) { | |
1897 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
1898 | SK_DBGCAT_DRV_ENTRY, | |
1899 | ("%s: Allocation of rx buffer failed !\n", | |
1900 | pAC->dev[pRxPort->PortIndex]->name)); | |
1901 | SK_PNMI_CNT_NO_RX_BUF(pAC, pRxPort->PortIndex); | |
1902 | return(SK_FALSE); | |
1903 | } | |
1904 | skb_reserve(pMsgBlock, 2); /* to align IP frames */ | |
1905 | /* skb allocated ok, so add buffer */ | |
1906 | pRxd = pRxPort->pRxdRingTail; | |
1907 | pRxPort->pRxdRingTail = pRxd->pNextRxd; | |
1908 | pRxPort->RxdRingFree--; | |
1909 | Length = pAC->RxBufSize; | |
1910 | PhysAddr = (SK_U64) pci_map_page(pAC->PciDev, | |
1911 | virt_to_page(pMsgBlock->data), | |
1912 | ((unsigned long) pMsgBlock->data & | |
1913 | ~PAGE_MASK), | |
1914 | pAC->RxBufSize - 2, | |
1915 | PCI_DMA_FROMDEVICE); | |
1916 | ||
1917 | pRxd->VDataLow = (SK_U32) (PhysAddr & 0xffffffff); | |
1918 | pRxd->VDataHigh = (SK_U32) (PhysAddr >> 32); | |
1919 | pRxd->pMBuf = pMsgBlock; | |
1920 | pRxd->RBControl = BMU_OWN | | |
1921 | BMU_STF | | |
1922 | BMU_IRQ_EOF | | |
1923 | BMU_TCP_CHECK | | |
1924 | Length; | |
1925 | return (SK_TRUE); | |
1926 | ||
1927 | } /* FillRxDescriptor */ | |
1928 | ||
1929 | ||
1930 | /***************************************************************************** | |
1931 | * | |
1932 | * ReQueueRxBuffer - fill one buffer back into the receive ring | |
1933 | * | |
1934 | * Description: | |
1935 | * Fill a given buffer back into the rx ring. The buffer | |
1936 | * has been previously allocated and aligned, and its phys. | |
1937 | * address calculated, so this is no more necessary. | |
1938 | * | |
1939 | * Returns: N/A | |
1940 | */ | |
1941 | static void ReQueueRxBuffer( | |
1942 | SK_AC *pAC, /* pointer to the adapter context struct */ | |
1943 | RX_PORT *pRxPort, /* ptr to port struct of ring to fill */ | |
1944 | struct sk_buff *pMsg, /* pointer to the buffer */ | |
1945 | SK_U32 PhysHigh, /* phys address high dword */ | |
1946 | SK_U32 PhysLow) /* phys address low dword */ | |
1947 | { | |
1948 | RXD *pRxd; /* the rxd to fill */ | |
1949 | SK_U16 Length; /* data fragment length */ | |
1950 | ||
1951 | pRxd = pRxPort->pRxdRingTail; | |
1952 | pRxPort->pRxdRingTail = pRxd->pNextRxd; | |
1953 | pRxPort->RxdRingFree--; | |
1954 | Length = pAC->RxBufSize; | |
1955 | ||
1956 | pRxd->VDataLow = PhysLow; | |
1957 | pRxd->VDataHigh = PhysHigh; | |
1958 | pRxd->pMBuf = pMsg; | |
1959 | pRxd->RBControl = BMU_OWN | | |
1960 | BMU_STF | | |
1961 | BMU_IRQ_EOF | | |
1962 | BMU_TCP_CHECK | | |
1963 | Length; | |
1964 | return; | |
1965 | } /* ReQueueRxBuffer */ | |
1966 | ||
1967 | /***************************************************************************** | |
1968 | * | |
1969 | * ReceiveIrq - handle a receive IRQ | |
1970 | * | |
1971 | * Description: | |
1972 | * This function is called when a receive IRQ is set. | |
1973 | * It walks the receive descriptor ring and sends up all | |
1974 | * frames that are complete. | |
1975 | * | |
1976 | * Returns: N/A | |
1977 | */ | |
1978 | static void ReceiveIrq( | |
1979 | SK_AC *pAC, /* pointer to adapter context */ | |
1980 | RX_PORT *pRxPort, /* pointer to receive port struct */ | |
1981 | SK_BOOL SlowPathLock) /* indicates if SlowPathLock is needed */ | |
1982 | { | |
1983 | RXD *pRxd; /* pointer to receive descriptors */ | |
1984 | SK_U32 Control; /* control field of descriptor */ | |
1985 | struct sk_buff *pMsg; /* pointer to message holding frame */ | |
1986 | struct sk_buff *pNewMsg; /* pointer to a new message for copying frame */ | |
1987 | int FrameLength; /* total length of received frame */ | |
1da177e4 LT |
1988 | SK_MBUF *pRlmtMbuf; /* ptr to a buffer for giving a frame to rlmt */ |
1989 | SK_EVPARA EvPara; /* an event parameter union */ | |
1990 | unsigned long Flags; /* for spin lock */ | |
1991 | int PortIndex = pRxPort->PortIndex; | |
1992 | unsigned int Offset; | |
1993 | unsigned int NumBytes; | |
1994 | unsigned int ForRlmt; | |
1995 | SK_BOOL IsBc; | |
1996 | SK_BOOL IsMc; | |
1997 | SK_BOOL IsBadFrame; /* Bad frame */ | |
1998 | ||
1999 | SK_U32 FrameStat; | |
1da177e4 LT |
2000 | SK_U64 PhysAddr; |
2001 | ||
2002 | rx_start: | |
2003 | /* do forever; exit if BMU_OWN found */ | |
2004 | for ( pRxd = pRxPort->pRxdRingHead ; | |
2005 | pRxPort->RxdRingFree < pAC->RxDescrPerRing ; | |
2006 | pRxd = pRxd->pNextRxd, | |
2007 | pRxPort->pRxdRingHead = pRxd, | |
2008 | pRxPort->RxdRingFree ++) { | |
2009 | ||
2010 | /* | |
2011 | * For a better understanding of this loop | |
2012 | * Go through every descriptor beginning at the head | |
2013 | * Please note: the ring might be completely received so the OWN bit | |
2014 | * set is not a good crirteria to leave that loop. | |
2015 | * Therefore the RingFree counter is used. | |
2016 | * On entry of this loop pRxd is a pointer to the Rxd that needs | |
2017 | * to be checked next. | |
2018 | */ | |
2019 | ||
2020 | Control = pRxd->RBControl; | |
2021 | ||
2022 | /* check if this descriptor is ready */ | |
2023 | if ((Control & BMU_OWN) != 0) { | |
2024 | /* this descriptor is not yet ready */ | |
2025 | /* This is the usual end of the loop */ | |
2026 | /* We don't need to start the ring again */ | |
2027 | FillRxRing(pAC, pRxPort); | |
2028 | return; | |
2029 | } | |
2030 | pAC->DynIrqModInfo.NbrProcessedDescr++; | |
2031 | ||
2032 | /* get length of frame and check it */ | |
2033 | FrameLength = Control & BMU_BBC; | |
2034 | if (FrameLength > pAC->RxBufSize) { | |
2035 | goto rx_failed; | |
2036 | } | |
2037 | ||
2038 | /* check for STF and EOF */ | |
2039 | if ((Control & (BMU_STF | BMU_EOF)) != (BMU_STF | BMU_EOF)) { | |
2040 | goto rx_failed; | |
2041 | } | |
2042 | ||
2043 | /* here we have a complete frame in the ring */ | |
2044 | pMsg = pRxd->pMBuf; | |
2045 | ||
2046 | FrameStat = pRxd->FrameStat; | |
2047 | ||
2048 | /* check for frame length mismatch */ | |
2049 | #define XMR_FS_LEN_SHIFT 18 | |
2050 | #define GMR_FS_LEN_SHIFT 16 | |
2051 | if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) { | |
2052 | if (FrameLength != (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT)) { | |
2053 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
2054 | SK_DBGCAT_DRV_RX_PROGRESS, | |
2055 | ("skge: Frame length mismatch (%u/%u).\n", | |
2056 | FrameLength, | |
2057 | (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT))); | |
2058 | goto rx_failed; | |
2059 | } | |
2060 | } | |
2061 | else { | |
2062 | if (FrameLength != (SK_U32) (FrameStat >> GMR_FS_LEN_SHIFT)) { | |
2063 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
2064 | SK_DBGCAT_DRV_RX_PROGRESS, | |
2065 | ("skge: Frame length mismatch (%u/%u).\n", | |
2066 | FrameLength, | |
2067 | (SK_U32) (FrameStat >> XMR_FS_LEN_SHIFT))); | |
2068 | goto rx_failed; | |
2069 | } | |
2070 | } | |
2071 | ||
2072 | /* Set Rx Status */ | |
2073 | if (pAC->GIni.GIChipId == CHIP_ID_GENESIS) { | |
2074 | IsBc = (FrameStat & XMR_FS_BC) != 0; | |
2075 | IsMc = (FrameStat & XMR_FS_MC) != 0; | |
2076 | IsBadFrame = (FrameStat & | |
2077 | (XMR_FS_ANY_ERR | XMR_FS_2L_VLAN)) != 0; | |
2078 | } else { | |
2079 | IsBc = (FrameStat & GMR_FS_BC) != 0; | |
2080 | IsMc = (FrameStat & GMR_FS_MC) != 0; | |
2081 | IsBadFrame = (((FrameStat & GMR_FS_ANY_ERR) != 0) || | |
2082 | ((FrameStat & GMR_FS_RX_OK) == 0)); | |
2083 | } | |
2084 | ||
2085 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 0, | |
2086 | ("Received frame of length %d on port %d\n", | |
2087 | FrameLength, PortIndex)); | |
2088 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 0, | |
2089 | ("Number of free rx descriptors: %d\n", | |
2090 | pRxPort->RxdRingFree)); | |
2091 | /* DumpMsg(pMsg, "Rx"); */ | |
2092 | ||
2093 | if ((Control & BMU_STAT_VAL) != BMU_STAT_VAL || (IsBadFrame)) { | |
2094 | #if 0 | |
2095 | (FrameStat & (XMR_FS_ANY_ERR | XMR_FS_2L_VLAN)) != 0) { | |
2096 | #endif | |
2097 | /* there is a receive error in this frame */ | |
2098 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
2099 | SK_DBGCAT_DRV_RX_PROGRESS, | |
2100 | ("skge: Error in received frame, dropped!\n" | |
2101 | "Control: %x\nRxStat: %x\n", | |
2102 | Control, FrameStat)); | |
2103 | ||
2104 | ReQueueRxBuffer(pAC, pRxPort, pMsg, | |
2105 | pRxd->VDataHigh, pRxd->VDataLow); | |
2106 | ||
2107 | continue; | |
2108 | } | |
2109 | ||
2110 | /* | |
2111 | * if short frame then copy data to reduce memory waste | |
2112 | */ | |
2113 | if ((FrameLength < SK_COPY_THRESHOLD) && | |
2114 | ((pNewMsg = alloc_skb(FrameLength+2, GFP_ATOMIC)) != NULL)) { | |
2115 | /* | |
2116 | * Short frame detected and allocation successfull | |
2117 | */ | |
2118 | /* use new skb and copy data */ | |
2119 | skb_reserve(pNewMsg, 2); | |
2120 | skb_put(pNewMsg, FrameLength); | |
2121 | PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32; | |
2122 | PhysAddr |= (SK_U64) pRxd->VDataLow; | |
2123 | ||
2124 | pci_dma_sync_single_for_cpu(pAC->PciDev, | |
2125 | (dma_addr_t) PhysAddr, | |
2126 | FrameLength, | |
2127 | PCI_DMA_FROMDEVICE); | |
596f86a8 SH |
2128 | memcpy(pNewMsg->data, pMsg, FrameLength); |
2129 | ||
1da177e4 LT |
2130 | pci_dma_sync_single_for_device(pAC->PciDev, |
2131 | (dma_addr_t) PhysAddr, | |
2132 | FrameLength, | |
2133 | PCI_DMA_FROMDEVICE); | |
2134 | ReQueueRxBuffer(pAC, pRxPort, pMsg, | |
2135 | pRxd->VDataHigh, pRxd->VDataLow); | |
2136 | ||
2137 | pMsg = pNewMsg; | |
2138 | ||
2139 | } | |
2140 | else { | |
2141 | /* | |
2142 | * if large frame, or SKB allocation failed, pass | |
2143 | * the SKB directly to the networking | |
2144 | */ | |
2145 | ||
2146 | PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32; | |
2147 | PhysAddr |= (SK_U64) pRxd->VDataLow; | |
2148 | ||
2149 | /* release the DMA mapping */ | |
2150 | pci_unmap_single(pAC->PciDev, | |
2151 | PhysAddr, | |
2152 | pAC->RxBufSize - 2, | |
2153 | PCI_DMA_FROMDEVICE); | |
2154 | ||
2155 | /* set length in message */ | |
2156 | skb_put(pMsg, FrameLength); | |
596f86a8 | 2157 | } /* frame > SK_COPY_TRESHOLD */ |
1da177e4 LT |
2158 | |
2159 | #ifdef USE_SK_RX_CHECKSUM | |
92f268e0 | 2160 | pMsg->csum = pRxd->TcpSums & 0xffff; |
596f86a8 | 2161 | pMsg->ip_summed = CHECKSUM_HW; |
1da177e4 | 2162 | #else |
596f86a8 | 2163 | pMsg->ip_summed = CHECKSUM_NONE; |
1da177e4 | 2164 | #endif |
596f86a8 | 2165 | |
1da177e4 LT |
2166 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("V")); |
2167 | ForRlmt = SK_RLMT_RX_PROTOCOL; | |
2168 | #if 0 | |
2169 | IsBc = (FrameStat & XMR_FS_BC)==XMR_FS_BC; | |
2170 | #endif | |
2171 | SK_RLMT_PRE_LOOKAHEAD(pAC, PortIndex, FrameLength, | |
2172 | IsBc, &Offset, &NumBytes); | |
2173 | if (NumBytes != 0) { | |
2174 | #if 0 | |
2175 | IsMc = (FrameStat & XMR_FS_MC)==XMR_FS_MC; | |
2176 | #endif | |
2177 | SK_RLMT_LOOKAHEAD(pAC, PortIndex, | |
2178 | &pMsg->data[Offset], | |
2179 | IsBc, IsMc, &ForRlmt); | |
2180 | } | |
2181 | if (ForRlmt == SK_RLMT_RX_PROTOCOL) { | |
2182 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("W")); | |
2183 | /* send up only frames from active port */ | |
2184 | if ((PortIndex == pAC->ActivePort) || | |
2185 | (pAC->RlmtNets == 2)) { | |
2186 | /* frame for upper layer */ | |
2187 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, 1,("U")); | |
2188 | #ifdef xDEBUG | |
2189 | DumpMsg(pMsg, "Rx"); | |
2190 | #endif | |
2191 | SK_PNMI_CNT_RX_OCTETS_DELIVERED(pAC, | |
2192 | FrameLength, pRxPort->PortIndex); | |
2193 | ||
2194 | pMsg->dev = pAC->dev[pRxPort->PortIndex]; | |
2195 | pMsg->protocol = eth_type_trans(pMsg, | |
2196 | pAC->dev[pRxPort->PortIndex]); | |
2197 | netif_rx(pMsg); | |
2198 | pAC->dev[pRxPort->PortIndex]->last_rx = jiffies; | |
2199 | } | |
2200 | else { | |
2201 | /* drop frame */ | |
2202 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
2203 | SK_DBGCAT_DRV_RX_PROGRESS, | |
2204 | ("D")); | |
2205 | DEV_KFREE_SKB(pMsg); | |
2206 | } | |
2207 | ||
2208 | } /* if not for rlmt */ | |
2209 | else { | |
2210 | /* packet for rlmt */ | |
2211 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
2212 | SK_DBGCAT_DRV_RX_PROGRESS, ("R")); | |
2213 | pRlmtMbuf = SkDrvAllocRlmtMbuf(pAC, | |
2214 | pAC->IoBase, FrameLength); | |
2215 | if (pRlmtMbuf != NULL) { | |
2216 | pRlmtMbuf->pNext = NULL; | |
2217 | pRlmtMbuf->Length = FrameLength; | |
2218 | pRlmtMbuf->PortIdx = PortIndex; | |
2219 | EvPara.pParaPtr = pRlmtMbuf; | |
2220 | memcpy((char*)(pRlmtMbuf->pData), | |
2221 | (char*)(pMsg->data), | |
2222 | FrameLength); | |
2223 | ||
2224 | /* SlowPathLock needed? */ | |
2225 | if (SlowPathLock == SK_TRUE) { | |
2226 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
2227 | SkEventQueue(pAC, SKGE_RLMT, | |
2228 | SK_RLMT_PACKET_RECEIVED, | |
2229 | EvPara); | |
2230 | pAC->CheckQueue = SK_TRUE; | |
2231 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
2232 | } else { | |
2233 | SkEventQueue(pAC, SKGE_RLMT, | |
2234 | SK_RLMT_PACKET_RECEIVED, | |
2235 | EvPara); | |
2236 | pAC->CheckQueue = SK_TRUE; | |
2237 | } | |
2238 | ||
2239 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, | |
2240 | SK_DBGCAT_DRV_RX_PROGRESS, | |
2241 | ("Q")); | |
2242 | } | |
2243 | if ((pAC->dev[pRxPort->PortIndex]->flags & | |
2244 | (IFF_PROMISC | IFF_ALLMULTI)) != 0 || | |
2245 | (ForRlmt & SK_RLMT_RX_PROTOCOL) == | |
2246 | SK_RLMT_RX_PROTOCOL) { | |
2247 | pMsg->dev = pAC->dev[pRxPort->PortIndex]; | |
2248 | pMsg->protocol = eth_type_trans(pMsg, | |
2249 | pAC->dev[pRxPort->PortIndex]); | |
2250 | netif_rx(pMsg); | |
2251 | pAC->dev[pRxPort->PortIndex]->last_rx = jiffies; | |
2252 | } | |
2253 | else { | |
2254 | DEV_KFREE_SKB(pMsg); | |
2255 | } | |
2256 | ||
2257 | } /* if packet for rlmt */ | |
2258 | } /* for ... scanning the RXD ring */ | |
2259 | ||
2260 | /* RXD ring is empty -> fill and restart */ | |
2261 | FillRxRing(pAC, pRxPort); | |
2262 | /* do not start if called from Close */ | |
2263 | if (pAC->BoardLevel > SK_INIT_DATA) { | |
2264 | ClearAndStartRx(pAC, PortIndex); | |
2265 | } | |
2266 | return; | |
2267 | ||
2268 | rx_failed: | |
2269 | /* remove error frame */ | |
2270 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ERROR, | |
2271 | ("Schrottdescriptor, length: 0x%x\n", FrameLength)); | |
2272 | ||
2273 | /* release the DMA mapping */ | |
2274 | ||
2275 | PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32; | |
2276 | PhysAddr |= (SK_U64) pRxd->VDataLow; | |
2277 | pci_unmap_page(pAC->PciDev, | |
2278 | PhysAddr, | |
2279 | pAC->RxBufSize - 2, | |
2280 | PCI_DMA_FROMDEVICE); | |
2281 | DEV_KFREE_SKB_IRQ(pRxd->pMBuf); | |
2282 | pRxd->pMBuf = NULL; | |
2283 | pRxPort->RxdRingFree++; | |
2284 | pRxPort->pRxdRingHead = pRxd->pNextRxd; | |
2285 | goto rx_start; | |
2286 | ||
2287 | } /* ReceiveIrq */ | |
2288 | ||
2289 | ||
2290 | /***************************************************************************** | |
2291 | * | |
2292 | * ClearAndStartRx - give a start receive command to BMU, clear IRQ | |
2293 | * | |
2294 | * Description: | |
2295 | * This function sends a start command and a clear interrupt | |
2296 | * command for one receive queue to the BMU. | |
2297 | * | |
2298 | * Returns: N/A | |
2299 | * none | |
2300 | */ | |
2301 | static void ClearAndStartRx( | |
2302 | SK_AC *pAC, /* pointer to the adapter context */ | |
2303 | int PortIndex) /* index of the receive port (XMAC) */ | |
2304 | { | |
2305 | SK_OUT8(pAC->IoBase, | |
2306 | RxQueueAddr[PortIndex]+Q_CSR, | |
2307 | CSR_START | CSR_IRQ_CL_F); | |
2308 | } /* ClearAndStartRx */ | |
2309 | ||
2310 | ||
2311 | /***************************************************************************** | |
2312 | * | |
2313 | * ClearTxIrq - give a clear transmit IRQ command to BMU | |
2314 | * | |
2315 | * Description: | |
2316 | * This function sends a clear tx IRQ command for one | |
2317 | * transmit queue to the BMU. | |
2318 | * | |
2319 | * Returns: N/A | |
2320 | */ | |
2321 | static void ClearTxIrq( | |
2322 | SK_AC *pAC, /* pointer to the adapter context */ | |
2323 | int PortIndex, /* index of the transmit port (XMAC) */ | |
2324 | int Prio) /* priority or normal queue */ | |
2325 | { | |
2326 | SK_OUT8(pAC->IoBase, | |
2327 | TxQueueAddr[PortIndex][Prio]+Q_CSR, | |
2328 | CSR_IRQ_CL_F); | |
2329 | } /* ClearTxIrq */ | |
2330 | ||
2331 | ||
2332 | /***************************************************************************** | |
2333 | * | |
2334 | * ClearRxRing - remove all buffers from the receive ring | |
2335 | * | |
2336 | * Description: | |
2337 | * This function removes all receive buffers from the ring. | |
2338 | * The receive BMU must be stopped before calling this function. | |
2339 | * | |
2340 | * Returns: N/A | |
2341 | */ | |
2342 | static void ClearRxRing( | |
2343 | SK_AC *pAC, /* pointer to adapter context */ | |
2344 | RX_PORT *pRxPort) /* pointer to rx port struct */ | |
2345 | { | |
2346 | RXD *pRxd; /* pointer to the current descriptor */ | |
2347 | unsigned long Flags; | |
2348 | SK_U64 PhysAddr; | |
2349 | ||
2350 | if (pRxPort->RxdRingFree == pAC->RxDescrPerRing) { | |
2351 | return; | |
2352 | } | |
2353 | spin_lock_irqsave(&pRxPort->RxDesRingLock, Flags); | |
2354 | pRxd = pRxPort->pRxdRingHead; | |
2355 | do { | |
2356 | if (pRxd->pMBuf != NULL) { | |
2357 | ||
2358 | PhysAddr = ((SK_U64) pRxd->VDataHigh) << (SK_U64)32; | |
2359 | PhysAddr |= (SK_U64) pRxd->VDataLow; | |
2360 | pci_unmap_page(pAC->PciDev, | |
2361 | PhysAddr, | |
2362 | pAC->RxBufSize - 2, | |
2363 | PCI_DMA_FROMDEVICE); | |
2364 | DEV_KFREE_SKB(pRxd->pMBuf); | |
2365 | pRxd->pMBuf = NULL; | |
2366 | } | |
2367 | pRxd->RBControl &= BMU_OWN; | |
2368 | pRxd = pRxd->pNextRxd; | |
2369 | pRxPort->RxdRingFree++; | |
2370 | } while (pRxd != pRxPort->pRxdRingTail); | |
2371 | pRxPort->pRxdRingTail = pRxPort->pRxdRingHead; | |
2372 | spin_unlock_irqrestore(&pRxPort->RxDesRingLock, Flags); | |
2373 | } /* ClearRxRing */ | |
2374 | ||
2375 | /***************************************************************************** | |
2376 | * | |
2377 | * ClearTxRing - remove all buffers from the transmit ring | |
2378 | * | |
2379 | * Description: | |
2380 | * This function removes all transmit buffers from the ring. | |
2381 | * The transmit BMU must be stopped before calling this function | |
2382 | * and transmitting at the upper level must be disabled. | |
2383 | * The BMU own bit of all descriptors is cleared, the rest is | |
2384 | * done by calling FreeTxDescriptors. | |
2385 | * | |
2386 | * Returns: N/A | |
2387 | */ | |
2388 | static void ClearTxRing( | |
2389 | SK_AC *pAC, /* pointer to adapter context */ | |
2390 | TX_PORT *pTxPort) /* pointer to tx prt struct */ | |
2391 | { | |
2392 | TXD *pTxd; /* pointer to the current descriptor */ | |
2393 | int i; | |
2394 | unsigned long Flags; | |
2395 | ||
2396 | spin_lock_irqsave(&pTxPort->TxDesRingLock, Flags); | |
2397 | pTxd = pTxPort->pTxdRingHead; | |
2398 | for (i=0; i<pAC->TxDescrPerRing; i++) { | |
2399 | pTxd->TBControl &= ~BMU_OWN; | |
2400 | pTxd = pTxd->pNextTxd; | |
2401 | } | |
2402 | FreeTxDescriptors(pAC, pTxPort); | |
2403 | spin_unlock_irqrestore(&pTxPort->TxDesRingLock, Flags); | |
2404 | } /* ClearTxRing */ | |
2405 | ||
2406 | /***************************************************************************** | |
2407 | * | |
2408 | * SkGeSetMacAddr - Set the hardware MAC address | |
2409 | * | |
2410 | * Description: | |
2411 | * This function sets the MAC address used by the adapter. | |
2412 | * | |
2413 | * Returns: | |
2414 | * 0, if everything is ok | |
2415 | * !=0, on error | |
2416 | */ | |
2417 | static int SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p) | |
2418 | { | |
2419 | ||
2420 | DEV_NET *pNet = netdev_priv(dev); | |
2421 | SK_AC *pAC = pNet->pAC; | |
2422 | ||
2423 | struct sockaddr *addr = p; | |
2424 | unsigned long Flags; | |
2425 | ||
2426 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2427 | ("SkGeSetMacAddr starts now...\n")); | |
2428 | if(netif_running(dev)) | |
2429 | return -EBUSY; | |
2430 | ||
2431 | memcpy(dev->dev_addr, addr->sa_data,dev->addr_len); | |
2432 | ||
2433 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
2434 | ||
2435 | if (pAC->RlmtNets == 2) | |
2436 | SkAddrOverride(pAC, pAC->IoBase, pNet->NetNr, | |
2437 | (SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS); | |
2438 | else | |
2439 | SkAddrOverride(pAC, pAC->IoBase, pAC->ActivePort, | |
2440 | (SK_MAC_ADDR*)dev->dev_addr, SK_ADDR_VIRTUAL_ADDRESS); | |
2441 | ||
2442 | ||
2443 | ||
2444 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
2445 | return 0; | |
2446 | } /* SkGeSetMacAddr */ | |
2447 | ||
2448 | ||
2449 | /***************************************************************************** | |
2450 | * | |
2451 | * SkGeSetRxMode - set receive mode | |
2452 | * | |
2453 | * Description: | |
2454 | * This function sets the receive mode of an adapter. The adapter | |
2455 | * supports promiscuous mode, allmulticast mode and a number of | |
2456 | * multicast addresses. If more multicast addresses the available | |
2457 | * are selected, a hash function in the hardware is used. | |
2458 | * | |
2459 | * Returns: | |
2460 | * 0, if everything is ok | |
2461 | * !=0, on error | |
2462 | */ | |
2463 | static void SkGeSetRxMode(struct SK_NET_DEVICE *dev) | |
2464 | { | |
2465 | ||
2466 | DEV_NET *pNet; | |
2467 | SK_AC *pAC; | |
2468 | ||
2469 | struct dev_mc_list *pMcList; | |
2470 | int i; | |
2471 | int PortIdx; | |
2472 | unsigned long Flags; | |
2473 | ||
2474 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2475 | ("SkGeSetRxMode starts now... ")); | |
2476 | ||
2477 | pNet = netdev_priv(dev); | |
2478 | pAC = pNet->pAC; | |
2479 | if (pAC->RlmtNets == 1) | |
2480 | PortIdx = pAC->ActivePort; | |
2481 | else | |
2482 | PortIdx = pNet->NetNr; | |
2483 | ||
2484 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
2485 | if (dev->flags & IFF_PROMISC) { | |
2486 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2487 | ("PROMISCUOUS mode\n")); | |
2488 | SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx, | |
2489 | SK_PROM_MODE_LLC); | |
2490 | } else if (dev->flags & IFF_ALLMULTI) { | |
2491 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2492 | ("ALLMULTI mode\n")); | |
2493 | SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx, | |
2494 | SK_PROM_MODE_ALL_MC); | |
2495 | } else { | |
2496 | SkAddrPromiscuousChange(pAC, pAC->IoBase, PortIdx, | |
2497 | SK_PROM_MODE_NONE); | |
2498 | SkAddrMcClear(pAC, pAC->IoBase, PortIdx, 0); | |
2499 | ||
2500 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2501 | ("Number of MC entries: %d ", dev->mc_count)); | |
2502 | ||
2503 | pMcList = dev->mc_list; | |
2504 | for (i=0; i<dev->mc_count; i++, pMcList = pMcList->next) { | |
2505 | SkAddrMcAdd(pAC, pAC->IoBase, PortIdx, | |
2506 | (SK_MAC_ADDR*)pMcList->dmi_addr, 0); | |
2507 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_MCA, | |
2508 | ("%02x:%02x:%02x:%02x:%02x:%02x\n", | |
2509 | pMcList->dmi_addr[0], | |
2510 | pMcList->dmi_addr[1], | |
2511 | pMcList->dmi_addr[2], | |
2512 | pMcList->dmi_addr[3], | |
2513 | pMcList->dmi_addr[4], | |
2514 | pMcList->dmi_addr[5])); | |
2515 | } | |
2516 | SkAddrMcUpdate(pAC, pAC->IoBase, PortIdx); | |
2517 | } | |
2518 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
2519 | ||
2520 | return; | |
2521 | } /* SkGeSetRxMode */ | |
2522 | ||
2523 | ||
2524 | /***************************************************************************** | |
2525 | * | |
2526 | * SkGeChangeMtu - set the MTU to another value | |
2527 | * | |
2528 | * Description: | |
2529 | * This function sets is called whenever the MTU size is changed | |
2530 | * (ifconfig mtu xxx dev ethX). If the MTU is bigger than standard | |
2531 | * ethernet MTU size, long frame support is activated. | |
2532 | * | |
2533 | * Returns: | |
2534 | * 0, if everything is ok | |
2535 | * !=0, on error | |
2536 | */ | |
2537 | static int SkGeChangeMtu(struct SK_NET_DEVICE *dev, int NewMtu) | |
2538 | { | |
2539 | DEV_NET *pNet; | |
8f7a17d1 | 2540 | struct net_device *pOtherDev; |
1da177e4 LT |
2541 | SK_AC *pAC; |
2542 | unsigned long Flags; | |
2543 | int i; | |
2544 | SK_EVPARA EvPara; | |
2545 | ||
2546 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2547 | ("SkGeChangeMtu starts now...\n")); | |
2548 | ||
2549 | pNet = netdev_priv(dev); | |
2550 | pAC = pNet->pAC; | |
2551 | ||
2552 | if ((NewMtu < 68) || (NewMtu > SK_JUMBO_MTU)) { | |
2553 | return -EINVAL; | |
2554 | } | |
2555 | ||
2556 | if(pAC->BoardLevel != SK_INIT_RUN) { | |
2557 | return -EINVAL; | |
2558 | } | |
2559 | ||
2560 | #ifdef SK_DIAG_SUPPORT | |
2561 | if (pAC->DiagModeActive == DIAG_ACTIVE) { | |
2562 | if (pAC->DiagFlowCtrl == SK_FALSE) { | |
2563 | return -1; /* still in use, deny any actions of MTU */ | |
2564 | } else { | |
2565 | pAC->DiagFlowCtrl = SK_FALSE; | |
2566 | } | |
2567 | } | |
2568 | #endif | |
2569 | ||
8f7a17d1 SH |
2570 | pOtherDev = pAC->dev[1 - pNet->NetNr]; |
2571 | ||
2572 | if ( netif_running(pOtherDev) && (pOtherDev->mtu > 1500) | |
2573 | && (NewMtu <= 1500)) | |
2574 | return 0; | |
1da177e4 LT |
2575 | |
2576 | pAC->RxBufSize = NewMtu + 32; | |
2577 | dev->mtu = NewMtu; | |
2578 | ||
2579 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2580 | ("New MTU: %d\n", NewMtu)); | |
2581 | ||
2582 | /* | |
2583 | ** Prevent any reconfiguration while changing the MTU | |
2584 | ** by disabling any interrupts | |
2585 | */ | |
2586 | SK_OUT32(pAC->IoBase, B0_IMSK, 0); | |
2587 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
2588 | ||
2589 | /* | |
2590 | ** Notify RLMT that any ports are to be stopped | |
2591 | */ | |
2592 | EvPara.Para32[0] = 0; | |
2593 | EvPara.Para32[1] = -1; | |
2594 | if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { | |
2595 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
2596 | EvPara.Para32[0] = 1; | |
2597 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
2598 | } else { | |
2599 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
2600 | } | |
2601 | ||
2602 | /* | |
2603 | ** After calling the SkEventDispatcher(), RLMT is aware about | |
2604 | ** the stopped ports -> configuration can take place! | |
2605 | */ | |
2606 | SkEventDispatcher(pAC, pAC->IoBase); | |
2607 | ||
2608 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
2609 | spin_lock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock); | |
2610 | netif_stop_queue(pAC->dev[i]); | |
2611 | ||
2612 | } | |
2613 | ||
2614 | /* | |
2615 | ** Depending on the desired MTU size change, a different number of | |
2616 | ** RX buffers need to be allocated | |
2617 | */ | |
2618 | if (NewMtu > 1500) { | |
2619 | /* | |
2620 | ** Use less rx buffers | |
2621 | */ | |
2622 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
2623 | if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { | |
2624 | pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing - | |
2625 | (pAC->RxDescrPerRing / 4); | |
2626 | } else { | |
2627 | if (i == pAC->ActivePort) { | |
2628 | pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing - | |
2629 | (pAC->RxDescrPerRing / 4); | |
2630 | } else { | |
2631 | pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing - | |
2632 | (pAC->RxDescrPerRing / 10); | |
2633 | } | |
2634 | } | |
2635 | } | |
2636 | } else { | |
2637 | /* | |
2638 | ** Use the normal amount of rx buffers | |
2639 | */ | |
2640 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
2641 | if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { | |
2642 | pAC->RxPort[i].RxFillLimit = 1; | |
2643 | } else { | |
2644 | if (i == pAC->ActivePort) { | |
2645 | pAC->RxPort[i].RxFillLimit = 1; | |
2646 | } else { | |
2647 | pAC->RxPort[i].RxFillLimit = pAC->RxDescrPerRing - | |
2648 | (pAC->RxDescrPerRing / 4); | |
2649 | } | |
2650 | } | |
2651 | } | |
2652 | } | |
2653 | ||
2654 | SkGeDeInit(pAC, pAC->IoBase); | |
2655 | ||
2656 | /* | |
2657 | ** enable/disable hardware support for long frames | |
2658 | */ | |
2659 | if (NewMtu > 1500) { | |
2660 | // pAC->JumboActivated = SK_TRUE; /* is never set back !!! */ | |
2661 | pAC->GIni.GIPortUsage = SK_JUMBO_LINK; | |
2662 | } else { | |
2663 | if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { | |
2664 | pAC->GIni.GIPortUsage = SK_MUL_LINK; | |
2665 | } else { | |
2666 | pAC->GIni.GIPortUsage = SK_RED_LINK; | |
2667 | } | |
2668 | } | |
2669 | ||
2670 | SkGeInit( pAC, pAC->IoBase, SK_INIT_IO); | |
2671 | SkI2cInit( pAC, pAC->IoBase, SK_INIT_IO); | |
2672 | SkEventInit(pAC, pAC->IoBase, SK_INIT_IO); | |
2673 | SkPnmiInit( pAC, pAC->IoBase, SK_INIT_IO); | |
2674 | SkAddrInit( pAC, pAC->IoBase, SK_INIT_IO); | |
2675 | SkRlmtInit( pAC, pAC->IoBase, SK_INIT_IO); | |
2676 | SkTimerInit(pAC, pAC->IoBase, SK_INIT_IO); | |
2677 | ||
2678 | /* | |
2679 | ** tschilling: | |
2680 | ** Speed and others are set back to default in level 1 init! | |
2681 | */ | |
2682 | GetConfiguration(pAC); | |
2683 | ||
2684 | SkGeInit( pAC, pAC->IoBase, SK_INIT_RUN); | |
2685 | SkI2cInit( pAC, pAC->IoBase, SK_INIT_RUN); | |
2686 | SkEventInit(pAC, pAC->IoBase, SK_INIT_RUN); | |
2687 | SkPnmiInit( pAC, pAC->IoBase, SK_INIT_RUN); | |
2688 | SkAddrInit( pAC, pAC->IoBase, SK_INIT_RUN); | |
2689 | SkRlmtInit( pAC, pAC->IoBase, SK_INIT_RUN); | |
2690 | SkTimerInit(pAC, pAC->IoBase, SK_INIT_RUN); | |
2691 | ||
2692 | /* | |
2693 | ** clear and reinit the rx rings here | |
2694 | */ | |
2695 | for (i=0; i<pAC->GIni.GIMacsFound; i++) { | |
2696 | ReceiveIrq(pAC, &pAC->RxPort[i], SK_TRUE); | |
2697 | ClearRxRing(pAC, &pAC->RxPort[i]); | |
2698 | FillRxRing(pAC, &pAC->RxPort[i]); | |
2699 | ||
2700 | /* | |
2701 | ** Enable transmit descriptor polling | |
2702 | */ | |
2703 | SkGePollTxD(pAC, pAC->IoBase, i, SK_TRUE); | |
2704 | FillRxRing(pAC, &pAC->RxPort[i]); | |
2705 | }; | |
2706 | ||
2707 | SkGeYellowLED(pAC, pAC->IoBase, 1); | |
2708 | SkDimEnableModerationIfNeeded(pAC); | |
2709 | SkDimDisplayModerationSettings(pAC); | |
2710 | ||
2711 | netif_start_queue(pAC->dev[pNet->PortNr]); | |
2712 | for (i=pAC->GIni.GIMacsFound-1; i>=0; i--) { | |
2713 | spin_unlock(&pAC->TxPort[i][TX_PRIO_LOW].TxDesRingLock); | |
2714 | } | |
2715 | ||
2716 | /* | |
2717 | ** Enable Interrupts again | |
2718 | */ | |
2719 | SK_OUT32(pAC->IoBase, B0_IMSK, pAC->GIni.GIValIrqMask); | |
2720 | SK_OUT32(pAC->IoBase, B0_HWE_IMSK, IRQ_HWE_MASK); | |
2721 | ||
2722 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); | |
2723 | SkEventDispatcher(pAC, pAC->IoBase); | |
2724 | ||
2725 | /* | |
2726 | ** Notify RLMT about the changing and restarting one (or more) ports | |
2727 | */ | |
2728 | if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { | |
2729 | EvPara.Para32[0] = pAC->RlmtNets; | |
2730 | EvPara.Para32[1] = -1; | |
2731 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_SET_NETS, EvPara); | |
2732 | EvPara.Para32[0] = pNet->PortNr; | |
2733 | EvPara.Para32[1] = -1; | |
2734 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); | |
2735 | ||
8f7a17d1 SH |
2736 | if (netif_running(pOtherDev)) { |
2737 | DEV_NET *pOtherNet = netdev_priv(pOtherDev); | |
1da177e4 LT |
2738 | EvPara.Para32[0] = pOtherNet->PortNr; |
2739 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); | |
2740 | } | |
2741 | } else { | |
2742 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_START, EvPara); | |
2743 | } | |
2744 | ||
2745 | SkEventDispatcher(pAC, pAC->IoBase); | |
2746 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
2747 | ||
2748 | /* | |
2749 | ** While testing this driver with latest kernel 2.5 (2.5.70), it | |
2750 | ** seems as if upper layers have a problem to handle a successful | |
2751 | ** return value of '0'. If such a zero is returned, the complete | |
2752 | ** system hangs for several minutes (!), which is in acceptable. | |
2753 | ** | |
2754 | ** Currently it is not clear, what the exact reason for this problem | |
2755 | ** is. The implemented workaround for 2.5 is to return the desired | |
2756 | ** new MTU size if all needed changes for the new MTU size where | |
2757 | ** performed. In kernels 2.2 and 2.4, a zero value is returned, | |
2758 | ** which indicates the successful change of the mtu-size. | |
2759 | */ | |
2760 | return NewMtu; | |
2761 | ||
2762 | } /* SkGeChangeMtu */ | |
2763 | ||
2764 | ||
2765 | /***************************************************************************** | |
2766 | * | |
2767 | * SkGeStats - return ethernet device statistics | |
2768 | * | |
2769 | * Description: | |
2770 | * This function return statistic data about the ethernet device | |
2771 | * to the operating system. | |
2772 | * | |
2773 | * Returns: | |
2774 | * pointer to the statistic structure. | |
2775 | */ | |
2776 | static struct net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev) | |
2777 | { | |
2778 | DEV_NET *pNet = netdev_priv(dev); | |
2779 | SK_AC *pAC = pNet->pAC; | |
2780 | SK_PNMI_STRUCT_DATA *pPnmiStruct; /* structure for all Pnmi-Data */ | |
2781 | SK_PNMI_STAT *pPnmiStat; /* pointer to virtual XMAC stat. data */ | |
2782 | SK_PNMI_CONF *pPnmiConf; /* pointer to virtual link config. */ | |
2783 | unsigned int Size; /* size of pnmi struct */ | |
2784 | unsigned long Flags; /* for spin lock */ | |
2785 | ||
2786 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2787 | ("SkGeStats starts now...\n")); | |
2788 | pPnmiStruct = &pAC->PnmiStruct; | |
2789 | ||
2790 | #ifdef SK_DIAG_SUPPORT | |
2791 | if ((pAC->DiagModeActive == DIAG_NOTACTIVE) && | |
2792 | (pAC->BoardLevel == SK_INIT_RUN)) { | |
2793 | #endif | |
2794 | SK_MEMSET(pPnmiStruct, 0, sizeof(SK_PNMI_STRUCT_DATA)); | |
2795 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
2796 | Size = SK_PNMI_STRUCT_SIZE; | |
2797 | SkPnmiGetStruct(pAC, pAC->IoBase, pPnmiStruct, &Size, pNet->NetNr); | |
2798 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
2799 | #ifdef SK_DIAG_SUPPORT | |
2800 | } | |
2801 | #endif | |
2802 | ||
2803 | pPnmiStat = &pPnmiStruct->Stat[0]; | |
2804 | pPnmiConf = &pPnmiStruct->Conf[0]; | |
2805 | ||
2806 | pAC->stats.rx_packets = (SK_U32) pPnmiStruct->RxDeliveredCts & 0xFFFFFFFF; | |
2807 | pAC->stats.tx_packets = (SK_U32) pPnmiStat->StatTxOkCts & 0xFFFFFFFF; | |
2808 | pAC->stats.rx_bytes = (SK_U32) pPnmiStruct->RxOctetsDeliveredCts; | |
2809 | pAC->stats.tx_bytes = (SK_U32) pPnmiStat->StatTxOctetsOkCts; | |
2810 | ||
8f7a17d1 | 2811 | if (dev->mtu <= 1500) { |
1da177e4 LT |
2812 | pAC->stats.rx_errors = (SK_U32) pPnmiStruct->InErrorsCts & 0xFFFFFFFF; |
2813 | } else { | |
2814 | pAC->stats.rx_errors = (SK_U32) ((pPnmiStruct->InErrorsCts - | |
2815 | pPnmiStat->StatRxTooLongCts) & 0xFFFFFFFF); | |
2816 | } | |
2817 | ||
2818 | ||
2819 | if (pAC->GIni.GP[0].PhyType == SK_PHY_XMAC && pAC->HWRevision < 12) | |
2820 | pAC->stats.rx_errors = pAC->stats.rx_errors - pPnmiStat->StatRxShortsCts; | |
2821 | ||
2822 | pAC->stats.tx_errors = (SK_U32) pPnmiStat->StatTxSingleCollisionCts & 0xFFFFFFFF; | |
2823 | pAC->stats.rx_dropped = (SK_U32) pPnmiStruct->RxNoBufCts & 0xFFFFFFFF; | |
2824 | pAC->stats.tx_dropped = (SK_U32) pPnmiStruct->TxNoBufCts & 0xFFFFFFFF; | |
2825 | pAC->stats.multicast = (SK_U32) pPnmiStat->StatRxMulticastOkCts & 0xFFFFFFFF; | |
2826 | pAC->stats.collisions = (SK_U32) pPnmiStat->StatTxSingleCollisionCts & 0xFFFFFFFF; | |
2827 | ||
2828 | /* detailed rx_errors: */ | |
2829 | pAC->stats.rx_length_errors = (SK_U32) pPnmiStat->StatRxRuntCts & 0xFFFFFFFF; | |
2830 | pAC->stats.rx_over_errors = (SK_U32) pPnmiStat->StatRxFifoOverflowCts & 0xFFFFFFFF; | |
2831 | pAC->stats.rx_crc_errors = (SK_U32) pPnmiStat->StatRxFcsCts & 0xFFFFFFFF; | |
2832 | pAC->stats.rx_frame_errors = (SK_U32) pPnmiStat->StatRxFramingCts & 0xFFFFFFFF; | |
2833 | pAC->stats.rx_fifo_errors = (SK_U32) pPnmiStat->StatRxFifoOverflowCts & 0xFFFFFFFF; | |
2834 | pAC->stats.rx_missed_errors = (SK_U32) pPnmiStat->StatRxMissedCts & 0xFFFFFFFF; | |
2835 | ||
2836 | /* detailed tx_errors */ | |
2837 | pAC->stats.tx_aborted_errors = (SK_U32) 0; | |
2838 | pAC->stats.tx_carrier_errors = (SK_U32) pPnmiStat->StatTxCarrierCts & 0xFFFFFFFF; | |
2839 | pAC->stats.tx_fifo_errors = (SK_U32) pPnmiStat->StatTxFifoUnderrunCts & 0xFFFFFFFF; | |
2840 | pAC->stats.tx_heartbeat_errors = (SK_U32) pPnmiStat->StatTxCarrierCts & 0xFFFFFFFF; | |
2841 | pAC->stats.tx_window_errors = (SK_U32) 0; | |
2842 | ||
2843 | return(&pAC->stats); | |
2844 | } /* SkGeStats */ | |
2845 | ||
2846 | ||
2847 | /***************************************************************************** | |
2848 | * | |
2849 | * SkGeIoctl - IO-control function | |
2850 | * | |
2851 | * Description: | |
2852 | * This function is called if an ioctl is issued on the device. | |
2853 | * There are three subfunction for reading, writing and test-writing | |
2854 | * the private MIB data structure (usefull for SysKonnect-internal tools). | |
2855 | * | |
2856 | * Returns: | |
2857 | * 0, if everything is ok | |
2858 | * !=0, on error | |
2859 | */ | |
2860 | static int SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd) | |
2861 | { | |
2862 | DEV_NET *pNet; | |
2863 | SK_AC *pAC; | |
2864 | void *pMemBuf; | |
2865 | struct pci_dev *pdev = NULL; | |
2866 | SK_GE_IOCTL Ioctl; | |
2867 | unsigned int Err = 0; | |
2868 | int Size = 0; | |
2869 | int Ret = 0; | |
2870 | unsigned int Length = 0; | |
2871 | int HeaderLength = sizeof(SK_U32) + sizeof(SK_U32); | |
2872 | ||
2873 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
2874 | ("SkGeIoctl starts now...\n")); | |
2875 | ||
2876 | pNet = netdev_priv(dev); | |
2877 | pAC = pNet->pAC; | |
2878 | ||
2879 | if(copy_from_user(&Ioctl, rq->ifr_data, sizeof(SK_GE_IOCTL))) { | |
2880 | return -EFAULT; | |
2881 | } | |
2882 | ||
2883 | switch(cmd) { | |
2884 | case SK_IOCTL_SETMIB: | |
2885 | case SK_IOCTL_PRESETMIB: | |
2886 | if (!capable(CAP_NET_ADMIN)) return -EPERM; | |
2887 | case SK_IOCTL_GETMIB: | |
2888 | if(copy_from_user(&pAC->PnmiStruct, Ioctl.pData, | |
2889 | Ioctl.Len<sizeof(pAC->PnmiStruct)? | |
2890 | Ioctl.Len : sizeof(pAC->PnmiStruct))) { | |
2891 | return -EFAULT; | |
2892 | } | |
2893 | Size = SkGeIocMib(pNet, Ioctl.Len, cmd); | |
2894 | if(copy_to_user(Ioctl.pData, &pAC->PnmiStruct, | |
2895 | Ioctl.Len<Size? Ioctl.Len : Size)) { | |
2896 | return -EFAULT; | |
2897 | } | |
2898 | Ioctl.Len = Size; | |
2899 | if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) { | |
2900 | return -EFAULT; | |
2901 | } | |
2902 | break; | |
2903 | case SK_IOCTL_GEN: | |
2904 | if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) { | |
2905 | Length = Ioctl.Len; | |
2906 | } else { | |
2907 | Length = sizeof(pAC->PnmiStruct) + HeaderLength; | |
2908 | } | |
2909 | if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) { | |
2910 | return -ENOMEM; | |
2911 | } | |
2912 | if(copy_from_user(pMemBuf, Ioctl.pData, Length)) { | |
2913 | Err = -EFAULT; | |
2914 | goto fault_gen; | |
2915 | } | |
2916 | if ((Ret = SkPnmiGenIoctl(pAC, pAC->IoBase, pMemBuf, &Length, 0)) < 0) { | |
2917 | Err = -EFAULT; | |
2918 | goto fault_gen; | |
2919 | } | |
2920 | if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) { | |
2921 | Err = -EFAULT; | |
2922 | goto fault_gen; | |
2923 | } | |
2924 | Ioctl.Len = Length; | |
2925 | if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) { | |
2926 | Err = -EFAULT; | |
2927 | goto fault_gen; | |
2928 | } | |
2929 | fault_gen: | |
2930 | kfree(pMemBuf); /* cleanup everything */ | |
2931 | break; | |
2932 | #ifdef SK_DIAG_SUPPORT | |
2933 | case SK_IOCTL_DIAG: | |
2934 | if (!capable(CAP_NET_ADMIN)) return -EPERM; | |
2935 | if (Ioctl.Len < (sizeof(pAC->PnmiStruct) + HeaderLength)) { | |
2936 | Length = Ioctl.Len; | |
2937 | } else { | |
2938 | Length = sizeof(pAC->PnmiStruct) + HeaderLength; | |
2939 | } | |
2940 | if (NULL == (pMemBuf = kmalloc(Length, GFP_KERNEL))) { | |
2941 | return -ENOMEM; | |
2942 | } | |
2943 | if(copy_from_user(pMemBuf, Ioctl.pData, Length)) { | |
2944 | Err = -EFAULT; | |
2945 | goto fault_diag; | |
2946 | } | |
2947 | pdev = pAC->PciDev; | |
2948 | Length = 3 * sizeof(SK_U32); /* Error, Bus and Device */ | |
2949 | /* | |
2950 | ** While coding this new IOCTL interface, only a few lines of code | |
2951 | ** are to to be added. Therefore no dedicated function has been | |
2952 | ** added. If more functionality is added, a separate function | |
2953 | ** should be used... | |
2954 | */ | |
2955 | * ((SK_U32 *)pMemBuf) = 0; | |
2956 | * ((SK_U32 *)pMemBuf + 1) = pdev->bus->number; | |
2957 | * ((SK_U32 *)pMemBuf + 2) = ParseDeviceNbrFromSlotName(pci_name(pdev)); | |
2958 | if(copy_to_user(Ioctl.pData, pMemBuf, Length) ) { | |
2959 | Err = -EFAULT; | |
2960 | goto fault_diag; | |
2961 | } | |
2962 | Ioctl.Len = Length; | |
2963 | if(copy_to_user(rq->ifr_data, &Ioctl, sizeof(SK_GE_IOCTL))) { | |
2964 | Err = -EFAULT; | |
2965 | goto fault_diag; | |
2966 | } | |
2967 | fault_diag: | |
2968 | kfree(pMemBuf); /* cleanup everything */ | |
2969 | break; | |
2970 | #endif | |
2971 | default: | |
2972 | Err = -EOPNOTSUPP; | |
2973 | } | |
2974 | ||
2975 | return(Err); | |
2976 | ||
2977 | } /* SkGeIoctl */ | |
2978 | ||
2979 | ||
2980 | /***************************************************************************** | |
2981 | * | |
2982 | * SkGeIocMib - handle a GetMib, SetMib- or PresetMib-ioctl message | |
2983 | * | |
2984 | * Description: | |
2985 | * This function reads/writes the MIB data using PNMI (Private Network | |
2986 | * Management Interface). | |
2987 | * The destination for the data must be provided with the | |
2988 | * ioctl call and is given to the driver in the form of | |
2989 | * a user space address. | |
2990 | * Copying from the user-provided data area into kernel messages | |
2991 | * and back is done by copy_from_user and copy_to_user calls in | |
2992 | * SkGeIoctl. | |
2993 | * | |
2994 | * Returns: | |
2995 | * returned size from PNMI call | |
2996 | */ | |
2997 | static int SkGeIocMib( | |
2998 | DEV_NET *pNet, /* pointer to the adapter context */ | |
2999 | unsigned int Size, /* length of ioctl data */ | |
3000 | int mode) /* flag for set/preset */ | |
3001 | { | |
3002 | unsigned long Flags; /* for spin lock */ | |
3003 | SK_AC *pAC; | |
3004 | ||
3005 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
3006 | ("SkGeIocMib starts now...\n")); | |
3007 | pAC = pNet->pAC; | |
3008 | /* access MIB */ | |
3009 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
3010 | switch(mode) { | |
3011 | case SK_IOCTL_GETMIB: | |
3012 | SkPnmiGetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size, | |
3013 | pNet->NetNr); | |
3014 | break; | |
3015 | case SK_IOCTL_PRESETMIB: | |
3016 | SkPnmiPreSetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size, | |
3017 | pNet->NetNr); | |
3018 | break; | |
3019 | case SK_IOCTL_SETMIB: | |
3020 | SkPnmiSetStruct(pAC, pAC->IoBase, &pAC->PnmiStruct, &Size, | |
3021 | pNet->NetNr); | |
3022 | break; | |
3023 | default: | |
3024 | break; | |
3025 | } | |
3026 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
3027 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_ENTRY, | |
3028 | ("MIB data access succeeded\n")); | |
3029 | return (Size); | |
3030 | } /* SkGeIocMib */ | |
3031 | ||
3032 | ||
3033 | /***************************************************************************** | |
3034 | * | |
3035 | * GetConfiguration - read configuration information | |
3036 | * | |
3037 | * Description: | |
3038 | * This function reads per-adapter configuration information from | |
3039 | * the options provided on the command line. | |
3040 | * | |
3041 | * Returns: | |
3042 | * none | |
3043 | */ | |
3044 | static void GetConfiguration( | |
3045 | SK_AC *pAC) /* pointer to the adapter context structure */ | |
3046 | { | |
3047 | SK_I32 Port; /* preferred port */ | |
3048 | SK_BOOL AutoSet; | |
3049 | SK_BOOL DupSet; | |
3050 | int LinkSpeed = SK_LSPEED_AUTO; /* Link speed */ | |
3051 | int AutoNeg = 1; /* autoneg off (0) or on (1) */ | |
3052 | int DuplexCap = 0; /* 0=both,1=full,2=half */ | |
3053 | int FlowCtrl = SK_FLOW_MODE_SYM_OR_REM; /* FlowControl */ | |
3054 | int MSMode = SK_MS_MODE_AUTO; /* master/slave mode */ | |
3055 | ||
3056 | SK_BOOL IsConTypeDefined = SK_TRUE; | |
3057 | SK_BOOL IsLinkSpeedDefined = SK_TRUE; | |
3058 | SK_BOOL IsFlowCtrlDefined = SK_TRUE; | |
3059 | SK_BOOL IsRoleDefined = SK_TRUE; | |
3060 | SK_BOOL IsModeDefined = SK_TRUE; | |
3061 | /* | |
3062 | * The two parameters AutoNeg. and DuplexCap. map to one configuration | |
3063 | * parameter. The mapping is described by this table: | |
3064 | * DuplexCap -> | both | full | half | | |
3065 | * AutoNeg | | | | | |
3066 | * ----------------------------------------------------------------- | |
3067 | * Off | illegal | Full | Half | | |
3068 | * ----------------------------------------------------------------- | |
3069 | * On | AutoBoth | AutoFull | AutoHalf | | |
3070 | * ----------------------------------------------------------------- | |
3071 | * Sense | AutoSense | AutoSense | AutoSense | | |
3072 | */ | |
3073 | int Capabilities[3][3] = | |
3074 | { { -1, SK_LMODE_FULL , SK_LMODE_HALF }, | |
3075 | {SK_LMODE_AUTOBOTH , SK_LMODE_AUTOFULL , SK_LMODE_AUTOHALF }, | |
3076 | {SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE, SK_LMODE_AUTOSENSE} }; | |
3077 | ||
3078 | #define DC_BOTH 0 | |
3079 | #define DC_FULL 1 | |
3080 | #define DC_HALF 2 | |
3081 | #define AN_OFF 0 | |
3082 | #define AN_ON 1 | |
3083 | #define AN_SENS 2 | |
3084 | #define M_CurrPort pAC->GIni.GP[Port] | |
3085 | ||
3086 | ||
3087 | /* | |
3088 | ** Set the default values first for both ports! | |
3089 | */ | |
3090 | for (Port = 0; Port < SK_MAX_MACS; Port++) { | |
3091 | M_CurrPort.PLinkModeConf = Capabilities[AN_ON][DC_BOTH]; | |
3092 | M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM; | |
3093 | M_CurrPort.PMSMode = SK_MS_MODE_AUTO; | |
3094 | M_CurrPort.PLinkSpeed = SK_LSPEED_AUTO; | |
3095 | } | |
3096 | ||
3097 | /* | |
3098 | ** Check merged parameter ConType. If it has not been used, | |
3099 | ** verify any other parameter (e.g. AutoNeg) and use default values. | |
3100 | ** | |
3101 | ** Stating both ConType and other lowlevel link parameters is also | |
3102 | ** possible. If this is the case, the passed ConType-parameter is | |
3103 | ** overwritten by the lowlevel link parameter. | |
3104 | ** | |
3105 | ** The following settings are used for a merged ConType-parameter: | |
3106 | ** | |
3107 | ** ConType DupCap AutoNeg FlowCtrl Role Speed | |
3108 | ** ------- ------ ------- -------- ---------- ----- | |
3109 | ** Auto Both On SymOrRem Auto Auto | |
3110 | ** 100FD Full Off None <ignored> 100 | |
3111 | ** 100HD Half Off None <ignored> 100 | |
3112 | ** 10FD Full Off None <ignored> 10 | |
3113 | ** 10HD Half Off None <ignored> 10 | |
3114 | ** | |
3115 | ** This ConType parameter is used for all ports of the adapter! | |
3116 | */ | |
3117 | if ( (ConType != NULL) && | |
3118 | (pAC->Index < SK_MAX_CARD_PARAM) && | |
3119 | (ConType[pAC->Index] != NULL) ) { | |
3120 | ||
3121 | /* Check chipset family */ | |
3122 | if ((!pAC->ChipsetType) && | |
3123 | (strcmp(ConType[pAC->Index],"Auto")!=0) && | |
3124 | (strcmp(ConType[pAC->Index],"")!=0)) { | |
3125 | /* Set the speed parameter back */ | |
3126 | printk("sk98lin: Illegal value \"%s\" " | |
3127 | "for ConType." | |
3128 | " Using Auto.\n", | |
3129 | ConType[pAC->Index]); | |
3130 | ||
3131 | sprintf(ConType[pAC->Index], "Auto"); | |
3132 | } | |
3133 | ||
3134 | if (strcmp(ConType[pAC->Index],"")==0) { | |
3135 | IsConTypeDefined = SK_FALSE; /* No ConType defined */ | |
3136 | } else if (strcmp(ConType[pAC->Index],"Auto")==0) { | |
3137 | for (Port = 0; Port < SK_MAX_MACS; Port++) { | |
3138 | M_CurrPort.PLinkModeConf = Capabilities[AN_ON][DC_BOTH]; | |
3139 | M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_SYM_OR_REM; | |
3140 | M_CurrPort.PMSMode = SK_MS_MODE_AUTO; | |
3141 | M_CurrPort.PLinkSpeed = SK_LSPEED_AUTO; | |
3142 | } | |
3143 | } else if (strcmp(ConType[pAC->Index],"100FD")==0) { | |
3144 | for (Port = 0; Port < SK_MAX_MACS; Port++) { | |
3145 | M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_FULL]; | |
3146 | M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE; | |
3147 | M_CurrPort.PMSMode = SK_MS_MODE_AUTO; | |
3148 | M_CurrPort.PLinkSpeed = SK_LSPEED_100MBPS; | |
3149 | } | |
3150 | } else if (strcmp(ConType[pAC->Index],"100HD")==0) { | |
3151 | for (Port = 0; Port < SK_MAX_MACS; Port++) { | |
3152 | M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_HALF]; | |
3153 | M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE; | |
3154 | M_CurrPort.PMSMode = SK_MS_MODE_AUTO; | |
3155 | M_CurrPort.PLinkSpeed = SK_LSPEED_100MBPS; | |
3156 | } | |
3157 | } else if (strcmp(ConType[pAC->Index],"10FD")==0) { | |
3158 | for (Port = 0; Port < SK_MAX_MACS; Port++) { | |
3159 | M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_FULL]; | |
3160 | M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE; | |
3161 | M_CurrPort.PMSMode = SK_MS_MODE_AUTO; | |
3162 | M_CurrPort.PLinkSpeed = SK_LSPEED_10MBPS; | |
3163 | } | |
3164 | } else if (strcmp(ConType[pAC->Index],"10HD")==0) { | |
3165 | for (Port = 0; Port < SK_MAX_MACS; Port++) { | |
3166 | M_CurrPort.PLinkModeConf = Capabilities[AN_OFF][DC_HALF]; | |
3167 | M_CurrPort.PFlowCtrlMode = SK_FLOW_MODE_NONE; | |
3168 | M_CurrPort.PMSMode = SK_MS_MODE_AUTO; | |
3169 | M_CurrPort.PLinkSpeed = SK_LSPEED_10MBPS; | |
3170 | } | |
3171 | } else { | |
3172 | printk("sk98lin: Illegal value \"%s\" for ConType\n", | |
3173 | ConType[pAC->Index]); | |
3174 | IsConTypeDefined = SK_FALSE; /* Wrong ConType defined */ | |
3175 | } | |
3176 | } else { | |
3177 | IsConTypeDefined = SK_FALSE; /* No ConType defined */ | |
3178 | } | |
3179 | ||
3180 | /* | |
3181 | ** Parse any parameter settings for port A: | |
3182 | ** a) any LinkSpeed stated? | |
3183 | */ | |
3184 | if (Speed_A != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3185 | Speed_A[pAC->Index] != NULL) { | |
3186 | if (strcmp(Speed_A[pAC->Index],"")==0) { | |
3187 | IsLinkSpeedDefined = SK_FALSE; | |
3188 | } else if (strcmp(Speed_A[pAC->Index],"Auto")==0) { | |
3189 | LinkSpeed = SK_LSPEED_AUTO; | |
3190 | } else if (strcmp(Speed_A[pAC->Index],"10")==0) { | |
3191 | LinkSpeed = SK_LSPEED_10MBPS; | |
3192 | } else if (strcmp(Speed_A[pAC->Index],"100")==0) { | |
3193 | LinkSpeed = SK_LSPEED_100MBPS; | |
3194 | } else if (strcmp(Speed_A[pAC->Index],"1000")==0) { | |
3195 | LinkSpeed = SK_LSPEED_1000MBPS; | |
3196 | } else { | |
3197 | printk("sk98lin: Illegal value \"%s\" for Speed_A\n", | |
3198 | Speed_A[pAC->Index]); | |
3199 | IsLinkSpeedDefined = SK_FALSE; | |
3200 | } | |
3201 | } else { | |
3202 | IsLinkSpeedDefined = SK_FALSE; | |
3203 | } | |
3204 | ||
3205 | /* | |
3206 | ** Check speed parameter: | |
3207 | ** Only copper type adapter and GE V2 cards | |
3208 | */ | |
3209 | if (((!pAC->ChipsetType) || (pAC->GIni.GICopperType != SK_TRUE)) && | |
3210 | ((LinkSpeed != SK_LSPEED_AUTO) && | |
3211 | (LinkSpeed != SK_LSPEED_1000MBPS))) { | |
3212 | printk("sk98lin: Illegal value for Speed_A. " | |
3213 | "Not a copper card or GE V2 card\n Using " | |
3214 | "speed 1000\n"); | |
3215 | LinkSpeed = SK_LSPEED_1000MBPS; | |
3216 | } | |
3217 | ||
3218 | /* | |
3219 | ** Decide whether to set new config value if somethig valid has | |
3220 | ** been received. | |
3221 | */ | |
3222 | if (IsLinkSpeedDefined) { | |
3223 | pAC->GIni.GP[0].PLinkSpeed = LinkSpeed; | |
3224 | } | |
3225 | ||
3226 | /* | |
3227 | ** b) Any Autonegotiation and DuplexCapabilities set? | |
3228 | ** Please note that both belong together... | |
3229 | */ | |
3230 | AutoNeg = AN_ON; /* tschilling: Default: Autonegotiation on! */ | |
3231 | AutoSet = SK_FALSE; | |
3232 | if (AutoNeg_A != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3233 | AutoNeg_A[pAC->Index] != NULL) { | |
3234 | AutoSet = SK_TRUE; | |
3235 | if (strcmp(AutoNeg_A[pAC->Index],"")==0) { | |
3236 | AutoSet = SK_FALSE; | |
3237 | } else if (strcmp(AutoNeg_A[pAC->Index],"On")==0) { | |
3238 | AutoNeg = AN_ON; | |
3239 | } else if (strcmp(AutoNeg_A[pAC->Index],"Off")==0) { | |
3240 | AutoNeg = AN_OFF; | |
3241 | } else if (strcmp(AutoNeg_A[pAC->Index],"Sense")==0) { | |
3242 | AutoNeg = AN_SENS; | |
3243 | } else { | |
3244 | printk("sk98lin: Illegal value \"%s\" for AutoNeg_A\n", | |
3245 | AutoNeg_A[pAC->Index]); | |
3246 | } | |
3247 | } | |
3248 | ||
3249 | DuplexCap = DC_BOTH; | |
3250 | DupSet = SK_FALSE; | |
3251 | if (DupCap_A != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3252 | DupCap_A[pAC->Index] != NULL) { | |
3253 | DupSet = SK_TRUE; | |
3254 | if (strcmp(DupCap_A[pAC->Index],"")==0) { | |
3255 | DupSet = SK_FALSE; | |
3256 | } else if (strcmp(DupCap_A[pAC->Index],"Both")==0) { | |
3257 | DuplexCap = DC_BOTH; | |
3258 | } else if (strcmp(DupCap_A[pAC->Index],"Full")==0) { | |
3259 | DuplexCap = DC_FULL; | |
3260 | } else if (strcmp(DupCap_A[pAC->Index],"Half")==0) { | |
3261 | DuplexCap = DC_HALF; | |
3262 | } else { | |
3263 | printk("sk98lin: Illegal value \"%s\" for DupCap_A\n", | |
3264 | DupCap_A[pAC->Index]); | |
3265 | } | |
3266 | } | |
3267 | ||
3268 | /* | |
3269 | ** Check for illegal combinations | |
3270 | */ | |
3271 | if ((LinkSpeed == SK_LSPEED_1000MBPS) && | |
3272 | ((DuplexCap == SK_LMODE_STAT_AUTOHALF) || | |
3273 | (DuplexCap == SK_LMODE_STAT_HALF)) && | |
3274 | (pAC->ChipsetType)) { | |
3275 | printk("sk98lin: Half Duplex not possible with Gigabit speed!\n" | |
3276 | " Using Full Duplex.\n"); | |
3277 | DuplexCap = DC_FULL; | |
3278 | } | |
3279 | ||
3280 | if ( AutoSet && AutoNeg==AN_SENS && DupSet) { | |
3281 | printk("sk98lin, Port A: DuplexCapabilities" | |
3282 | " ignored using Sense mode\n"); | |
3283 | } | |
3284 | ||
3285 | if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){ | |
3286 | printk("sk98lin: Port A: Illegal combination" | |
3287 | " of values AutoNeg. and DuplexCap.\n Using " | |
3288 | "Full Duplex\n"); | |
3289 | DuplexCap = DC_FULL; | |
3290 | } | |
3291 | ||
3292 | if (AutoSet && AutoNeg==AN_OFF && !DupSet) { | |
3293 | DuplexCap = DC_FULL; | |
3294 | } | |
3295 | ||
3296 | if (!AutoSet && DupSet) { | |
3297 | printk("sk98lin: Port A: Duplex setting not" | |
3298 | " possible in\n default AutoNegotiation mode" | |
3299 | " (Sense).\n Using AutoNegotiation On\n"); | |
3300 | AutoNeg = AN_ON; | |
3301 | } | |
3302 | ||
3303 | /* | |
3304 | ** set the desired mode | |
3305 | */ | |
3306 | if (AutoSet || DupSet) { | |
3307 | pAC->GIni.GP[0].PLinkModeConf = Capabilities[AutoNeg][DuplexCap]; | |
3308 | } | |
3309 | ||
3310 | /* | |
3311 | ** c) Any Flowcontrol-parameter set? | |
3312 | */ | |
3313 | if (FlowCtrl_A != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3314 | FlowCtrl_A[pAC->Index] != NULL) { | |
3315 | if (strcmp(FlowCtrl_A[pAC->Index],"") == 0) { | |
3316 | IsFlowCtrlDefined = SK_FALSE; | |
3317 | } else if (strcmp(FlowCtrl_A[pAC->Index],"SymOrRem") == 0) { | |
3318 | FlowCtrl = SK_FLOW_MODE_SYM_OR_REM; | |
3319 | } else if (strcmp(FlowCtrl_A[pAC->Index],"Sym")==0) { | |
3320 | FlowCtrl = SK_FLOW_MODE_SYMMETRIC; | |
3321 | } else if (strcmp(FlowCtrl_A[pAC->Index],"LocSend")==0) { | |
3322 | FlowCtrl = SK_FLOW_MODE_LOC_SEND; | |
3323 | } else if (strcmp(FlowCtrl_A[pAC->Index],"None")==0) { | |
3324 | FlowCtrl = SK_FLOW_MODE_NONE; | |
3325 | } else { | |
3326 | printk("sk98lin: Illegal value \"%s\" for FlowCtrl_A\n", | |
3327 | FlowCtrl_A[pAC->Index]); | |
3328 | IsFlowCtrlDefined = SK_FALSE; | |
3329 | } | |
3330 | } else { | |
3331 | IsFlowCtrlDefined = SK_FALSE; | |
3332 | } | |
3333 | ||
3334 | if (IsFlowCtrlDefined) { | |
3335 | if ((AutoNeg == AN_OFF) && (FlowCtrl != SK_FLOW_MODE_NONE)) { | |
3336 | printk("sk98lin: Port A: FlowControl" | |
3337 | " impossible without AutoNegotiation," | |
3338 | " disabled\n"); | |
3339 | FlowCtrl = SK_FLOW_MODE_NONE; | |
3340 | } | |
3341 | pAC->GIni.GP[0].PFlowCtrlMode = FlowCtrl; | |
3342 | } | |
3343 | ||
3344 | /* | |
3345 | ** d) What is with the RoleParameter? | |
3346 | */ | |
3347 | if (Role_A != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3348 | Role_A[pAC->Index] != NULL) { | |
3349 | if (strcmp(Role_A[pAC->Index],"")==0) { | |
3350 | IsRoleDefined = SK_FALSE; | |
3351 | } else if (strcmp(Role_A[pAC->Index],"Auto")==0) { | |
3352 | MSMode = SK_MS_MODE_AUTO; | |
3353 | } else if (strcmp(Role_A[pAC->Index],"Master")==0) { | |
3354 | MSMode = SK_MS_MODE_MASTER; | |
3355 | } else if (strcmp(Role_A[pAC->Index],"Slave")==0) { | |
3356 | MSMode = SK_MS_MODE_SLAVE; | |
3357 | } else { | |
3358 | printk("sk98lin: Illegal value \"%s\" for Role_A\n", | |
3359 | Role_A[pAC->Index]); | |
3360 | IsRoleDefined = SK_FALSE; | |
3361 | } | |
3362 | } else { | |
3363 | IsRoleDefined = SK_FALSE; | |
3364 | } | |
3365 | ||
3366 | if (IsRoleDefined == SK_TRUE) { | |
3367 | pAC->GIni.GP[0].PMSMode = MSMode; | |
3368 | } | |
3369 | ||
3370 | ||
3371 | ||
3372 | /* | |
3373 | ** Parse any parameter settings for port B: | |
3374 | ** a) any LinkSpeed stated? | |
3375 | */ | |
3376 | IsConTypeDefined = SK_TRUE; | |
3377 | IsLinkSpeedDefined = SK_TRUE; | |
3378 | IsFlowCtrlDefined = SK_TRUE; | |
3379 | IsModeDefined = SK_TRUE; | |
3380 | ||
3381 | if (Speed_B != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3382 | Speed_B[pAC->Index] != NULL) { | |
3383 | if (strcmp(Speed_B[pAC->Index],"")==0) { | |
3384 | IsLinkSpeedDefined = SK_FALSE; | |
3385 | } else if (strcmp(Speed_B[pAC->Index],"Auto")==0) { | |
3386 | LinkSpeed = SK_LSPEED_AUTO; | |
3387 | } else if (strcmp(Speed_B[pAC->Index],"10")==0) { | |
3388 | LinkSpeed = SK_LSPEED_10MBPS; | |
3389 | } else if (strcmp(Speed_B[pAC->Index],"100")==0) { | |
3390 | LinkSpeed = SK_LSPEED_100MBPS; | |
3391 | } else if (strcmp(Speed_B[pAC->Index],"1000")==0) { | |
3392 | LinkSpeed = SK_LSPEED_1000MBPS; | |
3393 | } else { | |
3394 | printk("sk98lin: Illegal value \"%s\" for Speed_B\n", | |
3395 | Speed_B[pAC->Index]); | |
3396 | IsLinkSpeedDefined = SK_FALSE; | |
3397 | } | |
3398 | } else { | |
3399 | IsLinkSpeedDefined = SK_FALSE; | |
3400 | } | |
3401 | ||
3402 | /* | |
3403 | ** Check speed parameter: | |
3404 | ** Only copper type adapter and GE V2 cards | |
3405 | */ | |
3406 | if (((!pAC->ChipsetType) || (pAC->GIni.GICopperType != SK_TRUE)) && | |
3407 | ((LinkSpeed != SK_LSPEED_AUTO) && | |
3408 | (LinkSpeed != SK_LSPEED_1000MBPS))) { | |
3409 | printk("sk98lin: Illegal value for Speed_B. " | |
3410 | "Not a copper card or GE V2 card\n Using " | |
3411 | "speed 1000\n"); | |
3412 | LinkSpeed = SK_LSPEED_1000MBPS; | |
3413 | } | |
3414 | ||
3415 | /* | |
3416 | ** Decide whether to set new config value if somethig valid has | |
3417 | ** been received. | |
3418 | */ | |
3419 | if (IsLinkSpeedDefined) { | |
3420 | pAC->GIni.GP[1].PLinkSpeed = LinkSpeed; | |
3421 | } | |
3422 | ||
3423 | /* | |
3424 | ** b) Any Autonegotiation and DuplexCapabilities set? | |
3425 | ** Please note that both belong together... | |
3426 | */ | |
3427 | AutoNeg = AN_SENS; /* default: do auto Sense */ | |
3428 | AutoSet = SK_FALSE; | |
3429 | if (AutoNeg_B != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3430 | AutoNeg_B[pAC->Index] != NULL) { | |
3431 | AutoSet = SK_TRUE; | |
3432 | if (strcmp(AutoNeg_B[pAC->Index],"")==0) { | |
3433 | AutoSet = SK_FALSE; | |
3434 | } else if (strcmp(AutoNeg_B[pAC->Index],"On")==0) { | |
3435 | AutoNeg = AN_ON; | |
3436 | } else if (strcmp(AutoNeg_B[pAC->Index],"Off")==0) { | |
3437 | AutoNeg = AN_OFF; | |
3438 | } else if (strcmp(AutoNeg_B[pAC->Index],"Sense")==0) { | |
3439 | AutoNeg = AN_SENS; | |
3440 | } else { | |
3441 | printk("sk98lin: Illegal value \"%s\" for AutoNeg_B\n", | |
3442 | AutoNeg_B[pAC->Index]); | |
3443 | } | |
3444 | } | |
3445 | ||
3446 | DuplexCap = DC_BOTH; | |
3447 | DupSet = SK_FALSE; | |
3448 | if (DupCap_B != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3449 | DupCap_B[pAC->Index] != NULL) { | |
3450 | DupSet = SK_TRUE; | |
3451 | if (strcmp(DupCap_B[pAC->Index],"")==0) { | |
3452 | DupSet = SK_FALSE; | |
3453 | } else if (strcmp(DupCap_B[pAC->Index],"Both")==0) { | |
3454 | DuplexCap = DC_BOTH; | |
3455 | } else if (strcmp(DupCap_B[pAC->Index],"Full")==0) { | |
3456 | DuplexCap = DC_FULL; | |
3457 | } else if (strcmp(DupCap_B[pAC->Index],"Half")==0) { | |
3458 | DuplexCap = DC_HALF; | |
3459 | } else { | |
3460 | printk("sk98lin: Illegal value \"%s\" for DupCap_B\n", | |
3461 | DupCap_B[pAC->Index]); | |
3462 | } | |
3463 | } | |
3464 | ||
3465 | ||
3466 | /* | |
3467 | ** Check for illegal combinations | |
3468 | */ | |
3469 | if ((LinkSpeed == SK_LSPEED_1000MBPS) && | |
3470 | ((DuplexCap == SK_LMODE_STAT_AUTOHALF) || | |
3471 | (DuplexCap == SK_LMODE_STAT_HALF)) && | |
3472 | (pAC->ChipsetType)) { | |
3473 | printk("sk98lin: Half Duplex not possible with Gigabit speed!\n" | |
3474 | " Using Full Duplex.\n"); | |
3475 | DuplexCap = DC_FULL; | |
3476 | } | |
3477 | ||
3478 | if (AutoSet && AutoNeg==AN_SENS && DupSet) { | |
3479 | printk("sk98lin, Port B: DuplexCapabilities" | |
3480 | " ignored using Sense mode\n"); | |
3481 | } | |
3482 | ||
3483 | if (AutoSet && AutoNeg==AN_OFF && DupSet && DuplexCap==DC_BOTH){ | |
3484 | printk("sk98lin: Port B: Illegal combination" | |
3485 | " of values AutoNeg. and DuplexCap.\n Using " | |
3486 | "Full Duplex\n"); | |
3487 | DuplexCap = DC_FULL; | |
3488 | } | |
3489 | ||
3490 | if (AutoSet && AutoNeg==AN_OFF && !DupSet) { | |
3491 | DuplexCap = DC_FULL; | |
3492 | } | |
3493 | ||
3494 | if (!AutoSet && DupSet) { | |
3495 | printk("sk98lin: Port B: Duplex setting not" | |
3496 | " possible in\n default AutoNegotiation mode" | |
3497 | " (Sense).\n Using AutoNegotiation On\n"); | |
3498 | AutoNeg = AN_ON; | |
3499 | } | |
3500 | ||
3501 | /* | |
3502 | ** set the desired mode | |
3503 | */ | |
3504 | if (AutoSet || DupSet) { | |
3505 | pAC->GIni.GP[1].PLinkModeConf = Capabilities[AutoNeg][DuplexCap]; | |
3506 | } | |
3507 | ||
3508 | /* | |
3509 | ** c) Any FlowCtrl parameter set? | |
3510 | */ | |
3511 | if (FlowCtrl_B != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3512 | FlowCtrl_B[pAC->Index] != NULL) { | |
3513 | if (strcmp(FlowCtrl_B[pAC->Index],"") == 0) { | |
3514 | IsFlowCtrlDefined = SK_FALSE; | |
3515 | } else if (strcmp(FlowCtrl_B[pAC->Index],"SymOrRem") == 0) { | |
3516 | FlowCtrl = SK_FLOW_MODE_SYM_OR_REM; | |
3517 | } else if (strcmp(FlowCtrl_B[pAC->Index],"Sym")==0) { | |
3518 | FlowCtrl = SK_FLOW_MODE_SYMMETRIC; | |
3519 | } else if (strcmp(FlowCtrl_B[pAC->Index],"LocSend")==0) { | |
3520 | FlowCtrl = SK_FLOW_MODE_LOC_SEND; | |
3521 | } else if (strcmp(FlowCtrl_B[pAC->Index],"None")==0) { | |
3522 | FlowCtrl = SK_FLOW_MODE_NONE; | |
3523 | } else { | |
3524 | printk("sk98lin: Illegal value \"%s\" for FlowCtrl_B\n", | |
3525 | FlowCtrl_B[pAC->Index]); | |
3526 | IsFlowCtrlDefined = SK_FALSE; | |
3527 | } | |
3528 | } else { | |
3529 | IsFlowCtrlDefined = SK_FALSE; | |
3530 | } | |
3531 | ||
3532 | if (IsFlowCtrlDefined) { | |
3533 | if ((AutoNeg == AN_OFF) && (FlowCtrl != SK_FLOW_MODE_NONE)) { | |
3534 | printk("sk98lin: Port B: FlowControl" | |
3535 | " impossible without AutoNegotiation," | |
3536 | " disabled\n"); | |
3537 | FlowCtrl = SK_FLOW_MODE_NONE; | |
3538 | } | |
3539 | pAC->GIni.GP[1].PFlowCtrlMode = FlowCtrl; | |
3540 | } | |
3541 | ||
3542 | /* | |
3543 | ** d) What is the RoleParameter? | |
3544 | */ | |
3545 | if (Role_B != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3546 | Role_B[pAC->Index] != NULL) { | |
3547 | if (strcmp(Role_B[pAC->Index],"")==0) { | |
3548 | IsRoleDefined = SK_FALSE; | |
3549 | } else if (strcmp(Role_B[pAC->Index],"Auto")==0) { | |
3550 | MSMode = SK_MS_MODE_AUTO; | |
3551 | } else if (strcmp(Role_B[pAC->Index],"Master")==0) { | |
3552 | MSMode = SK_MS_MODE_MASTER; | |
3553 | } else if (strcmp(Role_B[pAC->Index],"Slave")==0) { | |
3554 | MSMode = SK_MS_MODE_SLAVE; | |
3555 | } else { | |
3556 | printk("sk98lin: Illegal value \"%s\" for Role_B\n", | |
3557 | Role_B[pAC->Index]); | |
3558 | IsRoleDefined = SK_FALSE; | |
3559 | } | |
3560 | } else { | |
3561 | IsRoleDefined = SK_FALSE; | |
3562 | } | |
3563 | ||
3564 | if (IsRoleDefined) { | |
3565 | pAC->GIni.GP[1].PMSMode = MSMode; | |
3566 | } | |
3567 | ||
3568 | /* | |
3569 | ** Evaluate settings for both ports | |
3570 | */ | |
3571 | pAC->ActivePort = 0; | |
3572 | if (PrefPort != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3573 | PrefPort[pAC->Index] != NULL) { | |
3574 | if (strcmp(PrefPort[pAC->Index],"") == 0) { /* Auto */ | |
3575 | pAC->ActivePort = 0; | |
3576 | pAC->Rlmt.Net[0].Preference = -1; /* auto */ | |
3577 | pAC->Rlmt.Net[0].PrefPort = 0; | |
3578 | } else if (strcmp(PrefPort[pAC->Index],"A") == 0) { | |
3579 | /* | |
3580 | ** do not set ActivePort here, thus a port | |
3581 | ** switch is issued after net up. | |
3582 | */ | |
3583 | Port = 0; | |
3584 | pAC->Rlmt.Net[0].Preference = Port; | |
3585 | pAC->Rlmt.Net[0].PrefPort = Port; | |
3586 | } else if (strcmp(PrefPort[pAC->Index],"B") == 0) { | |
3587 | /* | |
3588 | ** do not set ActivePort here, thus a port | |
3589 | ** switch is issued after net up. | |
3590 | */ | |
3591 | if (pAC->GIni.GIMacsFound == 1) { | |
3592 | printk("sk98lin: Illegal value \"B\" for PrefPort.\n" | |
3593 | " Port B not available on single port adapters.\n"); | |
3594 | ||
3595 | pAC->ActivePort = 0; | |
3596 | pAC->Rlmt.Net[0].Preference = -1; /* auto */ | |
3597 | pAC->Rlmt.Net[0].PrefPort = 0; | |
3598 | } else { | |
3599 | Port = 1; | |
3600 | pAC->Rlmt.Net[0].Preference = Port; | |
3601 | pAC->Rlmt.Net[0].PrefPort = Port; | |
3602 | } | |
3603 | } else { | |
3604 | printk("sk98lin: Illegal value \"%s\" for PrefPort\n", | |
3605 | PrefPort[pAC->Index]); | |
3606 | } | |
3607 | } | |
3608 | ||
3609 | pAC->RlmtNets = 1; | |
3610 | ||
3611 | if (RlmtMode != NULL && pAC->Index<SK_MAX_CARD_PARAM && | |
3612 | RlmtMode[pAC->Index] != NULL) { | |
3613 | if (strcmp(RlmtMode[pAC->Index], "") == 0) { | |
3614 | pAC->RlmtMode = 0; | |
3615 | } else if (strcmp(RlmtMode[pAC->Index], "CheckLinkState") == 0) { | |
3616 | pAC->RlmtMode = SK_RLMT_CHECK_LINK; | |
3617 | } else if (strcmp(RlmtMode[pAC->Index], "CheckLocalPort") == 0) { | |
3618 | pAC->RlmtMode = SK_RLMT_CHECK_LINK | | |
3619 | SK_RLMT_CHECK_LOC_LINK; | |
3620 | } else if (strcmp(RlmtMode[pAC->Index], "CheckSeg") == 0) { | |
3621 | pAC->RlmtMode = SK_RLMT_CHECK_LINK | | |
3622 | SK_RLMT_CHECK_LOC_LINK | | |
3623 | SK_RLMT_CHECK_SEG; | |
3624 | } else if ((strcmp(RlmtMode[pAC->Index], "DualNet") == 0) && | |
3625 | (pAC->GIni.GIMacsFound == 2)) { | |
3626 | pAC->RlmtMode = SK_RLMT_CHECK_LINK; | |
3627 | pAC->RlmtNets = 2; | |
3628 | } else { | |
3629 | printk("sk98lin: Illegal value \"%s\" for" | |
3630 | " RlmtMode, using default\n", | |
3631 | RlmtMode[pAC->Index]); | |
3632 | pAC->RlmtMode = 0; | |
3633 | } | |
3634 | } else { | |
3635 | pAC->RlmtMode = 0; | |
3636 | } | |
3637 | ||
3638 | /* | |
3639 | ** Check the interrupt moderation parameters | |
3640 | */ | |
3641 | if (Moderation[pAC->Index] != NULL) { | |
3642 | if (strcmp(Moderation[pAC->Index], "") == 0) { | |
3643 | pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE; | |
3644 | } else if (strcmp(Moderation[pAC->Index], "Static") == 0) { | |
3645 | pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_STATIC; | |
3646 | } else if (strcmp(Moderation[pAC->Index], "Dynamic") == 0) { | |
3647 | pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_DYNAMIC; | |
3648 | } else if (strcmp(Moderation[pAC->Index], "None") == 0) { | |
3649 | pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE; | |
3650 | } else { | |
3651 | printk("sk98lin: Illegal value \"%s\" for Moderation.\n" | |
3652 | " Disable interrupt moderation.\n", | |
3653 | Moderation[pAC->Index]); | |
3654 | pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE; | |
3655 | } | |
3656 | } else { | |
3657 | pAC->DynIrqModInfo.IntModTypeSelect = C_INT_MOD_NONE; | |
3658 | } | |
3659 | ||
3660 | if (Stats[pAC->Index] != NULL) { | |
3661 | if (strcmp(Stats[pAC->Index], "Yes") == 0) { | |
3662 | pAC->DynIrqModInfo.DisplayStats = SK_TRUE; | |
3663 | } else { | |
3664 | pAC->DynIrqModInfo.DisplayStats = SK_FALSE; | |
3665 | } | |
3666 | } else { | |
3667 | pAC->DynIrqModInfo.DisplayStats = SK_FALSE; | |
3668 | } | |
3669 | ||
3670 | if (ModerationMask[pAC->Index] != NULL) { | |
3671 | if (strcmp(ModerationMask[pAC->Index], "Rx") == 0) { | |
3672 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY; | |
3673 | } else if (strcmp(ModerationMask[pAC->Index], "Tx") == 0) { | |
3674 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_ONLY; | |
3675 | } else if (strcmp(ModerationMask[pAC->Index], "Sp") == 0) { | |
3676 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_ONLY; | |
3677 | } else if (strcmp(ModerationMask[pAC->Index], "RxSp") == 0) { | |
3678 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX; | |
3679 | } else if (strcmp(ModerationMask[pAC->Index], "SpRx") == 0) { | |
3680 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_RX; | |
3681 | } else if (strcmp(ModerationMask[pAC->Index], "RxTx") == 0) { | |
3682 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX; | |
3683 | } else if (strcmp(ModerationMask[pAC->Index], "TxRx") == 0) { | |
3684 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX; | |
3685 | } else if (strcmp(ModerationMask[pAC->Index], "TxSp") == 0) { | |
3686 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX; | |
3687 | } else if (strcmp(ModerationMask[pAC->Index], "SpTx") == 0) { | |
3688 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_SP_TX; | |
3689 | } else if (strcmp(ModerationMask[pAC->Index], "RxTxSp") == 0) { | |
3690 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP; | |
3691 | } else if (strcmp(ModerationMask[pAC->Index], "RxSpTx") == 0) { | |
3692 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP; | |
3693 | } else if (strcmp(ModerationMask[pAC->Index], "TxRxSp") == 0) { | |
3694 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP; | |
3695 | } else if (strcmp(ModerationMask[pAC->Index], "TxSpRx") == 0) { | |
3696 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP; | |
3697 | } else if (strcmp(ModerationMask[pAC->Index], "SpTxRx") == 0) { | |
3698 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP; | |
3699 | } else if (strcmp(ModerationMask[pAC->Index], "SpRxTx") == 0) { | |
3700 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_TX_SP; | |
3701 | } else { /* some rubbish */ | |
3702 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_RX_ONLY; | |
3703 | } | |
3704 | } else { /* operator has stated nothing */ | |
3705 | pAC->DynIrqModInfo.MaskIrqModeration = IRQ_MASK_TX_RX; | |
3706 | } | |
3707 | ||
3708 | if (AutoSizing[pAC->Index] != NULL) { | |
3709 | if (strcmp(AutoSizing[pAC->Index], "On") == 0) { | |
3710 | pAC->DynIrqModInfo.AutoSizing = SK_FALSE; | |
3711 | } else { | |
3712 | pAC->DynIrqModInfo.AutoSizing = SK_FALSE; | |
3713 | } | |
3714 | } else { /* operator has stated nothing */ | |
3715 | pAC->DynIrqModInfo.AutoSizing = SK_FALSE; | |
3716 | } | |
3717 | ||
3718 | if (IntsPerSec[pAC->Index] != 0) { | |
3719 | if ((IntsPerSec[pAC->Index]< C_INT_MOD_IPS_LOWER_RANGE) || | |
3720 | (IntsPerSec[pAC->Index] > C_INT_MOD_IPS_UPPER_RANGE)) { | |
3721 | printk("sk98lin: Illegal value \"%d\" for IntsPerSec. (Range: %d - %d)\n" | |
3722 | " Using default value of %i.\n", | |
3723 | IntsPerSec[pAC->Index], | |
3724 | C_INT_MOD_IPS_LOWER_RANGE, | |
3725 | C_INT_MOD_IPS_UPPER_RANGE, | |
3726 | C_INTS_PER_SEC_DEFAULT); | |
3727 | pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT; | |
3728 | } else { | |
3729 | pAC->DynIrqModInfo.MaxModIntsPerSec = IntsPerSec[pAC->Index]; | |
3730 | } | |
3731 | } else { | |
3732 | pAC->DynIrqModInfo.MaxModIntsPerSec = C_INTS_PER_SEC_DEFAULT; | |
3733 | } | |
3734 | ||
3735 | /* | |
3736 | ** Evaluate upper and lower moderation threshold | |
3737 | */ | |
3738 | pAC->DynIrqModInfo.MaxModIntsPerSecUpperLimit = | |
3739 | pAC->DynIrqModInfo.MaxModIntsPerSec + | |
3740 | (pAC->DynIrqModInfo.MaxModIntsPerSec / 2); | |
3741 | ||
3742 | pAC->DynIrqModInfo.MaxModIntsPerSecLowerLimit = | |
3743 | pAC->DynIrqModInfo.MaxModIntsPerSec - | |
3744 | (pAC->DynIrqModInfo.MaxModIntsPerSec / 2); | |
3745 | ||
3746 | pAC->DynIrqModInfo.PrevTimeVal = jiffies; /* initial value */ | |
3747 | ||
3748 | ||
3749 | } /* GetConfiguration */ | |
3750 | ||
3751 | ||
3752 | /***************************************************************************** | |
3753 | * | |
3754 | * ProductStr - return a adapter identification string from vpd | |
3755 | * | |
3756 | * Description: | |
3757 | * This function reads the product name string from the vpd area | |
3758 | * and puts it the field pAC->DeviceString. | |
3759 | * | |
3760 | * Returns: N/A | |
3761 | */ | |
8f7a17d1 SH |
3762 | static inline int ProductStr( |
3763 | SK_AC *pAC, /* pointer to adapter context */ | |
3764 | char *DeviceStr, /* result string */ | |
3765 | int StrLen /* length of the string */ | |
1da177e4 LT |
3766 | ) |
3767 | { | |
1da177e4 LT |
3768 | char Keyword[] = VPD_NAME; /* vpd productname identifier */ |
3769 | int ReturnCode; /* return code from vpd_read */ | |
3770 | unsigned long Flags; | |
3771 | ||
3772 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
8f7a17d1 | 3773 | ReturnCode = VpdRead(pAC, pAC->IoBase, Keyword, DeviceStr, &StrLen); |
1da177e4 | 3774 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); |
8f7a17d1 SH |
3775 | |
3776 | return ReturnCode; | |
1da177e4 LT |
3777 | } /* ProductStr */ |
3778 | ||
3779 | /***************************************************************************** | |
3780 | * | |
3781 | * StartDrvCleanupTimer - Start timer to check for descriptors which | |
3782 | * might be placed in descriptor ring, but | |
3783 | * havent been handled up to now | |
3784 | * | |
3785 | * Description: | |
3786 | * This function requests a HW-timer fo the Yukon card. The actions to | |
3787 | * perform when this timer expires, are located in the SkDrvEvent(). | |
3788 | * | |
3789 | * Returns: N/A | |
3790 | */ | |
3791 | static void | |
3792 | StartDrvCleanupTimer(SK_AC *pAC) { | |
3793 | SK_EVPARA EventParam; /* Event struct for timer event */ | |
3794 | ||
3795 | SK_MEMSET((char *) &EventParam, 0, sizeof(EventParam)); | |
3796 | EventParam.Para32[0] = SK_DRV_RX_CLEANUP_TIMER; | |
3797 | SkTimerStart(pAC, pAC->IoBase, &pAC->DrvCleanupTimer, | |
3798 | SK_DRV_RX_CLEANUP_TIMER_LENGTH, | |
3799 | SKGE_DRV, SK_DRV_TIMER, EventParam); | |
3800 | } | |
3801 | ||
3802 | /***************************************************************************** | |
3803 | * | |
3804 | * StopDrvCleanupTimer - Stop timer to check for descriptors | |
3805 | * | |
3806 | * Description: | |
3807 | * This function requests a HW-timer fo the Yukon card. The actions to | |
3808 | * perform when this timer expires, are located in the SkDrvEvent(). | |
3809 | * | |
3810 | * Returns: N/A | |
3811 | */ | |
3812 | static void | |
3813 | StopDrvCleanupTimer(SK_AC *pAC) { | |
3814 | SkTimerStop(pAC, pAC->IoBase, &pAC->DrvCleanupTimer); | |
3815 | SK_MEMSET((char *) &pAC->DrvCleanupTimer, 0, sizeof(SK_TIMER)); | |
3816 | } | |
3817 | ||
3818 | /****************************************************************************/ | |
3819 | /* functions for common modules *********************************************/ | |
3820 | /****************************************************************************/ | |
3821 | ||
3822 | ||
3823 | /***************************************************************************** | |
3824 | * | |
3825 | * SkDrvAllocRlmtMbuf - allocate an RLMT mbuf | |
3826 | * | |
3827 | * Description: | |
3828 | * This routine returns an RLMT mbuf or NULL. The RLMT Mbuf structure | |
3829 | * is embedded into a socket buff data area. | |
3830 | * | |
3831 | * Context: | |
3832 | * runtime | |
3833 | * | |
3834 | * Returns: | |
3835 | * NULL or pointer to Mbuf. | |
3836 | */ | |
3837 | SK_MBUF *SkDrvAllocRlmtMbuf( | |
3838 | SK_AC *pAC, /* pointer to adapter context */ | |
3839 | SK_IOC IoC, /* the IO-context */ | |
3840 | unsigned BufferSize) /* size of the requested buffer */ | |
3841 | { | |
3842 | SK_MBUF *pRlmtMbuf; /* pointer to a new rlmt-mbuf structure */ | |
3843 | struct sk_buff *pMsgBlock; /* pointer to a new message block */ | |
3844 | ||
3845 | pMsgBlock = alloc_skb(BufferSize + sizeof(SK_MBUF), GFP_ATOMIC); | |
3846 | if (pMsgBlock == NULL) { | |
3847 | return (NULL); | |
3848 | } | |
3849 | pRlmtMbuf = (SK_MBUF*) pMsgBlock->data; | |
3850 | skb_reserve(pMsgBlock, sizeof(SK_MBUF)); | |
3851 | pRlmtMbuf->pNext = NULL; | |
3852 | pRlmtMbuf->pOs = pMsgBlock; | |
3853 | pRlmtMbuf->pData = pMsgBlock->data; /* Data buffer. */ | |
3854 | pRlmtMbuf->Size = BufferSize; /* Data buffer size. */ | |
3855 | pRlmtMbuf->Length = 0; /* Length of packet (<= Size). */ | |
3856 | return (pRlmtMbuf); | |
3857 | ||
3858 | } /* SkDrvAllocRlmtMbuf */ | |
3859 | ||
3860 | ||
3861 | /***************************************************************************** | |
3862 | * | |
3863 | * SkDrvFreeRlmtMbuf - free an RLMT mbuf | |
3864 | * | |
3865 | * Description: | |
3866 | * This routine frees one or more RLMT mbuf(s). | |
3867 | * | |
3868 | * Context: | |
3869 | * runtime | |
3870 | * | |
3871 | * Returns: | |
3872 | * Nothing | |
3873 | */ | |
3874 | void SkDrvFreeRlmtMbuf( | |
3875 | SK_AC *pAC, /* pointer to adapter context */ | |
3876 | SK_IOC IoC, /* the IO-context */ | |
3877 | SK_MBUF *pMbuf) /* size of the requested buffer */ | |
3878 | { | |
3879 | SK_MBUF *pFreeMbuf; | |
3880 | SK_MBUF *pNextMbuf; | |
3881 | ||
3882 | pFreeMbuf = pMbuf; | |
3883 | do { | |
3884 | pNextMbuf = pFreeMbuf->pNext; | |
3885 | DEV_KFREE_SKB_ANY(pFreeMbuf->pOs); | |
3886 | pFreeMbuf = pNextMbuf; | |
3887 | } while ( pFreeMbuf != NULL ); | |
3888 | } /* SkDrvFreeRlmtMbuf */ | |
3889 | ||
3890 | ||
3891 | /***************************************************************************** | |
3892 | * | |
3893 | * SkOsGetTime - provide a time value | |
3894 | * | |
3895 | * Description: | |
3896 | * This routine provides a time value. The unit is 1/HZ (defined by Linux). | |
3897 | * It is not used for absolute time, but only for time differences. | |
3898 | * | |
3899 | * | |
3900 | * Returns: | |
3901 | * Time value | |
3902 | */ | |
3903 | SK_U64 SkOsGetTime(SK_AC *pAC) | |
3904 | { | |
3905 | SK_U64 PrivateJiffies; | |
3906 | SkOsGetTimeCurrent(pAC, &PrivateJiffies); | |
3907 | return PrivateJiffies; | |
3908 | } /* SkOsGetTime */ | |
3909 | ||
3910 | ||
3911 | /***************************************************************************** | |
3912 | * | |
3913 | * SkPciReadCfgDWord - read a 32 bit value from pci config space | |
3914 | * | |
3915 | * Description: | |
3916 | * This routine reads a 32 bit value from the pci configuration | |
3917 | * space. | |
3918 | * | |
3919 | * Returns: | |
3920 | * 0 - indicate everything worked ok. | |
3921 | * != 0 - error indication | |
3922 | */ | |
3923 | int SkPciReadCfgDWord( | |
3924 | SK_AC *pAC, /* Adapter Control structure pointer */ | |
3925 | int PciAddr, /* PCI register address */ | |
3926 | SK_U32 *pVal) /* pointer to store the read value */ | |
3927 | { | |
3928 | pci_read_config_dword(pAC->PciDev, PciAddr, pVal); | |
3929 | return(0); | |
3930 | } /* SkPciReadCfgDWord */ | |
3931 | ||
3932 | ||
3933 | /***************************************************************************** | |
3934 | * | |
3935 | * SkPciReadCfgWord - read a 16 bit value from pci config space | |
3936 | * | |
3937 | * Description: | |
3938 | * This routine reads a 16 bit value from the pci configuration | |
3939 | * space. | |
3940 | * | |
3941 | * Returns: | |
3942 | * 0 - indicate everything worked ok. | |
3943 | * != 0 - error indication | |
3944 | */ | |
3945 | int SkPciReadCfgWord( | |
3946 | SK_AC *pAC, /* Adapter Control structure pointer */ | |
3947 | int PciAddr, /* PCI register address */ | |
3948 | SK_U16 *pVal) /* pointer to store the read value */ | |
3949 | { | |
3950 | pci_read_config_word(pAC->PciDev, PciAddr, pVal); | |
3951 | return(0); | |
3952 | } /* SkPciReadCfgWord */ | |
3953 | ||
3954 | ||
3955 | /***************************************************************************** | |
3956 | * | |
3957 | * SkPciReadCfgByte - read a 8 bit value from pci config space | |
3958 | * | |
3959 | * Description: | |
3960 | * This routine reads a 8 bit value from the pci configuration | |
3961 | * space. | |
3962 | * | |
3963 | * Returns: | |
3964 | * 0 - indicate everything worked ok. | |
3965 | * != 0 - error indication | |
3966 | */ | |
3967 | int SkPciReadCfgByte( | |
3968 | SK_AC *pAC, /* Adapter Control structure pointer */ | |
3969 | int PciAddr, /* PCI register address */ | |
3970 | SK_U8 *pVal) /* pointer to store the read value */ | |
3971 | { | |
3972 | pci_read_config_byte(pAC->PciDev, PciAddr, pVal); | |
3973 | return(0); | |
3974 | } /* SkPciReadCfgByte */ | |
3975 | ||
3976 | ||
1da177e4 LT |
3977 | /***************************************************************************** |
3978 | * | |
3979 | * SkPciWriteCfgWord - write a 16 bit value to pci config space | |
3980 | * | |
3981 | * Description: | |
3982 | * This routine writes a 16 bit value to the pci configuration | |
3983 | * space. The flag PciConfigUp indicates whether the config space | |
3984 | * is accesible or must be set up first. | |
3985 | * | |
3986 | * Returns: | |
3987 | * 0 - indicate everything worked ok. | |
3988 | * != 0 - error indication | |
3989 | */ | |
3990 | int SkPciWriteCfgWord( | |
3991 | SK_AC *pAC, /* Adapter Control structure pointer */ | |
3992 | int PciAddr, /* PCI register address */ | |
3993 | SK_U16 Val) /* pointer to store the read value */ | |
3994 | { | |
3995 | pci_write_config_word(pAC->PciDev, PciAddr, Val); | |
3996 | return(0); | |
3997 | } /* SkPciWriteCfgWord */ | |
3998 | ||
3999 | ||
4000 | /***************************************************************************** | |
4001 | * | |
4002 | * SkPciWriteCfgWord - write a 8 bit value to pci config space | |
4003 | * | |
4004 | * Description: | |
4005 | * This routine writes a 8 bit value to the pci configuration | |
4006 | * space. The flag PciConfigUp indicates whether the config space | |
4007 | * is accesible or must be set up first. | |
4008 | * | |
4009 | * Returns: | |
4010 | * 0 - indicate everything worked ok. | |
4011 | * != 0 - error indication | |
4012 | */ | |
4013 | int SkPciWriteCfgByte( | |
4014 | SK_AC *pAC, /* Adapter Control structure pointer */ | |
4015 | int PciAddr, /* PCI register address */ | |
4016 | SK_U8 Val) /* pointer to store the read value */ | |
4017 | { | |
4018 | pci_write_config_byte(pAC->PciDev, PciAddr, Val); | |
4019 | return(0); | |
4020 | } /* SkPciWriteCfgByte */ | |
4021 | ||
4022 | ||
4023 | /***************************************************************************** | |
4024 | * | |
4025 | * SkDrvEvent - handle driver events | |
4026 | * | |
4027 | * Description: | |
4028 | * This function handles events from all modules directed to the driver | |
4029 | * | |
4030 | * Context: | |
4031 | * Is called under protection of slow path lock. | |
4032 | * | |
4033 | * Returns: | |
4034 | * 0 if everything ok | |
4035 | * < 0 on error | |
4036 | * | |
4037 | */ | |
4038 | int SkDrvEvent( | |
4039 | SK_AC *pAC, /* pointer to adapter context */ | |
4040 | SK_IOC IoC, /* io-context */ | |
4041 | SK_U32 Event, /* event-id */ | |
4042 | SK_EVPARA Param) /* event-parameter */ | |
4043 | { | |
4044 | SK_MBUF *pRlmtMbuf; /* pointer to a rlmt-mbuf structure */ | |
4045 | struct sk_buff *pMsg; /* pointer to a message block */ | |
4046 | int FromPort; /* the port from which we switch away */ | |
4047 | int ToPort; /* the port we switch to */ | |
4048 | SK_EVPARA NewPara; /* parameter for further events */ | |
4049 | int Stat; | |
4050 | unsigned long Flags; | |
4051 | SK_BOOL DualNet; | |
4052 | ||
4053 | switch (Event) { | |
4054 | case SK_DRV_ADAP_FAIL: | |
4055 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4056 | ("ADAPTER FAIL EVENT\n")); | |
4057 | printk("%s: Adapter failed.\n", pAC->dev[0]->name); | |
4058 | /* disable interrupts */ | |
4059 | SK_OUT32(pAC->IoBase, B0_IMSK, 0); | |
4060 | /* cgoos */ | |
4061 | break; | |
4062 | case SK_DRV_PORT_FAIL: | |
4063 | FromPort = Param.Para32[0]; | |
4064 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4065 | ("PORT FAIL EVENT, Port: %d\n", FromPort)); | |
4066 | if (FromPort == 0) { | |
4067 | printk("%s: Port A failed.\n", pAC->dev[0]->name); | |
4068 | } else { | |
4069 | printk("%s: Port B failed.\n", pAC->dev[1]->name); | |
4070 | } | |
4071 | /* cgoos */ | |
4072 | break; | |
4073 | case SK_DRV_PORT_RESET: /* SK_U32 PortIdx */ | |
4074 | /* action list 4 */ | |
4075 | FromPort = Param.Para32[0]; | |
4076 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4077 | ("PORT RESET EVENT, Port: %d ", FromPort)); | |
4078 | NewPara.Para64 = FromPort; | |
4079 | SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara); | |
4080 | spin_lock_irqsave( | |
4081 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4082 | Flags); | |
4083 | ||
4084 | SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_HARD_RST); | |
7d17c1d6 | 4085 | netif_carrier_off(pAC->dev[Param.Para32[0]]); |
1da177e4 LT |
4086 | spin_unlock_irqrestore( |
4087 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4088 | Flags); | |
4089 | ||
4090 | /* clear rx ring from received frames */ | |
4091 | ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE); | |
4092 | ||
4093 | ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]); | |
4094 | spin_lock_irqsave( | |
4095 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4096 | Flags); | |
4097 | ||
4098 | /* tschilling: Handling of return value inserted. */ | |
4099 | if (SkGeInitPort(pAC, IoC, FromPort)) { | |
4100 | if (FromPort == 0) { | |
4101 | printk("%s: SkGeInitPort A failed.\n", pAC->dev[0]->name); | |
4102 | } else { | |
4103 | printk("%s: SkGeInitPort B failed.\n", pAC->dev[1]->name); | |
4104 | } | |
4105 | } | |
4106 | SkAddrMcUpdate(pAC,IoC, FromPort); | |
4107 | PortReInitBmu(pAC, FromPort); | |
4108 | SkGePollTxD(pAC, IoC, FromPort, SK_TRUE); | |
4109 | ClearAndStartRx(pAC, FromPort); | |
4110 | spin_unlock_irqrestore( | |
4111 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4112 | Flags); | |
4113 | break; | |
4114 | case SK_DRV_NET_UP: /* SK_U32 PortIdx */ | |
09f5a214 | 4115 | { struct net_device *dev = pAC->dev[Param.Para32[0]]; |
1da177e4 LT |
4116 | /* action list 5 */ |
4117 | FromPort = Param.Para32[0]; | |
4118 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4119 | ("NET UP EVENT, Port: %d ", Param.Para32[0])); | |
4120 | /* Mac update */ | |
4121 | SkAddrMcUpdate(pAC,IoC, FromPort); | |
4122 | ||
4123 | if (DoPrintInterfaceChange) { | |
4124 | printk("%s: network connection up using" | |
4125 | " port %c\n", pAC->dev[Param.Para32[0]]->name, 'A'+Param.Para32[0]); | |
4126 | ||
4127 | /* tschilling: Values changed according to LinkSpeedUsed. */ | |
4128 | Stat = pAC->GIni.GP[FromPort].PLinkSpeedUsed; | |
4129 | if (Stat == SK_LSPEED_STAT_10MBPS) { | |
4130 | printk(" speed: 10\n"); | |
4131 | } else if (Stat == SK_LSPEED_STAT_100MBPS) { | |
4132 | printk(" speed: 100\n"); | |
4133 | } else if (Stat == SK_LSPEED_STAT_1000MBPS) { | |
4134 | printk(" speed: 1000\n"); | |
4135 | } else { | |
4136 | printk(" speed: unknown\n"); | |
4137 | } | |
4138 | ||
4139 | ||
4140 | Stat = pAC->GIni.GP[FromPort].PLinkModeStatus; | |
4141 | if (Stat == SK_LMODE_STAT_AUTOHALF || | |
4142 | Stat == SK_LMODE_STAT_AUTOFULL) { | |
4143 | printk(" autonegotiation: yes\n"); | |
4144 | } | |
4145 | else { | |
4146 | printk(" autonegotiation: no\n"); | |
4147 | } | |
4148 | if (Stat == SK_LMODE_STAT_AUTOHALF || | |
4149 | Stat == SK_LMODE_STAT_HALF) { | |
4150 | printk(" duplex mode: half\n"); | |
4151 | } | |
4152 | else { | |
4153 | printk(" duplex mode: full\n"); | |
4154 | } | |
4155 | Stat = pAC->GIni.GP[FromPort].PFlowCtrlStatus; | |
4156 | if (Stat == SK_FLOW_STAT_REM_SEND ) { | |
4157 | printk(" flowctrl: remote send\n"); | |
4158 | } | |
4159 | else if (Stat == SK_FLOW_STAT_LOC_SEND ){ | |
4160 | printk(" flowctrl: local send\n"); | |
4161 | } | |
4162 | else if (Stat == SK_FLOW_STAT_SYMMETRIC ){ | |
4163 | printk(" flowctrl: symmetric\n"); | |
4164 | } | |
4165 | else { | |
4166 | printk(" flowctrl: none\n"); | |
4167 | } | |
4168 | ||
4169 | /* tschilling: Check against CopperType now. */ | |
4170 | if ((pAC->GIni.GICopperType == SK_TRUE) && | |
4171 | (pAC->GIni.GP[FromPort].PLinkSpeedUsed == | |
4172 | SK_LSPEED_STAT_1000MBPS)) { | |
4173 | Stat = pAC->GIni.GP[FromPort].PMSStatus; | |
4174 | if (Stat == SK_MS_STAT_MASTER ) { | |
4175 | printk(" role: master\n"); | |
4176 | } | |
4177 | else if (Stat == SK_MS_STAT_SLAVE ) { | |
4178 | printk(" role: slave\n"); | |
4179 | } | |
4180 | else { | |
4181 | printk(" role: ???\n"); | |
4182 | } | |
4183 | } | |
4184 | ||
4185 | /* | |
4186 | Display dim (dynamic interrupt moderation) | |
4187 | informations | |
4188 | */ | |
4189 | if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_STATIC) | |
4190 | printk(" irq moderation: static (%d ints/sec)\n", | |
4191 | pAC->DynIrqModInfo.MaxModIntsPerSec); | |
4192 | else if (pAC->DynIrqModInfo.IntModTypeSelect == C_INT_MOD_DYNAMIC) | |
4193 | printk(" irq moderation: dynamic (%d ints/sec)\n", | |
4194 | pAC->DynIrqModInfo.MaxModIntsPerSec); | |
4195 | else | |
4196 | printk(" irq moderation: disabled\n"); | |
4197 | ||
4198 | ||
09f5a214 SH |
4199 | printk(" scatter-gather: %s\n", |
4200 | (dev->features & NETIF_F_SG) ? "enabled" : "disabled"); | |
4201 | printk(" tx-checksum: %s\n", | |
4202 | (dev->features & NETIF_F_IP_CSUM) ? "enabled" : "disabled"); | |
4203 | printk(" rx-checksum: %s\n", | |
4204 | pAC->RxPort[Param.Para32[0]].RxCsum ? "enabled" : "disabled"); | |
1da177e4 LT |
4205 | |
4206 | } else { | |
4207 | DoPrintInterfaceChange = SK_TRUE; | |
4208 | } | |
4209 | ||
4210 | if ((Param.Para32[0] != pAC->ActivePort) && | |
4211 | (pAC->RlmtNets == 1)) { | |
4212 | NewPara.Para32[0] = pAC->ActivePort; | |
4213 | NewPara.Para32[1] = Param.Para32[0]; | |
4214 | SkEventQueue(pAC, SKGE_DRV, SK_DRV_SWITCH_INTERN, | |
4215 | NewPara); | |
4216 | } | |
4217 | ||
4218 | /* Inform the world that link protocol is up. */ | |
09f5a214 | 4219 | netif_carrier_on(dev); |
1da177e4 | 4220 | break; |
09f5a214 | 4221 | } |
1da177e4 LT |
4222 | case SK_DRV_NET_DOWN: /* SK_U32 Reason */ |
4223 | /* action list 7 */ | |
4224 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4225 | ("NET DOWN EVENT ")); | |
4226 | if (DoPrintInterfaceChange) { | |
4227 | printk("%s: network connection down\n", | |
4228 | pAC->dev[Param.Para32[1]]->name); | |
4229 | } else { | |
4230 | DoPrintInterfaceChange = SK_TRUE; | |
4231 | } | |
7d17c1d6 | 4232 | netif_carrier_off(pAC->dev[Param.Para32[1]]); |
1da177e4 LT |
4233 | break; |
4234 | case SK_DRV_SWITCH_HARD: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */ | |
4235 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4236 | ("PORT SWITCH HARD ")); | |
4237 | case SK_DRV_SWITCH_SOFT: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */ | |
4238 | /* action list 6 */ | |
4239 | printk("%s: switching to port %c\n", pAC->dev[0]->name, | |
4240 | 'A'+Param.Para32[1]); | |
4241 | case SK_DRV_SWITCH_INTERN: /* SK_U32 FromPortIdx SK_U32 ToPortIdx */ | |
4242 | FromPort = Param.Para32[0]; | |
4243 | ToPort = Param.Para32[1]; | |
4244 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4245 | ("PORT SWITCH EVENT, From: %d To: %d (Pref %d) ", | |
4246 | FromPort, ToPort, pAC->Rlmt.Net[0].PrefPort)); | |
4247 | NewPara.Para64 = FromPort; | |
4248 | SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara); | |
4249 | NewPara.Para64 = ToPort; | |
4250 | SkPnmiEvent(pAC, IoC, SK_PNMI_EVT_XMAC_RESET, NewPara); | |
4251 | spin_lock_irqsave( | |
4252 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4253 | Flags); | |
4254 | spin_lock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock); | |
4255 | SkGeStopPort(pAC, IoC, FromPort, SK_STOP_ALL, SK_SOFT_RST); | |
4256 | SkGeStopPort(pAC, IoC, ToPort, SK_STOP_ALL, SK_SOFT_RST); | |
4257 | spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock); | |
4258 | spin_unlock_irqrestore( | |
4259 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4260 | Flags); | |
4261 | ||
4262 | ReceiveIrq(pAC, &pAC->RxPort[FromPort], SK_FALSE); /* clears rx ring */ | |
4263 | ReceiveIrq(pAC, &pAC->RxPort[ToPort], SK_FALSE); /* clears rx ring */ | |
4264 | ||
4265 | ClearTxRing(pAC, &pAC->TxPort[FromPort][TX_PRIO_LOW]); | |
4266 | ClearTxRing(pAC, &pAC->TxPort[ToPort][TX_PRIO_LOW]); | |
4267 | spin_lock_irqsave( | |
4268 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4269 | Flags); | |
4270 | spin_lock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock); | |
4271 | pAC->ActivePort = ToPort; | |
4272 | #if 0 | |
4273 | SetQueueSizes(pAC); | |
4274 | #else | |
4275 | /* tschilling: New common function with minimum size check. */ | |
4276 | DualNet = SK_FALSE; | |
4277 | if (pAC->RlmtNets == 2) { | |
4278 | DualNet = SK_TRUE; | |
4279 | } | |
4280 | ||
4281 | if (SkGeInitAssignRamToQueues( | |
4282 | pAC, | |
4283 | pAC->ActivePort, | |
4284 | DualNet)) { | |
4285 | spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock); | |
4286 | spin_unlock_irqrestore( | |
4287 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4288 | Flags); | |
4289 | printk("SkGeInitAssignRamToQueues failed.\n"); | |
4290 | break; | |
4291 | } | |
4292 | #endif | |
4293 | /* tschilling: Handling of return values inserted. */ | |
4294 | if (SkGeInitPort(pAC, IoC, FromPort) || | |
4295 | SkGeInitPort(pAC, IoC, ToPort)) { | |
4296 | printk("%s: SkGeInitPort failed.\n", pAC->dev[0]->name); | |
4297 | } | |
4298 | if (Event == SK_DRV_SWITCH_SOFT) { | |
4299 | SkMacRxTxEnable(pAC, IoC, FromPort); | |
4300 | } | |
4301 | SkMacRxTxEnable(pAC, IoC, ToPort); | |
4302 | SkAddrSwap(pAC, IoC, FromPort, ToPort); | |
4303 | SkAddrMcUpdate(pAC, IoC, FromPort); | |
4304 | SkAddrMcUpdate(pAC, IoC, ToPort); | |
4305 | PortReInitBmu(pAC, FromPort); | |
4306 | PortReInitBmu(pAC, ToPort); | |
4307 | SkGePollTxD(pAC, IoC, FromPort, SK_TRUE); | |
4308 | SkGePollTxD(pAC, IoC, ToPort, SK_TRUE); | |
4309 | ClearAndStartRx(pAC, FromPort); | |
4310 | ClearAndStartRx(pAC, ToPort); | |
4311 | spin_unlock(&pAC->TxPort[ToPort][TX_PRIO_LOW].TxDesRingLock); | |
4312 | spin_unlock_irqrestore( | |
4313 | &pAC->TxPort[FromPort][TX_PRIO_LOW].TxDesRingLock, | |
4314 | Flags); | |
4315 | break; | |
4316 | case SK_DRV_RLMT_SEND: /* SK_MBUF *pMb */ | |
4317 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4318 | ("RLS ")); | |
4319 | pRlmtMbuf = (SK_MBUF*) Param.pParaPtr; | |
4320 | pMsg = (struct sk_buff*) pRlmtMbuf->pOs; | |
4321 | skb_put(pMsg, pRlmtMbuf->Length); | |
4322 | if (XmitFrame(pAC, &pAC->TxPort[pRlmtMbuf->PortIdx][TX_PRIO_LOW], | |
4323 | pMsg) < 0) | |
4324 | ||
4325 | DEV_KFREE_SKB_ANY(pMsg); | |
4326 | break; | |
4327 | case SK_DRV_TIMER: | |
4328 | if (Param.Para32[0] == SK_DRV_MODERATION_TIMER) { | |
4329 | /* | |
4330 | ** expiration of the moderation timer implies that | |
4331 | ** dynamic moderation is to be applied | |
4332 | */ | |
4333 | SkDimStartModerationTimer(pAC); | |
4334 | SkDimModerate(pAC); | |
4335 | if (pAC->DynIrqModInfo.DisplayStats) { | |
4336 | SkDimDisplayModerationSettings(pAC); | |
4337 | } | |
4338 | } else if (Param.Para32[0] == SK_DRV_RX_CLEANUP_TIMER) { | |
4339 | /* | |
4340 | ** check if we need to check for descriptors which | |
4341 | ** haven't been handled the last millisecs | |
4342 | */ | |
4343 | StartDrvCleanupTimer(pAC); | |
4344 | if (pAC->GIni.GIMacsFound == 2) { | |
4345 | ReceiveIrq(pAC, &pAC->RxPort[1], SK_FALSE); | |
4346 | } | |
4347 | ReceiveIrq(pAC, &pAC->RxPort[0], SK_FALSE); | |
4348 | } else { | |
4349 | printk("Expiration of unknown timer\n"); | |
4350 | } | |
4351 | break; | |
4352 | default: | |
4353 | break; | |
4354 | } | |
4355 | SK_DBG_MSG(NULL, SK_DBGMOD_DRV, SK_DBGCAT_DRV_EVENT, | |
4356 | ("END EVENT ")); | |
4357 | ||
4358 | return (0); | |
4359 | } /* SkDrvEvent */ | |
4360 | ||
4361 | ||
4362 | /***************************************************************************** | |
4363 | * | |
4364 | * SkErrorLog - log errors | |
4365 | * | |
4366 | * Description: | |
4367 | * This function logs errors to the system buffer and to the console | |
4368 | * | |
4369 | * Returns: | |
4370 | * 0 if everything ok | |
4371 | * < 0 on error | |
4372 | * | |
4373 | */ | |
4374 | void SkErrorLog( | |
4375 | SK_AC *pAC, | |
4376 | int ErrClass, | |
4377 | int ErrNum, | |
4378 | char *pErrorMsg) | |
4379 | { | |
4380 | char ClassStr[80]; | |
4381 | ||
4382 | switch (ErrClass) { | |
4383 | case SK_ERRCL_OTHER: | |
4384 | strcpy(ClassStr, "Other error"); | |
4385 | break; | |
4386 | case SK_ERRCL_CONFIG: | |
4387 | strcpy(ClassStr, "Configuration error"); | |
4388 | break; | |
4389 | case SK_ERRCL_INIT: | |
4390 | strcpy(ClassStr, "Initialization error"); | |
4391 | break; | |
4392 | case SK_ERRCL_NORES: | |
4393 | strcpy(ClassStr, "Out of resources error"); | |
4394 | break; | |
4395 | case SK_ERRCL_SW: | |
4396 | strcpy(ClassStr, "internal Software error"); | |
4397 | break; | |
4398 | case SK_ERRCL_HW: | |
4399 | strcpy(ClassStr, "Hardware failure"); | |
4400 | break; | |
4401 | case SK_ERRCL_COMM: | |
4402 | strcpy(ClassStr, "Communication error"); | |
4403 | break; | |
4404 | } | |
4405 | printk(KERN_INFO "%s: -- ERROR --\n Class: %s\n" | |
4406 | " Nr: 0x%x\n Msg: %s\n", pAC->dev[0]->name, | |
4407 | ClassStr, ErrNum, pErrorMsg); | |
4408 | ||
4409 | } /* SkErrorLog */ | |
4410 | ||
4411 | #ifdef SK_DIAG_SUPPORT | |
4412 | ||
4413 | /***************************************************************************** | |
4414 | * | |
4415 | * SkDrvEnterDiagMode - handles DIAG attach request | |
4416 | * | |
4417 | * Description: | |
4418 | * Notify the kernel to NOT access the card any longer due to DIAG | |
4419 | * Deinitialize the Card | |
4420 | * | |
4421 | * Returns: | |
4422 | * int | |
4423 | */ | |
4424 | int SkDrvEnterDiagMode( | |
4425 | SK_AC *pAc) /* pointer to adapter context */ | |
4426 | { | |
4427 | DEV_NET *pNet = netdev_priv(pAc->dev[0]); | |
4428 | SK_AC *pAC = pNet->pAC; | |
4429 | ||
4430 | SK_MEMCPY(&(pAc->PnmiBackup), &(pAc->PnmiStruct), | |
4431 | sizeof(SK_PNMI_STRUCT_DATA)); | |
4432 | ||
4433 | pAC->DiagModeActive = DIAG_ACTIVE; | |
4434 | if (pAC->BoardLevel > SK_INIT_DATA) { | |
8f7a17d1 | 4435 | if (netif_running(pAC->dev[0])) { |
1da177e4 LT |
4436 | pAC->WasIfUp[0] = SK_TRUE; |
4437 | pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ | |
4438 | DoPrintInterfaceChange = SK_FALSE; | |
4439 | SkDrvDeInitAdapter(pAC, 0); /* performs SkGeClose */ | |
4440 | } else { | |
4441 | pAC->WasIfUp[0] = SK_FALSE; | |
4442 | } | |
4443 | if (pNet != netdev_priv(pAC->dev[1])) { | |
4444 | pNet = netdev_priv(pAC->dev[1]); | |
8f7a17d1 | 4445 | if (netif_running(pAC->dev[1])) { |
1da177e4 LT |
4446 | pAC->WasIfUp[1] = SK_TRUE; |
4447 | pAC->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ | |
4448 | DoPrintInterfaceChange = SK_FALSE; | |
4449 | SkDrvDeInitAdapter(pAC, 1); /* do SkGeClose */ | |
4450 | } else { | |
4451 | pAC->WasIfUp[1] = SK_FALSE; | |
4452 | } | |
4453 | } | |
4454 | pAC->BoardLevel = SK_INIT_DATA; | |
4455 | } | |
4456 | return(0); | |
4457 | } | |
4458 | ||
4459 | /***************************************************************************** | |
4460 | * | |
4461 | * SkDrvLeaveDiagMode - handles DIAG detach request | |
4462 | * | |
4463 | * Description: | |
4464 | * Notify the kernel to may access the card again after use by DIAG | |
4465 | * Initialize the Card | |
4466 | * | |
4467 | * Returns: | |
4468 | * int | |
4469 | */ | |
4470 | int SkDrvLeaveDiagMode( | |
4471 | SK_AC *pAc) /* pointer to adapter control context */ | |
4472 | { | |
4473 | SK_MEMCPY(&(pAc->PnmiStruct), &(pAc->PnmiBackup), | |
4474 | sizeof(SK_PNMI_STRUCT_DATA)); | |
4475 | pAc->DiagModeActive = DIAG_NOTACTIVE; | |
4476 | pAc->Pnmi.DiagAttached = SK_DIAG_IDLE; | |
4477 | if (pAc->WasIfUp[0] == SK_TRUE) { | |
4478 | pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ | |
4479 | DoPrintInterfaceChange = SK_FALSE; | |
4480 | SkDrvInitAdapter(pAc, 0); /* first device */ | |
4481 | } | |
4482 | if (pAc->WasIfUp[1] == SK_TRUE) { | |
4483 | pAc->DiagFlowCtrl = SK_TRUE; /* for SkGeClose */ | |
4484 | DoPrintInterfaceChange = SK_FALSE; | |
4485 | SkDrvInitAdapter(pAc, 1); /* second device */ | |
4486 | } | |
4487 | return(0); | |
4488 | } | |
4489 | ||
4490 | /***************************************************************************** | |
4491 | * | |
4492 | * ParseDeviceNbrFromSlotName - Evaluate PCI device number | |
4493 | * | |
4494 | * Description: | |
4495 | * This function parses the PCI slot name information string and will | |
4496 | * retrieve the devcie number out of it. The slot_name maintianed by | |
4497 | * linux is in the form of '02:0a.0', whereas the first two characters | |
4498 | * represent the bus number in hex (in the sample above this is | |
4499 | * pci bus 0x02) and the next two characters the device number (0x0a). | |
4500 | * | |
4501 | * Returns: | |
4502 | * SK_U32: The device number from the PCI slot name | |
4503 | */ | |
4504 | ||
4505 | static SK_U32 ParseDeviceNbrFromSlotName( | |
4506 | const char *SlotName) /* pointer to pci slot name eg. '02:0a.0' */ | |
4507 | { | |
4508 | char *CurrCharPos = (char *) SlotName; | |
4509 | int FirstNibble = -1; | |
4510 | int SecondNibble = -1; | |
4511 | SK_U32 Result = 0; | |
4512 | ||
4513 | while (*CurrCharPos != '\0') { | |
4514 | if (*CurrCharPos == ':') { | |
4515 | while (*CurrCharPos != '.') { | |
4516 | CurrCharPos++; | |
4517 | if ( (*CurrCharPos >= '0') && | |
4518 | (*CurrCharPos <= '9')) { | |
4519 | if (FirstNibble == -1) { | |
4520 | /* dec. value for '0' */ | |
4521 | FirstNibble = *CurrCharPos - 48; | |
4522 | } else { | |
4523 | SecondNibble = *CurrCharPos - 48; | |
4524 | } | |
4525 | } else if ( (*CurrCharPos >= 'a') && | |
4526 | (*CurrCharPos <= 'f') ) { | |
4527 | if (FirstNibble == -1) { | |
4528 | FirstNibble = *CurrCharPos - 87; | |
4529 | } else { | |
4530 | SecondNibble = *CurrCharPos - 87; | |
4531 | } | |
4532 | } else { | |
4533 | Result = 0; | |
4534 | } | |
4535 | } | |
4536 | ||
4537 | Result = FirstNibble; | |
4538 | Result = Result << 4; /* first nibble is higher one */ | |
4539 | Result = Result | SecondNibble; | |
4540 | } | |
4541 | CurrCharPos++; /* next character */ | |
4542 | } | |
4543 | return (Result); | |
4544 | } | |
4545 | ||
4546 | /**************************************************************************** | |
4547 | * | |
4548 | * SkDrvDeInitAdapter - deinitialize adapter (this function is only | |
4549 | * called if Diag attaches to that card) | |
4550 | * | |
4551 | * Description: | |
4552 | * Close initialized adapter. | |
4553 | * | |
4554 | * Returns: | |
4555 | * 0 - on success | |
4556 | * error code - on error | |
4557 | */ | |
4558 | static int SkDrvDeInitAdapter( | |
4559 | SK_AC *pAC, /* pointer to adapter context */ | |
4560 | int devNbr) /* what device is to be handled */ | |
4561 | { | |
4562 | struct SK_NET_DEVICE *dev; | |
4563 | ||
4564 | dev = pAC->dev[devNbr]; | |
4565 | ||
4566 | /* On Linux 2.6 the network driver does NOT mess with reference | |
4567 | ** counts. The driver MUST be able to be unloaded at any time | |
4568 | ** due to the possibility of hotplug. | |
4569 | */ | |
4570 | if (SkGeClose(dev) != 0) { | |
4571 | return (-1); | |
4572 | } | |
4573 | return (0); | |
4574 | ||
4575 | } /* SkDrvDeInitAdapter() */ | |
4576 | ||
4577 | /**************************************************************************** | |
4578 | * | |
4579 | * SkDrvInitAdapter - Initialize adapter (this function is only | |
4580 | * called if Diag deattaches from that card) | |
4581 | * | |
4582 | * Description: | |
4583 | * Close initialized adapter. | |
4584 | * | |
4585 | * Returns: | |
4586 | * 0 - on success | |
4587 | * error code - on error | |
4588 | */ | |
4589 | static int SkDrvInitAdapter( | |
4590 | SK_AC *pAC, /* pointer to adapter context */ | |
4591 | int devNbr) /* what device is to be handled */ | |
4592 | { | |
4593 | struct SK_NET_DEVICE *dev; | |
4594 | ||
4595 | dev = pAC->dev[devNbr]; | |
4596 | ||
4597 | if (SkGeOpen(dev) != 0) { | |
4598 | return (-1); | |
4599 | } | |
4600 | ||
4601 | /* | |
4602 | ** Use correct MTU size and indicate to kernel TX queue can be started | |
4603 | */ | |
4604 | if (SkGeChangeMtu(dev, dev->mtu) != 0) { | |
4605 | return (-1); | |
4606 | } | |
4607 | return (0); | |
4608 | ||
4609 | } /* SkDrvInitAdapter */ | |
4610 | ||
4611 | #endif | |
4612 | ||
4613 | #ifdef DEBUG | |
4614 | /****************************************************************************/ | |
4615 | /* "debug only" section *****************************************************/ | |
4616 | /****************************************************************************/ | |
4617 | ||
4618 | ||
4619 | /***************************************************************************** | |
4620 | * | |
4621 | * DumpMsg - print a frame | |
4622 | * | |
4623 | * Description: | |
4624 | * This function prints frames to the system logfile/to the console. | |
4625 | * | |
4626 | * Returns: N/A | |
4627 | * | |
4628 | */ | |
4629 | static void DumpMsg(struct sk_buff *skb, char *str) | |
4630 | { | |
4631 | int msglen; | |
4632 | ||
4633 | if (skb == NULL) { | |
4634 | printk("DumpMsg(): NULL-Message\n"); | |
4635 | return; | |
4636 | } | |
4637 | ||
4638 | if (skb->data == NULL) { | |
4639 | printk("DumpMsg(): Message empty\n"); | |
4640 | return; | |
4641 | } | |
4642 | ||
4643 | msglen = skb->len; | |
4644 | if (msglen > 64) | |
4645 | msglen = 64; | |
4646 | ||
4647 | printk("--- Begin of message from %s , len %d (from %d) ----\n", str, msglen, skb->len); | |
4648 | ||
4649 | DumpData((char *)skb->data, msglen); | |
4650 | ||
4651 | printk("------- End of message ---------\n"); | |
4652 | } /* DumpMsg */ | |
4653 | ||
4654 | ||
4655 | ||
4656 | /***************************************************************************** | |
4657 | * | |
4658 | * DumpData - print a data area | |
4659 | * | |
4660 | * Description: | |
4661 | * This function prints a area of data to the system logfile/to the | |
4662 | * console. | |
4663 | * | |
4664 | * Returns: N/A | |
4665 | * | |
4666 | */ | |
4667 | static void DumpData(char *p, int size) | |
4668 | { | |
4669 | register int i; | |
4670 | int haddr, addr; | |
4671 | char hex_buffer[180]; | |
4672 | char asc_buffer[180]; | |
4673 | char HEXCHAR[] = "0123456789ABCDEF"; | |
4674 | ||
4675 | addr = 0; | |
4676 | haddr = 0; | |
4677 | hex_buffer[0] = 0; | |
4678 | asc_buffer[0] = 0; | |
4679 | for (i=0; i < size; ) { | |
4680 | if (*p >= '0' && *p <='z') | |
4681 | asc_buffer[addr] = *p; | |
4682 | else | |
4683 | asc_buffer[addr] = '.'; | |
4684 | addr++; | |
4685 | asc_buffer[addr] = 0; | |
4686 | hex_buffer[haddr] = HEXCHAR[(*p & 0xf0) >> 4]; | |
4687 | haddr++; | |
4688 | hex_buffer[haddr] = HEXCHAR[*p & 0x0f]; | |
4689 | haddr++; | |
4690 | hex_buffer[haddr] = ' '; | |
4691 | haddr++; | |
4692 | hex_buffer[haddr] = 0; | |
4693 | p++; | |
4694 | i++; | |
4695 | if (i%16 == 0) { | |
4696 | printk("%s %s\n", hex_buffer, asc_buffer); | |
4697 | addr = 0; | |
4698 | haddr = 0; | |
4699 | } | |
4700 | } | |
4701 | } /* DumpData */ | |
4702 | ||
4703 | ||
4704 | /***************************************************************************** | |
4705 | * | |
4706 | * DumpLong - print a data area as long values | |
4707 | * | |
4708 | * Description: | |
4709 | * This function prints a area of data to the system logfile/to the | |
4710 | * console. | |
4711 | * | |
4712 | * Returns: N/A | |
4713 | * | |
4714 | */ | |
4715 | static void DumpLong(char *pc, int size) | |
4716 | { | |
4717 | register int i; | |
4718 | int haddr, addr; | |
4719 | char hex_buffer[180]; | |
4720 | char asc_buffer[180]; | |
4721 | char HEXCHAR[] = "0123456789ABCDEF"; | |
4722 | long *p; | |
4723 | int l; | |
4724 | ||
4725 | addr = 0; | |
4726 | haddr = 0; | |
4727 | hex_buffer[0] = 0; | |
4728 | asc_buffer[0] = 0; | |
4729 | p = (long*) pc; | |
4730 | for (i=0; i < size; ) { | |
4731 | l = (long) *p; | |
4732 | hex_buffer[haddr] = HEXCHAR[(l >> 28) & 0xf]; | |
4733 | haddr++; | |
4734 | hex_buffer[haddr] = HEXCHAR[(l >> 24) & 0xf]; | |
4735 | haddr++; | |
4736 | hex_buffer[haddr] = HEXCHAR[(l >> 20) & 0xf]; | |
4737 | haddr++; | |
4738 | hex_buffer[haddr] = HEXCHAR[(l >> 16) & 0xf]; | |
4739 | haddr++; | |
4740 | hex_buffer[haddr] = HEXCHAR[(l >> 12) & 0xf]; | |
4741 | haddr++; | |
4742 | hex_buffer[haddr] = HEXCHAR[(l >> 8) & 0xf]; | |
4743 | haddr++; | |
4744 | hex_buffer[haddr] = HEXCHAR[(l >> 4) & 0xf]; | |
4745 | haddr++; | |
4746 | hex_buffer[haddr] = HEXCHAR[l & 0x0f]; | |
4747 | haddr++; | |
4748 | hex_buffer[haddr] = ' '; | |
4749 | haddr++; | |
4750 | hex_buffer[haddr] = 0; | |
4751 | p++; | |
4752 | i++; | |
4753 | if (i%8 == 0) { | |
4754 | printk("%4x %s\n", (i-8)*4, hex_buffer); | |
4755 | haddr = 0; | |
4756 | } | |
4757 | } | |
4758 | printk("------------------------\n"); | |
4759 | } /* DumpLong */ | |
4760 | ||
4761 | #endif | |
4762 | ||
4763 | static int __devinit skge_probe_one(struct pci_dev *pdev, | |
4764 | const struct pci_device_id *ent) | |
4765 | { | |
4766 | SK_AC *pAC; | |
4767 | DEV_NET *pNet = NULL; | |
4768 | struct net_device *dev = NULL; | |
4769 | static int boards_found = 0; | |
4770 | int error = -ENODEV; | |
bce7c95e | 4771 | int using_dac = 0; |
8f7a17d1 | 4772 | char DeviceStr[80]; |
1da177e4 LT |
4773 | |
4774 | if (pci_enable_device(pdev)) | |
4775 | goto out; | |
4776 | ||
4777 | /* Configure DMA attributes. */ | |
bce7c95e SH |
4778 | if (sizeof(dma_addr_t) > sizeof(u32) && |
4779 | !(error = pci_set_dma_mask(pdev, DMA_64BIT_MASK))) { | |
4780 | using_dac = 1; | |
4781 | error = pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK); | |
4782 | if (error < 0) { | |
4783 | printk(KERN_ERR "sk98lin %s unable to obtain 64 bit DMA " | |
4784 | "for consistent allocations\n", pci_name(pdev)); | |
4785 | goto out_disable_device; | |
4786 | } | |
4787 | } else { | |
4788 | error = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | |
4789 | if (error) { | |
4790 | printk(KERN_ERR "sk98lin %s no usable DMA configuration\n", | |
4791 | pci_name(pdev)); | |
4792 | goto out_disable_device; | |
4793 | } | |
4794 | } | |
1da177e4 | 4795 | |
16287557 SH |
4796 | error = -ENOMEM; |
4797 | dev = alloc_etherdev(sizeof(DEV_NET)); | |
4798 | if (!dev) { | |
4799 | printk(KERN_ERR "sk98lin: unable to allocate etherdev " | |
1da177e4 LT |
4800 | "structure!\n"); |
4801 | goto out_disable_device; | |
4802 | } | |
4803 | ||
4804 | pNet = netdev_priv(dev); | |
26fc3549 | 4805 | pNet->pAC = kzalloc(sizeof(SK_AC), GFP_KERNEL); |
1da177e4 | 4806 | if (!pNet->pAC) { |
16287557 | 4807 | printk(KERN_ERR "sk98lin: unable to allocate adapter " |
1da177e4 LT |
4808 | "structure!\n"); |
4809 | goto out_free_netdev; | |
4810 | } | |
4811 | ||
1da177e4 LT |
4812 | pAC = pNet->pAC; |
4813 | pAC->PciDev = pdev; | |
8f7a17d1 | 4814 | |
1da177e4 LT |
4815 | pAC->dev[0] = dev; |
4816 | pAC->dev[1] = dev; | |
1da177e4 LT |
4817 | pAC->CheckQueue = SK_FALSE; |
4818 | ||
1da177e4 | 4819 | dev->irq = pdev->irq; |
16287557 | 4820 | |
1da177e4 LT |
4821 | error = SkGeInitPCI(pAC); |
4822 | if (error) { | |
be0df20c | 4823 | printk(KERN_ERR "sk98lin: PCI setup failed: %i\n", error); |
1da177e4 LT |
4824 | goto out_free_netdev; |
4825 | } | |
4826 | ||
4827 | SET_MODULE_OWNER(dev); | |
4828 | dev->open = &SkGeOpen; | |
4829 | dev->stop = &SkGeClose; | |
4830 | dev->hard_start_xmit = &SkGeXmit; | |
4831 | dev->get_stats = &SkGeStats; | |
4832 | dev->set_multicast_list = &SkGeSetRxMode; | |
4833 | dev->set_mac_address = &SkGeSetMacAddr; | |
4834 | dev->do_ioctl = &SkGeIoctl; | |
4835 | dev->change_mtu = &SkGeChangeMtu; | |
4836 | #ifdef CONFIG_NET_POLL_CONTROLLER | |
4837 | dev->poll_controller = &SkGePollController; | |
4838 | #endif | |
1da177e4 LT |
4839 | SET_NETDEV_DEV(dev, &pdev->dev); |
4840 | SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps); | |
4841 | ||
09f5a214 | 4842 | /* Use only if yukon hardware */ |
1da177e4 | 4843 | if (pAC->ChipsetType) { |
09f5a214 SH |
4844 | #ifdef USE_SK_TX_CHECKSUM |
4845 | dev->features |= NETIF_F_IP_CSUM; | |
1da177e4 | 4846 | #endif |
09f5a214 SH |
4847 | #ifdef SK_ZEROCOPY |
4848 | dev->features |= NETIF_F_SG; | |
1da177e4 | 4849 | #endif |
09f5a214 SH |
4850 | #ifdef USE_SK_RX_CHECKSUM |
4851 | pAC->RxPort[0].RxCsum = 1; | |
1da177e4 | 4852 | #endif |
09f5a214 | 4853 | } |
1da177e4 | 4854 | |
bce7c95e SH |
4855 | if (using_dac) |
4856 | dev->features |= NETIF_F_HIGHDMA; | |
4857 | ||
1da177e4 LT |
4858 | pAC->Index = boards_found++; |
4859 | ||
16287557 SH |
4860 | error = SkGeBoardInit(dev, pAC); |
4861 | if (error) | |
1da177e4 LT |
4862 | goto out_free_netdev; |
4863 | ||
8f7a17d1 SH |
4864 | /* Read Adapter name from VPD */ |
4865 | if (ProductStr(pAC, DeviceStr, sizeof(DeviceStr)) != 0) { | |
16287557 | 4866 | error = -EIO; |
8f7a17d1 SH |
4867 | printk(KERN_ERR "sk98lin: Could not read VPD data.\n"); |
4868 | goto out_free_resources; | |
4869 | } | |
4870 | ||
1da177e4 | 4871 | /* Register net device */ |
16287557 SH |
4872 | error = register_netdev(dev); |
4873 | if (error) { | |
be0df20c | 4874 | printk(KERN_ERR "sk98lin: Could not register device.\n"); |
1da177e4 LT |
4875 | goto out_free_resources; |
4876 | } | |
4877 | ||
4878 | /* Print adapter specific string from vpd */ | |
8f7a17d1 | 4879 | printk("%s: %s\n", dev->name, DeviceStr); |
1da177e4 LT |
4880 | |
4881 | /* Print configuration settings */ | |
4882 | printk(" PrefPort:%c RlmtMode:%s\n", | |
4883 | 'A' + pAC->Rlmt.Net[0].Port[pAC->Rlmt.Net[0].PrefPort]->PortNumber, | |
4884 | (pAC->RlmtMode==0) ? "Check Link State" : | |
4885 | ((pAC->RlmtMode==1) ? "Check Link State" : | |
4886 | ((pAC->RlmtMode==3) ? "Check Local Port" : | |
4887 | ((pAC->RlmtMode==7) ? "Check Segmentation" : | |
4888 | ((pAC->RlmtMode==17) ? "Dual Check Link State" :"Error"))))); | |
4889 | ||
4890 | SkGeYellowLED(pAC, pAC->IoBase, 1); | |
4891 | ||
1da177e4 | 4892 | memcpy(&dev->dev_addr, &pAC->Addr.Net[0].CurrentMacAddress, 6); |
4f4c8150 | 4893 | memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); |
1da177e4 | 4894 | |
1da177e4 LT |
4895 | pNet->PortNr = 0; |
4896 | pNet->NetNr = 0; | |
4897 | ||
4898 | boards_found++; | |
4899 | ||
decf67aa SH |
4900 | pci_set_drvdata(pdev, dev); |
4901 | ||
1da177e4 LT |
4902 | /* More then one port found */ |
4903 | if ((pAC->GIni.GIMacsFound == 2 ) && (pAC->RlmtNets == 2)) { | |
decf67aa SH |
4904 | dev = alloc_etherdev(sizeof(DEV_NET)); |
4905 | if (!dev) { | |
4906 | printk(KERN_ERR "sk98lin: unable to allocate etherdev " | |
1da177e4 | 4907 | "structure!\n"); |
decf67aa | 4908 | goto single_port; |
1da177e4 LT |
4909 | } |
4910 | ||
1da177e4 LT |
4911 | pNet = netdev_priv(dev); |
4912 | pNet->PortNr = 1; | |
4913 | pNet->NetNr = 1; | |
4914 | pNet->pAC = pAC; | |
1da177e4 LT |
4915 | |
4916 | dev->open = &SkGeOpen; | |
4917 | dev->stop = &SkGeClose; | |
4918 | dev->hard_start_xmit = &SkGeXmit; | |
4919 | dev->get_stats = &SkGeStats; | |
4920 | dev->set_multicast_list = &SkGeSetRxMode; | |
4921 | dev->set_mac_address = &SkGeSetMacAddr; | |
4922 | dev->do_ioctl = &SkGeIoctl; | |
4923 | dev->change_mtu = &SkGeChangeMtu; | |
1da177e4 LT |
4924 | SET_NETDEV_DEV(dev, &pdev->dev); |
4925 | SET_ETHTOOL_OPS(dev, &SkGeEthtoolOps); | |
4926 | ||
1da177e4 | 4927 | if (pAC->ChipsetType) { |
09f5a214 SH |
4928 | #ifdef USE_SK_TX_CHECKSUM |
4929 | dev->features |= NETIF_F_IP_CSUM; | |
1da177e4 | 4930 | #endif |
09f5a214 SH |
4931 | #ifdef SK_ZEROCOPY |
4932 | dev->features |= NETIF_F_SG; | |
1da177e4 | 4933 | #endif |
09f5a214 SH |
4934 | #ifdef USE_SK_RX_CHECKSUM |
4935 | pAC->RxPort[1].RxCsum = 1; | |
1da177e4 | 4936 | #endif |
09f5a214 | 4937 | } |
1da177e4 | 4938 | |
bce7c95e SH |
4939 | if (using_dac) |
4940 | dev->features |= NETIF_F_HIGHDMA; | |
4941 | ||
decf67aa SH |
4942 | error = register_netdev(dev); |
4943 | if (error) { | |
4944 | printk(KERN_ERR "sk98lin: Could not register device" | |
4945 | " for second port. (%d)\n", error); | |
1da177e4 | 4946 | free_netdev(dev); |
decf67aa | 4947 | goto single_port; |
1da177e4 | 4948 | } |
decf67aa SH |
4949 | |
4950 | pAC->dev[1] = dev; | |
4951 | memcpy(&dev->dev_addr, | |
4952 | &pAC->Addr.Net[1].CurrentMacAddress, 6); | |
4953 | memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); | |
4954 | ||
4955 | printk("%s: %s\n", dev->name, DeviceStr); | |
4956 | printk(" PrefPort:B RlmtMode:Dual Check Link State\n"); | |
1da177e4 LT |
4957 | } |
4958 | ||
decf67aa SH |
4959 | single_port: |
4960 | ||
1da177e4 LT |
4961 | /* Save the hardware revision */ |
4962 | pAC->HWRevision = (((pAC->GIni.GIPciHwRev >> 4) & 0x0F)*10) + | |
4963 | (pAC->GIni.GIPciHwRev & 0x0F); | |
4964 | ||
4965 | /* Set driver globals */ | |
4966 | pAC->Pnmi.pDriverFileName = DRIVER_FILE_NAME; | |
4967 | pAC->Pnmi.pDriverReleaseDate = DRIVER_REL_DATE; | |
4968 | ||
4969 | memset(&pAC->PnmiBackup, 0, sizeof(SK_PNMI_STRUCT_DATA)); | |
4970 | memcpy(&pAC->PnmiBackup, &pAC->PnmiStruct, sizeof(SK_PNMI_STRUCT_DATA)); | |
4971 | ||
1da177e4 LT |
4972 | return 0; |
4973 | ||
4974 | out_free_resources: | |
4975 | FreeResources(dev); | |
4976 | out_free_netdev: | |
4977 | free_netdev(dev); | |
4978 | out_disable_device: | |
4979 | pci_disable_device(pdev); | |
4980 | out: | |
4981 | return error; | |
4982 | } | |
4983 | ||
4984 | static void __devexit skge_remove_one(struct pci_dev *pdev) | |
4985 | { | |
4986 | struct net_device *dev = pci_get_drvdata(pdev); | |
4987 | DEV_NET *pNet = netdev_priv(dev); | |
4988 | SK_AC *pAC = pNet->pAC; | |
4989 | struct net_device *otherdev = pAC->dev[1]; | |
4990 | ||
1da177e4 | 4991 | unregister_netdev(dev); |
1da177e4 LT |
4992 | |
4993 | SkGeYellowLED(pAC, pAC->IoBase, 0); | |
4994 | ||
4995 | if (pAC->BoardLevel == SK_INIT_RUN) { | |
4996 | SK_EVPARA EvPara; | |
4997 | unsigned long Flags; | |
4998 | ||
4999 | /* board is still alive */ | |
5000 | spin_lock_irqsave(&pAC->SlowPathLock, Flags); | |
5001 | EvPara.Para32[0] = 0; | |
5002 | EvPara.Para32[1] = -1; | |
5003 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
5004 | EvPara.Para32[0] = 1; | |
5005 | EvPara.Para32[1] = -1; | |
5006 | SkEventQueue(pAC, SKGE_RLMT, SK_RLMT_STOP, EvPara); | |
5007 | SkEventDispatcher(pAC, pAC->IoBase); | |
5008 | /* disable interrupts */ | |
5009 | SK_OUT32(pAC->IoBase, B0_IMSK, 0); | |
5010 | SkGeDeInit(pAC, pAC->IoBase); | |
5011 | spin_unlock_irqrestore(&pAC->SlowPathLock, Flags); | |
5012 | pAC->BoardLevel = SK_INIT_DATA; | |
5013 | /* We do NOT check here, if IRQ was pending, of course*/ | |
5014 | } | |
5015 | ||
5016 | if (pAC->BoardLevel == SK_INIT_IO) { | |
5017 | /* board is still alive */ | |
5018 | SkGeDeInit(pAC, pAC->IoBase); | |
5019 | pAC->BoardLevel = SK_INIT_DATA; | |
5020 | } | |
5021 | ||
5022 | FreeResources(dev); | |
5023 | free_netdev(dev); | |
5024 | if (otherdev != dev) | |
5025 | free_netdev(otherdev); | |
5026 | kfree(pAC); | |
5027 | } | |
5028 | ||
90158b83 RW |
5029 | #ifdef CONFIG_PM |
5030 | static int skge_suspend(struct pci_dev *pdev, pm_message_t state) | |
5031 | { | |
5032 | struct net_device *dev = pci_get_drvdata(pdev); | |
5033 | DEV_NET *pNet = netdev_priv(dev); | |
5034 | SK_AC *pAC = pNet->pAC; | |
5035 | struct net_device *otherdev = pAC->dev[1]; | |
5036 | ||
035a4a4f RW |
5037 | if (netif_running(dev)) { |
5038 | netif_carrier_off(dev); | |
90158b83 RW |
5039 | DoPrintInterfaceChange = SK_FALSE; |
5040 | SkDrvDeInitAdapter(pAC, 0); /* performs SkGeClose */ | |
035a4a4f | 5041 | netif_device_detach(dev); |
90158b83 RW |
5042 | } |
5043 | if (otherdev != dev) { | |
035a4a4f RW |
5044 | if (netif_running(otherdev)) { |
5045 | netif_carrier_off(otherdev); | |
90158b83 RW |
5046 | DoPrintInterfaceChange = SK_FALSE; |
5047 | SkDrvDeInitAdapter(pAC, 1); /* performs SkGeClose */ | |
035a4a4f | 5048 | netif_device_detach(otherdev); |
90158b83 RW |
5049 | } |
5050 | } | |
5051 | ||
5052 | pci_save_state(pdev); | |
5053 | pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); | |
5054 | if (pAC->AllocFlag & SK_ALLOC_IRQ) { | |
5055 | free_irq(dev->irq, dev); | |
5056 | } | |
5057 | pci_disable_device(pdev); | |
5058 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | |
5059 | ||
5060 | return 0; | |
5061 | } | |
5062 | ||
5063 | static int skge_resume(struct pci_dev *pdev) | |
5064 | { | |
5065 | struct net_device *dev = pci_get_drvdata(pdev); | |
5066 | DEV_NET *pNet = netdev_priv(dev); | |
5067 | SK_AC *pAC = pNet->pAC; | |
035a4a4f RW |
5068 | struct net_device *otherdev = pAC->dev[1]; |
5069 | int ret; | |
90158b83 RW |
5070 | |
5071 | pci_set_power_state(pdev, PCI_D0); | |
5072 | pci_restore_state(pdev); | |
5073 | pci_enable_device(pdev); | |
5074 | pci_set_master(pdev); | |
5075 | if (pAC->GIni.GIMacsFound == 2) | |
8f7a17d1 | 5076 | ret = request_irq(dev->irq, SkGeIsr, SA_SHIRQ, "sk98lin", dev); |
90158b83 | 5077 | else |
8f7a17d1 | 5078 | ret = request_irq(dev->irq, SkGeIsrOnePort, SA_SHIRQ, "sk98lin", dev); |
035a4a4f RW |
5079 | if (ret) { |
5080 | printk(KERN_WARNING "sk98lin: unable to acquire IRQ %d\n", dev->irq); | |
5081 | pAC->AllocFlag &= ~SK_ALLOC_IRQ; | |
5082 | dev->irq = 0; | |
5083 | pci_disable_device(pdev); | |
5084 | return -EBUSY; | |
5085 | } | |
90158b83 | 5086 | |
035a4a4f RW |
5087 | netif_device_attach(dev); |
5088 | if (netif_running(dev)) { | |
90158b83 RW |
5089 | DoPrintInterfaceChange = SK_FALSE; |
5090 | SkDrvInitAdapter(pAC, 0); /* first device */ | |
035a4a4f RW |
5091 | } |
5092 | if (otherdev != dev) { | |
5093 | netif_device_attach(otherdev); | |
5094 | if (netif_running(otherdev)) { | |
5095 | DoPrintInterfaceChange = SK_FALSE; | |
5096 | SkDrvInitAdapter(pAC, 1); /* second device */ | |
5097 | } | |
90158b83 RW |
5098 | } |
5099 | ||
5100 | return 0; | |
5101 | } | |
3fef3fa2 AM |
5102 | #else |
5103 | #define skge_suspend NULL | |
5104 | #define skge_resume NULL | |
90158b83 RW |
5105 | #endif |
5106 | ||
1da177e4 LT |
5107 | static struct pci_device_id skge_pci_tbl[] = { |
5108 | { PCI_VENDOR_ID_3COM, 0x1700, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
5109 | { PCI_VENDOR_ID_3COM, 0x80eb, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
5110 | { PCI_VENDOR_ID_SYSKONNECT, 0x4300, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
5111 | { PCI_VENDOR_ID_SYSKONNECT, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
9734c3fc SH |
5112 | /* DLink card does not have valid VPD so this driver gags |
5113 | * { PCI_VENDOR_ID_DLINK, 0x4c00, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
5114 | */ | |
1da177e4 | 5115 | { PCI_VENDOR_ID_MARVELL, 0x4320, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
1da177e4 LT |
5116 | { PCI_VENDOR_ID_MARVELL, 0x5005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
5117 | { PCI_VENDOR_ID_CNET, 0x434e, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, | |
9734c3fc | 5118 | { PCI_VENDOR_ID_LINKSYS, 0x1032, PCI_ANY_ID, 0x0015, }, |
1da177e4 | 5119 | { PCI_VENDOR_ID_LINKSYS, 0x1064, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, |
9734c3fc | 5120 | { 0 } |
1da177e4 LT |
5121 | }; |
5122 | ||
5123 | MODULE_DEVICE_TABLE(pci, skge_pci_tbl); | |
5124 | ||
5125 | static struct pci_driver skge_driver = { | |
5126 | .name = "sk98lin", | |
5127 | .id_table = skge_pci_tbl, | |
5128 | .probe = skge_probe_one, | |
5129 | .remove = __devexit_p(skge_remove_one), | |
90158b83 RW |
5130 | .suspend = skge_suspend, |
5131 | .resume = skge_resume, | |
1da177e4 LT |
5132 | }; |
5133 | ||
5134 | static int __init skge_init(void) | |
5135 | { | |
35b8fcab | 5136 | return pci_module_init(&skge_driver); |
1da177e4 LT |
5137 | } |
5138 | ||
5139 | static void __exit skge_exit(void) | |
5140 | { | |
5141 | pci_unregister_driver(&skge_driver); | |
1da177e4 LT |
5142 | } |
5143 | ||
5144 | module_init(skge_init); | |
5145 | module_exit(skge_exit); |