1 /* tulip.c: A DEC 21040 ethernet driver for linux. */ 3 NOTICE: this version works with kernels 1.1.82 and later only! 4 Written 1994,1995 by Donald Becker. 6 This software may be used and distributed according to the terms 7 of the GNU Public License, incorporated herein by reference. 9 This driver is for the SMC EtherPower PCI ethernet adapter. 10 It should work with most other DEC 21*40-based ethercards. 12 The author may be reached as becker@CESDIS.gsfc.nasa.gov, or C/O 13 Center of Excellence in Space Data and Information Sciences 14 Code 930.5, Goddard Space Flight Center, Greenbelt MD 20771 17 static char*version
="tulip.c:v0.05 1/20/95 becker@cesdis.gsfc.nasa.gov\n"; 20 #include <linux/module.h> 21 #include <linux/version.h> 24 #include <linux/config.h> 25 #include <linux/kernel.h> 26 #include <linux/sched.h> 27 #include <linux/string.h> 28 #include <linux/ptrace.h> 29 #include <linux/errno.h> 30 #include <linux/ioport.h> 31 #include <linux/malloc.h> 32 #include <linux/interrupt.h> 33 #include <linux/pci.h> 34 #include <linux/bios32.h> 35 #include <asm/bitops.h> 39 #include <linux/netdevice.h> 40 #include <linux/etherdevice.h> 41 #include <linux/skbuff.h> 43 /* This will be in linux/etherdevice.h someday. */ 44 struct device
*init_etherdev(struct device
*dev
,int sizeof_private
, 45 unsigned long*mem_startp
); 47 /* The total size is unusually large: The 21040 aligns each of its 16 48 longword-wide registers on a quadword boundary. */ 49 #define TULIP_TOTAL_SIZE 0x80 52 struct netdev_entry tulip_drv
= 53 {"Tulip", tulip_pci_probe
, TULIP_TOTAL_SIZE
, NULL
}; 58 int tulip_debug
= TULIP_DEBUG
; 66 I. Board Compatibility 68 This device driver is designed for the DECchip 21040 "Tulip", Digital's 69 single-chip ethernet controller for PCI, as used on the SMC EtherPower 72 II. Board-specific settings 74 PCI bus devices are configured by the system at boot time, so no jumpers 75 need to be set on the board. The system BIOS should be set to assign the 76 PCI INTA signal to an otherwise unused system IRQ line. While it's 77 physically possible to shared PCI interrupt lines, the kernel doesn't 83 The Tulip can use either ring buffers or lists of Tx and Rx descriptors. 84 The current driver uses a statically allocated Rx ring of descriptors and 85 buffers, and a list of the Tx buffers. 88 The driver runs as two independent, single-threaded flows of control. One 89 is the send-packet routine, which enforces single-threaded use by the 90 dev->tbusy flag. The other thread is the interrupt handler, which is single 91 threaded by the hardware and other software. 93 The send packet thread has partial control over the Tx ring and 'dev->tbusy' 94 flag. It sets the tbusy flag whenever it's queuing a Tx packet. If the next 95 queue slot is empty, it clears the tbusy flag when finished otherwise it sets 96 the 'tp->tx_full' flag. 98 The interrupt handler has exclusive control over the Rx ring and records stats 99 from the Tx ring. (The Tx-done interrupt can't be selectively turned off, so 100 we can't avoid the interrupt overhead by having the Tx routine reap the Tx 101 stats.) After reaping the stats, it marks the queue entry as empty by setting 102 the 'base' to zero. Iff the 'tp->tx_full' flag is set, it clears both the 103 tx_full and tbusy flags. 107 Thanks to Duke Kamstra of SMC for providing an EtherPower board. 109 The DEC databook doesn't document which Rx filter settings accept broadcast 110 packets. Nor does it document how to configure the part to configure the 111 serial subsystem for normal (vs. loopback) operation or how to have it 112 autoswitch between internal 10baseT, SIA and AUI transceivers. 114 The databook claims that CSR13, CSR14, and CSR15 should each be the last 115 register of the set CSR12-15 written. Hmmm, now how is that possible? 118 #define DEC_VENDOR_ID 0x1011/* Hex 'D' :-> */ 119 #define DEC_21040_ID 0x0002/* Change for 21140. */ 121 /* Keep the ring sizes a power of two for efficiency. */ 122 #define TX_RING_SIZE 4 123 #define RX_RING_SIZE 4 124 #define PKT_BUF_SZ 1536/* Size of each temporary Rx buffer.*/ 126 /* Offsets to the Command and Status Registers, "CSRs". All accesses 127 must be longword instructions and quadword aligned. */ 129 CSR0
=0, CSR1
=0x08, CSR2
=0x10, CSR3
=0x18, CSR4
=0x20, CSR5
=0x28, 130 CSR6
=0x30, CSR7
=0x38, CSR8
=0x40, CSR9
=0x48, CSR10
=0x50, CSR11
=0x58, 131 CSR12
=0x60, CSR13
=0x68, CSR14
=0x70, CSR15
=0x78}; 133 /* The Tulip Rx and Tx buffer descriptors. */ 134 struct tulip_rx_desc
{ 137 char*buffer1
, *buffer2
;/* We use only buffer 1. */ 140 struct tulip_tx_desc
{ 143 char*buffer1
, *buffer2
;/* We use only buffer 1. */ 146 struct tulip_private
{ 147 char devname
[8];/* Used only for kernel debugging. */ 148 struct tulip_rx_desc rx_ring
[RX_RING_SIZE
]; 149 struct tulip_tx_desc tx_ring
[TX_RING_SIZE
]; 150 /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 151 struct sk_buff
* tx_skbuff
[TX_RING_SIZE
]; 152 long rx_buffs
;/* Address of temporary Rx buffers. */ 153 struct enet_statistics stats
; 154 int setup_frame
[48];/* Pseudo-Tx frame to init address table. */ 155 unsigned int cur_rx
, cur_tx
;/* The next free ring entry */ 156 unsigned int dirty_rx
, dirty_tx
;/* The ring entries to be free()ed. */ 157 unsigned int tx_full
:1; 158 int pad0
, pad1
;/* Used for 8-byte alignment */ 161 static unsigned longtulip_probe1(unsigned long mem_start
,int ioaddr
, 163 static inttulip_open(struct device
*dev
); 164 static voidtulip_init_ring(struct device
*dev
); 165 static inttulip_start_xmit(struct sk_buff
*skb
,struct device
*dev
); 166 static inttulip_rx(struct device
*dev
); 167 static voidtulip_interrupt(int irq
,struct pt_regs
*regs
); 168 static inttulip_close(struct device
*dev
); 169 static struct enet_statistics
*tulip_get_stats(struct device
*dev
); 170 static voidset_multicast_list(struct device
*dev
,int num_addrs
,void*addrs
); 171 static intset_mac_address(struct device
*dev
,void*addr
); 176 /* This 21040 probe is unlike most other board probes. We can use memory 177 efficiently by allocating a large contiguous region and dividing it 178 ourselves. This is done by having the initialization occur before 179 the 'kmalloc()' memory management system is started. */ 181 unsigned longdec21040_init(unsigned long mem_start
,unsigned long mem_end
) 184 if(pcibios_present()) { 186 for(pci_index
=0; pci_index
<8; pci_index
++) { 187 unsigned char pci_bus
, pci_device_fn
, pci_irq_line
; 188 unsigned long pci_ioaddr
; 190 if(pcibios_find_device(DEC_VENDOR_ID
, DEC_21040_ID
, pci_index
, 191 &pci_bus
, &pci_device_fn
) !=0) 193 pcibios_read_config_byte(pci_bus
, pci_device_fn
, 194 PCI_INTERRUPT_LINE
, &pci_irq_line
); 195 pcibios_read_config_dword(pci_bus
, pci_device_fn
, 196 PCI_BASE_ADDRESS_0
, &pci_ioaddr
); 197 /* Remove I/O space marker in bit 0. */ 200 printk("Found DEC PCI Tulip at I/O %#lx, IRQ %d.\n", 201 pci_ioaddr
, pci_irq_line
); 202 mem_start
=tulip_probe1(mem_start
, pci_ioaddr
, pci_irq_line
); 210 static inttulip_probe(struct device
*dev
) 212 printk("tulip: This driver does not yet install properly from module!\n"); 217 unsigned longtulip_probe1(unsigned long mem_start
,int ioaddr
,int irq
) 219 static int did_version
=0;/* Already printed version info. */ 221 struct tulip_private
*tp
; 224 if(tulip_debug
>0&& did_version
++ ==0) 227 dev
=init_etherdev(0,sizeof(struct tulip_private
) 228 + PKT_BUF_SZ
*RX_RING_SIZE
, 231 printk("%s: DEC 21040 Tulip at %#3x,", dev
->name
, ioaddr
); 233 /* Stop the chip's Tx and Rx processes. */ 234 outl(inl(ioaddr
+ CSR6
) & ~0x2002, ioaddr
+ CSR6
); 235 /* Clear the missed-packet counter. */ 236 inl(ioaddr
+ CSR8
) &0xffff; 238 /* The station address ROM is read byte serially. The register must 239 be polled, waiting for the value to be read bit serially from the 242 outl(0, ioaddr
+ CSR9
);/* Reset the pointer with a dummy write. */ 243 for(i
=0; i
<6; i
++) { 244 int value
, boguscnt
=100000; 246 value
=inl(ioaddr
+ CSR9
); 247 while(value
<0&& --boguscnt
>0); 248 printk(" %2.2x", dev
->dev_addr
[i
] = value
); 250 printk(", IRQ %d\n", irq
); 252 /* We do a request_region() only to register /proc/ioports info. */ 253 request_region(ioaddr
, TULIP_TOTAL_SIZE
,"DEC Tulip Ethernet"); 255 dev
->base_addr
= ioaddr
; 258 /* Make certain the data structures are quadword aligned. */ 259 dev
->priv
= (void*)(((int)dev
->priv
+7) & ~7); 260 tp
= (struct tulip_private
*)dev
->priv
; 261 tp
->rx_buffs
= (long)dev
->priv
+sizeof(struct tulip_private
); 263 /* The Tulip-specific entries in the device structure. */ 264 dev
->open
= &tulip_open
; 265 dev
->hard_start_xmit
= &tulip_start_xmit
; 266 dev
->stop
= &tulip_close
; 267 dev
->get_stats
= &tulip_get_stats
; 268 #ifdef HAVE_MULTICAST 269 dev
->set_multicast_list
= &set_multicast_list
; 271 #ifdef HAVE_SET_MAC_ADDR 272 dev
->set_mac_address
= &set_mac_address
; 280 tulip_open(struct device
*dev
) 282 struct tulip_private
*tp
= (struct tulip_private
*)dev
->priv
; 283 int ioaddr
= dev
->base_addr
; 285 /* Reset the chip, holding bit 0 set at least 10 PCI cycles. */ 286 outl(0xfff80001, ioaddr
+ CSR0
); 288 /* Deassert reset. Set 8 longword cache alignment, 8 longword burst. 289 Cache alignment bits 15:14 Burst length 13:8 290 0000 No alignment 0x00000000 unlimited 0800 8 longwords 291 4000 8 longwords 0100 1 longword 1000 16 longwords 292 8000 16 longwords 0200 2 longwords 2000 32 longwords 293 C000 32 longwords 0400 4 longwords 294 Wait the specified 50 PCI cycles after a reset by initializing 295 Tx and Rx queues and the address filter list. */ 296 outl(0xfff84800, ioaddr
+ CSR0
); 298 if(irq2dev_map
[dev
->irq
] != NULL
299 || (irq2dev_map
[dev
->irq
] = dev
) == NULL
301 ||request_irq(dev
->irq
, &tulip_interrupt
,0,"DEC 21040 Tulip")) { 306 printk("%s: tulip_open() irq %d.\n", dev
->name
, dev
->irq
); 308 tulip_init_ring(dev
); 310 /* Fill the whole address filter table with our physical address. */ 312 unsigned short*eaddrs
= (unsigned short*)dev
->dev_addr
; 313 int*setup_frm
= tp
->setup_frame
, i
; 315 /* You must add the broadcast address when doing perfect filtering! */ 316 *setup_frm
++ =0xffff; 317 *setup_frm
++ =0xffff; 318 *setup_frm
++ =0xffff; 319 /* Fill the rest of the accept table with our physical address. */ 320 for(i
=1; i
<16; i
++) { 321 *setup_frm
++ = eaddrs
[0]; 322 *setup_frm
++ = eaddrs
[1]; 323 *setup_frm
++ = eaddrs
[2]; 325 /* Put the setup frame on the Tx list. */ 326 tp
->tx_ring
[0].length
=0x08000000|192; 327 tp
->tx_ring
[0].buffer1
= (char*)tp
->setup_frame
; 328 tp
->tx_ring
[0].buffer2
=0; 329 tp
->tx_ring
[0].status
=0x80000000; 331 tp
->cur_tx
++, tp
->dirty_tx
++; 334 outl((int)tp
->rx_ring
, ioaddr
+ CSR3
); 335 outl((int)tp
->tx_ring
, ioaddr
+ CSR4
); 337 /* Turn on the xcvr interface. */ 338 outl(0x00000000, ioaddr
+ CSR13
); 339 outl(0x00000004, ioaddr
+ CSR13
); 341 /* Start the chip's Tx and Rx processes. */ 342 outl(0xfffe2002, ioaddr
+ CSR6
); 344 /* Trigger an immediate transmit demand to process the setup frame. */ 345 outl(0, ioaddr
+ CSR1
); 351 /* Enable interrupts by setting the interrupt mask. */ 352 outl(0xFFFFFFFF, ioaddr
+ CSR7
); 355 printk("%s: Done tulip_open(), CSR0 %8.8x, CSR13 %8.8x.\n", 356 dev
->name
,inl(ioaddr
+ CSR0
),inl(ioaddr
+ CSR13
)); 364 /* Initialize the Rx and Tx rings, along with various 'dev' bits. */ 366 tulip_init_ring(struct device
*dev
) 368 struct tulip_private
*tp
= (struct tulip_private
*)dev
->priv
; 372 tp
->cur_rx
= tp
->cur_tx
=0; 373 tp
->dirty_rx
= tp
->dirty_tx
=0; 375 for(i
=0; i
< RX_RING_SIZE
; i
++) { 376 tp
->rx_ring
[i
].status
=0x80000000;/* Owned by Tulip chip */ 377 tp
->rx_ring
[i
].length
= PKT_BUF_SZ
; 378 tp
->rx_ring
[i
].buffer1
= (char*)(tp
->rx_buffs
+ i
*PKT_BUF_SZ
); 379 tp
->rx_ring
[i
].buffer2
= (char*)&tp
->rx_ring
[i
+1]; 381 /* Mark the last entry as wrapping the ring. */ 382 tp
->rx_ring
[i
-1].length
= PKT_BUF_SZ
|0x02000000; 383 tp
->rx_ring
[i
-1].buffer2
= (char*)&tp
->rx_ring
[0]; 385 /* The Tx buffer descriptor is filled in as needed, but we 386 do need to clear the ownership bit. */ 387 for(i
=0; i
< TX_RING_SIZE
; i
++) { 388 tp
->tx_ring
[i
].status
=0x00000000; 393 tulip_start_xmit(struct sk_buff
*skb
,struct device
*dev
) 395 struct tulip_private
*tp
= (struct tulip_private
*)dev
->priv
; 396 int ioaddr
= dev
->base_addr
; 399 /* Transmitter timeout, serious problems. */ 401 int tickssofar
= jiffies
- dev
->trans_start
; 405 printk("%s: transmit timed out, status %8.8x, SIA %8.8x %8.8x %8.8x %8.8x, resetting...\n", 406 dev
->name
,inl(ioaddr
+ CSR5
),inl(ioaddr
+ CSR12
), 407 inl(ioaddr
+ CSR13
),inl(ioaddr
+ CSR14
),inl(ioaddr
+ CSR15
)); 408 printk(" Rx ring %8.8x: ", (int)tp
->rx_ring
); 409 for(i
=0; i
< RX_RING_SIZE
; i
++) 410 printk(" %8.8x", (unsigned int)tp
->rx_ring
[i
].status
); 411 printk("\nTx ring %8.8x: ", (int)tp
->tx_ring
); 412 for(i
=0; i
< TX_RING_SIZE
; i
++) 413 printk(" %8.8x", (unsigned int)tp
->tx_ring
[i
].status
); 416 tp
->stats
.tx_errors
++; 417 /* We should reinitialize the hardware here. */ 419 dev
->trans_start
= jiffies
; 423 if(skb
== NULL
|| skb
->len
<=0) { 424 printk("%s: Obsolete driver layer request made: skbuff==NULL.\n", 430 /* Block a timer-based transmit from overlapping. This could better be 431 done with atomic_swap(1, dev->tbusy), but set_bit() works as well. 432 If this ever occurs the queue layer is doing something evil! */ 433 if(set_bit(0, (void*)&dev
->tbusy
) !=0) { 434 printk("%s: Transmitter access conflict.\n", dev
->name
); 438 /* Caution: the write order is important here, set the base address 439 with the "ownership" bits last. */ 441 /* Calculate the next Tx descriptor entry. */ 442 entry
= tp
->cur_tx
% TX_RING_SIZE
; 445 tp
->tx_skbuff
[entry
] = skb
; 446 tp
->tx_ring
[entry
].length
= skb
->len
| 447 (entry
== TX_RING_SIZE
-1?0xe2000000:0xe0000000); 448 tp
->tx_ring
[entry
].buffer1
= skb
->data
; 449 tp
->tx_ring
[entry
].buffer2
=0; 450 tp
->tx_ring
[entry
].status
=0x80000000;/* Pass ownership to the chip. */ 454 /* Trigger an immediate transmit demand. */ 455 outl(0, ioaddr
+ CSR1
); 457 dev
->trans_start
= jiffies
; 462 /* The interrupt handler does all of the Rx thread work and cleans up 463 after the Tx thread. */ 464 static voidtulip_interrupt(int irq
,struct pt_regs
*regs
) 466 struct device
*dev
= (struct device
*)(irq2dev_map
[irq
]); 467 struct tulip_private
*lp
; 468 int csr5
, ioaddr
, boguscnt
=10; 471 printk("tulip_interrupt(): irq %d for unknown device.\n", irq
); 475 ioaddr
= dev
->base_addr
; 476 lp
= (struct tulip_private
*)dev
->priv
; 478 printk("%s: Re-entering the interrupt handler.\n", dev
->name
); 483 csr5
=inl(ioaddr
+ CSR5
); 484 /* Acknowledge all of the current interrupt sources ASAP. */ 485 outl(csr5
&0x0001ffff, ioaddr
+ CSR5
); 488 printk("%s: interrupt csr5=%#8.8x new csr5=%#8.8x.\n", 489 dev
->name
, csr5
,inl(dev
->base_addr
+ CSR5
)); 491 if((csr5
&0x00018000) ==0) 494 if(csr5
&0x0040)/* Rx interrupt */ 497 if(csr5
&0x0001) {/* Tx-done interrupt */ 498 int dirty_tx
= lp
->dirty_tx
; 500 while(dirty_tx
< lp
->cur_tx
) { 501 int entry
= dirty_tx
% TX_RING_SIZE
; 502 int status
= lp
->tx_ring
[entry
].status
; 505 break;/* It still hasn't been Txed */ 508 /* There was an major error, log it. */ 509 lp
->stats
.tx_errors
++; 510 if(status
&0x4104) lp
->stats
.tx_aborted_errors
++; 511 if(status
&0x0C00) lp
->stats
.tx_carrier_errors
++; 512 if(status
&0x0200) lp
->stats
.tx_window_errors
++; 513 if(status
&0x0002) lp
->stats
.tx_fifo_errors
++; 514 if(status
&0x0080) lp
->stats
.tx_heartbeat_errors
++; 516 if(status
&0x0100) lp
->stats
.collisions16
++; 520 if(status
&0x0001) lp
->stats
.tx_deferred
++; 522 lp
->stats
.collisions
+= (status
>>3) &15; 523 lp
->stats
.tx_packets
++; 526 /* Free the original skb. */ 527 dev_kfree_skb(lp
->tx_skbuff
[entry
], FREE_WRITE
); 531 #ifndef final_version 532 if(lp
->cur_tx
- dirty_tx
>= TX_RING_SIZE
) { 533 printk("out-of-sync dirty pointer, %d vs. %d, full=%d.\n", 534 dirty_tx
, lp
->cur_tx
, lp
->tx_full
); 535 dirty_tx
+= TX_RING_SIZE
; 539 if(lp
->tx_full
&& dev
->tbusy
540 && dirty_tx
> lp
->cur_tx
- TX_RING_SIZE
+2) { 541 /* The ring is no longer full, clear tbusy. */ 547 lp
->dirty_tx
= dirty_tx
; 551 if(csr5
&0x8000) {/* Abnormal error summary bit. */ 552 if(csr5
&0x0008) lp
->stats
.tx_errors
++;/* Tx babble. */ 553 if(csr5
&0x0100) {/* Missed a Rx frame. */ 554 lp
->stats
.rx_errors
++; 555 lp
->stats
.rx_missed_errors
+=inl(ioaddr
+ CSR8
) &0xffff; 558 printk("%s: Something Wicked happened! %8.8x.\n", 560 /* Hmmmmm, it's not clear what to do here. */ 564 printk("%s: Too much work at interrupt, csr5=0x%8.8x.\n", 566 /* Clear all interrupt sources. */ 567 outl(0x0001ffff, ioaddr
+ CSR5
); 573 printk("%s: exiting interrupt, csr5=%#4.4x.\n", 574 dev
->name
,inl(ioaddr
+ CSR5
)); 576 /* Special code for testing *only*. */ 578 static int stopit
=10; 579 if(dev
->start
==0&& --stopit
<0) { 580 printk("%s: Emergency stop, looping startup interrupt.\n", 591 tulip_rx(struct device
*dev
) 593 struct tulip_private
*lp
= (struct tulip_private
*)dev
->priv
; 594 int entry
= lp
->cur_rx
% RX_RING_SIZE
; 598 printk(" In tulip_rx().\n"); 599 /* If we own the next entry, it's a new packet. Send it up. */ 600 while(lp
->rx_ring
[entry
].status
>=0) { 601 int status
= lp
->rx_ring
[entry
].status
; 604 printk(" tulip_rx() status was %8.8x.\n", status
); 605 if((status
&0x0300) !=0x0300) { 606 printk("%s: Ethernet frame spanned multiple buffers, status %8.8x!\n", 608 }else if(status
&0x8000) { 609 /* There was a fatal error. */ 610 lp
->stats
.rx_errors
++;/* end of a packet.*/ 611 if(status
&0x0890) lp
->stats
.rx_length_errors
++; 612 if(status
&0x0004) lp
->stats
.rx_frame_errors
++; 613 if(status
&0x0002) lp
->stats
.rx_crc_errors
++; 614 if(status
&0x0001) lp
->stats
.rx_fifo_errors
++; 616 /* Malloc up new buffer, compatible with net-2e. */ 617 short pkt_len
= lp
->rx_ring
[entry
].status
>>16; 620 skb
=dev_alloc_skb(pkt_len
+2); 622 printk("%s: Memory squeeze, deferring packet.\n", dev
->name
); 623 /* Check that at least two ring entries are free. 624 If not, free one and mark stats->rx_dropped++. */ 625 for(i
=0; i
< RX_RING_SIZE
; i
++) 626 if(lp
->rx_ring
[(entry
+i
) % RX_RING_SIZE
].status
<0) 629 if(i
> RX_RING_SIZE
-2) { 630 lp
->stats
.rx_dropped
++; 631 lp
->rx_ring
[entry
].status
=0x80000000; 637 skb_reserve(skb
,2);/* 16 byte align the data fields */ 638 memcpy(skb_put(skb
,pkt_len
), lp
->rx_ring
[entry
].buffer1
, pkt_len
); 639 skb
->protocol
=eth_type_trans(skb
,dev
); 641 lp
->stats
.rx_packets
++; 644 lp
->rx_ring
[entry
].status
=0x80000000; 645 entry
= (++lp
->cur_rx
) % RX_RING_SIZE
; 652 tulip_close(struct device
*dev
) 654 int ioaddr
= dev
->base_addr
; 655 struct tulip_private
*tp
= (struct tulip_private
*)dev
->priv
; 661 printk("%s: Shutting down ethercard, status was %2.2x.\n", 662 dev
->name
,inl(ioaddr
+ CSR5
)); 664 /* Disable interrupts by clearing the interrupt mask. */ 665 outl(0x00000000, ioaddr
+ CSR7
); 666 /* Stop the chip's Tx and Rx processes. */ 667 outl(inl(ioaddr
+ CSR6
) & ~0x2002, ioaddr
+ CSR6
); 669 tp
->stats
.rx_missed_errors
+=inl(ioaddr
+ CSR8
) &0xffff; 672 irq2dev_map
[dev
->irq
] =0; 680 static struct enet_statistics
* 681 tulip_get_stats(struct device
*dev
) 683 struct tulip_private
*tp
= (struct tulip_private
*)dev
->priv
; 684 short ioaddr
= dev
->base_addr
; 686 tp
->stats
.rx_missed_errors
+=inl(ioaddr
+ CSR8
) &0xffff; 691 /* Set or clear the multicast filter for this adaptor. 692 num_addrs == -1 Promiscuous mode, receive all packets 693 num_addrs == 0 Normal mode, clear multicast list 694 num_addrs > 0 Multicast mode, receive normal and MC packets, and do 695 best-effort filtering. 698 set_multicast_list(struct device
*dev
,int num_addrs
,void*addrs
) 700 short ioaddr
= dev
->base_addr
; 701 int csr6
=inl(ioaddr
+ CSR6
) & ~0x00D5; 704 /* Too many to filter perfectly -- accept all multicasts. */ 705 outl(csr6
|0x0080, ioaddr
+ CSR6
); 706 }else if(num_addrs
<0) {/* Set promiscuous. */ 707 outl(csr6
|0x00C0, ioaddr
+ CSR6
); 708 /* Log any net taps. */ 709 printk("%s: Promiscuous mode enabled.\n", dev
->name
); 711 struct tulip_private
*tp
= (struct tulip_private
*)dev
->priv
; 712 int*setup_frm
= tp
->setup_frame
; 713 unsigned short*eaddrs
= addrs
; 716 /* We have <= 15 addresses that we can use the wonderful 717 16 address perfect filtering of the Tulip. Note that only 718 the low shortword of setup_frame[] is valid. */ 719 outl(csr6
|0x0000, ioaddr
+ CSR6
); 720 for(i
=0; i
< num_addrs
; i
++) { 721 *setup_frm
++ = *eaddrs
++; 722 *setup_frm
++ = *eaddrs
++; 723 *setup_frm
++ = *eaddrs
++; 725 /* Fill the rest of the table with our physical address. */ 726 eaddrs
= (unsigned short*)dev
->dev_addr
; 728 *setup_frm
++ = eaddrs
[0]; 729 *setup_frm
++ = eaddrs
[1]; 730 *setup_frm
++ = eaddrs
[2]; 733 /* Now add this frame to the Tx list. */ 738 set_mac_address(struct device
*dev
,void*addr
) 743 printk("%s: Setting MAC address to ", dev
->name
); 745 printk(" %2.2x", dev
->dev_addr
[i
] = ((unsigned char*)addr
)[i
]); 751 char kernel_version
[] = UTS_RELEASE
; 752 static struct device dev_tulip
= { 753 " "/*"tulip"*/,0,0,0,0,0,0,0,0,0, NULL
, tulip_probe
}; 760 dev_tulip
.base_addr
= io
; 762 if(register_netdev(&dev_tulip
) !=0) { 763 printk("tulip: register_netdev() returned non-zero.\n"); 773 printk("tulip: device busy, remove delayed\n"); 776 unregister_netdev(&dev_tulip
); 783 * compile-command: "gcc -D__KERNEL__ -I/usr/src/linux/net/inet -Wall -Wstrict-prototypes -O6 -m486 -c tulip.c"