Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
r6040.c File Reference
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/crc32.h>
#include <linux/spinlock.h>
#include <linux/bitops.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/uaccess.h>
#include <linux/phy.h>
#include <asm/processor.h>

Go to the source code of this file.

Data Structures

struct  r6040_descriptor
 
struct  r6040_private
 

Macros

#define DRV_NAME   "r6040"
 
#define DRV_VERSION   "0.28"
 
#define DRV_RELDATE   "07Oct2011"
 
#define TX_TIMEOUT   (6000 * HZ / 1000)
 
#define R6040_IO_SIZE   256
 
#define MAX_MAC   2
 
#define MCR0   0x00 /* Control register 0 */
 
#define MCR0_RCVEN   0x0002 /* Receive enable */
 
#define MCR0_PROMISC   0x0020 /* Promiscuous mode */
 
#define MCR0_HASH_EN   0x0100 /* Enable multicast hash table function */
 
#define MCR0_XMTEN   0x1000 /* Transmission enable */
 
#define MCR0_FD   0x8000 /* Full/Half duplex */
 
#define MCR1   0x04 /* Control register 1 */
 
#define MAC_RST   0x0001 /* Reset the MAC */
 
#define MBCR   0x08 /* Bus control */
 
#define MT_ICR   0x0C /* TX interrupt control */
 
#define MR_ICR   0x10 /* RX interrupt control */
 
#define MTPR   0x14 /* TX poll command register */
 
#define TM2TX   0x0001 /* Trigger MAC to transmit */
 
#define MR_BSR   0x18 /* RX buffer size */
 
#define MR_DCR   0x1A /* RX descriptor control */
 
#define MLSR   0x1C /* Last status */
 
#define TX_FIFO_UNDR   0x0200 /* TX FIFO under-run */
 
#define TX_EXCEEDC   0x2000 /* Transmit exceed collision */
 
#define TX_LATEC   0x4000 /* Transmit late collision */
 
#define MMDIO   0x20 /* MDIO control register */
 
#define MDIO_WRITE   0x4000 /* MDIO write */
 
#define MDIO_READ   0x2000 /* MDIO read */
 
#define MMRD   0x24 /* MDIO read data register */
 
#define MMWD   0x28 /* MDIO write data register */
 
#define MTD_SA0   0x2C /* TX descriptor start address 0 */
 
#define MTD_SA1   0x30 /* TX descriptor start address 1 */
 
#define MRD_SA0   0x34 /* RX descriptor start address 0 */
 
#define MRD_SA1   0x38 /* RX descriptor start address 1 */
 
#define MISR   0x3C /* Status register */
 
#define MIER   0x40 /* INT enable register */
 
#define MSK_INT   0x0000 /* Mask off interrupts */
 
#define RX_FINISH   0x0001 /* RX finished */
 
#define RX_NO_DESC   0x0002 /* No RX descriptor available */
 
#define RX_FIFO_FULL   0x0004 /* RX FIFO full */
 
#define RX_EARLY   0x0008 /* RX early */
 
#define TX_FINISH   0x0010 /* TX finished */
 
#define TX_EARLY   0x0080 /* TX early */
 
#define EVENT_OVRFL   0x0100 /* Event counter overflow */
 
#define LINK_CHANGED   0x0200 /* PHY link changed */
 
#define ME_CISR   0x44 /* Event counter INT status */
 
#define ME_CIER   0x48 /* Event counter INT enable */
 
#define MR_CNT   0x50 /* Successfully received packet counter */
 
#define ME_CNT0   0x52 /* Event counter 0 */
 
#define ME_CNT1   0x54 /* Event counter 1 */
 
#define ME_CNT2   0x56 /* Event counter 2 */
 
#define ME_CNT3   0x58 /* Event counter 3 */
 
#define MT_CNT   0x5A /* Successfully transmit packet counter */
 
#define ME_CNT4   0x5C /* Event counter 4 */
 
#define MP_CNT   0x5E /* Pause frame counter register */
 
#define MAR0   0x60 /* Hash table 0 */
 
#define MAR1   0x62 /* Hash table 1 */
 
#define MAR2   0x64 /* Hash table 2 */
 
#define MAR3   0x66 /* Hash table 3 */
 
#define MID_0L   0x68 /* Multicast address MID0 Low */
 
#define MID_0M   0x6A /* Multicast address MID0 Medium */
 
#define MID_0H   0x6C /* Multicast address MID0 High */
 
#define MID_1L   0x70 /* MID1 Low */
 
#define MID_1M   0x72 /* MID1 Medium */
 
#define MID_1H   0x74 /* MID1 High */
 
#define MID_2L   0x78 /* MID2 Low */
 
#define MID_2M   0x7A /* MID2 Medium */
 
#define MID_2H   0x7C /* MID2 High */
 
#define MID_3L   0x80 /* MID3 Low */
 
#define MID_3M   0x82 /* MID3 Medium */
 
#define MID_3H   0x84 /* MID3 High */
 
#define PHY_CC   0x88 /* PHY status change configuration register */
 
#define SCEN   0x8000 /* PHY status change enable */
 
#define PHYAD_SHIFT   8 /* PHY address shift */
 
#define TMRDIV_SHIFT   0 /* Timer divider shift */
 
#define PHY_ST   0x8A /* PHY status register */
 
#define MAC_SM   0xAC /* MAC status machine */
 
#define MAC_SM_RST   0x0002 /* MAC status machine reset */
 
#define MAC_ID   0xBE /* Identifier register */
 
#define TX_DCNT   0x80 /* TX descriptor count */
 
#define RX_DCNT   0x80 /* RX descriptor count */
 
#define MAX_BUF_SIZE   0x600
 
#define RX_DESC_SIZE   (RX_DCNT * sizeof(struct r6040_descriptor))
 
#define TX_DESC_SIZE   (TX_DCNT * sizeof(struct r6040_descriptor))
 
#define MBCR_DEFAULT   0x012A /* MAC Bus Control Register */
 
#define MCAST_MAX   3 /* Max number multicast addresses to filter */
 
#define MAC_DEF_TIMEOUT   2048 /* Default MAC read/write operation timeout */
 
#define DSC_OWNER_MAC   0x8000 /* MAC is the owner of this descriptor */
 
#define DSC_RX_OK   0x4000 /* RX was successful */
 
#define DSC_RX_ERR   0x0800 /* RX PHY error */
 
#define DSC_RX_ERR_DRI   0x0400 /* RX dribble packet */
 
#define DSC_RX_ERR_BUF   0x0200 /* RX length exceeds buffer size */
 
#define DSC_RX_ERR_LONG   0x0100 /* RX length > maximum packet length */
 
#define DSC_RX_ERR_RUNT   0x0080 /* RX packet length < 64 byte */
 
#define DSC_RX_ERR_CRC   0x0040 /* RX CRC error */
 
#define DSC_RX_BCAST   0x0020 /* RX broadcast (no error) */
 
#define DSC_RX_MCAST   0x0010 /* RX multicast (no error) */
 
#define DSC_RX_MCH_HIT   0x0008 /* RX multicast hit in hash table (no error) */
 
#define DSC_RX_MIDH_HIT   0x0004 /* RX MID table hit (no error) */
 
#define DSC_RX_IDX_MID_MASK   3 /* RX mask for the index of matched MIDx */
 
#define RX_INTS   (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)
 
#define TX_INTS   (TX_FINISH)
 
#define INT_MASK   (RX_INTS | TX_INTS)
 

Functions

 MODULE_AUTHOR ("Sten Wang <[email protected]>,""Daniel Gimpelevich <[email protected]>,""Florian Fainelli <[email protected]>")
 
 MODULE_LICENSE ("GPL")
 
 MODULE_DESCRIPTION ("RDC R6040 NAPI PCI FastEthernet driver")
 
 MODULE_VERSION (DRV_VERSION" "DRV_RELDATE)
 
struct r6040_descriptor __aligned (32)
 
 MODULE_DEVICE_TABLE (pci, r6040_pci_tbl)
 
 module_pci_driver (r6040_driver)
 

Variables

u16 status
 
u16 len
 
__le32 buf
 
__le32 ndesc
 
u32 rev1
 
charvbufp
 
struct r6040_descriptorvndescp
 
struct sk_buffskb_ptr
 
u32 rev2
 
struct r6040_private __aligned
 

Macro Definition Documentation

#define DRV_NAME   "r6040"

Definition at line 51 of file r6040.c.

#define DRV_RELDATE   "07Oct2011"

Definition at line 53 of file r6040.c.

#define DRV_VERSION   "0.28"

Definition at line 52 of file r6040.c.

#define DSC_OWNER_MAC   0x8000 /* MAC is the owner of this descriptor */

Definition at line 150 of file r6040.c.

#define DSC_RX_BCAST   0x0020 /* RX broadcast (no error) */

Definition at line 158 of file r6040.c.

#define DSC_RX_ERR   0x0800 /* RX PHY error */

Definition at line 152 of file r6040.c.

#define DSC_RX_ERR_BUF   0x0200 /* RX length exceeds buffer size */

Definition at line 154 of file r6040.c.

#define DSC_RX_ERR_CRC   0x0040 /* RX CRC error */

Definition at line 157 of file r6040.c.

#define DSC_RX_ERR_DRI   0x0400 /* RX dribble packet */

Definition at line 153 of file r6040.c.

#define DSC_RX_ERR_LONG   0x0100 /* RX length > maximum packet length */

Definition at line 155 of file r6040.c.

#define DSC_RX_ERR_RUNT   0x0080 /* RX packet length < 64 byte */

Definition at line 156 of file r6040.c.

#define DSC_RX_IDX_MID_MASK   3 /* RX mask for the index of matched MIDx */

Definition at line 162 of file r6040.c.

#define DSC_RX_MCAST   0x0010 /* RX multicast (no error) */

Definition at line 159 of file r6040.c.

#define DSC_RX_MCH_HIT   0x0008 /* RX multicast hit in hash table (no error) */

Definition at line 160 of file r6040.c.

#define DSC_RX_MIDH_HIT   0x0004 /* RX MID table hit (no error) */

Definition at line 161 of file r6040.c.

#define DSC_RX_OK   0x4000 /* RX was successful */

Definition at line 151 of file r6040.c.

#define EVENT_OVRFL   0x0100 /* Event counter overflow */

Definition at line 102 of file r6040.c.

#define INT_MASK   (RX_INTS | TX_INTS)

Definition at line 174 of file r6040.c.

#define LINK_CHANGED   0x0200 /* PHY link changed */

Definition at line 103 of file r6040.c.

#define MAC_DEF_TIMEOUT   2048 /* Default MAC read/write operation timeout */

Definition at line 147 of file r6040.c.

#define MAC_ID   0xBE /* Identifier register */

Definition at line 137 of file r6040.c.

#define MAC_RST   0x0001 /* Reset the MAC */

Definition at line 72 of file r6040.c.

#define MAC_SM   0xAC /* MAC status machine */

Definition at line 135 of file r6040.c.

#define MAC_SM_RST   0x0002 /* MAC status machine reset */

Definition at line 136 of file r6040.c.

#define MAR0   0x60 /* Hash table 0 */

Definition at line 114 of file r6040.c.

#define MAR1   0x62 /* Hash table 1 */

Definition at line 115 of file r6040.c.

#define MAR2   0x64 /* Hash table 2 */

Definition at line 116 of file r6040.c.

#define MAR3   0x66 /* Hash table 3 */

Definition at line 117 of file r6040.c.

#define MAX_BUF_SIZE   0x600

Definition at line 141 of file r6040.c.

#define MAX_MAC   2

Definition at line 62 of file r6040.c.

#define MBCR   0x08 /* Bus control */

Definition at line 73 of file r6040.c.

#define MBCR_DEFAULT   0x012A /* MAC Bus Control Register */

Definition at line 144 of file r6040.c.

#define MCAST_MAX   3 /* Max number multicast addresses to filter */

Definition at line 145 of file r6040.c.

#define MCR0   0x00 /* Control register 0 */

Definition at line 65 of file r6040.c.

#define MCR0_FD   0x8000 /* Full/Half duplex */

Definition at line 70 of file r6040.c.

#define MCR0_HASH_EN   0x0100 /* Enable multicast hash table function */

Definition at line 68 of file r6040.c.

#define MCR0_PROMISC   0x0020 /* Promiscuous mode */

Definition at line 67 of file r6040.c.

#define MCR0_RCVEN   0x0002 /* Receive enable */

Definition at line 66 of file r6040.c.

#define MCR0_XMTEN   0x1000 /* Transmission enable */

Definition at line 69 of file r6040.c.

#define MCR1   0x04 /* Control register 1 */

Definition at line 71 of file r6040.c.

#define MDIO_READ   0x2000 /* MDIO read */

Definition at line 86 of file r6040.c.

#define MDIO_WRITE   0x4000 /* MDIO write */

Definition at line 85 of file r6040.c.

#define ME_CIER   0x48 /* Event counter INT enable */

Definition at line 105 of file r6040.c.

#define ME_CISR   0x44 /* Event counter INT status */

Definition at line 104 of file r6040.c.

#define ME_CNT0   0x52 /* Event counter 0 */

Definition at line 107 of file r6040.c.

#define ME_CNT1   0x54 /* Event counter 1 */

Definition at line 108 of file r6040.c.

#define ME_CNT2   0x56 /* Event counter 2 */

Definition at line 109 of file r6040.c.

#define ME_CNT3   0x58 /* Event counter 3 */

Definition at line 110 of file r6040.c.

#define ME_CNT4   0x5C /* Event counter 4 */

Definition at line 112 of file r6040.c.

#define MID_0H   0x6C /* Multicast address MID0 High */

Definition at line 120 of file r6040.c.

#define MID_0L   0x68 /* Multicast address MID0 Low */

Definition at line 118 of file r6040.c.

#define MID_0M   0x6A /* Multicast address MID0 Medium */

Definition at line 119 of file r6040.c.

#define MID_1H   0x74 /* MID1 High */

Definition at line 123 of file r6040.c.

#define MID_1L   0x70 /* MID1 Low */

Definition at line 121 of file r6040.c.

#define MID_1M   0x72 /* MID1 Medium */

Definition at line 122 of file r6040.c.

#define MID_2H   0x7C /* MID2 High */

Definition at line 126 of file r6040.c.

#define MID_2L   0x78 /* MID2 Low */

Definition at line 124 of file r6040.c.

#define MID_2M   0x7A /* MID2 Medium */

Definition at line 125 of file r6040.c.

#define MID_3H   0x84 /* MID3 High */

Definition at line 129 of file r6040.c.

#define MID_3L   0x80 /* MID3 Low */

Definition at line 127 of file r6040.c.

#define MID_3M   0x82 /* MID3 Medium */

Definition at line 128 of file r6040.c.

#define MIER   0x40 /* INT enable register */

Definition at line 94 of file r6040.c.

#define MISR   0x3C /* Status register */

Definition at line 93 of file r6040.c.

#define MLSR   0x1C /* Last status */

Definition at line 80 of file r6040.c.

#define MMDIO   0x20 /* MDIO control register */

Definition at line 84 of file r6040.c.

#define MMRD   0x24 /* MDIO read data register */

Definition at line 87 of file r6040.c.

#define MMWD   0x28 /* MDIO write data register */

Definition at line 88 of file r6040.c.

#define MP_CNT   0x5E /* Pause frame counter register */

Definition at line 113 of file r6040.c.

#define MR_BSR   0x18 /* RX buffer size */

Definition at line 78 of file r6040.c.

#define MR_CNT   0x50 /* Successfully received packet counter */

Definition at line 106 of file r6040.c.

#define MR_DCR   0x1A /* RX descriptor control */

Definition at line 79 of file r6040.c.

#define MR_ICR   0x10 /* RX interrupt control */

Definition at line 75 of file r6040.c.

#define MRD_SA0   0x34 /* RX descriptor start address 0 */

Definition at line 91 of file r6040.c.

#define MRD_SA1   0x38 /* RX descriptor start address 1 */

Definition at line 92 of file r6040.c.

#define MSK_INT   0x0000 /* Mask off interrupts */

Definition at line 95 of file r6040.c.

#define MT_CNT   0x5A /* Successfully transmit packet counter */

Definition at line 111 of file r6040.c.

#define MT_ICR   0x0C /* TX interrupt control */

Definition at line 74 of file r6040.c.

#define MTD_SA0   0x2C /* TX descriptor start address 0 */

Definition at line 89 of file r6040.c.

#define MTD_SA1   0x30 /* TX descriptor start address 1 */

Definition at line 90 of file r6040.c.

#define MTPR   0x14 /* TX poll command register */

Definition at line 76 of file r6040.c.

#define PHY_CC   0x88 /* PHY status change configuration register */

Definition at line 130 of file r6040.c.

#define PHY_ST   0x8A /* PHY status register */

Definition at line 134 of file r6040.c.

#define PHYAD_SHIFT   8 /* PHY address shift */

Definition at line 132 of file r6040.c.

#define R6040_IO_SIZE   256

Definition at line 59 of file r6040.c.

#define RX_DCNT   0x80 /* RX descriptor count */

Definition at line 140 of file r6040.c.

#define RX_DESC_SIZE   (RX_DCNT * sizeof(struct r6040_descriptor))

Definition at line 142 of file r6040.c.

#define RX_EARLY   0x0008 /* RX early */

Definition at line 99 of file r6040.c.

#define RX_FIFO_FULL   0x0004 /* RX FIFO full */

Definition at line 98 of file r6040.c.

#define RX_FINISH   0x0001 /* RX finished */

Definition at line 96 of file r6040.c.

#define RX_INTS   (RX_FIFO_FULL | RX_NO_DESC | RX_FINISH)

Definition at line 172 of file r6040.c.

#define RX_NO_DESC   0x0002 /* No RX descriptor available */

Definition at line 97 of file r6040.c.

#define SCEN   0x8000 /* PHY status change enable */

Definition at line 131 of file r6040.c.

#define TM2TX   0x0001 /* Trigger MAC to transmit */

Definition at line 77 of file r6040.c.

#define TMRDIV_SHIFT   0 /* Timer divider shift */

Definition at line 133 of file r6040.c.

#define TX_DCNT   0x80 /* TX descriptor count */

Definition at line 139 of file r6040.c.

#define TX_DESC_SIZE   (TX_DCNT * sizeof(struct r6040_descriptor))

Definition at line 143 of file r6040.c.

#define TX_EARLY   0x0080 /* TX early */

Definition at line 101 of file r6040.c.

#define TX_EXCEEDC   0x2000 /* Transmit exceed collision */

Definition at line 82 of file r6040.c.

#define TX_FIFO_UNDR   0x0200 /* TX FIFO under-run */

Definition at line 81 of file r6040.c.

#define TX_FINISH   0x0010 /* TX finished */

Definition at line 100 of file r6040.c.

#define TX_INTS   (TX_FINISH)

Definition at line 173 of file r6040.c.

#define TX_LATEC   0x4000 /* Transmit late collision */

Definition at line 83 of file r6040.c.

#define TX_TIMEOUT   (6000 * HZ / 1000)

Definition at line 56 of file r6040.c.

Function Documentation

struct r6040_descriptor __aligned ( 32  )
MODULE_AUTHOR ( "Sten Wang <[email protected] ,
""Daniel Gimpelevich< daniel @gimpelevich.san-francisco.ca.us >  ,
""Florian Fainelli< florian @openwrt.org >"   
)
MODULE_DESCRIPTION ( "RDC R6040 NAPI PCI FastEthernet driver )
MODULE_DEVICE_TABLE ( pci  ,
r6040_pci_tbl   
)
MODULE_LICENSE ( "GPL"  )
module_pci_driver ( r6040_driver  )
MODULE_VERSION ( DRV_VERSION" "  DRV_RELDATE)

Variable Documentation

struct r6040_private __aligned

Definition at line 187 of file r6040.c.

u16 len

Definition at line 186 of file r6040.c.

__le32 ndesc

Definition at line 188 of file r6040.c.

u32 rev1

Definition at line 189 of file r6040.c.

u32 rev2

Definition at line 193 of file r6040.c.

struct sk_buff* skb_ptr

Definition at line 192 of file r6040.c.

Definition at line 186 of file r6040.c.

char* vbufp

Definition at line 190 of file r6040.c.

Definition at line 191 of file r6040.c.