Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

rtl_3c905cx_drv.h

Go to the documentation of this file.
00001 /*
00002         The original file was written 1996-1999 by Donald Becker.
00003 
00004         This software may be used and distributed according to the terms
00005         of the GNU General Public License, incorporated herein by reference.
00006 
00007         This driver is for the 3Com "Vortex" and "Boomerang" series ethercards.
00008         Members of the series include Fast EtherLink 3c590/3c592/3c595/3c597
00009         and the EtherLink XL 3c900 and 3c905 cards.
00010 
00011         Problem reports and questions should be directed to
00012         vortex@scyld.com
00013 
00014         The author may be reached as becker@scyld.com, or C/O
00015         Scyld Computing Corporation
00016         410 Severn Ave., Suite 210
00017         Annapolis MD 21403
00018 
00019         Linux Kernel Additions (better to see the last one first):
00020         
00021         0.99H+lk0.9 - David S. Miller - softnet, PCI DMA updates
00022         0.99H+lk1.0 - Jeff Garzik <jgarzik@mandrakesoft.com>
00023                 Remove compatibility defines for kernel versions < 2.2.x.
00024                 Update for new 2.3.x module interface
00025         LK1.1.2 (March 19, 2000)
00026         * New PCI interface (jgarzik)
00027 
00028     LK1.1.3 25 April 2000, Andrew Morton <andrewm@uow.edu.au>
00029     - Merged with 3c575_cb.c
00030     - Don't set RxComplete in boomerang interrupt enable reg
00031     - spinlock in vortex_timer to protect mdio functions
00032     - disable local interrupts around call to vortex_interrupt in
00033       vortex_tx_timeout() (So vortex_interrupt can use spin_lock())
00034     - Select window 3 in vortex_timer()'s write to Wn3_MAC_Ctrl
00035     - In vortex_start_xmit(), move the lock to _after_ we've altered
00036       vp->cur_tx and vp->tx_full.  This defeats the race between
00037       vortex_start_xmit() and vortex_interrupt which was identified
00038       by Bogdan Costescu.
00039     - Merged back support for six new cards from various sources
00040     - Set vortex_have_pci if pci_module_init returns zero (fixes cardbus
00041       insertion oops)
00042     - Tell it that 3c905C has NWAY for 100bT autoneg
00043     - Fix handling of SetStatusEnd in 'Too much work..' code, as
00044       per 2.3.99's 3c575_cb (Dave Hinds).
00045     - Split ISR into two for vortex & boomerang
00046     - Fix MOD_INC/DEC races
00047     - Handle resource allocation failures.
00048     - Fix 3CCFE575CT LED polarity
00049     - Make tx_interrupt_mitigation the default
00050 
00051     LK1.1.4 25 April 2000, Andrew Morton <andrewm@uow.edu.au>    
00052     - Add extra TxReset to vortex_up() to fix 575_cb hotplug initialisation probs.
00053     - Put vortex_info_tbl into __devinitdata
00054     - In the vortex_error StatsFull HACK, disable stats in vp->intr_enable as well
00055       as in the hardware.
00056     - Increased the loop counter in issue_and_wait from 2,000 to 4,000.
00057 
00058     LK1.1.5 28 April 2000, andrewm
00059     - Added powerpc defines (John Daniel <jdaniel@etresoft.com> said these work...)
00060     - Some extra diagnostics
00061     - In vortex_error(), reset the Tx on maxCollisions.  Otherwise most
00062       chips usually get a Tx timeout.
00063     - Added extra_reset module parm
00064     - Replaced some inline timer manip with mod_timer
00065       (Franois romieu <Francois.Romieu@nic.fr>)
00066     - In vortex_up(), don't make Wn3_config initialisation dependent upon has_nway
00067       (this came across from 3c575_cb).
00068 
00069     LK1.1.6 06 Jun 2000, andrewm
00070     - Backed out the PPC defines.
00071     - Use del_timer_sync(), mod_timer().
00072     - Fix wrapped ulong comparison in boomerang_rx()
00073     - Add IS_TORNADO, use it to suppress 3c905C checksum error msg
00074       (Donald Becker, I Lee Hetherington <ilh@sls.lcs.mit.edu>)
00075     - Replace union wn3_config with BFINS/BFEXT manipulation for
00076       sparc64 (Pete Zaitcev, Peter Jones)
00077     - In vortex_error, do_tx_reset and vortex_tx_timeout(Vortex):
00078       do a netif_wake_queue() to better recover from errors. (Anders Pedersen,
00079       Donald Becker)
00080     - Print a warning on out-of-memory (rate limited to 1 per 10 secs)
00081     - Added two more Cardbus 575 NICs: 5b57 and 6564 (Paul Wagland)
00082 
00083     LK1.1.7 2 Jul 2000 andrewm
00084     - Better handling of shared IRQs
00085     - Reset the transmitter on a Tx reclaim error
00086     - Fixed crash under OOM during vortex_open() (Mark Hemment)
00087     - Fix Rx cessation problem during OOM (help from Mark Hemment)
00088     - The spinlocks around the mdio access were blocking interrupts for 300uS.
00089       Fix all this to use spin_lock_bh() within mdio_read/write
00090     - Only write to TxFreeThreshold if it's a boomerang - other NICs don't
00091       have one.
00092     - Added 802.3x MAC-layer flow control support
00093 
00094    LK1.1.8 13 Aug 2000 andrewm
00095     - Ignore request_region() return value - already reserved if Cardbus.
00096     - Merged some additional Cardbus flags from Don's 0.99Qk
00097     - Some fixes for 3c556 (Fred Maciel)
00098     - Fix for EISA initialisation (Jan Rekorajski)
00099     - Renamed MII_XCVR_PWR and EEPROM_230 to align with 3c575_cb and D. Becker's drivers
00100     - Fixed MII_XCVR_PWR for 3CCFE575CT
00101     - Added INVERT_LED_PWR, used it.
00102     - Backed out the extra_reset stuff
00103 
00104    LK1.1.9 12 Sep 2000 andrewm
00105     - Backed out the tx_reset_resume flags.  It was a no-op.
00106     - In vortex_error, don't reset the Tx on txReclaim errors
00107     - In vortex_error, don't reset the Tx on maxCollisions errors.
00108       Hence backed out all the DownListPtr logic here.
00109     - In vortex_error, give Tornado cards a partial TxReset on
00110       maxCollisions (David Hinds).  Defined MAX_COLLISION_RESET for this.
00111     - Redid some driver flags and device names based on pcmcia_cs-3.1.20.
00112     - Fixed a bug where, if vp->tx_full is set when the interface
00113       is downed, it remains set when the interface is upped.  Bad
00114       things happen.
00115 
00116    LK1.1.10 17 Sep 2000 andrewm
00117     - Added EEPROM_8BIT for 3c555 (Fred Maciel)
00118     - Added experimental support for the 3c556B Laptop Hurricane (Louis Gerbarg)
00119     - Add HAS_NWAY to "3c900 Cyclone 10Mbps TPO"
00120 
00121    LK1.1.11 13 Nov 2000 andrewm
00122     - Dump MOD_INC/DEC_USE_COUNT, use SET_MODULE_OWNER
00123 
00124    LK1.1.12 1 Jan 2001 andrewm (2.4.0-pre1)
00125     - Call pci_enable_device before we request our IRQ (Tobias Ringstrom)
00126     - Add 3c590 PCI latency timer hack to vortex_probe1 (from 0.99Ra)
00127     - Added extended issue_and_wait for the 3c905CX.
00128     - Look for an MII on PHY index 24 first (3c905CX oddity).
00129     - Add HAS_NWAY to 3cSOHO100-TX (Brett Frankenberger)
00130     - Don't free skbs we don't own on oom path in vortex_open().
00131 
00132    LK1.1.13 27 Jan 2001
00133     - Added explicit `medialock' flag so we can truly
00134       lock the media type down with `options'.
00135     - "check ioremap return and some tidbits" (Arnaldo Carvalho de Melo <acme@conectiva.com.br>)
00136     - Added and used EEPROM_NORESET for 3c556B PM resumes.
00137     - Fixed leakage of vp->rx_ring.
00138     - Break out separate HAS_HWCKSM device capability flag.
00139     - Kill vp->tx_full (ANK)
00140     - Merge zerocopy fragment handling (ANK?)
00141 
00142    LK1.1.14 15 Feb 2001
00143     - Enable WOL.  Can be turned on with `enable_wol' module option.
00144     - EISA and PCI initialisation fixes (jgarzik, Manfred Spraul)
00145     - If a device's internalconfig register reports it has NWAY,
00146       use it, even if autoselect is enabled.
00147 
00148    LK1.1.15 6 June 2001 akpm
00149     - Prevent double counting of received bytes (Lars Christensen)
00150     - Add ethtool support (jgarzik)
00151     - Add module parm descriptions (Andrzej M. Krzysztofowicz)
00152     - Implemented alloc_etherdev() API
00153     - Special-case the 'Tx error 82' message.
00154 
00155    LK1.1.16 18 July 2001 akpm
00156     - Make NETIF_F_SG dependent upon nr_free_highpages(), not on CONFIG_HIGHMEM
00157     - Lessen verbosity of bootup messages
00158     - Fix WOL - use new PM API functions.
00159     - Use netif_running() instead of vp->open in suspend/resume.
00160     - Don't reset the interface logic on open/close/rmmod.  It upsets
00161       autonegotiation, and hence DHCP (from 0.99T).
00162     - Back out EEPROM_NORESET flag because of the above (we do it for all
00163       NICs).
00164     - Correct 3c982 identification string
00165     - Rename wait_for_completion() to issue_and_wait() to avoid completion.h
00166       clash.
00167 
00168 
00169 =====================================================================================
00170                           PORTING TO RT-LINUX                       
00171 =====================================================================================
00172 
00173    LK1.1.17 14 March 2003 
00174             Sergio Perez Alcañiz <serpeal@disca.upv.es>  
00175             Departamento de Informática de Sistemas y Computadores          
00176             Universidad Politécnica de Valencia                             
00177             Valencia (Spain)                      
00178 
00179             The RTL-lwIP project has been supported by the Spanish Government Research    
00180             Office (CICYT) under grant TIC2002-04123-C03-03                          
00181             SISTEMAS DE TIEMPO REAL EMPOTRADOS, FIABLES Y DISTRIBUIDOS BASADOS EN 
00182             COMPONENTES
00183 
00184             Porting the driver to RT-Linux, that is:
00185             -Giving to the driver the RT-Linux driver architecture (open, close, read,
00186              write, ioctl).
00187             -Using my own buffer management.
00188             -No NIC stats allowed.
00189             -Some calls of pci stuff have been implemented.
00190             -Changing the interrupts management and the handler phylosophy.
00191             -Changing the "receive" and "send" phylosophy.
00192             -Introducing signaling.
00193             -Registering threads that want to be notified of the arrival of a packet.
00194             -IP filtering.
00195             -Ethernet filtering.
00196             ­Some functions added in order to ask the driver for some NIC info (such as
00197              the MAC address).
00198              - ....
00199 
00200              The porting is just for the 3Com905C-X card. So no other cards are supported
00201              (as far as I know...). 
00202              
00203              Just take a look at it.
00204 =====================================================================================
00205 
00206     - see Documentation/networking/vortex.txt
00207 */
00208 
00209 #include <linux/kernel.h>
00210 #include <linux/module.h>
00211 #include <linux/pci.h>
00212 #include <linux/config.h>
00213 #include <linux/module.h>
00214 #include <linux/kernel.h>
00215 #include <linux/sched.h>
00216 #include <linux/string.h>
00217 #include <linux/timer.h>
00218 #include <linux/errno.h>
00219 #include <linux/in.h>
00220 #include <linux/ioport.h>
00221 #include <linux/slab.h>
00222 #include <linux/interrupt.h>
00223 #include <linux/mii.h>
00224 #include <linux/init.h>
00225 #include <linux/netdevice.h>
00226 #include <linux/etherdevice.h>
00227 #include <linux/skbuff.h>
00228 #include <linux/ethtool.h>
00229 #include <linux/highmem.h>
00230 #include <asm/irq.h>                    /* For NR_IRQS only. */
00231 #include <asm/bitops.h>
00232 #include <asm/io.h>
00233 #include <asm/uaccess.h>
00234 
00235 #include <rtl_sched.h>
00236 #include <signal.h>
00237 #include <time.h>
00238 
00239 #define DRV_NAME        "3c59x"
00240 #define DRV_VERSION     "0.1"
00241 #define DRV_RELDATE     "27 december 2002"
00242 
00243 #define MAX_THREADS 10
00244 
00245 #define COM3_VENDOR_ID 0x10B7
00246 #define COM3_DEVICE_ID 0X9200
00247 
00248 #define BFEXT(value, offset, bitcount)  \
00249     ((((unsigned long)(value)) >> (offset)) & ((1 << (bitcount)) - 1))
00250 
00251 #define BFINS(lhs, rhs, offset, bitcount)                                       \
00252         (((lhs) & ~((((1 << (bitcount)) - 1)) << (offset))) |   \
00253         (((rhs) & ((1 << (bitcount)) - 1)) << (offset)))
00254 
00255 #define RAM_SIZE(v)             BFEXT(v, 0, 3)
00256 #define RAM_WIDTH(v)    BFEXT(v, 3, 1)
00257 #define RAM_SPEED(v)    BFEXT(v, 4, 2)
00258 #define ROM_SIZE(v)             BFEXT(v, 6, 2)
00259 #define RAM_SPLIT(v)    BFEXT(v, 16, 2)
00260 #define XCVR(v)                 BFEXT(v, 20, 4)
00261 #define AUTOSELECT(v)   BFEXT(v, 24, 1)
00262 
00263 /* Operational definitions.
00264    These are not used by other compilation units and thus are not
00265    exported in a ".h" file.
00266 
00267    First the windows.  There are eight register windows, with the command
00268    and status registers available in each.
00269    */
00270 #define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD)
00271 #define EL3_CMD 0x0e
00272 #define EL3_STATUS 0x0e
00273 
00274 /* A few values that may be tweaked. */
00275 /* Keep the ring sizes a power of two for efficiency. */
00276 #define TX_RING_SIZE    16
00277 #define RX_RING_SIZE    32
00278 #define PKT_BUF_SZ              1536                    /* Size of each temporary Rx buffer.*/
00279 #define MAX_ADDR_LEN    8               /* Largest hardware address length */
00280 
00281 /* The top five bits written to EL3_CMD are a command, the lower
00282    11 bits are the parameter, if applicable.
00283    Note that 11 parameters bits was fine for ethernet, but the new chip
00284    can handle FDDI length frames (~4500 octets) and now parameters count
00285    32-bit 'Dwords' rather than octets. */
00286 
00287 enum vortex_cmd {
00288         TotalReset = 0<<11, SelectWindow = 1<<11, StartCoax = 2<<11,
00289         RxDisable = 3<<11, RxEnable = 4<<11, RxReset = 5<<11,
00290         UpStall = 6<<11, UpUnstall = (6<<11)+1,
00291         DownStall = (6<<11)+2, DownUnstall = (6<<11)+3,
00292         RxDiscard = 8<<11, TxEnable = 9<<11, TxDisable = 10<<11, TxReset = 11<<11,
00293         FakeIntr = 12<<11, AckIntr = 13<<11, SetIntrEnb = 14<<11,
00294         SetStatusEnb = 15<<11, SetRxFilter = 16<<11, SetRxThreshold = 17<<11,
00295         SetTxThreshold = 18<<11, SetTxStart = 19<<11,
00296         StartDMAUp = 20<<11, StartDMADown = (20<<11)+1, StatsEnable = 21<<11,
00297         StatsDisable = 22<<11, StopCoax = 23<<11, SetFilterBit = 25<<11,};
00298 
00299 /* The SetRxFilter command accepts the following classes: */
00300 enum RxFilter {
00301         RxStation = 1, RxMulticast = 2, RxBroadcast = 4, RxProm = 8 };
00302 
00303 /* Bits in the general status register. */
00304 enum vortex_status {
00305         IntLatch = 0x0001, HostError = 0x0002, TxComplete = 0x0004,
00306         TxAvailable = 0x0008, RxComplete = 0x0010, RxEarly = 0x0020,
00307         IntReq = 0x0040, StatsFull = 0x0080,
00308         DMADone = 1<<8, DownComplete = 1<<9, UpComplete = 1<<10,
00309         DMAInProgress = 1<<11,                  /* DMA controller is still busy.*/
00310         CmdInProgress = 1<<12,                  /* EL3_CMD is still busy.*/
00311 };
00312 
00313 /* Register window 1 offsets, the window used in normal operation.
00314    On the Vortex this window is always mapped at offsets 0x10-0x1f. */
00315 enum Window1 {
00316         TX_FIFO = 0x10,  RX_FIFO = 0x10,  RxErrors = 0x14,
00317         RxStatus = 0x18,  Timer=0x1A, TxStatus = 0x1B,
00318         TxFree = 0x1C, /* Remaining free bytes in Tx buffer. */
00319 };
00320 enum Window0 {
00321         Wn0EepromCmd = 10,              /* Window 0: EEPROM command register. */
00322         Wn0EepromData = 12,             /* Window 0: EEPROM results register. */
00323         IntrStatus=0x0E,                /* Valid in all windows. */
00324 };
00325 enum Win0_EEPROM_bits {
00326         EEPROM_Read = 0x80, EEPROM_WRITE = 0x40, EEPROM_ERASE = 0xC0,
00327         EEPROM_EWENB = 0x30,            /* Enable erasing/writing for 10 msec. */
00328         EEPROM_EWDIS = 0x00,            /* Disable EWENB before 10 msec timeout. */
00329 };
00330 /* EEPROM locations. */
00331 enum eeprom_offset {
00332         PhysAddr01=0, PhysAddr23=1, PhysAddr45=2, ModelID=3,
00333         EtherLink3ID=7, IFXcvrIO=8, IRQLine=9,
00334         NodeAddr01=10, NodeAddr23=11, NodeAddr45=12,
00335         DriverTune=13, Checksum=15};
00336 
00337 enum Window2 {                  /* Window 2. */
00338         Wn2_ResetOptions=12,
00339 };
00340 enum Window3 {                  /* Window 3: MAC/config bits. */
00341         Wn3_Config=0, Wn3_MAC_Ctrl=6, Wn3_Options=8,
00342 };
00343 
00344 enum Window4 {          /* Window 4: Xcvr/media bits. */
00345         Wn4_FIFODiag = 4, Wn4_NetDiag = 6, Wn4_PhysicalMgmt=8, Wn4_Media = 10,
00346 };
00347 enum Win4_Media_bits {
00348         Media_SQE = 0x0008,             /* Enable SQE error counting for AUI. */
00349         Media_10TP = 0x00C0,    /* Enable link beat and jabber for 10baseT. */
00350         Media_Lnk = 0x0080,             /* Enable just link beat for 100TX/100FX. */
00351         Media_LnkBeat = 0x0800,
00352 };
00353 
00354 enum Window7 {                                  /* Window 7: Bus Master control. */
00355         Wn7_MasterAddr = 0, Wn7_MasterLen = 6, Wn7_MasterStatus = 12,
00356 };
00357 /* Boomerang bus master control registers. */
00358 enum MasterCtrl {
00359         PktStatus = 0x20, DownListPtr = 0x24, FragAddr = 0x28, FragLen = 0x2c,
00360         TxFreeThreshold = 0x2f, UpPktStatus = 0x30, UpListPtr = 0x38,
00361 };
00362 
00363 /* The Rx and Tx descriptor lists.
00364    Caution Alpha hackers: these types are 32 bits!  Note also the 8 byte
00365    alignment contraint on tx_ring[] and rx_ring[]. */
00366 #define LAST_FRAG       0x80000000                      /* Last Addr/Len pair in descriptor. */
00367 #define DN_COMPLETE     0x00010000                      /* This packet has been downloaded */
00368 
00369 /* Values for the Rx status entry. */
00370 enum rx_desc_status {
00371         RxDComplete=0x00008000, RxDError=0x4000,
00372         /* See boomerang_rx() for actual error bits */
00373         IPChksumErr=1<<25, TCPChksumErr=1<<26, UDPChksumErr=1<<27,
00374         IPChksumValid=1<<29, TCPChksumValid=1<<30, UDPChksumValid=1<<31,
00375 };
00376 
00377 /* Values for the Tx status entry. */
00378 enum tx_desc_status {
00379         CRCDisable=0x2000, TxDComplete=0x8000,
00380         AddIPChksum=0x02000000, AddTCPChksum=0x04000000, AddUDPChksum=0x08000000,
00381         TxIntrUploaded=0x80000000,              /* IRQ when in FIFO, but maybe not sent. */
00382 };
00383 
00384 /* The action to take with a media selection timer tick.
00385    Note that we deviate from the 3Com order by checking 10base2 before AUI.
00386  */
00387 enum xcvr_types {
00388         XCVR_10baseT=0, XCVR_AUI, XCVR_10baseTOnly, XCVR_10base2, XCVR_100baseTx,
00389         XCVR_100baseFx, XCVR_MII=6, XCVR_NWAY=8, XCVR_ExtMII=9, XCVR_Default=10,
00390 };
00391 
00392 /* Chip features we care about in vp->capabilities, read from the EEPROM. */
00393 enum ChipCaps { CapBusMaster=0x20, CapPwrMgmt=0x2000 };
00394 
00395 
00396 /* This table drives the PCI probe routines.  It's mostly boilerplate in all
00397    of the drivers, and will likely be provided by some future kernel.
00398 */
00399 enum pci_flags_bit {
00400         PCI_USES_IO=1, PCI_USES_MEM=2, PCI_USES_MASTER=4,
00401         PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
00402 };
00403 
00404 enum {  IS_VORTEX=1, IS_BOOMERANG=2, IS_CYCLONE=4, IS_TORNADO=8,
00405         EEPROM_8BIT=0x10,       /* AKPM: Uses 0x230 as the base bitmaps for EEPROM reads */
00406         HAS_PWR_CTRL=0x20, HAS_MII=0x40, HAS_NWAY=0x80, HAS_CB_FNS=0x100,
00407         INVERT_MII_PWR=0x200, INVERT_LED_PWR=0x400, MAX_COLLISION_RESET=0x800,
00408         EEPROM_OFFSET=0x1000, HAS_HWCKSM=0x2000 };
00409 
00410 #define DO_ZEROCOPY 0
00411 
00412 struct boom_rx_desc {
00413         u32 next;                                       /* Last entry points to 0.   */
00414         s32 status;
00415         u32 addr;                                       /* Up to 63 addr/len pairs possible. */
00416         s32 length;                                     /* Set LAST_FRAG to indicate last pair. */
00417 };
00418 
00419 struct boom_tx_desc {
00420   u32 next;                                     /* Last entry points to 0.   */
00421   s32 status;                                   /* bits 0:12 length, others see below.  */
00422   u32 addr;
00423   s32 length;
00424 };
00425 
00426 struct vortex_private {
00427   /* The Rx and Tx rings should be quad-word-aligned. */
00428   struct boom_rx_desc* rx_ring;
00429   struct boom_tx_desc* tx_ring;
00430   dma_addr_t rx_ring_dma;
00431   dma_addr_t tx_ring_dma;
00432   /* The addresses of transmit- and receive-in-place skbuffs. */
00433   unsigned char *rx_skbuff[RX_RING_SIZE];
00434   unsigned char *tx_skbuff[TX_RING_SIZE];
00435   struct net_device *next_module;               /* NULL if PCI device */
00436   unsigned int cur_rx, cur_tx;          /* The next free ring entry */
00437   unsigned int dirty_rx, dirty_tx;      /* The ring entries to be free()ed. */
00438   struct net_device_stats stats;
00439   struct sk_buff *tx_skb;                               /* Packet being eaten by bus master ctrl.  */
00440   dma_addr_t tx_skb_dma;                                /* Allocated DMA address for bus master ctrl DMA.   */
00441   /* PCI configuration space information. */
00442   struct pci_dev *pdev;
00443   char *cb_fn_base;                                     /* CardBus function status addr space. */
00444   
00445   /* Some values here only for performance evaluation and path-coverage */
00446   int rx_nocopy, rx_copy, queued_packet, rx_csumhits;
00447   int card_idx;
00448   
00449   int options;                                          /* User-settable misc. driver options. */
00450   unsigned int media_override:4,                /* Passed-in media type. */
00451     default_media:4,                            /* Read from the EEPROM/Wn3_Config. */
00452     full_duplex:1, 
00453     force_fd:1, 
00454     autoselect:1,
00455     bus_master:1,                                       /* Vortex can only do a fragment bus-m. */
00456     full_bus_master_tx:1, full_bus_master_rx:2, /* Boomerang  */
00457     flow_ctrl:1,                                        /* Use 802.3x flow control (PAUSE only) */
00458     partner_flow_ctrl:1,                        /* Partner supports flow control */
00459     has_nway:1,
00460     enable_wol:1,                                       /* Wake-on-LAN is enabled */
00461     pm_state_valid:1,                           /* power_state[] has sane contents */
00462     open:1,
00463     medialock:1,
00464     must_free_region:1;                         /* Flag: if zero, Cardbus owns the I/O region */
00465   int drv_flags;
00466   u16 status_enable;
00467   u16 intr_enable;
00468   u16 available_media;                          /* From Wn3_Options. */
00469   u16 capabilities, info1, info2;               /* Various, from EEPROM. */
00470   u16 advertising;                                      /* NWay media advertisement */
00471   unsigned char phys[2];                                /* MII device addresses. */
00472   u16 deferred;                                         /* Resend these interrupts when we
00473                                                          * bale from the ISR */
00474   u16 io_size;                                          /* Size of PCI region (for release_region) */
00475   spinlock_t lock;                                      /* Serialise access to device & its vortex_private */
00476   spinlock_t mdio_lock;                         /* Serialise access to mdio hardware */
00477   u32 power_state[16];
00478   int mtu;
00479   unsigned char dev_addr[MAX_ADDR_LEN]; /* hw address   */
00480   long ioaddr;
00481   unsigned long rx_packets;
00482   unsigned long rx_frames_for_us;
00483   unsigned char if_port;
00484   int must_free_irq;
00485 };
00486 
00487 static struct vortex_chip_info {
00488         const char *name;
00489         int flags;
00490         int drv_flags;
00491         int io_size;
00492 } vortex_info = {"3c905C Tornado",
00493                      PCI_USES_IO|PCI_USES_MASTER, IS_TORNADO|HAS_NWAY|HAS_HWCKSM, 128, };
00494 
00495 enum vortex_chips {
00496         CH_3C590 = 0,
00497         CH_3C592,
00498         CH_3C597,
00499         CH_3C595_1,
00500         CH_3C595_2,
00501 
00502         CH_3C595_3,
00503         CH_3C900_1,
00504         CH_3C900_2,
00505         CH_3C900_3,
00506         CH_3C900_4,
00507 
00508         CH_3C900_5,
00509         CH_3C900B_FL,
00510         CH_3C905_1,
00511         CH_3C905_2,
00512         CH_3C905B_1,
00513 
00514         CH_3C905B_2,
00515         CH_3C905B_FX,
00516         CH_3C905C,
00517         CH_3C980,
00518         CH_3C9805,
00519 
00520         CH_3CSOHO100_TX,
00521         CH_3C555,
00522         CH_3C556,
00523         CH_3C556B,
00524         CH_3C575,
00525 
00526         CH_3C575_1,
00527         CH_3CCFE575,
00528         CH_3CCFE575CT,
00529         CH_3CCFE656,
00530         CH_3CCFEM656,
00531 
00532         CH_3CCFEM656_1,
00533         CH_3C450,
00534 };
00535 
00536 static struct media_table {
00537         char *name;
00538         unsigned int media_bits:16,             /* Bits to set in Wn4_Media register. */
00539                 mask:8,                         /* The transceiver-present bit in Wn3_Config.*/
00540                 next:8;                         /* The media type to try next. */
00541         int wait;                               /* Time before we check media status. */
00542 } media_tbl[] = {
00543   { "10baseT",   Media_10TP,0x08, XCVR_10base2, (14*HZ)/10},
00544   { "10Mbs AUI", Media_SQE, 0x20, XCVR_Default, (1*HZ)/10},
00545   { "undefined", 0,                     0x80, XCVR_10baseT, 10000},
00546   { "10base2",   0,                     0x10, XCVR_AUI,         (1*HZ)/10},
00547   { "100baseTX", Media_Lnk, 0x02, XCVR_100baseFx, (14*HZ)/10},
00548   { "100baseFX", Media_Lnk, 0x04, XCVR_MII,             (14*HZ)/10},
00549   { "MII",               0,                     0x41, XCVR_10baseT, 3*HZ },
00550   { "undefined", 0,                     0x01, XCVR_10baseT, 10000},
00551   { "Autonegotiate", 0,         0x41, XCVR_10baseT, 3*HZ},
00552   { "MII-External",      0,             0x41, XCVR_10baseT, 3*HZ },
00553   { "Default",   0,                     0xFF, XCVR_10baseT, 10000},
00554 };
00555 
00556 static char mii_preamble_required;
00557 static const int mtu = 1500;
00558 /* Maximum events (Rx packets, etc.) to handle at each interrupt. */
00559 static int max_interrupt_work = 32;
00560 
00561 /* "Knobs" that adjust features and parameters. */
00562 /* Set the copy breakpoint for the copy-only-tiny-frames scheme.
00563    Setting to > 1512 effectively disables this feature. */
00564 #ifndef __arm__
00565 static const int rx_copybreak = 200;
00566 #else
00567 /* ARM systems perform better by disregarding the bus-master
00568    transfer capability of these cards. -- rmk */
00569 static const int rx_copybreak = 1513;
00570 #endif
00571 
00572 struct pci_dev *rtl_3COM905C_init_device(void);
00573 int rtl_3COM905C_start_up_device(struct pci_dev *dev);
00574 static void rtl_3COM905C_mdio_write(int phy_id, int location, int value);
00575 static int rtl_3COM905C_mdio_read(int phy_id, int location);
00576 static void rtl_3COM905C_mdio_sync(long ioaddr, int bits);
00577 static int vortex_open(struct pci_dev *dev);
00578 static void vortex_up(struct pci_dev *dev);
00579 static void rtl_3COM905C_issue_and_wait(int cmd);
00580 static void rtl_3COM905C_set_rx_mode(void);
00581 static void rtl_3COM905C_acpi_set_WOL(void);
00582 static int boomerang_rx(struct pci_dev *dev);
00583 static void vortex_down(struct pci_dev *dev);
00584 static void vortex_error(struct pci_dev *dev, int status);
00585 static int vortex_close(struct pci_dev *dev);
00586 static void vortex_remove_one (struct pci_dev *pdev);
00587 static int rt_3c905c_send_packet(const char *buffer, size_t size);
00588 void rt_3c905c_send_signal(void);
00589 
00590 #define PCI_DEBUG 0
00591 #define EEPROM_CONTENTS_DEBUG 0
00592 #define MAC_ADDRESS_DEBUG 0
00593 #define FUNCTION_CALL_DEBUG 0
00594 #define INITIALIZATION_DEBUG 0
00595 #define RECEIVE_DEBUG 0
00596 #define PACKET_DATA_DEBUG 0
00597 #define INTERRUPT_DEBUG 0
00598 #define TRANSMIT_DEBUG 0
00599 #define ERROR_DEBUG 1
00600 
00601 #define SIGALRM2 RTL_SIGUSR1
00602 
00603 #define DEBUG(x,y) if(x) printk y
00604 
00605 #include <rtl_sync.h>
00606 #include <rtl_core.h>
00607 #include <rtl_printf.h>
00608 #include <time.h>
00609 #include <asm/io.h>
00610 #include <rtl_posixio.h>
00611 #include <sys/mman.h>
00612 #include <errno.h>
00613 #include <unistd.h>
00614 #include <rtl.h>
00615 #include <rtl_malloc.h>
00616 #include <rtl_sema.h>
00617 #include <rtl_sync.h>
00618 #include "memcopy.h"
00619 
00620 static int rtl_3COM905C_open (struct rtl_file *filp);
00621 static int rtl_3COM905C_release (struct rtl_file *filp);
00622 static ssize_t rtl_3COM905C_write(struct rtl_file *filp, const char *buf, size_t count, loff_t* ppos);
00623 static int rtl_3COM905C_ioctl(struct rtl_file * filp, unsigned int request, unsigned long other);
00624 static ssize_t rtl_3COM905C_read(struct rtl_file *filp, char *buf, size_t count, loff_t* ppos);
00625 
00626 
00627 
00628 
00629 
00630 

Generated on Wed Jan 14 12:58:57 2004 for RTL-lwIP-0.4 by doxygen 1.3.4