⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 skge.c

📁 F:worksip2440a board可启动u-boot-like.tar.gz F:worksip2440a board可启动u-boot-like.tar.gz
💻 C
📖 第 1 页 / 共 5 页
字号:
/****************************************************************************** * * Name:    skge.c * Project:	GEnesis, PCI Gigabit Ethernet Adapter * Version:	$Revision: 1.1.1.1 $ * Date:       	$Date: 2005/06/27 17:05:08 $ * Purpose:	The main driver source module * ******************************************************************************//****************************************************************************** * *	(C)Copyright 1998-2003 SysKonnect GmbH. * *	Driver for SysKonnect Gigabit Ethernet Server Adapters: * *	SK-9871 (single link 1000Base-ZX) *	SK-9872 (dual link   1000Base-ZX) *	SK-9861 (single link 1000Base-SX, VF45 Volition Plug) *	SK-9862 (dual link   1000Base-SX, VF45 Volition Plug) *	SK-9841 (single link 1000Base-LX) *	SK-9842 (dual link   1000Base-LX) *	SK-9843 (single link 1000Base-SX) *	SK-9844 (dual link   1000Base-SX) *	SK-9821 (single link 1000Base-T) *	SK-9822 (dual link   1000Base-T) *	SK-9881 (single link 1000Base-SX V2 LC) *	SK-9871 (single link 1000Base-ZX V2) *	SK-9861 (single link 1000Base-SX V2, VF45 Volition Plug) *	SK-9841 (single link 1000Base-LX V2) *	SK-9843 (single link 1000Base-SX V2) *	SK-9821 (single link 1000Base-T V2) * *	Created 10-Feb-1999, based on Linux' acenic.c, 3c59x.c and *	SysKonnects GEnesis Solaris driver *	Author: Christoph Goos (cgoos@syskonnect.de) *	        Mirko Lindner (mlindner@syskonnect.de) * *	Address all question to: linux@syskonnect.de * *	The technical manual for the adapters is available from SysKonnect's *	web pages: www.syskonnect.com *	Goto "Support" and search Knowledge Base for "manual". * *	This program is free software; you can redistribute it and/or modify *	it under the terms of the GNU General Public License as published by *	the Free Software Foundation; either version 2 of the License, or *	(at your option) any later version. * *	The information in this file is provided "AS IS" without warranty. * ******************************************************************************//****************************************************************************** * * History: * *	$Log: skge.c,v $ *	Revision 1.1.1.1  2005/06/27 17:05:08  linuxpark *	Initial import. *	 *	Revision 1.46  2003/02/25 14:16:36  mlindner *	Fix: Copyright statement * *	Revision 1.45  2003/02/25 13:25:55  mlindner *	Add: Performance improvements *	Add: Support for various vendors *	Fix: Init function * *	Revision 1.44  2003/01/09 09:25:26  mlindner *	Fix: Remove useless init_module/cleanup_module forward declarations * *	Revision 1.43  2002/11/29 08:42:41  mlindner *	Fix: Boot message * *	Revision 1.42  2002/11/28 13:30:23  mlindner *	Add: New frame check * *	Revision 1.41  2002/11/27 13:55:18  mlindner *	Fix: Drop wrong csum packets *	Fix: Initialize proc_entry after hw check * *	Revision 1.40  2002/10/31 07:50:37  tschilli *	Function SkGeInitAssignRamToQueues() from common module inserted. *	Autonegotiation is set to ON for all adapters. *	LinkSpeedUsed is used in link up status report. *	Role parameter will show up for 1000 Mbps links only. *	GetConfiguration() inserted after init level 1 in SkGeChangeMtu(). *	All return values of SkGeInit() and SkGeInitPort() are checked. * *	Revision 1.39  2002/10/02 12:56:05  mlindner *	Add: Support for Yukon *	Add: Support for ZEROCOPY, scatter-gather and hw checksum *	Add: New transmit ring function (use SG and TCP/UDP hardware checksumming) *	Add: New init function *	Add: Speed check and setup *	Add: Merge source for kernel 2.2.x and 2.4.x *	Add: Opcode check for tcp *	Add: Frame length check *	Fix: Transmit complete interrupt *	Fix: Interrupt moderation * *	Revision 1.29.2.13  2002/01/14 12:44:52  mlindner *	Fix: Rlmt modes * *	Revision 1.29.2.12  2001/12/07 12:06:18  mlindner *	Fix: malloc -> slab changes * *	Revision 1.29.2.11  2001/12/06 15:19:20  mlindner *	Add: DMA attributes *	Fix: Module initialisation *	Fix: pci_map_single and pci_unmap_single replaced * *	Revision 1.29.2.10  2001/12/06 09:56:50  mlindner *	Corrected some printk's * *	Revision 1.29.2.9  2001/09/05 12:15:34  mlindner *	Add: LBFO Changes *	Fix: Counter Errors (Jumbo == to long errors) *	Fix: Changed pAC->PciDev declaration *	Fix: too short counters * *	Revision 1.29.2.8  2001/06/25 12:10:44  mlindner *	fix: ReceiveIrq() changed. * *	Revision 1.29.2.7  2001/06/25 08:07:05  mlindner *	fix: RLMT locking in ReceiveIrq() changed. * *	Revision 1.29.2.6  2001/05/21 07:59:29  mlindner *	fix: MTU init problems * *	Revision 1.29.2.5  2001/05/08 11:25:08  mlindner *	fix: removed VLAN error message * *	Revision 1.29.2.4  2001/05/04 13:31:43  gklug *	fix: do not handle eth_copy on bad fragments received. * *	Revision 1.29.2.3  2001/04/23 08:06:43  mlindner *	Fix: error handling * *	Revision 1.29.2.2  2001/03/15 12:04:54  mlindner *	Fixed memory problem * *	Revision 1.29.2.1  2001/03/12 16:41:44  mlindner *	add: procfs function *	add: dual-net function *	add: RLMT networks *	add: extended PNMI features * *	Kernel 2.4.x specific: *	Revision 1.xx  2000/09/12 13:31:56  cgoos *	Fixed missign "dev=NULL in skge_probe. *	Added counting for jumbo frames (corrects error statistic). *	Removed VLAN tag check (enables VLAN support). * *	Kernel 2.2.x specific: *	Revision 1.29  2000/02/21 13:31:56  cgoos *	Fixed "unused" warning for UltraSPARC change. * *	Partially kernel 2.2.x specific: *	Revision 1.28  2000/02/21 10:32:36  cgoos *	Added fixes for UltraSPARC. *	Now printing RlmtMode and PrefPort setting at startup. *	Changed XmitFrame return value. *	Fixed rx checksum calculation for BIG ENDIAN systems. *	Fixed rx jumbo frames counted as ierrors. * * *	Revision 1.27  1999/11/25 09:06:28  cgoos *	Changed base_addr to unsigned long. * *	Revision 1.26  1999/11/22 13:29:16  cgoos *	Changed license header to GPL. *	Changes for inclusion in linux kernel (2.2.13). *	Removed 2.0.x defines. *	Changed SkGeProbe to skge_probe. *	Added checks in SkGeIoctl. * *	Revision 1.25  1999/10/07 14:47:52  cgoos *	Changed 984x to 98xx. * *	Revision 1.24  1999/09/30 07:21:01  cgoos *	Removed SK_RLMT_SLOW_LOOKAHEAD option. *	Giving spanning tree packets also to OS now. * *	Revision 1.23  1999/09/29 07:36:50  cgoos *	Changed assignment for IsBc/IsMc. * *	Revision 1.22  1999/09/28 12:57:09  cgoos *	Added CheckQueue also to Single-Port-ISR. * *	Revision 1.21  1999/09/28 12:42:41  cgoos *	Changed parameter strings for RlmtMode. * *	Revision 1.20  1999/09/28 12:37:57  cgoos *	Added CheckQueue for fast delivery of RLMT frames. * *	Revision 1.19  1999/09/16 07:57:25  cgoos *	Copperfield changes. * *	Revision 1.18  1999/09/03 13:06:30  cgoos *	Fixed RlmtMode=CheckSeg bug: wrong DEV_KFREE_SKB in RLMT_SEND caused *	double allocated skb's. *	FrameStat in ReceiveIrq was accessed via wrong Rxd. *	Queue size for async. standby Tx queue was zero. *	FillRxLimit of 0 could cause problems with ReQueue, changed to 1. *	Removed debug output of checksum statistic. * *	Revision 1.17  1999/08/11 13:55:27  cgoos *	Transmit descriptor polling was not reenabled after SkGePortInit. * *	Revision 1.16  1999/07/27 15:17:29  cgoos *	Added some "\n" in output strings (removed while debuging...). * *	Revision 1.15  1999/07/23 12:09:30  cgoos *	Performance optimization, rx checksumming, large frame support. * *	Revision 1.14  1999/07/14 11:26:27  cgoos *	Removed Link LED settings (now in RLMT). *	Added status output at NET UP. *	Fixed SMP problems with Tx and SWITCH running in parallel. *	Fixed return code problem at RLMT_SEND event. * *	Revision 1.13  1999/04/07 10:11:42  cgoos *	Fixed Single Port problems. *	Fixed Multi-Adapter problems. *	Always display startup string. * *	Revision 1.12  1999/03/29 12:26:37  cgoos *	Reversed locking to fine granularity. *	Fixed skb double alloc problem (caused by incorrect xmit return code). *	Enhanced function descriptions. * *	Revision 1.11  1999/03/15 13:10:51  cgoos *	Changed device identifier in output string to ethX. * *	Revision 1.10  1999/03/15 12:12:34  cgoos *	Changed copyright notice. * *	Revision 1.9  1999/03/15 12:10:17  cgoos *	Changed locking to one driver lock. *	Added check of SK_AC-size (for consistency with library). * *	Revision 1.8  1999/03/08 11:44:02  cgoos *	Fixed missing dev->tbusy in SkGeXmit. *	Changed large frame (jumbo) buffer number. *	Added copying of short frames. * *	Revision 1.7  1999/03/04 13:26:57  cgoos *	Fixed spinlock calls for SMP. * *	Revision 1.6  1999/03/02 09:53:51  cgoos *	Added descriptor revertion for big endian machines. * *	Revision 1.5  1999/03/01 08:50:59  cgoos *	Fixed SkGeChangeMtu. *	Fixed pci config space accesses. * *	Revision 1.4  1999/02/18 15:48:44  cgoos *	Corrected some printk's. * *	Revision 1.3  1999/02/18 12:45:55  cgoos *	Changed SK_MAX_CARD_PARAM to default 16 * *	Revision 1.2  1999/02/18 10:55:32  cgoos *	Removed SkGeDrvTimeStamp function. *	Printing "ethX:" before adapter type at adapter init. * * *	10-Feb-1999 cg	Created, based on Linux' acenic.c, 3c59x.c and *			SysKonnects GEnesis Solaris driver * ******************************************************************************//****************************************************************************** * * Possible compiler options (#define xxx / -Dxxx): * *	debugging can be enable by changing SK_DEBUG_CHKMOD and *	SK_DEBUG_CHKCAT in makefile (described there). * ******************************************************************************//****************************************************************************** * * Description: * *	This is the main module of the Linux GE driver. * *	All source files except skge.c, skdrv1st.h, skdrv2nd.h and sktypes.h *	are part of SysKonnect's COMMON MODULES for the SK-98xx adapters. *	Those are used for drivers on multiple OS', so some thing may seem *	unnecessary complicated on Linux. Please do not try to 'clean up' *	them without VERY good reasons, because this will make it more *	difficult to keep the Linux driver in synchronisation with the *	other versions. * * Include file hierarchy: * *	<linux/module.h> * *	"h/skdrv1st.h" *		<linux/version.h> *		<linux/types.h> *		<linux/kernel.h> *		<linux/string.h> *		<linux/errno.h> *		<linux/ioport.h> *		<linux/slab.h> *		<linux/interrupt.h> *		<linux/pci.h> *		<asm/byteorder.h> *		<asm/bitops.h> *		<asm/io.h> *		<linux/netdevice.h> *		<linux/etherdevice.h> *		<linux/skbuff.h> *	    those three depending on kernel version used: *		<linux/bios32.h> *		<linux/init.h> *		<asm/uaccess.h> *		<net/checksum.h> * *		"h/skerror.h" *		"h/skdebug.h" *		"h/sktypes.h" *		"h/lm80.h" *		"h/xmac_ii.h" * *      "h/skdrv2nd.h" *		"h/skqueue.h" *		"h/skgehwt.h" *		"h/sktimer.h" *		"h/ski2c.h" *		"h/skgepnmi.h" *		"h/skvpd.h" *		"h/skgehw.h" *		"h/skgeinit.h" *		"h/skaddr.h" *		"h/skgesirq.h" *		"h/skcsum.h" *		"h/skrlmt.h" * ******************************************************************************/#include <config.h>#ifdef CONFIG_SK98#include	"h/skversion.h"#if 0#include	<linux/module.h>#include	<linux/init.h>#include 	<linux/proc_fs.h>#endif#include	"h/skdrv1st.h"#include	"h/skdrv2nd.h"/* defines ******************************************************************//* for debuging on x86 only *//* #define BREAKPOINT() asm(" int $3"); *//* use the scatter-gather functionality with sendfile() */#if 0#define SK_ZEROCOPY#endif/* use of a transmit complete interrupt */#define USE_TX_COMPLETE/* use interrupt moderation (for tx complete only) */#define USE_INT_MOD#define INTS_PER_SEC	1000/* * threshold for copying small receive frames * set to 0 to avoid copying, set to 9001 to copy all frames */#define SK_COPY_THRESHOLD	50/* number of adapters that can be configured via command line params */#define SK_MAX_CARD_PARAM	16/* * use those defines for a compile-in version of the driver instead * of command line parameters *//* #define LINK_SPEED_A	{"Auto", }		*//* #define LINK_SPEED_B	{"Auto", }		*//* #define AUTO_NEG_A	{"Sense", }		*//* #define AUTO_NEG_B	{"Sense", }		*//* #define DUP_CAP_A	{"Both", }		*//* #define DUP_CAP_B	{"Both", }		*//* #define FLOW_CTRL_A	{"SymOrRem", }		*//* #define FLOW_CTRL_B	{"SymOrRem", }		*//* #define ROLE_A	{"Auto", }		*//* #define ROLE_B	{"Auto", }		*//* #define PREF_PORT	{"A", }			*//* #define RLMT_MODE	{"CheckLinkState", }	*/#define DEV_KFREE_SKB(skb) dev_kfree_skb(skb)#define DEV_KFREE_SKB_IRQ(skb) dev_kfree_skb_irq(skb)#define DEV_KFREE_SKB_ANY(skb) dev_kfree_skb_any(skb)/* function prototypes ******************************************************/static void	FreeResources(struct SK_NET_DEVICE *dev);static int	SkGeBoardInit(struct SK_NET_DEVICE *dev, SK_AC *pAC);static SK_BOOL	BoardAllocMem(SK_AC *pAC);static void	BoardFreeMem(SK_AC *pAC);static void	BoardInitMem(SK_AC *pAC);static void	SetupRing(SK_AC*, void*, uintptr_t, RXD**, RXD**, RXD**,			int*, SK_BOOL);#if 0static void	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);static void	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);static int	SkGeOpen(struct SK_NET_DEVICE *dev);static int	SkGeClose(struct SK_NET_DEVICE *dev);static int	SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);static int	SkGeSetMacAddr(struct SK_NET_DEVICE *dev, void *p);static void	SkGeSetRxMode(struct SK_NET_DEVICE *dev);static struct	net_device_stats *SkGeStats(struct SK_NET_DEVICE *dev);static int	SkGeIoctl(struct SK_NET_DEVICE *dev, struct ifreq *rq, int cmd);#elsevoid	SkGeIsr(int irq, void *dev_id, struct pt_regs *ptregs);void	SkGeIsrOnePort(int irq, void *dev_id, struct pt_regs *ptregs);int	SkGeOpen(struct SK_NET_DEVICE *dev);int	SkGeClose(struct SK_NET_DEVICE *dev);int	SkGeXmit(struct sk_buff *skb, struct SK_NET_DEVICE *dev);#endifstatic void	GetConfiguration(SK_AC*);static void	ProductStr(SK_AC*);static int	XmitFrame(SK_AC*, TX_PORT*, struct sk_buff*);static void	FreeTxDescriptors(SK_AC*pAC, TX_PORT*);static void	FillRxRing(SK_AC*, RX_PORT*);static SK_BOOL	FillRxDescriptor(SK_AC*, RX_PORT*);#if 0static void	ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL);#elsevoid	ReceiveIrq(SK_AC*, RX_PORT*, SK_BOOL);#endifstatic void ClearAndStartRx(SK_AC*, int);static void	ClearTxIrq(SK_AC*, int, int);static void	ClearRxRing(SK_AC*, RX_PORT*);static void	ClearTxRing(SK_AC*, TX_PORT*);#if 0static void	SetQueueSizes(SK_AC	*pAC);static int	SkGeChangeMtu(struct SK_NET_DEVICE *dev, int new_mtu);#endifstatic void	PortReInitBmu(SK_AC*, int);#if 0static int	SkGeIocMib(DEV_NET*, unsigned int, int);static int	XmitFrameSG(SK_AC*, TX_PORT*, struct sk_buff*);#endif/*Extern *//* external Proc function */extern int proc_read(	char	*buffer,	char	**buffer_location,	off_t	offset,	int		buffer_length,	int		*eof,	void	*data);#ifdef DEBUGstatic void	DumpMsg(struct sk_buff*, char*);static void	DumpData(char*, int);static void	DumpLong(char*, int);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -