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

📄 nmclan_cs.c

📁 pcmcia驱动源代码,直接可以在linux2.6下使用 !
💻 C
📖 第 1 页 / 共 4 页
字号:
/* ----------------------------------------------------------------------------Linux PCMCIA ethernet adapter driver for the New Media Ethernet LAN.  nmclan_cs.c,v 0.16 1995/07/01 06:42:17 rpao Exp rpao  The Ethernet LAN uses the Advanced Micro Devices (AMD) Am79C940 Media  Access Controller for Ethernet (MACE).  It is essentially the Am2150  PCMCIA Ethernet card contained in the Am2150 Demo Kit.Written by Roger C. Pao <rpao@paonet.org>  Copyright 1995 Roger C. Pao  Linux 2.5 cleanups Copyright Red Hat 2003  This software may be used and distributed according to the terms of  the GNU General Public License.Ported to Linux 1.3.* network driver environment by  Matti Aarnio <mea@utu.fi>References  Am2150 Technical Reference Manual, Revision 1.0, August 17, 1993  Am79C940 (MACE) Data Sheet, 1994  Am79C90 (C-LANCE) Data Sheet, 1994  Linux PCMCIA Programmer's Guide v1.17  /usr/src/linux/net/inet/dev.c, Linux kernel 1.2.8  Eric Mears, New Media Corporation  Tom Pollard, New Media Corporation  Dean Siasoyco, New Media Corporation  Ken Lesniak, Silicon Graphics, Inc. <lesniak@boston.sgi.com>  Donald Becker <becker@scyld.com>  David Hinds <dahinds@users.sourceforge.net>  The Linux client driver is based on the 3c589_cs.c client driver by  David Hinds.  The Linux network driver outline is based on the 3c589_cs.c driver,  the 8390.c driver, and the example skeleton.c kernel code, which are  by Donald Becker.  The Am2150 network driver hardware interface code is based on the  OS/9000 driver for the New Media Ethernet LAN by Eric Mears.  Special thanks for testing and help in debugging this driver goes  to Ken Lesniak.-------------------------------------------------------------------------------Driver Notes and Issues-------------------------------------------------------------------------------1. Developed on a Dell 320SLi   PCMCIA Card Services 2.6.2   Linux dell 1.2.10 #1 Thu Jun 29 20:23:41 PDT 1995 i3862. rc.pcmcia may require loading pcmcia_core with io_speed=300:   'insmod pcmcia_core.o io_speed=300'.   This will avoid problems with fast systems which causes rx_framecnt   to return random values.3. If hot extraction does not work for you, use 'ifconfig eth0 down'   before extraction.4. There is a bad slow-down problem in this driver.5. Future: Multicast processing.  In the meantime, do _not_ compile your   kernel with multicast ip enabled.-------------------------------------------------------------------------------History-------------------------------------------------------------------------------Log: nmclan_cs.c,v * 2.5.75-ac1 2003/07/11 Alan Cox <alan@redhat.com> * Fixed hang on card eject as we probe it * Cleaned up to use new style locking. * * Revision 0.16  1995/07/01  06:42:17  rpao * Bug fix: nmclan_reset() called CardServices incorrectly. * * Revision 0.15  1995/05/24  08:09:47  rpao * Re-implement MULTI_TX dev->tbusy handling. * * Revision 0.14  1995/05/23  03:19:30  rpao * Added, in nmclan_config(), "tuple.Attributes = 0;". * Modified MACE ID check to ignore chip revision level. * Avoid tx_free_frames race condition between _start_xmit and _interrupt. * * Revision 0.13  1995/05/18  05:56:34  rpao * Statistics changes. * Bug fix: nmclan_reset did not enable TX and RX: call restore_multicast_list. * Bug fix: mace_interrupt checks ~MACE_IMR_DEFAULT.  Fixes driver lockup. * * Revision 0.12  1995/05/14  00:12:23  rpao * Statistics overhaul. *95/05/13 rpao	V0.10a		Bug fix: MACE statistics counters used wrong I/O ports.		Bug fix: mace_interrupt() needed to allow statistics to be		processed without RX or TX interrupts pending.95/05/11 rpao	V0.10		Multiple transmit request processing.		Modified statistics to use MACE counters where possible.95/05/10 rpao	V0.09 Bug fix: Must use IO_DATA_PATH_WIDTH_AUTO.		*Released95/05/10 rpao	V0.08		Bug fix: Make all non-exported functions private by using		static keyword.		Bug fix: Test IntrCnt _before_ reading MACE_IR.95/05/10 rpao	V0.07 Statistics.95/05/09 rpao	V0.06 Fix rx_framecnt problem by addition of PCIC wait states.---------------------------------------------------------------------------- */#define DRV_NAME	"nmclan_cs"#define DRV_VERSION	"0.16"/* ----------------------------------------------------------------------------Conditional Compilation Options---------------------------------------------------------------------------- */#define MULTI_TX			0#define RESET_ON_TIMEOUT		1#define TX_INTERRUPTABLE		1#define RESET_XILINX			0/* ----------------------------------------------------------------------------Include Files---------------------------------------------------------------------------- */#include <linux/module.h>#include <linux/kernel.h>#include <linux/init.h>#include <linux/ptrace.h>#include <linux/slab.h>#include <linux/string.h>#include <linux/timer.h>#include <linux/interrupt.h>#include <linux/in.h>#include <linux/delay.h>#include <linux/ethtool.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <linux/if_arp.h>#include <linux/ioport.h>#include <linux/bitops.h>#include <pcmcia/cs_types.h>#include <pcmcia/cs.h>#include <pcmcia/cisreg.h>#include <pcmcia/cistpl.h>#include <pcmcia/ds.h>#include <asm/uaccess.h>#include <asm/io.h>#include <asm/system.h>/* ----------------------------------------------------------------------------Defines---------------------------------------------------------------------------- */#define ETHER_ADDR_LEN			ETH_ALEN					/* 6 bytes in an Ethernet Address */#define MACE_LADRF_LEN			8					/* 8 bytes in Logical Address Filter *//* Loop Control Defines */#define MACE_MAX_IR_ITERATIONS		10#define MACE_MAX_RX_ITERATIONS		12	/*	TBD: Dean brought this up, and I assumed the hardware would	handle it:	If MACE_MAX_RX_ITERATIONS is > 1, rx_framecnt may still be	non-zero when the isr exits.  We may not get another interrupt	to process the remaining packets for some time.	*//*The Am2150 has a Xilinx XC3042 field programmable gate array (FPGA)which manages the interface between the MACE and the PCMCIA bus.  Italso includes buffer management for the 32K x 8 SRAM to control up tofour transmit and 12 receive frames at a time.*/#define AM2150_MAX_TX_FRAMES		4#define AM2150_MAX_RX_FRAMES		12/* Am2150 Ethernet Card I/O Mapping */#define AM2150_RCV			0x00#define AM2150_XMT			0x04#define AM2150_XMT_SKIP			0x09#define AM2150_RCV_NEXT			0x0A#define AM2150_RCV_FRAME_COUNT		0x0B#define AM2150_MACE_BANK		0x0C#define AM2150_MACE_BASE		0x10/* MACE Registers */#define MACE_RCVFIFO			0#define MACE_XMTFIFO			1#define MACE_XMTFC			2#define MACE_XMTFS			3#define MACE_XMTRC			4#define MACE_RCVFC			5#define MACE_RCVFS			6#define MACE_FIFOFC			7#define MACE_IR				8#define MACE_IMR			9#define MACE_PR				10#define MACE_BIUCC			11#define MACE_FIFOCC			12#define MACE_MACCC			13#define MACE_PLSCC			14#define MACE_PHYCC			15#define MACE_CHIPIDL			16#define MACE_CHIPIDH			17#define MACE_IAC			18/* Reserved */#define MACE_LADRF			20#define MACE_PADR			21/* Reserved *//* Reserved */#define MACE_MPC			24/* Reserved */#define MACE_RNTPC			26#define MACE_RCVCC			27/* Reserved */#define MACE_UTR			29#define MACE_RTR1			30#define MACE_RTR2			31/* MACE Bit Masks */#define MACE_XMTRC_EXDEF		0x80#define MACE_XMTRC_XMTRC		0x0F#define MACE_XMTFS_XMTSV		0x80#define MACE_XMTFS_UFLO			0x40#define MACE_XMTFS_LCOL			0x20#define MACE_XMTFS_MORE			0x10#define MACE_XMTFS_ONE			0x08#define MACE_XMTFS_DEFER		0x04#define MACE_XMTFS_LCAR			0x02#define MACE_XMTFS_RTRY			0x01#define MACE_RCVFS_RCVSTS		0xF000#define MACE_RCVFS_OFLO			0x8000#define MACE_RCVFS_CLSN			0x4000#define MACE_RCVFS_FRAM			0x2000#define MACE_RCVFS_FCS			0x1000#define MACE_FIFOFC_RCVFC		0xF0#define MACE_FIFOFC_XMTFC		0x0F#define MACE_IR_JAB			0x80#define MACE_IR_BABL			0x40#define MACE_IR_CERR			0x20#define MACE_IR_RCVCCO			0x10#define MACE_IR_RNTPCO			0x08#define MACE_IR_MPCO			0x04#define MACE_IR_RCVINT			0x02#define MACE_IR_XMTINT			0x01#define MACE_MACCC_PROM			0x80#define MACE_MACCC_DXMT2PD		0x40#define MACE_MACCC_EMBA			0x20#define MACE_MACCC_RESERVED		0x10#define MACE_MACCC_DRCVPA		0x08#define MACE_MACCC_DRCVBC		0x04#define MACE_MACCC_ENXMT		0x02#define MACE_MACCC_ENRCV		0x01#define MACE_PHYCC_LNKFL		0x80#define MACE_PHYCC_DLNKTST		0x40#define MACE_PHYCC_REVPOL		0x20#define MACE_PHYCC_DAPC			0x10#define MACE_PHYCC_LRT			0x08#define MACE_PHYCC_ASEL			0x04#define MACE_PHYCC_RWAKE		0x02#define MACE_PHYCC_AWAKE		0x01#define MACE_IAC_ADDRCHG		0x80#define MACE_IAC_PHYADDR		0x04#define MACE_IAC_LOGADDR		0x02#define MACE_UTR_RTRE			0x80#define MACE_UTR_RTRD			0x40#define MACE_UTR_RPA			0x20#define MACE_UTR_FCOLL			0x10#define MACE_UTR_RCVFCSE		0x08#define MACE_UTR_LOOP_INCL_MENDEC	0x06#define MACE_UTR_LOOP_NO_MENDEC		0x04#define MACE_UTR_LOOP_EXTERNAL		0x02#define MACE_UTR_LOOP_NONE		0x00#define MACE_UTR_RESERVED		0x01/* Switch MACE register bank (only 0 and 1 are valid) */#define MACEBANK(win_num) outb((win_num), ioaddr + AM2150_MACE_BANK)#define MACE_IMR_DEFAULT \  (0xFF - \    ( \      MACE_IR_CERR | \      MACE_IR_RCVCCO | \      MACE_IR_RNTPCO | \      MACE_IR_MPCO | \      MACE_IR_RCVINT | \      MACE_IR_XMTINT \    ) \  )#undef MACE_IMR_DEFAULT#define MACE_IMR_DEFAULT 0x00 /* New statistics handling: grab everything */#define TX_TIMEOUT		((400*HZ)/1000)/* ----------------------------------------------------------------------------Type Definitions---------------------------------------------------------------------------- */typedef struct _mace_statistics {    /* MACE_XMTFS */    int xmtsv;    int uflo;    int lcol;    int more;    int one;    int defer;    int lcar;    int rtry;    /* MACE_XMTRC */    int exdef;    int xmtrc;    /* RFS1--Receive Status (RCVSTS) */    int oflo;    int clsn;    int fram;    int fcs;    /* RFS2--Runt Packet Count (RNTPC) */    int rfs_rntpc;    /* RFS3--Receive Collision Count (RCVCC) */    int rfs_rcvcc;    /* MACE_IR */    int jab;    int babl;    int cerr;    int rcvcco;    int rntpco;    int mpco;    /* MACE_MPC */    int mpc;    /* MACE_RNTPC */    int rntpc;    /* MACE_RCVCC */    int rcvcc;} mace_statistics;typedef struct _mace_private {	struct pcmcia_device	*p_dev;    dev_node_t node;    struct net_device_stats linux_stats; /* Linux statistics counters */    mace_statistics mace_stats; /* MACE chip statistics counters */    /* restore_multicast_list() state variables */    int multicast_ladrf[MACE_LADRF_LEN]; /* Logical address filter */    int multicast_num_addrs;    char tx_free_frames; /* Number of free transmit frame buffers */    char tx_irq_disabled; /* MACE TX interrupt disabled */        spinlock_t bank_lock; /* Must be held if you step off bank 0 */} mace_private;/* ----------------------------------------------------------------------------Private Global Variables---------------------------------------------------------------------------- */#ifdef PCMCIA_DEBUGstatic char rcsid[] ="nmclan_cs.c,v 0.16 1995/07/01 06:42:17 rpao Exp rpao";static char *version =DRV_NAME " " DRV_VERSION " (Roger C. Pao)";#endifstatic const char *if_names[]={    "Auto", "10baseT", "BNC",};/* ----------------------------------------------------------------------------Parameters	These are the parameters that can be set during loading with	'insmod'.---------------------------------------------------------------------------- */MODULE_DESCRIPTION("New Media PCMCIA ethernet driver");MODULE_LICENSE("GPL");#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0)

⌨️ 快捷键说明

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