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

Go to the source code of this file.

Data Structures

struct  chip_info
 
struct  hamachi_desc
 
struct  hamachi_private
 

Macros

#define DRV_NAME   "hamachi"
 
#define DRV_VERSION   "2.1"
 
#define DRV_RELDATE   "Sept 11, 2006"
 
#define final_version
 
#define hamachi_debug   debug
 
#define MAX_UNITS   8 /* More are supported, limit only on options */
 
#define TX_RING_SIZE   64
 
#define RX_RING_SIZE   512
 
#define TX_TOTAL_SIZE   TX_RING_SIZE*sizeof(struct hamachi_desc)
 
#define RX_TOTAL_SIZE   RX_RING_SIZE*sizeof(struct hamachi_desc)
 
#define RX_CHECKSUM
 
#define TX_TIMEOUT   (5*HZ)
 
#define IP_MF   0x2000 /* IP more frags from <netinet/ip.h> */
 
#define IP_OFFSET   2
 
#define RUN_AT(x)   (jiffies + (x))
 
#define ADDRLEN   32
 
#define cpu_to_leXX(addr)   cpu_to_le32(addr)
 
#define leXX_to_cpu(addr)   le32_to_cpu(addr)
 
#define PKT_BUF_SZ   1536
 
#define MAX_FRAME_SIZE   1518
 
#define PRIV_ALIGN   15 /* Required alignment mask */
 
#define MII_CNT   4
 

Enumerations

enum  capability_flags {
  CanHaveMII =1, HasMII =1, FullTxStatus =2, IsGigabit =4,
  HasMulticastBug =8, FullRxStatus =16, HasMACAddrBug =32, DontUseEeprom =64
}
 
enum  hamachi_offsets {
  TxDMACtrl =0x00, TxCmd =0x04, TxStatus =0x06, TxPtr =0x08,
  TxCurPtr =0x10, RxDMACtrl =0x20, RxCmd =0x24, RxStatus =0x26,
  RxPtr =0x28, RxCurPtr =0x30, PCIClkMeas =0x060, MiscStatus =0x066,
  ChipRev =0x68, ChipReset =0x06B, LEDCtrl =0x06C, VirtualJumpers =0x06D,
  GPIO =0x6E, TxChecksum =0x074, RxChecksum =0x076, TxIntrCtrl =0x078,
  RxIntrCtrl =0x07C, InterruptEnable =0x080, InterruptClear =0x084, IntrStatus =0x088,
  EventStatus =0x08C, MACCnfg =0x0A0, FrameGap0 =0x0A2, FrameGap1 =0x0A4,
  MACCnfg2 =0x0B0, RxDepth =0x0B8, FlowCtrl =0x0BC, MaxFrameSize =0x0CE,
  AddrMode =0x0D0, StationAddr =0x0D2, ANCtrl =0x0E0, ANStatus =0x0E2,
  ANXchngCtrl =0x0E4, ANAdvertise =0x0E8, ANLinkPartnerAbility =0x0EA, EECmdStatus =0x0F0,
  EEData =0x0F1, EEAddr =0x0F2, FIFOcfg =0x0F8
}
 
enum  MII_offsets {
  MII_Cmd =0xA6, MII_Addr =0xA8, MII_Wr_Data =0xAA, MII_Rd_Data =0xAC,
  MII_Status =0xAE
}
 
enum  intr_status_bits {
  IntrLinkChange =0xf0000000, IntrStatsMax =0x08000000, IntrAbnormalSummary =0x02000000, IntrGeneralTimer =0x01000000,
  IntrSoftware =0x800000, IntrRxComplQ1Low =0x400000, IntrTxComplQLow =0x200000, IntrPCI =0x100000,
  IntrDMAErr =0x080000, IntrTxDataLow =0x040000, IntrRxComplQ2Low =0x020000, IntrRxDescQ1Low =0x010000,
  IntrNormalSummary =0x8000, IntrTxDone =0x4000, IntrTxDMADone =0x2000, IntrTxEmpty =0x1000,
  IntrEarlyRxQ2 =0x0800, IntrEarlyRxQ1 =0x0400, IntrRxQ2Done =0x0200, IntrRxQ1Done =0x0100,
  IntrRxGFPDead =0x80, IntrRxDescQ2Low =0x40, IntrNoTxCsum =0x20, IntrTxBadID =0x10,
  IntrHiPriTxBadID =0x08, IntrRxGfp =0x04, IntrTxGfp =0x02, IntrPCIPad =0x01,
  IntrRxDone =IntrRxQ2Done | IntrRxQ1Done, IntrRxEmpty =IntrRxDescQ1Low | IntrRxDescQ2Low, IntrNormalMask =0xff00, IntrAbnormalMask =0x3ff00fe,
  IntrSummary =0x0001, IntrPCIErr =0x0002, IntrMACCtrl =0x0008, IntrTxDone =0x0004,
  IntrRxDone =0x0010, IntrRxStart =0x0020, IntrDrvRqst =0x0040, StatsMax =0x0080,
  LinkChange =0x0100, IntrTxDMADone =0x0200, IntrRxDMADone =0x0400, RFCON = 0x00020000,
  RFCOFF = 0x00010000, LSCStatus = 0x00008000, ANCStatus = 0x00004000, FBE = 0x00002000,
  FBEMask = 0x00001800, ParityErr = 0x00000000, TargetErr = 0x00001000, MasterErr = 0x00000800,
  TUNF = 0x00000400, ROVF = 0x00000200, ETI = 0x00000100, ERI = 0x00000080,
  CNTOVF = 0x00000040, RBU = 0x00000020, TBU = 0x00000010, TI = 0x00000008,
  RI = 0x00000004, RxErr = 0x00000002, IntrRxDone =0x01, IntrRxPCIFault =0x02,
  IntrRxPCIErr =0x04, IntrTxDone =0x100, IntrTxPCIFault =0x200, IntrTxPCIErr =0x400,
  LinkChange =0x10000, NegotiationChange =0x20000, StatsMax =0x40000, IntrRxDone =0x01,
  IntrRxInvalid =0x02, IntrRxPCIFault =0x04, IntrRxPCIErr =0x08, IntrTxDone =0x10,
  IntrTxInvalid =0x20, IntrTxPCIFault =0x40, IntrTxPCIErr =0x80, IntrEarlyRx =0x100,
  IntrWakeup =0x200, IntrRxDone = 0x0001, IntrTxDone = 0x0002, IntrRxErr = 0x0004,
  IntrTxError = 0x0008, IntrRxEmpty = 0x0020, IntrPCIErr = 0x0040, IntrStatsMax = 0x0080,
  IntrRxEarly = 0x0100, IntrTxUnderrun = 0x0210, IntrRxOverflow = 0x0400, IntrRxDropped = 0x0800,
  IntrRxNoBuf = 0x1000, IntrTxAborted = 0x2000, IntrLinkChange = 0x4000, IntrRxWakeUp = 0x8000,
  IntrTxDescRace = 0x080000, IntrNormalSummary = IntrRxDone | IntrTxDone, IntrTxErrSummary
}
 
enum  desc_status_bits {
  DescOwned = 0x80000000, DescWholePkt = 0x60000000, DescEndPkt = 0x40000000, DescStartPkt = 0x20000000,
  DescEndRing = 0x02000000, DescUseLink = 0x01000000, RxDescErrorSummary = 0x8000, RxDescCRCError = 0x0002,
  RxDescCollisionSeen = 0x0040, RxDescFrameTooLong = 0x0080, RxDescRunt = 0x0800, RxDescDescErr = 0x4000,
  RxWholePkt = 0x00000300, RxLengthOver2047 = 0x38000010, DescOwn =0x8000, DescEndPacket =0x4000,
  DescEndRing =0x2000, LastFrag =0x80000000, DescIntrOnTx =0x8000, DescIntrOnDMADone =0x80000000,
  DisableAlign = 0x00000001, DescOwn =0x80000000, DescMore =0x40000000, DescIntr =0x20000000,
  DescNoCRC =0x10000000, DescPktOK =0x08000000, DescSizeMask =0xfff, DescTxAbort =0x04000000,
  DescTxFIFO =0x02000000, DescTxCarrier =0x01000000, DescTxDefer =0x00800000, DescTxExcDefer =0x00400000,
  DescTxOOWCol =0x00200000, DescTxExcColl =0x00100000, DescTxCollCount =0x000f0000, DescRxAbort =0x04000000,
  DescRxOver =0x02000000, DescRxDest =0x01800000, DescRxLong =0x00400000, DescRxRunt =0x00200000,
  DescRxInvalid =0x00100000, DescRxCRC =0x00080000, DescRxAlign =0x00040000, DescRxLoop =0x00020000,
  DesRxColl =0x00010000, DescOwn =0x80000000, DescEndPacket =0x40000000, DescEndRing =0x20000000,
  DescIntr =0x10000000, RX_EOP =0x0040, DescOwn =0x8000, DescOwn =0x80000000
}
 

Functions

 MODULE_AUTHOR ("Donald Becker <[email protected]>, Eric Kasten <[email protected]>, Keith Underwood <[email protected]>")
 
 MODULE_DESCRIPTION ("Packet Engines 'Hamachi' GNIC-II Gigabit Ethernet driver")
 
 MODULE_LICENSE ("GPL")
 
 module_param (max_interrupt_work, int, 0)
 
 module_param (mtu, int, 0)
 
 module_param (debug, int, 0)
 
 module_param (min_rx_pkt, int, 0)
 
 module_param (max_rx_gap, int, 0)
 
 module_param (max_rx_latency, int, 0)
 
 module_param (min_tx_pkt, int, 0)
 
 module_param (max_tx_gap, int, 0)
 
 module_param (max_tx_latency, int, 0)
 
 module_param (rx_copybreak, int, 0)
 
 module_param_array (rx_params, int, NULL, 0)
 
 module_param_array (tx_params, int, NULL, 0)
 
 module_param_array (options, int, NULL, 0)
 
 module_param_array (full_duplex, int, NULL, 0)
 
 module_param (force32, int, 0)
 
 MODULE_PARM_DESC (max_interrupt_work,"GNIC-II maximum events handled per interrupt")
 
 MODULE_PARM_DESC (mtu,"GNIC-II MTU (all boards)")
 
 MODULE_PARM_DESC (debug,"GNIC-II debug level (0-7)")
 
 MODULE_PARM_DESC (min_rx_pkt,"GNIC-II minimum Rx packets processed between interrupts")
 
 MODULE_PARM_DESC (max_rx_gap,"GNIC-II maximum Rx inter-packet gap in 8.192 microsecond units")
 
 MODULE_PARM_DESC (max_rx_latency,"GNIC-II time between Rx interrupts in 8.192 microsecond units")
 
 MODULE_PARM_DESC (min_tx_pkt,"GNIC-II minimum Tx packets processed between interrupts")
 
 MODULE_PARM_DESC (max_tx_gap,"GNIC-II maximum Tx inter-packet gap in 8.192 microsecond units")
 
 MODULE_PARM_DESC (max_tx_latency,"GNIC-II time between Tx interrupts in 8.192 microsecond units")
 
 MODULE_PARM_DESC (rx_copybreak,"GNIC-II copy breakpoint for copy-only-tiny-frames")
 
 MODULE_PARM_DESC (rx_params,"GNIC-II min_rx_pkt+max_rx_gap+max_rx_latency")
 
 MODULE_PARM_DESC (tx_params,"GNIC-II min_tx_pkt+max_tx_gap+max_tx_latency")
 
 MODULE_PARM_DESC (options,"GNIC-II Bits 0-3: media type, bits 4-6: as force32, bit 7: half duplex, bit 9 full duplex")
 
 MODULE_PARM_DESC (full_duplex,"GNIC-II full duplex setting(s) (1)")
 
 MODULE_PARM_DESC (force32,"GNIC-II: Bit 0: 32 bit PCI, bit 1: disable parity, bit 2: 64 bit PCI (all boards)")
 
 MODULE_DEVICE_TABLE (pci, hamachi_pci_tbl)
 
 module_init (hamachi_init)
 
 module_exit (hamachi_exit)
 

Macro Definition Documentation

#define ADDRLEN   32

Definition at line 196 of file hamachi.c.

#define cpu_to_leXX (   addr)    cpu_to_le32(addr)

Definition at line 204 of file hamachi.c.

#define DRV_NAME   "hamachi"

Definition at line 29 of file hamachi.c.

#define DRV_RELDATE   "Sept 11, 2006"

Definition at line 31 of file hamachi.c.

#define DRV_VERSION   "2.1"

Definition at line 30 of file hamachi.c.

#define final_version

Definition at line 37 of file hamachi.c.

#define hamachi_debug   debug

Definition at line 38 of file hamachi.c.

#define IP_MF   0x2000 /* IP more frags from <netinet/ip.h> */

Definition at line 181 of file hamachi.c.

#define IP_OFFSET   2

Definition at line 189 of file hamachi.c.

#define leXX_to_cpu (   addr)    le32_to_cpu(addr)

Definition at line 205 of file hamachi.c.

#define MAX_FRAME_SIZE   1518

Definition at line 412 of file hamachi.c.

#define MAX_UNITS   8 /* More are supported, limit only on options */

Definition at line 85 of file hamachi.c.

#define MII_CNT   4

Definition at line 480 of file hamachi.c.

#define PKT_BUF_SZ   1536

Definition at line 406 of file hamachi.c.

#define PRIV_ALIGN   15 /* Required alignment mask */

Definition at line 479 of file hamachi.c.

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

Definition at line 193 of file hamachi.c.

#define RX_CHECKSUM

Definition at line 137 of file hamachi.c.

#define RX_RING_SIZE   512

Definition at line 120 of file hamachi.c.

#define RX_TOTAL_SIZE   RX_RING_SIZE*sizeof(struct hamachi_desc)

Definition at line 122 of file hamachi.c.

#define TX_RING_SIZE   64

Definition at line 119 of file hamachi.c.

#define TX_TIMEOUT   (5*HZ)

Definition at line 141 of file hamachi.c.

#define TX_TOTAL_SIZE   TX_RING_SIZE*sizeof(struct hamachi_desc)

Definition at line 121 of file hamachi.c.

Enumeration Type Documentation

Enumerator:
CanHaveMII 
HasMII 
FullTxStatus 
IsGigabit 
HasMulticastBug 
FullRxStatus 
HasMACAddrBug 
DontUseEeprom 

Definition at line 418 of file hamachi.c.

Enumerator:
DescOwned 
DescWholePkt 
DescEndPkt 
DescStartPkt 
DescEndRing 
DescUseLink 
RxDescErrorSummary 
RxDescCRCError 
RxDescCollisionSeen 
RxDescFrameTooLong 
RxDescRunt 
RxDescDescErr 
RxWholePkt 
RxLengthOver2047 
DescOwn 
DescEndPacket 
DescEndRing 
LastFrag 
DescIntrOnTx 
DescIntrOnDMADone 
DisableAlign 
DescOwn 
DescMore 
DescIntr 
DescNoCRC 
DescPktOK 
DescSizeMask 
DescTxAbort 
DescTxFIFO 
DescTxCarrier 
DescTxDefer 
DescTxExcDefer 
DescTxOOWCol 
DescTxExcColl 
DescTxCollCount 
DescRxAbort 
DescRxOver 
DescRxDest 
DescRxLong 
DescRxRunt 
DescRxInvalid 
DescRxCRC 
DescRxAlign 
DescRxLoop 
DesRxColl 
DescOwn 
DescEndPacket 
DescEndRing 
DescIntr 
RX_EOP 
DescOwn 
DescOwn 

Definition at line 474 of file hamachi.c.

Enumerator:
TxDMACtrl 
TxCmd 
TxStatus 
TxPtr 
TxCurPtr 
RxDMACtrl 
RxCmd 
RxStatus 
RxPtr 
RxCurPtr 
PCIClkMeas 
MiscStatus 
ChipRev 
ChipReset 
LEDCtrl 
VirtualJumpers 
GPIO 
TxChecksum 
RxChecksum 
TxIntrCtrl 
RxIntrCtrl 
InterruptEnable 
InterruptClear 
IntrStatus 
EventStatus 
MACCnfg 
FrameGap0 
FrameGap1 
MACCnfg2 
RxDepth 
FlowCtrl 
MaxFrameSize 
AddrMode 
StationAddr 
ANCtrl 
ANStatus 
ANXchngCtrl 
ANAdvertise 
ANLinkPartnerAbility 
EECmdStatus 
EEData 
EEAddr 
FIFOcfg 

Definition at line 430 of file hamachi.c.

Enumerator:
IntrLinkChange 
IntrStatsMax 
IntrAbnormalSummary 
IntrGeneralTimer 
IntrSoftware 
IntrRxComplQ1Low 
IntrTxComplQLow 
IntrPCI 
IntrDMAErr 
IntrTxDataLow 
IntrRxComplQ2Low 
IntrRxDescQ1Low 
IntrNormalSummary 
IntrTxDone 
IntrTxDMADone 
IntrTxEmpty 
IntrEarlyRxQ2 
IntrEarlyRxQ1 
IntrRxQ2Done 
IntrRxQ1Done 
IntrRxGFPDead 
IntrRxDescQ2Low 
IntrNoTxCsum 
IntrTxBadID 
IntrHiPriTxBadID 
IntrRxGfp 
IntrTxGfp 
IntrPCIPad 
IntrRxDone 
IntrRxEmpty 
IntrNormalMask 
IntrAbnormalMask 
IntrSummary 
IntrPCIErr 
IntrMACCtrl 
IntrTxDone 
IntrRxDone 
IntrRxStart 
IntrDrvRqst 
StatsMax 
LinkChange 
IntrTxDMADone 
IntrRxDMADone 
RFCON 
RFCOFF 
LSCStatus 
ANCStatus 
FBE 
FBEMask 
ParityErr 
TargetErr 
MasterErr 
TUNF 
ROVF 
ETI 
ERI 
CNTOVF 
RBU 
TBU 
TI 
RI 
RxErr 
IntrRxDone 
IntrRxPCIFault 
IntrRxPCIErr 
IntrTxDone 
IntrTxPCIFault 
IntrTxPCIErr 
LinkChange 
NegotiationChange 
StatsMax 
IntrRxDone 
IntrRxInvalid 
IntrRxPCIFault 
IntrRxPCIErr 
IntrTxDone 
IntrTxInvalid 
IntrTxPCIFault 
IntrTxPCIErr 
IntrEarlyRx 
IntrWakeup 
IntrRxDone 
IntrTxDone 
IntrRxErr 
IntrTxError 
IntrRxEmpty 
IntrPCIErr 
IntrStatsMax 
IntrRxEarly 
IntrTxUnderrun 
IntrRxOverflow 
IntrRxDropped 
IntrRxNoBuf 
IntrTxAborted 
IntrLinkChange 
IntrRxWakeUp 
IntrTxDescRace 
IntrNormalSummary 
IntrTxErrSummary 

Definition at line 457 of file hamachi.c.

Enumerator:
MII_Cmd 
MII_Addr 
MII_Wr_Data 
MII_Rd_Data 
MII_Status 

Definition at line 451 of file hamachi.c.

Function Documentation

MODULE_AUTHOR ( "Donald Becker <[email protected] ,
Eric Kasten< kasten @nscl.msu.edu >  ,
Keith Underwood< keithu @parl.clemson.edu >"   
)
MODULE_DESCRIPTION ( "Packet Engines 'Hamachi' GNIC-II Gigabit Ethernet driver )
MODULE_DEVICE_TABLE ( pci  ,
hamachi_pci_tbl   
)
module_exit ( hamachi_exit  )
module_init ( hamachi_init  )
MODULE_LICENSE ( "GPL"  )
module_param ( max_interrupt_work  ,
int  ,
 
)
module_param ( mtu  ,
int  ,
 
)
module_param ( debug  ,
int  ,
 
)
module_param ( min_rx_pkt  ,
int  ,
 
)
module_param ( max_rx_gap  ,
int  ,
 
)
module_param ( max_rx_latency  ,
int  ,
 
)
module_param ( min_tx_pkt  ,
int  ,
 
)
module_param ( max_tx_gap  ,
int  ,
 
)
module_param ( max_tx_latency  ,
int  ,
 
)
module_param ( rx_copybreak  ,
int  ,
 
)
module_param ( force32  ,
int  ,
 
)
module_param_array ( rx_params  ,
int  ,
NULL  ,
 
)
module_param_array ( tx_params  ,
int  ,
NULL  ,
 
)
module_param_array ( options  ,
int  ,
NULL  ,
 
)
module_param_array ( full_duplex  ,
int  ,
NULL  ,
 
)
MODULE_PARM_DESC ( max_interrupt_work  ,
"GNIC-II maximum events handled per interrupt  
)
MODULE_PARM_DESC ( mtu  ,
"GNIC-II MTU (all boards)"   
)
MODULE_PARM_DESC ( debug  ,
"GNIC-II debug level (0-7)"   
)
MODULE_PARM_DESC ( min_rx_pkt  ,
"GNIC-II minimum Rx packets processed between interrupts"   
)
MODULE_PARM_DESC ( max_rx_gap  ,
"GNIC-II maximum Rx inter-packet gap in 8.192 microsecond units  
)
MODULE_PARM_DESC ( max_rx_latency  ,
"GNIC-II time between Rx interrupts in 8.192 microsecond units  
)
MODULE_PARM_DESC ( min_tx_pkt  ,
"GNIC-II minimum Tx packets processed between interrupts"   
)
MODULE_PARM_DESC ( max_tx_gap  ,
"GNIC-II maximum Tx inter-packet gap in 8.192 microsecond units  
)
MODULE_PARM_DESC ( max_tx_latency  ,
"GNIC-II time between Tx interrupts in 8.192 microsecond units  
)
MODULE_PARM_DESC ( rx_copybreak  ,
"GNIC-II copy breakpoint for copy-only-tiny-frames"   
)
MODULE_PARM_DESC ( rx_params  ,
"GNIC-II min_rx_pkt+max_rx_gap+max_rx_latency"   
)
MODULE_PARM_DESC ( tx_params  ,
"GNIC-II min_tx_pkt+max_tx_gap+max_tx_latency"   
)
MODULE_PARM_DESC ( options  ,
"GNIC-II Bits 0-3: media  type,
bits 4-6:as  force32,
bit 7:half  duplex,
bit 9 full duplex  
)
MODULE_PARM_DESC ( full_duplex  ,
"GNIC-II full duplex setting(s) (1)"   
)
MODULE_PARM_DESC ( force32  ,
"GNIC-II: Bit 0: 32 bit  PCI,
bit 1:disable  parity,
bit 2:64 bit PCI(all boards)"   
)