Main Page | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

rtl8139.c File Reference

#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/malloc.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <asm/processor.h>
#include <asm/bitops.h>
#include <asm/io.h>
#include <linux/delay.h>
#include <linux/bios32.h>

Include dependency graph for rtl8139.c:

Go to the source code of this file.

Data Structures

struct  pci_id_info

Defines

#define rtl8129_debug   debug
#define MAX_UNITS   8
#define RX_BUF_LEN_IDX   3
#define RX_BUF_LEN   (8192 << RX_BUF_LEN_IDX)
#define TX_BUF_SIZE   1536
#define TX_FIFO_THRESH   256
#define RX_FIFO_THRESH   4
#define RX_DMA_BURST   4
#define TX_DMA_BURST   4
#define TX_TIMEOUT   (4*HZ)
#define RUN_AT(x)   (jiffies + (x))
#define test_and_set_bit(val, addr)   set_bit(val, addr)
#define net_device_stats   enet_statistics
#define PCI_SUPPORT_VER1
#define dev_free_skb(skb)   dev_kfree_skb(skb, FREE_WRITE);
#define RTL8129_TOTAL_SIZE   0x80
#define NUM_TX_DESC   4
#define EE_SHIFT_CLK   0x04
#define EE_CS   0x08
#define EE_DATA_WRITE   0x02
#define EE_WRITE_0   0x00
#define EE_WRITE_1   0x02
#define EE_DATA_READ   0x01
#define EE_ENB   (0x80 | EE_CS)
#define eeprom_delay()   inl(ee_addr)
#define EE_WRITE_CMD   (5 << 6)
#define EE_READ_CMD   (6 << 6)
#define EE_ERASE_CMD   (7 << 6)
#define MDIO_DIR   0x80
#define MDIO_DATA_OUT   0x04
#define MDIO_DATA_IN   0x02
#define MDIO_CLK   0x01
#define MDIO_WRITE0   (MDIO_DIR)
#define MDIO_WRITE1   (MDIO_DIR | MDIO_DATA_OUT)
#define mdio_delay()   inb(mdio_addr)

Enumerations

enum  pci_flags_bit {
  PCI_USES_IO = 1, PCI_USES_MEM = 2, PCI_USES_MASTER = 4, PCI_ADDR0 = 0x10<<0,
  PCI_ADDR1 = 0x10<<1, PCI_ADDR2 = 0x10<<2, PCI_ADDR3 = 0x10<<3
}
enum  { HAS_MII_XCVR = 0x01, HAS_CHIP_XCVR = 0x02, HAS_LNK_CHNG = 0x04 }
enum  RTL8129_registers {
  MAC0 = 0, MAR0 = 8, TxStatus0 = 0x10, TxAddr0 = 0x20,
  RxBuf = 0x30, RxEarlyCnt = 0x34, RxEarlyStatus = 0x36, ChipCmd = 0x37,
  RxBufPtr = 0x38, RxBufAddr = 0x3A, IntrMask = 0x3C, IntrStatus = 0x3E,
  TxConfig = 0x40, RxConfig = 0x44, Timer = 0x48, RxMissed = 0x4C,
  Cfg9346 = 0x50, Config0 = 0x51, Config1 = 0x52, FlashReg = 0x54,
  GPPinData = 0x58, GPPinDir = 0x59, MII_SMI = 0x5A, HltClk = 0x5B,
  MultiIntr = 0x5C, TxSummary = 0x60, MII_BMCR = 0x62, MII_BMSR = 0x64,
  NWayAdvert = 0x66, NWayLPAR = 0x68, NWayExpansion = 0x6A, FIFOTMS = 0x70,
  CSCR = 0x74, PARA78 = 0x78, PARA7c = 0x7c
}
enum  ChipCmdBits { CmdReset = 0x10, CmdRxEnb = 0x08, CmdTxEnb = 0x04, RxBufEmpty = 0x01 }
enum  IntrStatusBits {
  PCIErr = 0x8000, PCSTimeout = 0x4000, RxFIFOOver = 0x40, RxUnderrun = 0x20,
  RxOverflow = 0x10, TxErr = 0x08, TxOK = 0x04, RxErr = 0x02,
  RxOK = 0x01
}
enum  TxStatusBits {
  TxHostOwns = 0x2000, TxUnderrun = 0x4000, TxStatOK = 0x8000, TxOutOfWindow = 0x20000000,
  TxAborted = 0x40000000, TxCarrierLost = 0x80000000
}
enum  RxStatusBits {
  RxMulticast = 0x8000, RxPhysical = 0x4000, RxBroadcast = 0x2000, RxBadSymbol = 0x0020,
  RxRunt = 0x0010, RxTooLong = 0x0008, RxCRCErr = 0x0004, RxBadAlign = 0x0002,
  RxStatusOK = 0x0001
}
enum  CSCRBits {
  CSCR_LinkOKBit = 0x0400, CSCR_LinkChangeBit = 0x0800, CSCR_LinkStatusBits = 0x0f000, CSCR_LinkDownOffCmd = 0x003c0,
  CSCR_LinkDownCmd = 0x0f3c0
}
enum  rx_mode_bits {
  AcceptErr = 0x20, AcceptRunt = 0x10, AcceptBroadcast = 0x08, AcceptMulticast = 0x04,
  AcceptMyPhys = 0x02, AcceptAllPhys = 0x01
}

Functions

static struct device * rtl8129_probe1 (int pci_bus, int pci_devfn, struct device *dev, long ioaddr, int irq, int chp_idx, int fnd_cnt)
static int rtl8129_open (struct device *dev)
static int read_eeprom (long ioaddr, int location)
static int mdio_read (struct device *dev, int phy_id, int location)
static void mdio_write (struct device *dev, int phy_id, int location, int val)
static void rtl8129_timer (unsigned long data)
static void rtl8129_tx_timeout (struct device *dev)
static void rtl8129_init_ring (struct device *dev)
static int rtl8129_start_xmit (struct sk_buff *skb, struct device *dev)
static int rtl8129_rx (struct device *dev)
static void rtl8129_interrupt (int irq, void *dev_instance, struct pt_regs *regs)
static int rtl8129_close (struct device *dev)
static int mii_ioctl (struct device *dev, struct ifreq *rq, int cmd)
static struct enet_statistics * rtl8129_get_stats (struct device *dev)
static u32 ether_crc (int length, unsigned char *data)
static void set_rx_mode (struct device *dev)
int rtl8139_probe (struct device *dev)
static void mdio_sync (long mdio_addr)

Variables

static const char * version
static int max_interrupt_work = 20
static int rtl8129_debug = 1
static int multicast_filter_limit = 32
static int options [MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}
static int full_duplex [MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}
static struct pci_id_info pci_tbl []
static int rtl_cap_tbl []
unsigned long param [4][4]
static struct device * root_rtl8129_dev = NULL
static char mii_2_8139_map [8]
static unsigned const ethernet_polynomial = 0x04c11db7U


Define Documentation

#define dev_free_skb skb   )     dev_kfree_skb(skb, FREE_WRITE);
 

Definition at line 100 of file rtl8139.c.

#define EE_CS   0x08
 

Definition at line 518 of file rtl8139.c.

#define EE_DATA_READ   0x01
 

Definition at line 522 of file rtl8139.c.

#define EE_DATA_WRITE   0x02
 

Definition at line 519 of file rtl8139.c.

#define EE_ENB   (0x80 | EE_CS)
 

Definition at line 523 of file rtl8139.c.

#define EE_ERASE_CMD   (7 << 6)
 

Definition at line 534 of file rtl8139.c.

#define EE_READ_CMD   (6 << 6)
 

Definition at line 533 of file rtl8139.c.

#define EE_SHIFT_CLK   0x04
 

Definition at line 517 of file rtl8139.c.

#define EE_WRITE_0   0x00
 

Definition at line 520 of file rtl8139.c.

#define EE_WRITE_1   0x02
 

Definition at line 521 of file rtl8139.c.

#define EE_WRITE_CMD   (5 << 6)
 

Definition at line 532 of file rtl8139.c.

 
#define eeprom_delay  )     inl(ee_addr)
 

Definition at line 529 of file rtl8139.c.

#define MAX_UNITS   8
 

Definition at line 36 of file rtl8139.c.

#define MDIO_CLK   0x01
 

Definition at line 579 of file rtl8139.c.

#define MDIO_DATA_IN   0x02
 

Definition at line 578 of file rtl8139.c.

#define MDIO_DATA_OUT   0x04
 

Definition at line 577 of file rtl8139.c.

 
#define mdio_delay  )     inb(mdio_addr)
 

Definition at line 583 of file rtl8139.c.

#define MDIO_DIR   0x80
 

Definition at line 576 of file rtl8139.c.

#define MDIO_WRITE0   (MDIO_DIR)
 

Definition at line 580 of file rtl8139.c.

#define MDIO_WRITE1   (MDIO_DIR | MDIO_DATA_OUT)
 

Definition at line 581 of file rtl8139.c.

#define net_device_stats   enet_statistics
 

Definition at line 88 of file rtl8139.c.

#define NUM_TX_DESC   4
 

Definition at line 196 of file rtl8139.c.

#define PCI_SUPPORT_VER1
 

Definition at line 95 of file rtl8139.c.

#define rtl8129_debug   debug
 

Definition at line 28 of file rtl8139.c.

Referenced by rtl8129_close(), rtl8129_interrupt(), rtl8129_open(), rtl8129_probe1(), rtl8129_rx(), rtl8129_start_xmit(), rtl8129_timer(), rtl8129_tx_timeout(), and set_rx_mode().

#define RTL8129_TOTAL_SIZE   0x80
 

Definition at line 106 of file rtl8139.c.

#define RUN_AT x   )     (jiffies + (x))
 

Definition at line 80 of file rtl8139.c.

#define RX_BUF_LEN   (8192 << RX_BUF_LEN_IDX)
 

Definition at line 42 of file rtl8139.c.

#define RX_BUF_LEN_IDX   3
 

Definition at line 41 of file rtl8139.c.

#define RX_DMA_BURST   4
 

Definition at line 52 of file rtl8139.c.

#define RX_FIFO_THRESH   4
 

Definition at line 51 of file rtl8139.c.

#define test_and_set_bit val,
addr   )     set_bit(val, addr)
 

Definition at line 85 of file rtl8139.c.

#define TX_BUF_SIZE   1536
 

Definition at line 44 of file rtl8139.c.

#define TX_DMA_BURST   4
 

Definition at line 53 of file rtl8139.c.

#define TX_FIFO_THRESH   256
 

Definition at line 48 of file rtl8139.c.

#define TX_TIMEOUT   (4*HZ)
 

Definition at line 57 of file rtl8139.c.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
HAS_MII_XCVR 
HAS_CHIP_XCVR 
HAS_LNK_CHNG 

Definition at line 189 of file rtl8139.c.

enum ChipCmdBits
 

Enumeration values:
CmdReset 
CmdRxEnb 
CmdTxEnb 
RxBufEmpty 

Definition at line 221 of file rtl8139.c.

enum CSCRBits
 

Enumeration values:
CSCR_LinkOKBit 
CSCR_LinkChangeBit 
CSCR_LinkStatusBits 
CSCR_LinkDownOffCmd 
CSCR_LinkDownCmd 

Definition at line 242 of file rtl8139.c.

enum IntrStatusBits
 

Enumeration values:
PCIErr 
PCSTimeout 
RxFIFOOver 
RxUnderrun 
RxOverflow 
TxErr 
TxOK 
RxErr 
RxOK 

Definition at line 225 of file rtl8139.c.

enum pci_flags_bit
 

Enumeration values:
PCI_USES_IO 
PCI_USES_MEM 
PCI_USES_MASTER 
PCI_ADDR0 
PCI_ADDR1 
PCI_ADDR2 
PCI_ADDR3 

Definition at line 160 of file rtl8139.c.

enum RTL8129_registers
 

Enumeration values:
MAC0 
MAR0 
TxStatus0 
TxAddr0 
RxBuf 
RxEarlyCnt 
RxEarlyStatus 
ChipCmd 
RxBufPtr 
RxBufAddr 
IntrMask 
IntrStatus 
TxConfig 
RxConfig 
Timer 
RxMissed 
Cfg9346 
Config0 
Config1 
FlashReg 
GPPinData 
GPPinDir 
MII_SMI 
HltClk 
MultiIntr 
TxSummary 
MII_BMCR 
MII_BMSR 
NWayAdvert 
NWayLPAR 
NWayExpansion 
FIFOTMS 
CSCR 
PARA78 
PARA7c 

Definition at line 199 of file rtl8139.c.

enum rx_mode_bits
 

Enumeration values:
AcceptErr 
AcceptRunt 
AcceptBroadcast 
AcceptMulticast 
AcceptMyPhys 
AcceptAllPhys 

Definition at line 1407 of file rtl8139.c.

enum RxStatusBits
 

Enumeration values:
RxMulticast 
RxPhysical 
RxBroadcast 
RxBadSymbol 
RxRunt 
RxTooLong 
RxCRCErr 
RxBadAlign 
RxStatusOK 

Definition at line 234 of file rtl8139.c.

enum TxStatusBits
 

Enumeration values:
TxHostOwns 
TxUnderrun 
TxStatOK 
TxOutOfWindow 
TxAborted 
TxCarrierLost 

Definition at line 230 of file rtl8139.c.


Function Documentation

static u32 ether_crc int  length,
unsigned char *  data
[inline, static]
 

Definition at line 1392 of file rtl8139.c.

References bit, and crc.

static int mdio_read struct device *  dev,
int  phy_id,
int  location
[static]
 

Definition at line 601 of file rtl8139.c.

References i, inb, inw, MDIO_CLK, MDIO_DATA_IN, MDIO_DATA_OUT, mdio_delay, MDIO_DIR, mdio_sync(), MII_SMI, and outb.

Here is the call graph for this function:

static void mdio_sync long  mdio_addr  )  [static]
 

Definition at line 589 of file rtl8139.c.

References i, MDIO_CLK, mdio_delay, MDIO_WRITE1, and outb.

static void mdio_write struct device *  dev,
int  phy_id,
int  location,
int  val
[static]
 

Definition at line 634 of file rtl8139.c.

References i, MDIO_CLK, mdio_delay, mdio_sync(), MDIO_WRITE0, MDIO_WRITE1, MII_SMI, outb, and outw.

Here is the call graph for this function:

static int mii_ioctl struct device *  dev,
struct ifreq rq,
int  cmd
[static]
 

Definition at line 1352 of file rtl8139.c.

References CAP_NET_ADMIN, capable, data, EOPNOTSUPP, EPERM, mdio_read(), mdio_write(), rtl8129_private::phys, SIOCDEVPRIVATE, tp, u16, and x1f.

Here is the call graph for this function:

static int read_eeprom long  ioaddr,
int  location
[static]
 

Definition at line 536 of file rtl8139.c.

References Cfg9346, EE_CS, EE_DATA_READ, EE_DATA_WRITE, EE_ENB, EE_READ_CMD, EE_SHIFT_CLK, eeprom_delay, i, inb, outb, and read_cmd.

static int rtl8129_close struct device *  dev  )  [static]
 

Definition at line 1307 of file rtl8139.c.

References Cfg9346, ChipCmd, Config1, del_timer(), dev_free_skb, free_irq(), HltClk, i, inl, IntrMask, IntrStatus, inw, ioaddr, KERN_DEBUG, kfree(), MOD_DEC_USE_COUNT, NUM_TX_DESC, outb, outl, outw, printk, rtl8129_debug, rtl8129_private::rx_ring, RxMissed, rtl8129_private::stats, rtl8129_private::timer, tp, rtl8129_private::tx_bufs, rtl8129_private::tx_skbuff, x00, and x03.

Referenced by rtl8129_probe1().

Here is the call graph for this function:

static struct enet_statistics * rtl8129_get_stats struct device *  dev  )  [static]
 

Definition at line 1375 of file rtl8139.c.

References inl, ioaddr, outl, RxMissed, rtl8129_private::stats, and tp.

Referenced by rtl8129_probe1().

static void rtl8129_init_ring struct device *  dev  )  [static]
 

Definition at line 944 of file rtl8139.c.

References rtl8129_private::cur_rx, rtl8129_private::cur_tx, rtl8129_private::dirty_tx, i, NUM_TX_DESC, tp, rtl8129_private::tx_buf, TX_BUF_SIZE, rtl8129_private::tx_bufs, rtl8129_private::tx_full, and rtl8129_private::tx_skbuff.

Referenced by rtl8129_open().

static void rtl8129_interrupt int  irq,
void *  dev_instance,
struct pt_regs regs
[static]
 

Definition at line 1013 of file rtl8139.c.

References Cfg9346, rtl8129_private::chip_id, ChipCmd, clear_bit, CmdRxEnb, CmdTxEnb, Config1, CSCR, CSCR_LinkChangeBit, rtl8129_private::cur_rx, rtl8129_private::cur_tx, dev, dev_free_skb, device, rtl8129_private::dirty_tx, entry, rtl8129_private::full_duplex, HAS_LNK_CHNG, inl, IntrStatus, inw, ioaddr, KERN_DEBUG, KERN_ERR, KERN_NOTICE, KERN_WARNING, mark_bh, max_interrupt_work, NET_BH, NUM_TX_DESC, NWayLPAR, outb, outl, outw, rtl8129_private::pci_bus, PCI_COMMAND, rtl8129_private::pci_devfn, pcibios_read_config_dword(), PCIErr, PCSTimeout, printk, rtl8129_debug, rtl8129_rx(), rtl_cap_tbl, RX_BUF_LEN, RX_BUF_LEN_IDX, RX_DMA_BURST, RX_FIFO_THRESH, RxBufAddr, RxBufPtr, RxConfig, RxErr, RxFIFOOver, RxMissed, RxOK, RxOverflow, RxUnderrun, rtl8129_private::stats, status, test_and_set_bit, tp, TX_DMA_BURST, rtl8129_private::tx_flag, rtl8129_private::tx_full, rtl8129_private::tx_skbuff, TxAborted, TxCarrierLost, TxConfig, TxErr, TxOK, TxOutOfWindow, TxStatOK, TxStatus0, TxUnderrun, u32, x00, x20, x60, xffff, and xffffffff.

Referenced by rtl8129_open(), and rtl8129_timer().

Here is the call graph for this function:

static int rtl8129_open struct device *  dev  )  [static]
 

Definition at line 667 of file rtl8139.c.

References add_timer(), Cfg9346, rtl8129_private::chip_id, ChipCmd, CmdReset, CmdRxEnb, CmdTxEnb, Config1, timer_list::data, rtl8129_private::duplex_lock, EAGAIN, ENOMEM, timer_list::expires, free_irq(), rtl8129_private::full_duplex, timer_list::function, GPPinData, HAS_MII_XCVR, HZ, i, inb, init_timer(), IntrMask, ioaddr, KERN_DEBUG, KERN_ERR, KERN_INFO, kfree(), kmalloc(), long, MAC0, mdio_read(), MOD_INC_USE_COUNT, NULL, NUM_TX_DESC, outb, outl, outw, PCIErr, PCSTimeout, rtl8129_private::phys, printk, request_irq(), rtl8129_debug, rtl8129_init_ring(), rtl8129_interrupt(), rtl8129_timer(), rtl_cap_tbl, RUN_AT, RX_BUF_LEN, RX_BUF_LEN_IDX, RX_DMA_BURST, RX_FIFO_THRESH, rtl8129_private::rx_ring, RxBuf, RxConfig, RxErr, RxFIFOOver, RxMissed, RxOK, RxOverflow, RxUnderrun, SA_SHIRQ, set_rx_mode(), rtl8129_private::timer, tp, TX_BUF_SIZE, rtl8129_private::tx_bufs, TX_DMA_BURST, TX_FIFO_THRESH, rtl8129_private::tx_flag, TxConfig, TxErr, TxOK, u16, virt_to_bus, x00, x20, x60, and xffff.

Referenced by rtl8129_probe1().

Here is the call graph for this function:

static struct device * rtl8129_probe1 int  pci_bus,
int  pci_devfn,
struct device *  dev,
long  ioaddr,
int  irq,
int  chp_idx,
int  fnd_cnt
[static]
 

Definition at line 408 of file rtl8139.c.

References Cfg9346, Config1, full_duplex, HAS_MII_XCVR, HltClk, i, inb, init_etherdev(), KERN_INFO, kmalloc(), le16_to_cpu, MAC0, MAX_UNITS, mdio_read(), mdio_write(), memset, mii_ioctl(), mii_status(), pci_id_info::name, outb, phys, printk, read_eeprom(), request_region, rtl8129_close(), rtl8129_debug, rtl8129_get_stats(), rtl8129_open(), rtl8129_start_xmit(), rtl_cap_tbl, set_rx_mode(), tp, u16, version, x00, x03, and xffff.

Here is the call graph for this function:

static int rtl8129_rx struct device *  dev  )  [static]
 

Definition at line 1196 of file rtl8139.c.

References ChipCmd, CmdRxEnb, CmdTxEnb, rtl8129_private::cur_rx, sk_buff::dev, eth_copy_and_sum(), eth_type_trans(), i, inb, inw, ioaddr, KERN_DEBUG, KERN_NOTICE, KERN_WARNING, le32_to_cpu, memcpy, memset, netif_rx(), NULL, outb, outl, outw, printk, sk_buff::protocol, rtl8129_debug, RX_BUF_LEN, RX_BUF_LEN_IDX, RX_DMA_BURST, RX_FIFO_THRESH, rtl8129_private::rx_ring, rx_ring, RxBadAlign, RxBadSymbol, RxBufAddr, RxBufPtr, RxConfig, RxCRCErr, RxRunt, RxTooLong, rtl8129_private::stats, tp, u16, u32, and xcc.

Referenced by rtl8129_interrupt().

Here is the call graph for this function:

static int rtl8129_start_xmit struct sk_buff skb,
struct device *  dev
[static]
 

Definition at line 960 of file rtl8139.c.

References clear_bit, rtl8129_private::cur_tx, sk_buff::data, rtl8129_private::dirty_tx, entry, ETH_ZLEN, ioaddr, jiffies, KERN_DEBUG, sk_buff::len, memcpy, NULL, NUM_TX_DESC, outl, printk, rtl8129_debug, rtl8129_tx_timeout(), test_and_set_bit, tp, rtl8129_private::tx_buf, rtl8129_private::tx_flag, rtl8129_private::tx_full, rtl8129_private::tx_skbuff, TX_TIMEOUT, TxAddr0, TxStatus0, and virt_to_bus.

Referenced by rtl8129_probe1().

Here is the call graph for this function:

static void rtl8129_timer unsigned long  data  )  [static]
 

Definition at line 763 of file rtl8139.c.

References add_timer(), Cfg9346, rtl8129_private::chip_id, Config0, Config1, CSCR, CSCR_LinkDownCmd, CSCR_LinkDownOffCmd, CSCR_LinkOKBit, CSCR_LinkStatusBits, dev, device, rtl8129_private::duplex_lock, timer_list::expires, FIFOTMS, rtl8129_private::full_duplex, GPPinData, HAS_MII_XCVR, HZ, inb, inl, IntrMask, IntrStatus, inw, ioaddr, jiffies, KERN_DEBUG, KERN_ERR, KERN_INFO, mdio_read(), next_tick, NWayLPAR, outb, outl, outw, PARA78, PARA78_default, PARA7c, PARA7c_default, PARA7c_xxx, param, rtl8129_private::phys, printk, rtl8129_debug, rtl8129_interrupt(), rtl8129_tx_timeout(), rtl_cap_tbl, RUN_AT, RxEarlyStatus, RxOK, status, rtl8129_private::timer, tp, rtl8129_private::twist_cnt, rtl8129_private::twistie, TX_TIMEOUT, TxOK, x00, x1000, x20, x60, and xffff.

Referenced by rtl8129_open().

Here is the call graph for this function: