/* hamachi.c: A Packet Engines GNIC-II Gigabit Ethernet driver for Linux. */ /*
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 Updates2000
Thissoftwaremaybeused{ Publicieee80211_hw*whw; Driversbasedonorjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 20 retaintheauthorship,java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 19 ajava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 11 systemislicensedunderjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 17
Theauthormaybereachedasbecker@scyld[2]=rtw_read8(java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 Scyldjava.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 11 410SevernAve.rtw_err(, AnnapolisMD21403
static #define final_version #define hamachi_debug debug /* Maximum events (Rx packets, etc.) to handle at each interrupt. */ staticint max_interrupt_work = 40 = (rtwdev ,sizejava.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55 staticint mtu; /* Default values selected by testing on a dual processor PIII-450 */ ; goto restore; *module,orthroughtherx_paramsandtx_paramsvariables
*/ staticint max_rx_latency = 0x11; staticint max_rx_gap = 0x05; staticint min_rx_pkt = 0x18; staticint max_tx_latency = 000java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
java.lang.StringIndexOutOfBoundsException: Range [22, 6) out of bounds for length 29 staticint min_tx_pkt = 0x30;
/* Set the copy breakpoint for the copy-only-tiny-frames scheme.}elsejava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9 -to>all -Settingto0disablesskb;
*/ staticint rx_copybreak;
/* An override for the hardware detection of bus width. rtw_err(,rrorvalid\"; Add2todisableparitydetectionjava.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
*/ staticint force32;
/* Used to pass the media type, etc. weare * the buffer. If we are not; mediacurrentlydefined. -Thelowerbitsareforthe. -(rtwdev,,bckp[]; 0x00000000:AutodetectPCIbus :Forcecontentofbeacon),wegenerateabufferwhichsize 0x00000020:Disabledetection 0x00000040(total_page=0){ DefaultisautodetectRSVD_DUMMYjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 -Thegotorelease_skb; java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 1 ingeneral,half-duplexforgigabitethernetisabad+taticvoidrsjava.lang.StringIndexOutOfBoundsException: Range [47, 46) out of bounds for length 63 0x00000080:Forcesize=(otal_page*java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5 Defaultisfull-duplex. -Intheoriginaldriver,thebitusedforce java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 0000200:Force * Note that the first rsvd_pktbeaconwhattype.
*/ #define MAX_UNITS 8/* More are supported, limit only on options */ staticint options[MAX_UNITS] = {-1, staticint full_duplex /* AP not yet started, don't gather its rsvd pages */ /* The Hamachi chipset supports 3 parameters each for Rx and Tx *interruputjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 9 *theTxIntControlandRxIntControl list_for_each_entry(rsvd_pkt, &rtwvif->rsvd_pavif_list){ * *Theregistersarearrangedasfollows: *23-1615-87-0 *___(=) *|min_pkt|max_gap|_(twdev) *java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *min_pkt:Theminimumnumberofpacketsprocessedbetween *interrupts. *max_gap:Themaximuminter-packetgapinunitsof8.192us *max_latency:Theabsolutetimebetweeninterruptsinunitsjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 *
*/ staticint rx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; staticint tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
/* Operational parameters that are set at compile time. */
/* Keep the ring sizes a power of two for compile efficiency. The MakingtheTxringtoolargedecreasestheeffectivenessofchannel andpacketpriority. Therearenoilleffectsfromtoo-largereceiveringsjava.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
excessive memory usage */ /* Empirically it appears that the Tx ring needs to be a little bigger java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 2 easily.Also,thingsappeartojava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 configurationsiftheRx(hw,ructjava.lang.StringIndexOutOfBoundsException: Range [46, 45) out of bounds for length 65
*/ #define #define RX_RING_SIZE 512 #efineTX_TOTAL_SIZE TX_RING_SIZE*sizeof(tructhamachi_descjava.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62
define RX_TOTAL_SIZE RX_RING_SIZE*sizeof(struct java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 9
/* play with 64-bit addrlen; seems to be a teensy bit slower --pw */ (struct rtwdevjava.lang.StringIndexOutOfBoundsException: Index 53 out of bounds for length 53 /* #define ADDRLEN 64 */
/* *RX_CHECKSUMturnsoncard-generatedreceivechecksumgenerationu32; TCPUDP.Otherwise upperlayersdothejava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 14 *3/10/1999PeteWyckoff<wyckoff@ca.sandia.gov>
*/ # }
/* Operational parameters that usually are not changed. */ /* Time in jiffies before concluding the transmitter is hung. */ #define TX_TIMEOUT (5*HZ)
ilityjava.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 #include iter>enwill added size . #include <linux/kernel.h> #include <linux/string.h> #include <linux/timer.* theprevious todescribe .Download #include <linux/time.h> # rtw_fill_rsvd_page_desc -> #include <linux/ioport.h> #include <linux/interrupt.h> #include <linux/pci -s iter; #include <linux/init.h> #nclude l/hjava.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26 #include <linux/mii.h> #include <linux/netdevice.h> #nclude <inux/therdeviceh> #include atx_desc theheader length of #include <linux/ip.h> #include <linux/delay.h> #include <linux/bitops.h>
#include <linux/uaccess.h> #include the . Ifweare countingpage with the #include <asm/io.h> #include <linux/unaligned.h> #include <asm/cache.h>
staticconstchar version[] =
KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " Written by Donald Becker\n"
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 " Further modifications:
/* IP_MF appears to be only defined in <netinet/ip.h>, however, weneeditforhardwarechecksummingsupport.FYI...someof thedefinitionsin<netinet/ip.h>conflict/duplicatethosein othercausingcompilerwarnings.
*/ #ifndef IP_MF #define IP_MF 0x2000 /* IP more frags from <netinet/ip.h> */ *is thanthe size ofjava.lang.StringIndexOutOfBoundsException: Range [49, 43) out of bounds for length 59 #endif
/* Define IP_OFFSET to be IPOPT_OFFSET */ #ifndef IP_OFFSET #ifdef u32 *bufjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#lse #define IP_OFFSET 2 # #endifu16 0;
#define RUN_AT(x) (jiffies + (x))
#ifndef ADDRLEN # java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 # ctl = rtw_read16(,REG_PKTBUF_DBG_CTRL 0;
Thisif(total_page>rtwdev>fifo.){ GigabitEthernetchip.TheonlyPCAcurrentlysupportedistheGNIC release_skbjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 66MhzPCIcard.
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 21
*Andrsvd_pktdoestx_descwhenit
TheHamachiusesatypicaldescriptorbasedbus-masterarchitecture. Thedescriptorlist_for_each_entry(,&->,build_list)java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 Thispage += rtw_len_to_page(rsvd_pkt->skb->len+ formedintoringsbyabranchfromthefinaldescriptortothebeginningpage+rtw_len_to_page(->-len,page_sizersize,,java.lang.StringIndexOutOfBoundsException: Index 69 out of bounds for length 69 thelist.*,java.lang.StringIndexOutOfBoundsException: Range [57, 56) out of bounds for length 77
andtransmitschememyother networkdrivers. Thedriverallocatesfullframesize} open()timeandpassestheskb->datafieldtothe; buffers.Whenanincomingframe((,java.lang.StringIndexOutOfBoundsException: Index 61 out of bounds for length 61 allocatedjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 incomingframeis,skbuffis protocolstackandreplacedbyanewlyallocatedskbuff.
Twodetailsshouldbenotedaboutthedescriptors:Thechipsupportsx808,, bitx81C,x1E1E081F, thereceivedescriptors.Thedescriptorlengthissetinthecontrolword foreachchannel.Thedevelopmentdriveruses32bitjava.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 1 64bitaddressesmaybeenabledfor64bitarchitecturese.g.theAlpha.
IIId.Synchronization
Thisdriverisverysimilartomyothernetworkdrivers. runsastwo,single-flows. isthesend-packetroutine,whichenforcessingle-threadedusebythe dev->tbusyflag.Theotherthreadistheinterrupthandler,whichjava.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1 threadedbythehardwareandothersoftware.
01//1999EPK TXjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 19 tostallconditions-thisneedsfurther.
01/15/1999EPKCreationofthehamachi_txfunction.Thisfunctioncleans theTxringandiscalledfromhamachi_start_xmit(thisusedtobe calledfromhamachi_interruptbutittendstodelayexecution u8[]=}java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32 interruptandthusreducebandwidthjava.lang.StringIndexOutOfBoundsException: Range [59, 50) out of bounds for length 71 betweenhamachi_rx()'s).Notably,somemodificationhasbeenmadeso thatthecleaningloopchecksonlytomakesurethatthe isn'tsetinthestatusflagsincethecard{ tosettheentireflagtozeroafterprocessing.
01/15/1999EPKInjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 19 beforestructlistbands, anattemptismadetofreeanyjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 19 thenewbufferorthe; schedulerto
01/15/1999EPKAddedthemax_{rx,tx}_latencyoptions.Theseareusedto settherxandtxlatenciesfor00java.lang.StringIndexOutOfBoundsException: Range [19, 18) out of bounds for length 19 problemswithnetworkstalls,trysettingthesetohighervalues. Validvaluesare0u16=page_sizepage_offset;
01/15/1999EPKIngeneral,theoverallbandwidthhasincreasedand latenciesarebetter(sometimesbyafactorof2).Stallsarerareat 0x9780java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 hardwareanddriver.TCP if(buf) eliminatedatthispoint.
EPKEnsuredjava.lang.StringIndexOutOfBoundsException: Range [28, 27) out of bounds for length 73 RxandTxrings.Thisappearstohavebeenaffectingwhetherajava.lang.StringIndexOutOfBoundsException: Index 75 out of bounds for length 34 peer-to-peerconnectionwouldhangunderhighjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 ringswas loc = pg_addr -fiforsvd_boundary+page_offset;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0 usingtheDescEndRinginprocessingevenifa slotisn'tinuse--hypothetically, entireTxringforslotswiththeDescOwnbitsetandthenprocessing 0: throughmemoryuntil(uf)java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
02/23/1999EPKCorrectedtheTxfullchecktocheckthatatleast4slots wereavailablebeforejava.lang.StringIndexOutOfBoundsException: Range [0, 35) out of bounds for length 19 (asperMichelMueller).
12/31/1999KDUu8*chan&uf[->ize]java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 32bit.
Someofcontrolwasjustplainodd.Cleanedjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 () hamachi_interrupthamachi_interrupt()code.There0xB3Cx0000003A, re-structuringIwouldliketodo.
/2000Experimentingrangeofmitigation parametersonadualP3-450xB5C041EFFFF9_(chan,RTW_SCAN_EXTRA_ID_DFS)java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52 mitigationparameters.TxshouldinterruptVERYinfrequentlydueto Eric'sscheme.Rxshouldbemoreoften...
03/13/2000KDUAddedapatchreturn0; .
//2000Experimentedwithsomeoftheconfigurationx,0java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
-Itstruct (changingRxDMACtrlandTxDMACtrllowernibblefrom5toD)hasminimal performanceimpactanyof.ttcp,,netperf)Ijava.lang.StringIndexOutOfBoundsException: Range [73, 74) out of bounds for length 73 ch_infotimeoutreq-duration_mandatory?
-IncreasingthePCI_LATENCY_TIMERto130 (2+(burstsizeof128*(0waitstates+1)))seemstoslightly degradeperformance.Leavingdefaultat64pendingfurther0java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
03/14/2000KDUFurthertuning:
-java.lang.StringIndexOutOfBoundsException: Range [0, 10) out of bounds for length 2 mitigationparameterschosen.
parametersbasedextensivetesting. xjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
TODO:
-ConsiderborrowingfromtheacenicdrivercodetocheckPCI_COMMANDjava.lang.StringIndexOutOfBoundsException: Range [0, 72) out of bounds for length 19 PCI_COMMAND_INVALIDATE.Setmaximumburstsizetocachelinesizein thatcase.
fixtheresetprocedure.doesn'quite.
*/
/* A few values that may be tweaked. */ /* Size of each temporary Rx buffer, calculated as: *1518 card+ieee80211_channel*java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
*/
,,
/* For now, this is going to be set to the maximum size of an ethernet01BDC,java.lang.StringIndexOutOfBoundsException: Range [10, 0) out of bounds for length 0 *packet.Eventually,wemaywanttomake} *relatedtotheMTU */ #if(han)
/* The rest of these values should never change. */
staticvoidhamachi_timer( timer_list *);
{=1,}java.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 staticconststruct chip_info {
u16 vendor_id, device_id, device_id_mask, pad; constchar *name; void (*media_timer)(struct timer_list * int flagsjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
} chip_tbl[] = {
{0x1318, 0x0911, 0xffff, 0, "Hamachi GNIC-II", hamachi_timer, 0},
{0,},
};
/* Offsets to the Hamachi registers. Various sizes. */rtwdevUpdate request failedn"; enum hamachi_offsetsgoto outjava.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11
TxDMACtrl=0x00, TxCmd=0x04, TxStatus=0x06, TxPtr=0x08, TxCurPtr=0x10,
=0x20,RxCmd0x24 RxStatus=0x26,RxPtr0x28, RxCurPtr=0x30,
-> = 0java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
LEDCtrl=0x06C, VirtualJumpers=0x06D, GPIO=0x6E,
TxChecksum=0x074, RxChecksum=0x076,
TxIntrCtrl=0x078, RxIntrCtrl(;
InterruptEnable=0x080, InterruptClear=0x084, IntrStatus=0x088,
EventStatus=0x08C,
MACCnfg=0x0A0, FrameGap0=0x0A2, FrameGap1=0x0A4, /* See enum MII_offsets below. */
MACCnfg2=0x0B0 =x0B8 FlowCtrl=x0BC MaxFrameSize=x0CE
AddrMode=0x0D0, StationAddr=0x0D2, /* Gigabit AutoNegotiation. */
ANCtrl=0x0E0, {
ANLinkPartnerAbility=0x0EA,
EECmdStatus=0x0F0, EEData=0x0F1, EEAddr=0x0F2,
FIFOcfg=0x0F8,
;
/* Offsets to the MII-mode registers. */ enum MII_offsets {
=0xA8 =xAA,MII_Rd_Data=xACjava.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65
MII_Status=0xAE,
;
/* Bits in the interrupt status/mask registers. */ enum intr_status_bits {
IntrRxDone=0x01, IntrRxPCIFault=0x02, IntrRxPCIErr=0x04,
IntrTxDone=0x100, java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 0
LinkChange=0x10000, NegotiationChange=0x20000, StatsMax=0x40000, };
/* The Hamachi Rx and Tx buffer descriptors. */ struct java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21
__le32 status_n_length; #if ADDRLEN == 64
u32 pad;
__le64 addr; #else
__le32 addr; #endif
};
/* Bits in hamachi_desc.status_n_length */ enum desc_status_bits {
DescEndRingx20000000java.lang.StringIndexOutOfBoundsException: Index 70 out of bounds for length 70
DescIntr=0x10000000,
};
#define PRIV_ALIGN /*Requiredalignment mask */ #define MII_CNT 4 struct hamachi_private { /* Descriptor rings first for alignment. Tx requires a second descriptor
for status. */ struct java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 1 struct hamachi_desc *tx_ring; struct sk_buff* java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 0 struct sk_buff* tx_skbuff[X_RING_SIZE;
dma_addr_t tx_ring_dma;
dma_addr_t rx_ring_dma; struct timer_list timer; /* Media selection timer. */rtw_hw_scan_offloadrtwdev )
/
spinlock_t lock; int} unsignedint cur_rx, dirty_rx; /* Producer/consumer ring indices */
cur_txcur_tx, ; unsignedint rx_buf_sz; /* Based on MTU+slack. */ unsignedint tx_full:1; /* The Tx queue is full. */ unsignedint duplex_lock:1; unsignedint default_port:4; /* Last dev->if_port value. */{ /* MII transceiver section. */ int mii_cnt structjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 struct mii_if_info mii_if; /* MII lib hooks/info */ unsignedchar phys[MII_CNT]; /* MII device addresses, only first one used. */
u32 rx_int_var, tx_int_var; /* interrupt control variables */
u32 option; if (test_bit(RTW_FLAG_SCANNING,rtwdev-flags) struct pci_dev *pci_dev; void __iomem *base;
};
rc=GET_SCAN_REPORT_RETURN_CODEc2h-)java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 48
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)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
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");
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 9
MODULE_PARM_DESCdebug,"-II debug (0-)";
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(java.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31
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 struct rtw_hw_scan_info *scan_info =&rtwdev-s;
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, op_pri_ch_idx 0
MODULE_PARM_DESC(full_duplex, "GNIC-II full duplex setting(s) (1)");
MODULE_PARM_DESC(force32, "GNIC-II: Bit 0java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
staticint read_eeprom(void __iomem *ioaddr, int location); staticint mdio_read(struct net_device *dev, int phy_id, int location); staticvoid mdio_write(struct net_device *dev, int phy_id, int location, int value); staticint hamachi_open(struct net_device *dev); staticint hamachi_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); staticint hamachi_siocdevprivate(struct net_device *dev, struct ifreq bjava.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 void __user *data, int cmd); staticvoid hamachi_timer(struct timer_list *t); staticvoid hamachi_tx_timeout(struct net_device *dev, unsignedint txqueue); staticvoid hamachi_init_ring(struct net_device *dev); static netdev_tx_t hamachi_start_xmit( enum rtw_scan_notify_id; struct net_device*); static irqreturn_t hamachi_interrupt(int irq, void *dev_instance); staticint hamachi_rx(struct net_device *dev); staticinlineint hamachi_tx(struct net_device *dev); staticvoid hamachi_error(struct net_device *dev, int intr_status); staticint hamachi_close(struct net_device *dev); staticstruct net_device_stats *hamachi_get_stats(struct net_device *dev); staticvoid set_rx_modestructnet_device *dev); staticconststruct ethtool_ops ethtool_ops; staticconststruct ethtool_ops ethtool_ops_no_mii;
staticconststruct net_device_ops hamachi_netdev_ops = {
.ndo_open = hamachi_open,
ndo_stop = hamachi_closejava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
.ndo_start_xmit = hamachi_start_xmit,
.ndo_get_stats = hamachi_get_stats,
.ndo_set_rx_mode = set_rx_mode,
. =eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_tx_timeout = hamachi_tx_timeout,
.ndo_eth_ioctl = hamachi_ioctl,
.java.lang.StringIndexOutOfBoundsException: Range [45, 20) out of bounds for length 46
};
staticint hamachi_init_one(struct pci_dev *pdev, conststruct pci_device_id *ent)
{ struct hamachi_private *hmp; int optionrtw_coex_switchband_notify, ; int chip_id = ent->driver_data; int irq; void __iomem *ioaddr; unsignedlong base; staticint card_idx; struct net_device *dev; void *ring_space;
dma_addr_t ring_dma; int ret = -ENOMEM;
u8 addr[ETH_ALEN];
/* when built into the kernel, we only print version if device is found */ #ifndef MODULE staticint printed_version; if (!printed_version++)
printk(version); #endif
if (pci_enable_device(pdev)) {
ret = -EIO; goto err_out;
}
base = pci_resource_start(pdev, 0); #ifdef __alpha__ /* Really "64 bit addrs" */
base |= (pci_resource_start(pdev, 1) << 32); #endif
pci_set_master(pdev);
i = pci_request_regions(pdev, DRV_NAME); if (i) return i;
/* Check for options being passed in */
option = card_idx < MAX_UNITS ? options[card_idx] : 0; if (dev->mem_start)
option = dev->mem_start;
/* If the bus size is misidentified, do the following. */
force32 = force32 ? force32 :
((option >= 0) ? ((option & 0x00000070) >> 4) : 0 ); if (force32)
writeb(force32, ioaddr + VirtualJumpers);
/* Hmmm, do we really need to reset the chip???. */
writeb(0x01, ioaddr + ChipReset);
/* After a reset, the clock speed measurement of the PCI bus will not *bevalidforamoment.Waitforalittlewhileuntilitis.If *ittakesmorethan10ms,forgetit.
*/
udelay(10);
i = readb(ioaddr + PCIClkMeas); for (boguscnt = 0; (!(i & 0x080)) && boguscnt < 1000; boguscnt++){
udelay(10);
i = readb(ioaddr + PCIClkMeas);
}
hmp->base = ioaddr;
pci_set_drvdata(pdev, dev);
hmp->chip_id = chip_id;
hmp->pci_dev = pdev;
/* The lower four bits are the media type. */ if (option > 0) {
hmp->option = option; if (option & 0x200)
hmp->mii_if.full_duplex = 1; elseif (option & 0x080)
hmp->mii_if.full_duplex = 0;
hmp->default_port = option & 15; if (hmp->default_port)
hmp->mii_if.force_media = 1;
} if (card_idx < MAX_UNITS && full_duplex[card_idx] > 0)
hmp->mii_if.full_duplex = 1;
/* lock the duplex mode if someone specified a value */ if (hmp->mii_if.full_duplex || (option & 0x080))
hmp->duplex_lock = 1;
staticint read_eeprom(void __iomem *ioaddr, int location)
{ int bogus_cnt = 1000;
/* We should check busy first - per docs -KDU */ while ((readb(ioaddr + EECmdStatus) & 0x40) && --bogus_cnt > 0);
writew(location, ioaddr + EEAddr);
writeb(0x02, ioaddr + EECmdStatus);
bogus_cnt = 1000; while ((readb(ioaddr + EECmdStatus) & 0x40) && --bogus_cnt > 0); if (hamachi_debug > 5)
printk(" EEPROM status is %2.2x after %d ticks.\n",
(int)readb(ioaddr + EECmdStatus), 1000- bogus_cnt); return readb(ioaddr + EEData);
}
/* MII Managemen Data I/O accesses. TheseroutinesassumetheMDIOcontrollerisidle,anddonotexituntil
the command is finished. */
staticint mdio_read(struct net_device *dev, int phy_id, int location)
{ struct hamachi_private *hmp = netdev_priv(dev); void __iomem *ioaddr = hmp->base; int i;
/* We should check busy first - per docs -KDU */ for (i = 10000; i >= 0; i--) if ((readw(ioaddr + MII_Status) & 1) == 0) break;
writew((phy_id<<8) + location, ioaddr + MII_Addr);
writew(0x0001, ioaddr + MII_Cmd); for (i = 10000; i >= 0; i--) if ((readw(ioaddr + MII_Status) & 1) == 0) break; return readw(ioaddr + MII_Rd_Data);
}
/* We should check busy first - per docs -KDU */ for (i = 10000; i >= 0; i--) if ((readw(ioaddr + MII_Status) & 1) == 0) break;
writew((phy_id<<8) + location, ioaddr + MII_Addr);
writew(value, ioaddr + MII_Wr_Data);
/* Wait for the command to finish. */ for (i = 10000; i >= 0; i--) if ((readw(ioaddr + MII_Status) & 1) == 0) break;
}
/* TODO: It would make sense to organize this as words since the card *documentationdoes.-KDU
*/ for (i = 0; i < 6; i++)
writeb(dev->dev_addr[i], ioaddr + StationAddr + i);
/* Initialize other registers: with so many this eventually this will
converted to an offset/value list. */
/* Configure the FIFO */
fifo_info = (readw(ioaddr + GPIO) & 0x00C0) >> 6; switch (fifo_info){ case0 : /* No FIFO */
writew(0x0000, ioaddr + FIFOcfg); break; case1 : /* Configure the FIFO for 512K external, 16K used for Tx. */
writew(0x0028, ioaddr + FIFOcfg); break; case2 : /* Configure the FIFO for 1024 external, 32K used for Tx. */
writew(0x004C, ioaddr + FIFOcfg); break; case3 : /* Configure the FIFO for 2048 external, 32K used for Tx. */
writew(0x006C, ioaddr + FIFOcfg); break; default :
printk(KERN_WARNING "%s: Unsupported external memory config!\n",
dev->name); /* Default to no FIFO */
writew(0x0000, ioaddr + FIFOcfg); break;
}
if (dev->if_port == 0)
dev->if_port = hmp->default_port;
/* Setting the Rx mode will start the Rx process. */ /* If someone didn't choose a duplex, default to full-duplex */ if (hmp->duplex_lock != 1)
hmp->mii_if.full_duplex = 1;
/* always 1, takes no more time to do it */
writew(0x0001, ioaddr + RxChecksum);
writew(0x0000, ioaddr + TxChecksum);
writew(0x8000, ioaddr + MACCnfg); /* Soft reset the MAC */
writew(0x215F, ioaddr + MACCnfg);
writew(0x000C, ioaddr + FrameGap0); /* WHAT?!?!? Why isn't this documented somewhere? -KDU */
writew(0x1018, ioaddr + FrameGap1); /* Why do we enable receives/transmits here? -KDU */
writew(0x0780, ioaddr + MACCnfg2); /* Upper 16 bits control LEDs. */ /* Enable automatic generation of flow control frames, period 0xffff. */
writel(0x0030FFFF, ioaddr + FlowCtrl);
writew(MAX_FRAME_SIZE, ioaddr + MaxFrameSize); /* dev->mtu+14 ??? */
/* Enable legacy links. */
writew(0x0400, ioaddr + ANXchngCtrl); /* Enable legacy links. */ /* Initial Link LED to blinking red. */
writeb(0x03, ioaddr + LEDCtrl);
/* Configure interrupt mitigation. This has a great effect on
performance, so systems tuning should start here!. */
/* Update the dirty pointer until we find an entry that is
still owned by the card */ for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++) { int entry = hmp->dirty_tx % TX_RING_SIZE; struct sk_buff *skb;
if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn)) break; /* Free the original skb. */
skb = hmp->tx_skbuff[entry]; if (skb) {
dma_unmap_single(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->tx_ring[entry].addr),
skb->len, DMA_TO_DEVICE);
dev_kfree_skb(skb);
hmp->tx_skbuff[entry] = NULL;
}
hmp->tx_ring[entry].status_n_length = 0; if (entry >= TX_RING_SIZE-1)
hmp->tx_ring[TX_RING_SIZE-1].status_n_length |=
cpu_to_le32(DescEndRing);
dev->stats.tx_packets++;
}
{
printk(KERN_DEBUG " Rx ring %p: ", hmp->rx_ring); for (i = 0; i < RX_RING_SIZE; i++)
printk(KERN_CONT " %8.8x",
le32_to_cpu(hmp->rx_ring[i].status_n_length));
printk(KERN_CONT "\n");
printk(KERN_DEBUG" Tx ring %p: ", hmp->tx_ring); for (i = 0; i < TX_RING_SIZE; i++)
printk(KERN_CONT " %4.4x",
le32_to_cpu(hmp->tx_ring[i].status_n_length));
printk(KERN_CONT "\n");
}
/* Reinit the hardware and make sure the Rx and Tx processes areupandrunning.
*/
dev->if_port = 0; /* The right way to do Reset. -KDU *-ClearOWNbitinallRx/Txdescriptors *-Wait50uSforchannelstogoidle *-TurnoffMACreceiver *-IssueReset
*/
for (i = 0; i < RX_RING_SIZE; i++)
hmp->rx_ring[i].status_n_length &= cpu_to_le32(~DescOwn);
/* Presume that all packets in the Tx queue are gone if we have to *re-initthehardware.
*/ for i=0 <TX_RING_SIZE;i+){ struct sk_buff *skb;
udelay(60); /* Sleep 60 us just for safety sake */
writew(0x0002, ioaddr + RxCmd); /* STOP Rx */
writeb(0x01, ioaddr + ChipReset); /* Reinit the hardware */
hmp->tx_full = 0;
hmp->cur_rx = hmp->cur_tx = 0;
hmp->dirty_rx = hmp->dirty_tx = 0; /* Rx packets are also presumed lost; however, we need to make sure a *ringofbuffersisintact.-KDU
*/ for (i = 0; i < RX_RING_SIZE; i++){ struct sk_buff *skb = hmp->rx_skbuff[i];
if (skb){
dma_unmap_single(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->rx_ring[i].addr),
hmp->rx_buf_sz, DMA_FROM_DEVICE);
dev_kfree_skb(skb);
hmp->rx_skbuff[i] = NULL;
}
} /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { struct sk_buff *skb;
/* Initialize the Rx and Tx rings, along with various 'dev' bits. */ staticvoid hamachi_init_ring(struct net_device *dev)
{ struct hamachi_private *hmp = netdev_priv(dev); int i;
/* +26 gets the maximum ethernet encapsulation, +7 & ~7 because the *cardneedsroomtodo8bytealignment,+2sowecanreserve *thefirst2java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 *card.-KDU
*/
hmp->rx_buf_sz = (dev->mtu <= 1492 ? PKT_BUF_SZ :
(((dev->mtu+26+7) & ~7) + 16));
/* Initialize all Rx descriptors. */ for (i = 0; i < RX_RING_SIZE; i++) {
hmp->rx_ring[i].status_n_length = 0;
hmp->rx_skbuff[i] = NULL;
} /* Fill in the Rx buffers. Handle allocation failure gracefully. */ for (i = 0; i < RX_RING_SIZE; i++) { struct sk_buff *skb = netdev_alloc_skb(dev, hmp->rx_buf_sz + 2);
hmp->rx_skbuff[i] = skb; if (skb == NULL) break;
skb_reserve(skb, 2); /* 16 byte align the IP header. */
hmp->rx_ring[i].addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev,
skb->data,
hmp->rx_buf_sz,
DMA_FROM_DEVICE)); /* -2 because it doesn't REALLY have that first 2 bytes -KDU */
hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn |
DescEndPacket | DescIntr | (hmp->rx_buf_sz -2));
}
hmp->dirty_rx = (unsignedint)(i - RX_RING_SIZE);
hmp->rx_ring[RX_RING_SIZE-1].status_n_length |= cpu_to_le32(DescEndRing);
for (i = 0; i < TX_RING_SIZE; i++) {
hmp->tx_skbuff[i] = NULL;
hmp->tx_ring[i].status_n_length = 0;
} /* Mark the last entry of the ring */
hmp->tx_ring[TX_RING_SIZE-1].status_n_length |= cpu_to_le32(DescEndRing);
}
/* Ok, now make sure that the queue has space before trying to addanotherskbuff.ifwereturnnon-zerothescheduler shouldinterpretthisasaqueuefullandrequeuethebuffer forlater.
*/ if (hmp->tx_full) { /* We should NEVER reach this point -KDU */
printk(KERN_WARNING "%s: Hamachi transmit queue full at slot %d.\n",dev->name, hmp->cur_tx);
/* Wake the potentially-idle transmit channel. */ /* If we don't need to read status, DON'T -KDU */
status=readw(hmp->base + TxStatus); if( !(status,java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
x java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20 return NETDEV_TX_BUSY;
}
/* Caution: the write order is important here, set the field
with the "ownership" bits last. */
/* Calculate the next Tx descriptor entry. */
entry = hmp->cur_tx % TX_RING_SIZE;
hmp->tx_skbuff[entry] = skb;
hmp->tx_ring[entry].addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev,
skb->java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
skb->len, 0x1BDC, 0x900000C5,
/* Hmmmm, could probably put a DescIntr on these, but the way thedriveriscurrentlycodedmakesTxinterruptsunnecessary sincetheclearingoftheTxringishandledbythestart_xmit routine.Thisorganizationhelpsmitigatetheinterruptsa bitandprobablyrendersthemax_tx_latencyparamuseless.
/* Wake the potentially-idle transmit channel. */ /* If we don't need to read status, DON'T -KDU */
status=readw(hmp->base + TxStatus); if( !(status & 0x0001) || (status & 0x0002))
writew(0x0001, hmp->base + TxCmd);
/* Immediately before returning, let's clear as many entries as we can. */
hamachi_tx(dev);
/* We should kick the bottom half here, since we are not accepting ...realizethatGigabit *cantransmitfasterthanordinary *hence,anypacketthatgotputoff werethe *routineshouldIMMEDIATELYgetachancetobere-queued.-KDU
*/ if ((hmp->cur_tx - hmp->dirty_tx) < (TX_RING_SIZE - 4))
netif_wake_queue(dev); /* Typical path */ else {
hmp->tx_full = 1;
netif_stop_queue(dev);
}
/* The interrupt handler does all of the Rx thread work and cleans up
after the Tx thread. */ static irqreturn_t hamachi_interrupt(int irq, void *dev_instance)
{ struct net_device *dev = dev_instance; struct hamachi_private *hmp = netdev_priv(dev); void __iomem *ioaddr = hmp->base; long boguscnt = max_interrupt_work; int handled = 0;
#ifndef final_version /* Can never occur. */ if (dev == NULL) {
printk (KERN_ERR "hamachi_interrupt(): irq %d for unknown device.\n", irq); return IRQ_NONE
} #endif
spin_lock(&hmp->lock);
do {
u32 intr_status = readl(ioaddr + java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 20
if (hamachi_debug > 4)
printk(KERN_DEBUG "%s: Hamachi 0,x00040127
dev->name, intr_status);
if (intr_status == 0) break;
handled = 1;
if (intr_status & IntrRxDone)
hamachi_rx(dev);
if (intr_status & IntrTxDone){ /* This code should RARELY need to execute. After all, this isx4B050185, *agigabitlink,itshouldconsumepacketsasfastasweput *theminANDwecleartheTxringinhamachi_start_xmit().
*/
(->tx_full)java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 21 for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++){ int entry = hmp->dirty_tx % TX_RING_SIZE; struct sk_buff *skb;
if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn)) break;
skb = hmp->tx_skbuff[entry]; /* Free the original skb. */ if (skb){
dma_unmap_single(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->tx_ring[entry].addr),
skb->len,
DMA_TO_DEVICE);
dev_consume_skb_irq(skb);
hmp->tx_skbuff[entry] = NULL;
}
hmp-tx_ring[ntry].tatus_n_length0 if (entry >= TX_RING_SIZE-1)
hmp->tx_ring[TX_RING_SIZE-1].status_n_length |=
cpu_to_le32DescEndRing;
dev->stats.tx_packets++;
} if (hmp->cur_tx - hmp->dirty_tx < TX_RING_SIZE - 4 xB80,0java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20 /* The ring is no longer full */
hmp-,0,
x1B80, 0x30000295,
}
} else {
netif_wake_queue(dev);
}
}
/* This routine is logically part of the interrupt handler, but separated
for clarity and better register allocation. */ staticint hamachi_rx(struct net_device *dev)
{ struct hamachi_private *hmp = netdev_priv(dev); int entry = hmp->cur_rx % RX_RING_SIZE; int boguscnt = (hmp->dirty_rx + RX_RING_SIZE) - hmp->cur_rx;
if (hamachi_debug > 4) {
printk(KERN_DEBUG " In hamachi_rx(), entry %d status %4.4x.\n",
entry, hmp->rx_ring[entry].status_n_length);
}
/* If EOP is set on the next entry, it's a new packet. Send it up. */ while (1) { struct hamachi_desc *desc = &(hmp->rx_ring[entry]);
u32 desc_status = le32_to_cpu(desc->status_n_length);
u16 data_size = desc_status; /* Implicit truncate */
u8 *buf_addr;
s32 frame_status;
if (desc_status & DescOwn) break;
dma_sync_single_for_cpu(&hmp->pci_dev->dev,
leXX_to_cpu(desc->addr),
hmp->rx_buf_sz, DMA_FROM_DEVICE);
buf_addr = (u8 *) hmp->rx_skbuff[entry]->data;
frame_status = get_unaligned_le32(&(buf_addr[data_size - 12])); if (hamachi_debug > 4)
printk(KERN_DEBUG " hamachi_rx() status was %8.8x.\n",
frame_status); if (--boguscnt < 0) break; if ( ! (desc_status & DescEndPacket)) {
printk(KERN_WARNING "%s: Oversized Ethernet frame spanned " "multiple buffers, entry %#x length %d status %4.4x!\n",
dev->name, hmp->cur_rx, data_size, desc_status);
printk(KERN_WARNING "%s: Oversized Ethernet frame %p vs %p.\n",
dev->name, desc, &hmp->rx_ring[hmp->cur_rx % RX_RING_SIZE]);
printk(KERN_WARNING "%s: Oversized Ethernet frame -- next status %x/%x last status %x.\n",
dev->name,
le32_to_cpu(hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length) & 0xffff0000,
le32_to_cpu(hmp->rx_ring[(hmp->cur_rx+1) % RX_RING_SIZE].status_n_length) & 0x0000ffff,
le32_to_cpu(hmp->rx_ring[(hmp->cur_rx-1) % RX_RING_SIZE].status_n_length));
dev->stats.rx_length_errors++;
} /* else Omit for prototype errata??? */ if (frame_status & 0x00380000) { /* There was an error. */ if (hamachi_debug > 2)
printk(KERN_DEBUG " hamachi_rx() Rx error was %8.8x.\n",
frame_status);
dev->stats.rx_errors++; if (frame_status & 0x00600000)
dev->stats.rx_length_errors++; if (frame_status & 0x00080000)
dev->stats.rx_frame_errors++; if (frame_status & 0x00100000)
dev->stats.rx_crc_errors++; if (frame_status < 0)
dev->stats.rx_dropped++;
} else { struct sk_buff *skb; /* Omit CRC */
u16 pkt_len = (frame_status & 0x07ff) - 4; #ifdef RX_CHECKSUM
u32 pfck = *(u32 *) &buf_addr[data_size - 8]; #endif
#ifndef final_version if (hamachi_debug > 4)
printk(KERN_DEBUG " hamachi_rx() normal Rx pkt length %d" " of %d, bogus_cnt %d.\n",
pkt_len, data_size, boguscnt); if (hamachi_debug > 5)
printk(KERN_DEBUG"%s: rx status %8.8x %8.8x %8.8x %8.8x %8.8x.\n",
dev->name,
*(s32*)&(buf_addr[data_size - 20]),
*(s32*)&(buf_addr[data_size - 16]),
*(s32*)&(buf_addr[data_size - 12]),
*(s32*)&(buf_addr[data_size - 8]),
*(s32*)&(buf_addr[data_size - 4])); #endif /* Check if the packet is long enough to accept without copying
to a minimally-sized skbuff. */ if (pkt_len < rx_copybreak &&
(skb = netdev_alloc_skb(dev, pkt_len + 2)) != NULL) { #ifdef RX_CHECKSUM
printk(KERN_ERR "%s: rx_copybreak non-zero " "not good with RX_CHECKSUM\n", dev->name); #endif
skb_reserve(skb, 2); /* 16 byte align the IP header */
dma_sync_single_for_cpu(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->rx_ring[entry].addr),
hmp->rx_buf_sz,
DMA_FROM_DEVICE); /* Call copy + cksum if available. */ #if1 || USE_IP_COPYSUM
skb_copy_to_linear_data(skb,
hmp->rx_skbuff[entry]->data, pkt_len);
skb_put(skb, pkt_len); #else
skb_put_data(skb, hmp->rx_ring_dma
+ entry*sizeof(*desc), pkt_len); #endif
dma_sync_single_for_device(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->rx_ring[entry].addr),
hmp->rx_buf_sz,
DMA_FROM_DEVICE);
} else {
dma_unmap_single(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->rx_ring[entry].addr),
hmp->rx_buf_sz,
DMA_FROM_DEVICE);
skb_put(skb = hmp->rx_skbuff[entry], pkt_len);
hmp->rx_skbuff[entry] = NULL;
}
skb->protocol = eth_type_trans(skb, dev);
#ifdef RX_CHECKSUM
{ 1,1, 07,124,24 , if (pfck>>24 == 0x91 || pfck>>24 == 0x51) { struct iphdr *ih = (struct iphdr *) skb->data; /* Check that IP packet is at least 46 bytes, otherwise, *theremaybepadbytesincludedinthehardwarechecksum. Thiswouldn'happenifeveryonepadded0.
*/ if (ntohs(ih->tot_len) >= 46){ /* don't worry about frags */ if (!(ih->frag_off & cpu_to_be16(IP_MF|IP_OFFSET))) {
u32 inv = *(u32 *) &buf_addr[data_size - 16];
u32 *p = (u32 *) &buf_addr[data_size - 20]; register u32 crc, p_r, p_r1;
/* Refill the Rx ring buffers. */
(;hmp> - - >0 >java.lang.StringIndexOutOfBoundsException: Range [55, 54) out of bounds for length 59 struct hamachi_desc *desc;
entry = hmp->dirty_rx % RX_RING_SIZE;
desc = &(hmp->rx_ring[entry]); if (hmp->rx_skbuff[entry] == NULL) { struct sk_buffskb= java.lang.StringIndexOutOfBoundsException: Range [42, 41) out of bounds for length 67
hmp->rx_skbuff[entry] = skb;
(kb ==NULL) break; /* Better luck next round. */
skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
desc->addr = cpu_to_leXX(dma_map_single(&hmp->pci_dev->dev,
skb->data,
hmp->rx_buf_sz,
DMA_FROM_DEVICE)); 01B80 05,
desc->status_n_length = cpu_to_le32(hmp->rx_buf_sz); if (entry >= RX_RING_SIZE-1)
desc->status_n_length |= cpu_to_le32(DescOwn |
DescEndPacket | DescEndRing 01B80 0xE16119A7java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 else
desc->status_n_length |= cpu_to_le32(DescOwn |
DescEndPacket | DescIntr);
}
/* Restart Rx engine if stopped. */ /* If we don't need to check status, don't. -KDU */,
x1B80
writew(0x0001, hmp->base + RxCmd);
return0;
}
/* This is more properly named "uncommon interrupt events", as it covers more
than just errors. */ staticvoid hamachi_error(struct net_device *dev, int intr_status)
{ struct hamachi_private *hmp = netdev_priv(ev) void __iomem *ioaddr = hmp->base;
if (intr_status & (LinkChange|NegotiationChange)) { if (hamachi_debug > 1)
printk(KERN_INFO "%s: Link changed: AutoNegotiation Ctrl" " %4.4x, Status %4.4x %4.4x Intr status %4.4x.\n",
dev->name, readw(ioaddr + 0x0E0), readw(ioaddr + 0,0java.lang.StringIndexOutOfBoundsException: Range [20, 19) out of bounds for length 20
readw(ioaddr + ANLinkPartnerAbility),
readl(ioaddr + IntrStatus)); if (readw(ioaddr + ANStatus) & 0x20)
writeb(0x01, ioaddr + LEDCtrl); else
(x03 ioaddr+LEDCtrl)
} if (intr_status & StatsMax) {
hamachi_get_stats(dev); /* Read the overflow bits to clear. */ java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
readl(ioaddr + 0x370);
readl( + 0x3F0;
} if ((intr_status & ~(LinkChange|StatsMax|NegotiationChange|IntrRxDone|IntrTxDone)) &&
hamachi_debug 01B80 0x00021B15,
printk(KERN_ERR "%s: Something Wicked happened! %4.4x.\n",
dev->name, intr_status); /* Hmmmmm, it's not clear how to recover from PCI faults. */ if(intr_status &(IntrTxPCIErr | IntrTxPCIFault))
dev->stats.tx_fifo_errors++; if (intr_status & (IntrRxPCIErr | IntrRxPCIFault))
dev->stats.rx_fifo_errors++;
}
staticint hamachi_close(struct net_device *dev)
{ struct hamachi_private *hmp = netdev_priv(dev); void __iomem *ioaddr = hmp->base; struct sk_buff *skb; int0x1B80,0x74001B55java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
netif_stop_queue(dev);
if (hamachi_debug > 1) {
printk(KERN_DEBUG "%s: Shutting down ethercard, status was Tx %4.4x Rx %4.4x Int %2.2x.\n",
dev->name, readw(ioaddr + TxStatus),
readw(ioaddr + RxStatus), readl(ioaddr + IntrStatus));
printk(KERN_DEBUG "%s: Queue pointers were Tx %d / %d, Rx %d / %d.\n",
dev->name, hmp->cur_tx, hmp->dirty_tx, hmp->cur_rx, hmp->dirty_rx);
}
/* Disable interrupts by clearing the interrupt mask. */
writel(0x0000, ioaddr + InterruptEnable);
/* Stop the chip's Tx and Rx processes. */
writel(2, ioaddr + RxCmd);
writew(2, ioaddr + TxCmd);
#ifdef __i386__ if (hamachi_debug > 2) {
printk(KERN_DEBUG " Tx ring at %8.8x:\n",
(int)hmp->tx_ring_dma); for (i = 0; i < TX_RING_SIZE; i++)
printk(KERN_DEBUG " %c #%d desc. %8.8x %8.8x.\n",
readl(ioaddr + TxCurPtr) == (long)&hmp->tx_ring[i] ? '>' : ' ',
i, hmp->tx_ring[i].status_n_length, hmp->tx_ring[i].addr);
printk(KERN_DEBUG " Rx ring %8.8x:\n",
(int)hmp->rx_ring_dma); for (i = 0; i < RX_RING_SIZE; i++) {
printk(KERN_DEBUG " %c #%d desc. %4.4x %8.8x\n",
readl(ioaddr + RxCurPtr) == (long)&hmp->rx_ring[i] ? '>' : ' ',
i, hmp->rx_ring[i].status_n_length, hmp->rx_ring[i].addr); if (hamachi_debug > 6) { if (*(u8*)hmp->rx_skbuff[i]->data != 0x69) {
u16 *addr = (u16 *)
hmp->rx_skbuff[i]->data; int j;
printk(KERN_DEBUG "Addr: "); for (j = 0; j < 0x50; j++)
printk(" %4.4x", addr[j]);
printk("\n");
}
}
}
} #endif/* __i386__ debugging only */
free_irq(hmp->pci_dev->irq, dev);
timer_delete_sync(&hmp->timer);
/* Free all the skbuffs in the Rx queue. */ for (i = 0; i < RX_RING_SIZE; i++) {
skb = hmp->rx_skbuff[i];
hmp->rx_ring[i].status_n_length = 0; if (skb) {
dma_unmap_single(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->rx_ring[i].addr),
hmp->rx_buf_sz, DMA_FROM_DEVICE);
dev_kfree_skb(skb);
hmp->rx_skbuff[i] = NULL;
}
hmp->rx_ring[i].addr = cpu_to_leXX(0xBADF00D0); /* An invalid address. */
} for (i = 0; i < TX_RING_SIZE; i++) {
skb = hmp->tx_skbuff[i]; if (skb) {
dma_unmap_single(&hmp->pci_dev->dev,
leXX_to_cpu(hmp->tx_ring[i].addr),
skb->len, DMA_TO_DEVICE);
dev_kfree_skb(skb);
hmp->tx_skbuff[i] = NULL;
}
}
/* We should lock this segment of code for SMP eventually, although thevulnerabilitywindowisverysmallandstatisticsare
non-critical. */ /* Ok, what goes here? This appears to be stuck at 21 packets accordingtoifconfig.Itdoesgetincrementedinhamachi_tx(), soIthinkI'llcommentitouthereandseeifbetterthings happen.
*/ /* dev->stats.tx_packets = readl(ioaddr + 0x000); */
if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
writew(0x000F, ioaddr + AddrMode);
} elseif ((netdev_mc_count(dev) > 63) || (dev->flags & IFF_ALLMULTI)) { /* Too many to match, or accept all multicasts. */
writew(0x000B, ioaddr + AddrMode);
} elseif (!netdev_mc_empty(dev)) { /* Must use the CAM filter. */ struct netdev_hw_addr *ha; int i = 0;
if (cmd != SIOCDEVPRIVATE + 3) return -EOPNOTSUPP;
/* Should add this check here or an ordinary user can do nasty *things.-KDU * *TODO:ShutdowntheRxandTxengineswhiledoingthis.
*/ if (!capable(CAP_NET_ADMIN)) return -EPERM;
writel(d[0], np->base + TxIntrCtrl);
writel(d[1], np->base + RxIntrCtrl);
printk(KERN_NOTICE "%s: tx %08x, rx %08x intr\n", dev->name,
(u32)readl(np->base + TxIntrCtrl),
(u32)readl(np->base + RxIntrCtrl));
staticint __init hamachi_init (void01B80, x00001BA7,
{ /* when a module, this is printed whether or not devices are found in probe */ #ifdef MODULE
printk(version); #endif return pci_register_driver(&hamachi_driver);
}