/*------------------------------------------------------------------------
. smc9194.c
. This is a driver for SMC's 9000 series of Ethernet cards.
.
. Copyright (C) 1996 by Erik Stahlman
. This software may be used and distributed according to the terms
. of the GNU General Public License, incorporated herein by reference.
.
. "Features" of the SMC chip:
. 4608 byte packet memory. ( for the 91C92. Others have more )
. EEPROM for configuration
. AUI/TP selection ( mine has 10Base2/10BaseT select )
.
. Arguments:
. io = for the base address
. irq = for the IRQ
. ifport = 0 for autodetect, 1 for TP, 2 for AUI ( or 10base2 )
.
. author:
. Erik Stahlman ( [email protected] )
. contributors:
. Arnaldo Carvalho de Melo <[email protected]>
.
. Hardware multicast code from Peter Cammaert ( [email protected] )
.
. Sources:
. o SMC databook
. o skeleton.c by Donald Becker ( [email protected] )
. o ( a LOT of advice from Becker as well )
.
. History:
. 12/07/95 Erik Stahlman written, got receive/xmit handled
. 01/03/96 Erik Stahlman worked out some bugs, actually usable!!! :-)
. 01/06/96 Erik Stahlman cleaned up some, better testing, etc
. 01/29/96 Erik Stahlman fixed autoirq, added multicast
. 02/01/96 Erik Stahlman 1. disabled all interrupts in smc_reset
. 2. got rid of post-decrementing bug -- UGH.
. 02/13/96 Erik Stahlman Tried to fix autoirq failure. Added more
. descriptive error messages.
. 02/15/96 Erik Stahlman Fixed typo that caused detection failure
. 02/23/96 Erik Stahlman Modified it to fit into kernel tree
. Added support to change hardware address
. Cleared stats on opens
. 02/26/96 Erik Stahlman Trial support for Kernel 1.2.13
. Kludge for automatic IRQ detection
. 03/04/96 Erik Stahlman Fixed kernel 1.3.70 +
. Fixed bug reported by Gardner Buchanan in
. smc_enable, with outw instead of outb
. 03/06/96 Erik Stahlman Added hardware multicast from Peter Cammaert
. 04/14/00 Heiko Pruessing (SMA Regelsysteme) Fixed bug in chip memory
. allocation
. 08/20/00 Arnaldo Melo fix kfree(skb) in smc_hardware_send_packet
. 12/15/00 Christian Jullien fix "Warning: kfree_skb on hard IRQ"
. 11/08/01 Matt Domsch Use common crc32 function
----------------------------------------------------------------------------*/
static const char version[] =
"smc9194.c:v0.14 12/15/00 by Erik Stahlman ([email protected])";
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/fcntl.h>
#include <linux/interrupt.h>
#include <linux/ioport.h>
#include <linux/in.h>
#include <linux/string.h>
#include <linux/init.h>
#include <linux/crc32.h>
#include <linux/errno.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/bitops.h>
#include <asm/io.h>
#include "smc9194.h"
#define DRV_NAME "smc9194"
/*------------------------------------------------------------------------
.
. Configuration options, for the experienced user to change.
.
-------------------------------------------------------------------------*/
/*
. Do you want to use 32 bit xfers? This should work on all chips, as
. the chipset is designed to accommodate them.
*/
#ifdef __sh__
#undef USE_32_BIT
#else
#define USE_32_BIT 1
#endif
/*
.the SMC9194 can be at any of the following port addresses. To change,
.for a slightly different card, you can add it to the array. Keep in
.mind that the array must end in zero.
*/
struct devlist {
unsigned int port;
unsigned int irq;
};
static struct devlist smc_devlist[] __initdata = {
{.port = 0x200, .irq = 0},
{.port = 0x220, .irq = 0},
{.port = 0x240, .irq = 0},
{.port = 0x260, .irq = 0},
{.port = 0x280, .irq = 0},
{.port = 0x2A0, .irq = 0},
{.port = 0x2C0, .irq = 0},
{.port = 0x2E0, .irq = 0},
{.port = 0x300, .irq = 0},
{.port = 0x320, .irq = 0},
{.port = 0x340, .irq = 0},
{.port = 0x360, .irq = 0},
{.port = 0x380, .irq = 0},
{.port = 0x3A0, .irq = 0},
{.port = 0x3C0, .irq = 0},
{.port = 0x3E0, .irq = 0},
{.port = 0, .irq = 0},
};
/*
. Wait time for memory to be free. This probably shouldn't be
. tuned that much, as waiting for this means nothing else happens
. in the system
*/
#define MEMORY_WAIT_TIME 16
/*
. DEBUGGING LEVELS
.
. 0 for normal operation
. 1 for slightly more details
. >2 for various levels of increasingly useless information
. 2 for interrupt tracking, status flags
. 3 for packet dumps, etc.
*/
#define SMC_DEBUG 0
#if (SMC_DEBUG > 2 )
#define PRINTK3(x) printk x
#else
#define PRINTK3(x)
#endif
#if SMC_DEBUG > 1
#define PRINTK2(x) printk x
#else
#define PRINTK2(x)
#endif
#ifdef SMC_DEBUG
#define PRINTK(x) printk x
#else
#define PRINTK(x)
#endif
/*------------------------------------------------------------------------
.
. The internal workings of the driver. If you are changing anything
. here with the SMC stuff, you should have the datasheet and known
. what you are doing.
.
-------------------------------------------------------------------------*/
#define CARDNAME "SMC9194"
/* store this information for the driver.. */
struct smc_local {
/*
If I have to wait until memory is available to send
a packet, I will store the skbuff here, until I get the
desired memory. Then, I'll send it out and free it.
*/
struct sk_buff * saved_skb;
/*
. This keeps track of how many packets that I have
. sent out. When an TX_EMPTY interrupt comes, I know
. that all of these have been sent.
*/
int packets_waiting;
};
/*-----------------------------------------------------------------
.
. The driver can be entered at any of the following entry points.
.
.------------------------------------------------------------------ */
/*
. This is called by register_netdev(). It is responsible for
. checking the portlist for the SMC9000 series chipset. If it finds
. one, then it will initialize the device, find the hardware information,
. and sets up the appropriate device parameters.
. NOTE: Interrupts are *OFF* when this procedure is called.
.
. NB:This shouldn't be static since it is referred to externally.
*/
struct net_device *smc_init(int unit);
/*
. The kernel calls this function when someone wants to use the device,
. typically 'ifconfig ethX up'.
*/
static int smc_open(struct net_device *dev);
/*
. Our watchdog timed out. Called by the networking layer
*/
static void smc_timeout(struct net_device *dev);
/*
. This is called by the kernel in response to 'ifconfig ethX down'. It
. is responsible for cleaning up everything that the open routine
. does, and maybe putting the card into a powerdown state.
*/
static int smc_close(struct net_device *dev);
/*
. Finally, a call to set promiscuous mode ( for TCPDUMP and related
. programs ) and multicast modes.
*/
static void smc_set_multicast_list(struct net_device *dev);
/*---------------------------------------------------------------
.
. Interrupt level calls..
.
----------------------------------------------------------------*/
/*
. Handles the actual interrupt
*/
static irqreturn_t smc_interrupt(int irq, void *);
/*
. This is a separate procedure to handle the receipt of a packet, to
. leave the interrupt code looking slightly cleaner
*/
static inline void smc_rcv( struct net_device *dev );
/*
. This handles a TX interrupt, which is only called when an error
. relating to a packet is sent.
*/
static inline void smc_tx( struct net_device * dev );
/*
------------------------------------------------------------
.
. Internal routines
.
------------------------------------------------------------
*/
/*
. Test if a given location contains a chip, trying to cause as
. little damage as possible if it's not a SMC chip.
*/
static int smc_probe(struct net_device *dev, int ioaddr);
/*
. A rather simple routine to print out a packet for debugging purposes.
*
smc9194.rar_The Information
版权申诉
92 浏览量
2022-09-20
22:07:10
上传
评论
收藏 16KB RAR 举报
我虽横行却不霸道
- 粉丝: 75
- 资源: 1万+
最新资源
- 基于matlab 概率神经网络的分类预测-基于PNN的变压器故障诊断源代码+详细教程
- IMG_2779.PNG
- 基于matlab Elman神经网络的数据预测-电力负荷预测模型研究源代码+详细教程
- 架构师软考知识点整理2
- 基于matlab SOM神经网络的数据分类-柴油机故障诊断源代码+详细教程
- 2023.cpp
- 基于matlab 自组织竞争网络在模式分类中的应用-患者癌症发病预测源代码+详细教程
- 在线考试系统 JAVA+Spring+SpringMVC+MyBatis
- 毕业设计基于Python卷积神经网络CNN的图像分类系统源码+模型+说明文档+全部数据资料.zip
- matlab 基于SVM的手写字体识别源代码+详细教程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈