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

📄 rtl_3c59x.c

📁 最新rtlinux内核源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/*        The original file was written 1996-1999 by Donald Becker.	This software may be used and distributed according to the terms	of the GNU General Public License, incorporated herein by reference.	This driver is for the 3Com "Vortex" and "Boomerang" series ethercards.	Members of the series include Fast EtherLink 3c590/3c592/3c595/3c597	and the EtherLink XL 3c900 and 3c905 cards.	Problem reports and questions should be directed to	vortex@scyld.com	The author may be reached as becker@scyld.com, or C/O	Scyld Computing Corporation	410 Severn Ave., Suite 210	Annapolis MD 21403	Linux Kernel Additions (better to see the last one first):	 	0.99H+lk0.9 - David S. Miller - softnet, PCI DMA updates 	0.99H+lk1.0 - Jeff Garzik <jgarzik@mandrakesoft.com>		Remove compatibility defines for kernel versions < 2.2.x.		Update for new 2.3.x module interface	LK1.1.2 (March 19, 2000)	* New PCI interface (jgarzik)    LK1.1.3 25 April 2000, Andrew Morton <andrewm@uow.edu.au>    - Merged with 3c575_cb.c    - Don't set RxComplete in boomerang interrupt enable reg    - spinlock in vortex_timer to protect mdio functions    - disable local interrupts around call to vortex_interrupt in      vortex_tx_timeout() (So vortex_interrupt can use spin_lock())    - Select window 3 in vortex_timer()'s write to Wn3_MAC_Ctrl    - In vortex_start_xmit(), move the lock to _after_ we've altered      vp->cur_tx and vp->tx_full.  This defeats the race between      vortex_start_xmit() and vortex_interrupt which was identified      by Bogdan Costescu.    - Merged back support for six new cards from various sources    - Set vortex_have_pci if pci_module_init returns zero (fixes cardbus      insertion oops)    - Tell it that 3c905C has NWAY for 100bT autoneg    - Fix handling of SetStatusEnd in 'Too much work..' code, as      per 2.3.99's 3c575_cb (Dave Hinds).    - Split ISR into two for vortex & boomerang    - Fix MOD_INC/DEC races    - Handle resource allocation failures.    - Fix 3CCFE575CT LED polarity    - Make tx_interrupt_mitigation the default    LK1.1.4 25 April 2000, Andrew Morton <andrewm@uow.edu.au>        - Add extra TxReset to vortex_up() to fix 575_cb hotplug initialisation probs.    - Put vortex_info_tbl into __devinitdata    - In the vortex_error StatsFull HACK, disable stats in vp->intr_enable as well      as in the hardware.    - Increased the loop counter in issue_and_wait from 2,000 to 4,000.    LK1.1.5 28 April 2000, andrewm    - Added powerpc defines (John Daniel <jdaniel@etresoft.com> said these work...)    - Some extra diagnostics    - In vortex_error(), reset the Tx on maxCollisions.  Otherwise most      chips usually get a Tx timeout.    - Added extra_reset module parm    - Replaced some inline timer manip with mod_timer      (Franois romieu <Francois.Romieu@nic.fr>)    - In vortex_up(), don't make Wn3_config initialisation dependent upon has_nway      (this came across from 3c575_cb).    LK1.1.6 06 Jun 2000, andrewm    - Backed out the PPC defines.    - Use del_timer_sync(), mod_timer().    - Fix wrapped ulong comparison in boomerang_rx()    - Add IS_TORNADO, use it to suppress 3c905C checksum error msg      (Donald Becker, I Lee Hetherington <ilh@sls.lcs.mit.edu>)    - Replace union wn3_config with BFINS/BFEXT manipulation for      sparc64 (Pete Zaitcev, Peter Jones)    - In vortex_error, do_tx_reset and vortex_tx_timeout(Vortex):      do a netif_wake_queue() to better recover from errors. (Anders Pedersen,      Donald Becker)    - Print a warning on out-of-memory (rate limited to 1 per 10 secs)    - Added two more Cardbus 575 NICs: 5b57 and 6564 (Paul Wagland)    LK1.1.7 2 Jul 2000 andrewm    - Better handling of shared IRQs    - Reset the transmitter on a Tx reclaim error    - Fixed crash under OOM during vortex_open() (Mark Hemment)    - Fix Rx cessation problem during OOM (help from Mark Hemment)    - The spinlocks around the mdio access were blocking interrupts for 300uS.      Fix all this to use spin_lock_bh() within mdio_read/write    - Only write to TxFreeThreshold if it's a boomerang - other NICs don't      have one.    - Added 802.3x MAC-layer flow control support   LK1.1.8 13 Aug 2000 andrewm    - Ignore request_region() return value - already reserved if Cardbus.    - Merged some additional Cardbus flags from Don's 0.99Qk    - Some fixes for 3c556 (Fred Maciel)    - Fix for EISA initialisation (Jan Rekorajski)    - Renamed MII_XCVR_PWR and EEPROM_230 to align with 3c575_cb and D. Becker's drivers    - Fixed MII_XCVR_PWR for 3CCFE575CT    - Added INVERT_LED_PWR, used it.    - Backed out the extra_reset stuff   LK1.1.9 12 Sep 2000 andrewm    - Backed out the tx_reset_resume flags.  It was a no-op.    - In vortex_error, don't reset the Tx on txReclaim errors    - In vortex_error, don't reset the Tx on maxCollisions errors.      Hence backed out all the DownListPtr logic here.    - In vortex_error, give Tornado cards a partial TxReset on      maxCollisions (David Hinds).  Defined MAX_COLLISION_RESET for this.    - Redid some driver flags and device names based on pcmcia_cs-3.1.20.    - Fixed a bug where, if vp->tx_full is set when the interface      is downed, it remains set when the interface is upped.  Bad      things happen.   LK1.1.10 17 Sep 2000 andrewm    - Added EEPROM_8BIT for 3c555 (Fred Maciel)    - Added experimental support for the 3c556B Laptop Hurricane (Louis Gerbarg)    - Add HAS_NWAY to "3c900 Cyclone 10Mbps TPO"   LK1.1.11 13 Nov 2000 andrewm    - Dump MOD_INC/DEC_USE_COUNT, use SET_MODULE_OWNER   LK1.1.12 1 Jan 2001 andrewm (2.4.0-pre1)    - Call pci_enable_device before we request our IRQ (Tobias Ringstrom)    - Add 3c590 PCI latency timer hack to vortex_probe1 (from 0.99Ra)    - Added extended issue_and_wait for the 3c905CX.    - Look for an MII on PHY index 24 first (3c905CX oddity).    - Add HAS_NWAY to 3cSOHO100-TX (Brett Frankenberger)    - Don't free skbs we don't own on oom path in vortex_open().   LK1.1.13 27 Jan 2001    - Added explicit `medialock' flag so we can truly      lock the media type down with `options'.    - "check ioremap return and some tidbits" (Arnaldo Carvalho de Melo <acme@conectiva.com.br>)    - Added and used EEPROM_NORESET for 3c556B PM resumes.    - Fixed leakage of vp->rx_ring.    - Break out separate HAS_HWCKSM device capability flag.    - Kill vp->tx_full (ANK)    - Merge zerocopy fragment handling (ANK?)   LK1.1.14 15 Feb 2001    - Enable WOL.  Can be turned on with `enable_wol' module option.    - EISA and PCI initialisation fixes (jgarzik, Manfred Spraul)    - If a device's internalconfig register reports it has NWAY,      use it, even if autoselect is enabled.   LK1.1.15 6 June 2001 akpm    - Prevent double counting of received bytes (Lars Christensen)    - Add ethtool support (jgarzik)    - Add module parm descriptions (Andrzej M. Krzysztofowicz)    - Implemented alloc_etherdev() API    - Special-case the 'Tx error 82' message.   LK1.1.16 18 July 2001 akpm    - Make NETIF_F_SG dependent upon nr_free_highpages(), not on CONFIG_HIGHMEM    - Lessen verbosity of bootup messages    - Fix WOL - use new PM API functions.    - Use netif_running() instead of vp->open in suspend/resume.    - Don't reset the interface logic on open/close/rmmod.  It upsets      autonegotiation, and hence DHCP (from 0.99T).    - Back out EEPROM_NORESET flag because of the above (we do it for all      NICs).    - Correct 3c982 identification string    - Rename wait_for_completion() to issue_and_wait() to avoid completion.h      clash.=====================================================================================                          PORTING TO RT-LINUX                       =====================================================================================   LK1.1.17 14 March 2003             Sergio Perez Alca駃z  <serpeal@upvnet.upv.es>  Departamento            de  Inform醫ica  de  Sistemas  y Computadores  Universidad            Polit閏nica de Valencia	    The RTL-lwIP project  has  been supported by  the  Spanish	    Government  Research   Office (CICYT)     under      grant	    TIC2002-04123-C03-03   SISTEMAS DE TIEMPO REAL EMPOTRADOS,	    FIABLES Y DISTRIBUIDOS BASADOS EN COMPONENTES          Valencia (Spain)                      	    Porting the driver to RT-Linux, that is:	    -Giving to  the  driver the RT-Linux  driver  architecture	    (open, close, read, write, ioctl).	    -Using my own buffer management.	    -No NIC stats allowed.	    -Some calls of pci stuff have been implemented.	    -Changing  the    interrupts management and    the handler	    phylosophy.	    -Changing the "receive" and "send" phylosophy.	    -Introducing signaling.	    -Registering threads  that  want  to  be notified  of  the	    arrival of a packet.	    -IP filtering.	    -Ethernet filtering.	     - ....	     The porting is just for  the 3Com905C-X card. So no other	     cards are supported (as far as I know...).	     	     Just take a look at it.   LK1.1.18     12     January    2004            Sergio Perez Alca駃z <serpeal@upvnet.upv.es> Departamento            de Inform醫ica de Sistemas y Computadores Universidad            Polit閏nica de Valencia	    The  REDD    project has  been   supported by  the Spanish	    Government    Research  Office    (CICYT)  under     grant	    TIC2002-04123-C03-03   SISTEMAS DE TIEMPO REAL EMPOTRADOS,	    FIABLES  Y DISTRIBUIDOS  BASADOS  EN COMPONENTES  Valencia	    (Spain)	    -Removed threads  registration (to  better comply with the	    POSIX standard).            -Added  a semaphore   to block   threads  when they    are            performing a read and there are not packets available.	    -Modified to use the  new release of DIDMA (Dynamic Memory	    Allocator) now called TLSF.   LK1.1.19     1     December    2004            Sergio Perez Alca駃z <serpeal@upvnet.upv.es> Departamento            de Inform醫ica de Sistemas y Computadores Universidad            Polit閏nica de Valencia	    - Driver  modified  to provide the   O_NOBLOCK access mode	    (non-blocking access).  	    -  Driver modified to  support  the zero copy technique or	    not, depending on the options set in the reddopts.h.	    -   Driver  modified to  support   the   FAKE architecture	    described in the reddoopts.h=====================================================================================    - see Documentation/networking/vortex.txt*/MODULE_LICENSE("GPL");static int rt_3c905c_interrupted = 0, rt_3c905c_writting = 0;/***************************************************************************************//* This function is called in the cleanup_module function, and it must do other stuff  *//* not done in the cleanup_module function in order to "close" the driver. In some     *//* implementations this function could be empty.                                       *//***************************************************************************************/static void other_stuff_closing(void){  rtl_3COM905C_issue_and_wait(UpStall);  rtl_3COM905C_issue_and_wait(DownStall);}/***************************************************************************************//* This is the interrupt handler. It is executed when the ethernet card raises an      *//* interrupt and interrupts are enabled. In the initialisation phase we've forced the  *//* card to only generate the UpComplete interrupt, that is, when a full incoming       *//* packet has been processed.                                                          *//***************************************************************************************/unsigned int boomerang_interrupt(unsigned int irq , struct pt_regs *regs){  long ioaddr = private_data.ioaddr;  int status = inw(ioaddr + EL3_STATUS);  int work_done = max_interrupt_work;  struct pci_dev *dev = eth_dev;  inside_the_interrupt_handler = 1;  rt_3c905c_interrupted++;  if(rt_3c905c_writting & rt_3c905c_interrupted)    rtl_printf("I've been interrupted %d times\n",rt_3c905c_interrupted);  if (status & UpComplete) {    private_data.rx_packets++;        rtl_3COM905C_issue_and_wait(UpStall);    while(private_data.rx_ring[private_data.cur_rx % RX_RING_SIZE].status & 0x00008000){      boomerang_rx(dev);      outw(AckIntr | UpComplete, ioaddr + EL3_CMD);      if (--work_done < 0)	break;    }    outw(UpUnstall, ioaddr + EL3_CMD);  }    if (status & DownComplete){    rtl_printf("Se acaba de enviar el paquete\n");    outw(AckIntr | DownComplete, ioaddr + EL3_CMD);  }    /* Check for all uncommon interrupts at once. */  if (status & (HostError | RxEarly | StatsFull | IntReq)){    rtl_printf("VORTEX_ERROR\n");    vortex_error(dev, status);  }    /* Acknowledge the IRQ. */  outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);  if (private_data.cb_fn_base){	    writel(0x8000, private_data.cb_fn_base + 4);  }    /* We must be sure that we're out of the interrupt handler before cleanup_modules */  /* is executed. If cleanup_modules is being executed, we don't have to enable the */  /* irq. If enabled, then the system could crash.                                  */  if(!trying_to_close)    rtl_hard_enable_irq(private_data.pdev->irq);      rt_3c905c_interrupted--;  return (inside_the_interrupt_handler = 0);}/***************************************************************************************//* This is the function called when an incoming packet has succesfuly arrived, so we   *//* have to copy it into internal buffers.                                              *//***************************************************************************************/static int boomerang_rx(struct pci_dev *dev){  int entry = private_data.cur_rx % RX_RING_SIZE;  int rx_status;  int rx_work_limit = private_data.dirty_rx + RX_RING_SIZE - private_data.cur_rx;  unsigned char *buffer;  int temp = private_data.rx_ring[entry].status & 0x1fff;  buffer =private_data.rx_skbuff[entry];  filter_incoming_packet(buffer, temp);  while ((rx_status = le32_to_cpu(private_data.rx_ring[entry].status)) & RxDComplete){    if (--rx_work_limit < 0)      break;    if (!(rx_status & RxDError))  /* Error, update stats. */      private_data.stats.rx_packets++;  }  entry = (++private_data.cur_rx) % RX_RING_SIZE;  /* Refill the Rx ring buffers. */  for (; private_data.cur_rx - private_data.dirty_rx > 0; private_data.dirty_rx++) {    entry = private_data.dirty_rx % RX_RING_SIZE;    private_data.rx_ring[entry].status = 0;	/* Clear complete bit. */  }  return 0;}/***************************************************************************************//* This function does internal initialisations of the card. It writes into internal    *//* registers and checks the card capabilities.                                         *//***************************************************************************************/static int start_up_device(struct pci_dev *dev){  struct vortex_chip_info * const vci = &vortex_info;  unsigned int eeprom[0x40], checksum = 0;		/* EEPROM contents */  char *print_name;  int retval;  long ioaddr;  int i,step;  print_name = dev ? dev->slot_name : "3c59x";  ioaddr = rt_pci_resource_start(dev, 0);  private_data.drv_flags = vci->drv_flags;  private_data.has_nway = (vci->drv_flags & HAS_NWAY) ? 1 : 0;  private_data.io_size = vci->io_size;  private_data.card_idx = 0;  private_data.ioaddr = ioaddr;  private_data.media_override = 7;  private_data.mtu = mtu;  print_name = dev ? dev->slot_name : "3c59x";  /* PCI-only startup logic */  if (dev) {    if (request_region(ioaddr, vci->io_size, print_name) != NULL){      private_data.must_free_region = 1;     }    /* enable bus-mastering if necessary */		    if (vci->flags & PCI_USES_MASTER)      pci_set_master (dev);    private_data.pdev = dev;    /* Makes sure rings are at least 16 byte aligned. */    private_data.rx_ring = pci_alloc_consistent(dev, sizeof(struct boom_rx_desc) * RX_RING_SIZE, &private_data.rx_ring_dma);    private_data.tx_ring = pci_alloc_consistent(dev, sizeof(struct boom_tx_desc) * TX_RING_SIZE, &private_data.tx_ring_dma);    retval = -ENOMEM;    if ((private_data.rx_ring == 0) || (private_data.tx_ring == 0))      goto free_region;            EL3WINDOW(0);    {      int base;

⌨️ 快捷键说明

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