aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/hamachi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/hamachi.c')
-rw-r--r--drivers/net/hamachi.c256
1 files changed, 124 insertions, 132 deletions
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c
index 0ea4cb4a0d8..5c89ae78a51 100644
--- a/drivers/net/hamachi.c
+++ b/drivers/net/hamachi.c
@@ -3,7 +3,7 @@
3 Written 1998-2000 by Donald Becker. 3 Written 1998-2000 by Donald Becker.
4 Updates 2000 by Keith Underwood. 4 Updates 2000 by Keith Underwood.
5 5
6 This software may be used and distributed according to the terms of 6 This software may be used and distributed according to the terms of
7 the GNU General Public License (GPL), incorporated herein by reference. 7 the GNU General Public License (GPL), incorporated herein by reference.
8 Drivers based on or derived from this code fall under the GPL and must 8 Drivers based on or derived from this code fall under the GPL and must
9 retain the authorship, copyright and license notice. This file is not 9 retain the authorship, copyright and license notice. This file is not
@@ -20,22 +20,15 @@
20 20
21 Support and updates available at 21 Support and updates available at
22 http://www.scyld.com/network/hamachi.html 22 http://www.scyld.com/network/hamachi.html
23 [link no longer provides useful info -jgarzik]
23 or 24 or
24 http://www.parl.clemson.edu/~keithu/hamachi.html 25 http://www.parl.clemson.edu/~keithu/hamachi.html
25 26
26
27
28 Linux kernel changelog:
29
30 LK1.0.1:
31 - fix lack of pci_dev<->dev association
32 - ethtool support (jgarzik)
33
34*/ 27*/
35 28
36#define DRV_NAME "hamachi" 29#define DRV_NAME "hamachi"
37#define DRV_VERSION "1.01+LK1.0.1" 30#define DRV_VERSION "2.1"
38#define DRV_RELDATE "5/18/2001" 31#define DRV_RELDATE "Sept 11, 2006"
39 32
40 33
41/* A few user-configurable values. */ 34/* A few user-configurable values. */
@@ -53,7 +46,7 @@ static int mtu;
53static int max_rx_latency = 0x11; 46static int max_rx_latency = 0x11;
54static int max_rx_gap = 0x05; 47static int max_rx_gap = 0x05;
55static int min_rx_pkt = 0x18; 48static int min_rx_pkt = 0x18;
56static int max_tx_latency = 0x00; 49static int max_tx_latency = 0x00;
57static int max_tx_gap = 0x00; 50static int max_tx_gap = 0x00;
58static int min_tx_pkt = 0x30; 51static int min_tx_pkt = 0x30;
59 52
@@ -83,7 +76,7 @@ static int force32;
83 - The next bit can be used to force half-duplex. This is a bad 76 - The next bit can be used to force half-duplex. This is a bad
84 idea since no known implementations implement half-duplex, and, 77 idea since no known implementations implement half-duplex, and,
85 in general, half-duplex for gigabit ethernet is a bad idea. 78 in general, half-duplex for gigabit ethernet is a bad idea.
86 0x00000080 : Force half-duplex 79 0x00000080 : Force half-duplex
87 Default is full-duplex. 80 Default is full-duplex.
88 - In the original driver, the ninth bit could be used to force 81 - In the original driver, the ninth bit could be used to force
89 full-duplex. Maintain that for compatibility 82 full-duplex. Maintain that for compatibility
@@ -94,7 +87,7 @@ static int options[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
94static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 87static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
95/* The Hamachi chipset supports 3 parameters each for Rx and Tx 88/* The Hamachi chipset supports 3 parameters each for Rx and Tx
96 * interruput management. Parameters will be loaded as specified into 89 * interruput management. Parameters will be loaded as specified into
97 * the TxIntControl and RxIntControl registers. 90 * the TxIntControl and RxIntControl registers.
98 * 91 *
99 * The registers are arranged as follows: 92 * The registers are arranged as follows:
100 * 23 - 16 15 - 8 7 - 0 93 * 23 - 16 15 - 8 7 - 0
@@ -102,10 +95,10 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
102 * | min_pkt | max_gap | max_latency | 95 * | min_pkt | max_gap | max_latency |
103 * --------------------------------- 96 * ---------------------------------
104 * min_pkt : The minimum number of packets processed between 97 * min_pkt : The minimum number of packets processed between
105 * interrupts. 98 * interrupts.
106 * max_gap : The maximum inter-packet gap in units of 8.192 us 99 * max_gap : The maximum inter-packet gap in units of 8.192 us
107 * max_latency : The absolute time between interrupts in units of 8.192 us 100 * max_latency : The absolute time between interrupts in units of 8.192 us
108 * 101 *
109 */ 102 */
110static int rx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 103static int rx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
111static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; 104static int tx_params[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1};
@@ -190,7 +183,7 @@ KERN_INFO " Further modifications by Keith Underwood <keithu@parl.clemson.edu>
190 other linux headers causing many compiler warnings. 183 other linux headers causing many compiler warnings.
191*/ 184*/
192#ifndef IP_MF 185#ifndef IP_MF
193 #define IP_MF 0x2000 /* IP more frags from <netinet/ip.h> */ 186 #define IP_MF 0x2000 /* IP more frags from <netinet/ip.h> */
194#endif 187#endif
195 188
196/* Define IP_OFFSET to be IPOPT_OFFSET */ 189/* Define IP_OFFSET to be IPOPT_OFFSET */
@@ -211,9 +204,9 @@ KERN_INFO " Further modifications by Keith Underwood <keithu@parl.clemson.edu>
211/* Condensed bus+endian portability operations. */ 204/* Condensed bus+endian portability operations. */
212#if ADDRLEN == 64 205#if ADDRLEN == 64
213#define cpu_to_leXX(addr) cpu_to_le64(addr) 206#define cpu_to_leXX(addr) cpu_to_le64(addr)
214#else 207#else
215#define cpu_to_leXX(addr) cpu_to_le32(addr) 208#define cpu_to_leXX(addr) cpu_to_le32(addr)
216#endif 209#endif
217 210
218 211
219/* 212/*
@@ -298,30 +291,30 @@ Hamachi Engineering Design Specification, 5/15/97
298 291
299IVc. Errata 292IVc. Errata
300 293
301None noted. 294None noted.
302 295
303V. Recent Changes 296V. Recent Changes
304 297
30501/15/1999 EPK Enlargement of the TX and RX ring sizes. This appears 29801/15/1999 EPK Enlargement of the TX and RX ring sizes. This appears
306 to help avoid some stall conditions -- this needs further research. 299 to help avoid some stall conditions -- this needs further research.
307 300
30801/15/1999 EPK Creation of the hamachi_tx function. This function cleans 30101/15/1999 EPK Creation of the hamachi_tx function. This function cleans
309 the Tx ring and is called from hamachi_start_xmit (this used to be 302 the Tx ring and is called from hamachi_start_xmit (this used to be
310 called from hamachi_interrupt but it tends to delay execution of the 303 called from hamachi_interrupt but it tends to delay execution of the
311 interrupt handler and thus reduce bandwidth by reducing the latency 304 interrupt handler and thus reduce bandwidth by reducing the latency
312 between hamachi_rx()'s). Notably, some modification has been made so 305 between hamachi_rx()'s). Notably, some modification has been made so
313 that the cleaning loop checks only to make sure that the DescOwn bit 306 that the cleaning loop checks only to make sure that the DescOwn bit
314 isn't set in the status flag since the card is not required 307 isn't set in the status flag since the card is not required
315 to set the entire flag to zero after processing. 308 to set the entire flag to zero after processing.
316 309
31701/15/1999 EPK In the hamachi_start_tx function, the Tx ring full flag is 31001/15/1999 EPK In the hamachi_start_tx function, the Tx ring full flag is
318 checked before attempting to add a buffer to the ring. If the ring is full 311 checked before attempting to add a buffer to the ring. If the ring is full
319 an attempt is made to free any dirty buffers and thus find space for 312 an attempt is made to free any dirty buffers and thus find space for
320 the new buffer or the function returns non-zero which should case the 313 the new buffer or the function returns non-zero which should case the
321 scheduler to reschedule the buffer later. 314 scheduler to reschedule the buffer later.
322 315
32301/15/1999 EPK Some adjustments were made to the chip initialization. 31601/15/1999 EPK Some adjustments were made to the chip initialization.
324 End-to-end flow control should now be fully active and the interrupt 317 End-to-end flow control should now be fully active and the interrupt
325 algorithm vars have been changed. These could probably use further tuning. 318 algorithm vars have been changed. These could probably use further tuning.
326 319
32701/15/1999 EPK Added the max_{rx,tx}_latency options. These are used to 32001/15/1999 EPK Added the max_{rx,tx}_latency options. These are used to
@@ -329,7 +322,7 @@ V. Recent Changes
329 problems with network stalls, try setting these to higher values. 322 problems with network stalls, try setting these to higher values.
330 Valid values are 0x00 through 0xff. 323 Valid values are 0x00 through 0xff.
331 324
33201/15/1999 EPK In general, the overall bandwidth has increased and 32501/15/1999 EPK In general, the overall bandwidth has increased and
333 latencies are better (sometimes by a factor of 2). Stalls are rare at 326 latencies are better (sometimes by a factor of 2). Stalls are rare at
334 this point, however there still appears to be a bug somewhere between the 327 this point, however there still appears to be a bug somewhere between the
335 hardware and driver. TCP checksum errors under load also appear to be 328 hardware and driver. TCP checksum errors under load also appear to be
@@ -341,20 +334,20 @@ V. Recent Changes
341 rings was typically getting set correctly, but the Tx ring wasn't getting 334 rings was typically getting set correctly, but the Tx ring wasn't getting
342 the DescEndRing bit set during initialization. ??? Does this mean the 335 the DescEndRing bit set during initialization. ??? Does this mean the
343 hamachi card is using the DescEndRing in processing even if a particular 336 hamachi card is using the DescEndRing in processing even if a particular
344 slot isn't in use -- hypothetically, the card might be searching the 337 slot isn't in use -- hypothetically, the card might be searching the
345 entire Tx ring for slots with the DescOwn bit set and then processing 338 entire Tx ring for slots with the DescOwn bit set and then processing
346 them. If the DescEndRing bit isn't set, then it might just wander off 339 them. If the DescEndRing bit isn't set, then it might just wander off
347 through memory until it hits a chunk of data with that bit set 340 through memory until it hits a chunk of data with that bit set
348 and then looping back. 341 and then looping back.
349 342
35002/09/1999 EPK Added Michel Mueller's TxDMA Interrupt and Tx-timeout 34302/09/1999 EPK Added Michel Mueller's TxDMA Interrupt and Tx-timeout
351 problem (TxCmd and RxCmd need only to be set when idle or stopped. 344 problem (TxCmd and RxCmd need only to be set when idle or stopped.
352 345
35302/09/1999 EPK Added code to check/reset dev->tbusy in hamachi_interrupt. 34602/09/1999 EPK Added code to check/reset dev->tbusy in hamachi_interrupt.
354 (Michel Mueller pointed out the ``permanently busy'' potential 347 (Michel Mueller pointed out the ``permanently busy'' potential
355 problem here). 348 problem here).
356 349
35702/22/1999 EPK Added Pete Wyckoff's ioctl to control the Tx/Rx latencies. 35002/22/1999 EPK Added Pete Wyckoff's ioctl to control the Tx/Rx latencies.
358 351
35902/23/1999 EPK Verified that the interrupt status field bits for Tx were 35202/23/1999 EPK Verified that the interrupt status field bits for Tx were
360 incorrectly defined and corrected (as per Michel Mueller). 353 incorrectly defined and corrected (as per Michel Mueller).
@@ -370,7 +363,7 @@ V. Recent Changes
370 363
37102/20/2000 KDU Some of the control was just plain odd. Cleaned up the 36402/20/2000 KDU Some of the control was just plain odd. Cleaned up the
372hamachi_start_xmit() and hamachi_interrupt() code. There is still some 365hamachi_start_xmit() and hamachi_interrupt() code. There is still some
373re-structuring I would like to do. 366re-structuring I would like to do.
374 367
37503/01/2000 KDU Experimenting with a WIDE range of interrupt mitigation 36803/01/2000 KDU Experimenting with a WIDE range of interrupt mitigation
376parameters on a dual P3-450 setup yielded the new default interrupt 369parameters on a dual P3-450 setup yielded the new default interrupt
@@ -378,25 +371,25 @@ mitigation parameters. Tx should interrupt VERY infrequently due to
378Eric's scheme. Rx should be more often... 371Eric's scheme. Rx should be more often...
379 372
38003/13/2000 KDU Added a patch to make the Rx Checksum code interact 37303/13/2000 KDU Added a patch to make the Rx Checksum code interact
381nicely with non-linux machines. 374nicely with non-linux machines.
382 375
38303/13/2000 KDU Experimented with some of the configuration values: 37603/13/2000 KDU Experimented with some of the configuration values:
384 377
385 -It seems that enabling PCI performance commands for descriptors 378 -It seems that enabling PCI performance commands for descriptors
386 (changing RxDMACtrl and TxDMACtrl lower nibble from 5 to D) has minimal 379 (changing RxDMACtrl and TxDMACtrl lower nibble from 5 to D) has minimal
387 performance impact for any of my tests. (ttcp, netpipe, netperf) I will 380 performance impact for any of my tests. (ttcp, netpipe, netperf) I will
388 leave them that way until I hear further feedback. 381 leave them that way until I hear further feedback.
389 382
390 -Increasing the PCI_LATENCY_TIMER to 130 383 -Increasing the PCI_LATENCY_TIMER to 130
391 (2 + (burst size of 128 * (0 wait states + 1))) seems to slightly 384 (2 + (burst size of 128 * (0 wait states + 1))) seems to slightly
392 degrade performance. Leaving default at 64 pending further information. 385 degrade performance. Leaving default at 64 pending further information.
393 386
39403/14/2000 KDU Further tuning: 38703/14/2000 KDU Further tuning:
395 388
396 -adjusted boguscnt in hamachi_rx() to depend on interrupt 389 -adjusted boguscnt in hamachi_rx() to depend on interrupt
397 mitigation parameters chosen. 390 mitigation parameters chosen.
398 391
399 -Selected a set of interrupt parameters based on some extensive testing. 392 -Selected a set of interrupt parameters based on some extensive testing.
400 These may change with more testing. 393 These may change with more testing.
401 394
402TO DO: 395TO DO:
@@ -405,14 +398,14 @@ TO DO:
405PCI_COMMAND_INVALIDATE. Set maximum burst size to cache line size in 398PCI_COMMAND_INVALIDATE. Set maximum burst size to cache line size in
406that case. 399that case.
407 400
408-fix the reset procedure. It doesn't quite work. 401-fix the reset procedure. It doesn't quite work.
409*/ 402*/
410 403
411/* A few values that may be tweaked. */ 404/* A few values that may be tweaked. */
412/* Size of each temporary Rx buffer, calculated as: 405/* Size of each temporary Rx buffer, calculated as:
413 * 1518 bytes (ethernet packet) + 2 bytes (to get 8 byte alignment for 406 * 1518 bytes (ethernet packet) + 2 bytes (to get 8 byte alignment for
414 * the card) + 8 bytes of status info + 8 bytes for the Rx Checksum + 407 * the card) + 8 bytes of status info + 8 bytes for the Rx Checksum +
415 * 2 more because we use skb_reserve. 408 * 2 more because we use skb_reserve.
416 */ 409 */
417#define PKT_BUF_SZ 1538 410#define PKT_BUF_SZ 1538
418 411
@@ -472,7 +465,7 @@ enum intr_status_bits {
472 465
473/* The Hamachi Rx and Tx buffer descriptors. */ 466/* The Hamachi Rx and Tx buffer descriptors. */
474struct hamachi_desc { 467struct hamachi_desc {
475 u32 status_n_length; 468 u32 status_n_length;
476#if ADDRLEN == 64 469#if ADDRLEN == 64
477 u32 pad; 470 u32 pad;
478 u64 addr; 471 u64 addr;
@@ -483,7 +476,7 @@ struct hamachi_desc {
483 476
484/* Bits in hamachi_desc.status_n_length */ 477/* Bits in hamachi_desc.status_n_length */
485enum desc_status_bits { 478enum desc_status_bits {
486 DescOwn=0x80000000, DescEndPacket=0x40000000, DescEndRing=0x20000000, 479 DescOwn=0x80000000, DescEndPacket=0x40000000, DescEndRing=0x20000000,
487 DescIntr=0x10000000, 480 DescIntr=0x10000000,
488}; 481};
489 482
@@ -553,7 +546,7 @@ MODULE_PARM_DESC(tx_params, "GNIC-II min_tx_pkt+max_tx_gap+max_tx_latency");
553MODULE_PARM_DESC(options, "GNIC-II Bits 0-3: media type, bits 4-6: as force32, bit 7: half duplex, bit 9 full duplex"); 546MODULE_PARM_DESC(options, "GNIC-II Bits 0-3: media type, bits 4-6: as force32, bit 7: half duplex, bit 9 full duplex");
554MODULE_PARM_DESC(full_duplex, "GNIC-II full duplex setting(s) (1)"); 547MODULE_PARM_DESC(full_duplex, "GNIC-II full duplex setting(s) (1)");
555MODULE_PARM_DESC(force32, "GNIC-II: Bit 0: 32 bit PCI, bit 1: disable parity, bit 2: 64 bit PCI (all boards)"); 548MODULE_PARM_DESC(force32, "GNIC-II: Bit 0: 32 bit PCI, bit 1: disable parity, bit 2: 64 bit PCI (all boards)");
556 549
557static int read_eeprom(void __iomem *ioaddr, int location); 550static int read_eeprom(void __iomem *ioaddr, int location);
558static int mdio_read(struct net_device *dev, int phy_id, int location); 551static int mdio_read(struct net_device *dev, int phy_id, int location);
559static void mdio_write(struct net_device *dev, int phy_id, int location, int value); 552static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
@@ -570,8 +563,8 @@ static void hamachi_error(struct net_device *dev, int intr_status);
570static int hamachi_close(struct net_device *dev); 563static int hamachi_close(struct net_device *dev);
571static struct net_device_stats *hamachi_get_stats(struct net_device *dev); 564static struct net_device_stats *hamachi_get_stats(struct net_device *dev);
572static void set_rx_mode(struct net_device *dev); 565static void set_rx_mode(struct net_device *dev);
573static struct ethtool_ops ethtool_ops; 566static const struct ethtool_ops ethtool_ops;
574static struct ethtool_ops ethtool_ops_no_mii; 567static const struct ethtool_ops ethtool_ops_no_mii;
575 568
576static int __devinit hamachi_init_one (struct pci_dev *pdev, 569static int __devinit hamachi_init_one (struct pci_dev *pdev,
577 const struct pci_device_id *ent) 570 const struct pci_device_id *ent)
@@ -608,7 +601,8 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
608 pci_set_master(pdev); 601 pci_set_master(pdev);
609 602
610 i = pci_request_regions(pdev, DRV_NAME); 603 i = pci_request_regions(pdev, DRV_NAME);
611 if (i) return i; 604 if (i)
605 return i;
612 606
613 irq = pdev->irq; 607 irq = pdev->irq;
614 ioaddr = ioremap(base, 0x400); 608 ioaddr = ioremap(base, 0x400);
@@ -665,7 +659,7 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
665 option = dev->mem_start; 659 option = dev->mem_start;
666 660
667 /* If the bus size is misidentified, do the following. */ 661 /* If the bus size is misidentified, do the following. */
668 force32 = force32 ? force32 : 662 force32 = force32 ? force32 :
669 ((option >= 0) ? ((option & 0x00000070) >> 4) : 0 ); 663 ((option >= 0) ? ((option & 0x00000070) >> 4) : 0 );
670 if (force32) 664 if (force32)
671 writeb(force32, ioaddr + VirtualJumpers); 665 writeb(force32, ioaddr + VirtualJumpers);
@@ -677,11 +671,11 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
677 * be valid for a moment. Wait for a little while until it is. If 671 * be valid for a moment. Wait for a little while until it is. If
678 * it takes more than 10ms, forget it. 672 * it takes more than 10ms, forget it.
679 */ 673 */
680 udelay(10); 674 udelay(10);
681 i = readb(ioaddr + PCIClkMeas); 675 i = readb(ioaddr + PCIClkMeas);
682 for (boguscnt = 0; (!(i & 0x080)) && boguscnt < 1000; boguscnt++){ 676 for (boguscnt = 0; (!(i & 0x080)) && boguscnt < 1000; boguscnt++){
683 udelay(10); 677 udelay(10);
684 i = readb(ioaddr + PCIClkMeas); 678 i = readb(ioaddr + PCIClkMeas);
685 } 679 }
686 680
687 hmp->base = ioaddr; 681 hmp->base = ioaddr;
@@ -720,9 +714,9 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
720 714
721 rx_int_var = card_idx < MAX_UNITS ? rx_params[card_idx] : -1; 715 rx_int_var = card_idx < MAX_UNITS ? rx_params[card_idx] : -1;
722 tx_int_var = card_idx < MAX_UNITS ? tx_params[card_idx] : -1; 716 tx_int_var = card_idx < MAX_UNITS ? tx_params[card_idx] : -1;
723 hmp->rx_int_var = rx_int_var >= 0 ? rx_int_var : 717 hmp->rx_int_var = rx_int_var >= 0 ? rx_int_var :
724 (min_rx_pkt << 16 | max_rx_gap << 8 | max_rx_latency); 718 (min_rx_pkt << 16 | max_rx_gap << 8 | max_rx_latency);
725 hmp->tx_int_var = tx_int_var >= 0 ? tx_int_var : 719 hmp->tx_int_var = tx_int_var >= 0 ? tx_int_var :
726 (min_tx_pkt << 16 | max_tx_gap << 8 | max_tx_latency); 720 (min_tx_pkt << 16 | max_tx_gap << 8 | max_tx_latency);
727 721
728 722
@@ -789,10 +783,10 @@ static int __devinit hamachi_init_one (struct pci_dev *pdev,
789 return 0; 783 return 0;
790 784
791err_out_unmap_rx: 785err_out_unmap_rx:
792 pci_free_consistent(pdev, RX_TOTAL_SIZE, hmp->rx_ring, 786 pci_free_consistent(pdev, RX_TOTAL_SIZE, hmp->rx_ring,
793 hmp->rx_ring_dma); 787 hmp->rx_ring_dma);
794err_out_unmap_tx: 788err_out_unmap_tx:
795 pci_free_consistent(pdev, TX_TOTAL_SIZE, hmp->tx_ring, 789 pci_free_consistent(pdev, TX_TOTAL_SIZE, hmp->tx_ring,
796 hmp->tx_ring_dma); 790 hmp->tx_ring_dma);
797err_out_cleardev: 791err_out_cleardev:
798 free_netdev (dev); 792 free_netdev (dev);
@@ -862,7 +856,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
862 return; 856 return;
863} 857}
864 858
865 859
866static int hamachi_open(struct net_device *dev) 860static int hamachi_open(struct net_device *dev)
867{ 861{
868 struct hamachi_private *hmp = netdev_priv(dev); 862 struct hamachi_private *hmp = netdev_priv(dev);
@@ -871,7 +865,7 @@ static int hamachi_open(struct net_device *dev)
871 u32 rx_int_var, tx_int_var; 865 u32 rx_int_var, tx_int_var;
872 u16 fifo_info; 866 u16 fifo_info;
873 867
874 i = request_irq(dev->irq, &hamachi_interrupt, SA_SHIRQ, dev->name, dev); 868 i = request_irq(dev->irq, &hamachi_interrupt, IRQF_SHARED, dev->name, dev);
875 if (i) 869 if (i)
876 return i; 870 return i;
877 871
@@ -892,7 +886,7 @@ static int hamachi_open(struct net_device *dev)
892 writel(cpu_to_le32(hmp->tx_ring_dma), ioaddr + TxPtr); 886 writel(cpu_to_le32(hmp->tx_ring_dma), ioaddr + TxPtr);
893#endif 887#endif
894 888
895 /* TODO: It would make sense to organize this as words since the card 889 /* TODO: It would make sense to organize this as words since the card
896 * documentation does. -KDU 890 * documentation does. -KDU
897 */ 891 */
898 for (i = 0; i < 6; i++) 892 for (i = 0; i < 6; i++)
@@ -904,36 +898,36 @@ static int hamachi_open(struct net_device *dev)
904 /* Configure the FIFO */ 898 /* Configure the FIFO */
905 fifo_info = (readw(ioaddr + GPIO) & 0x00C0) >> 6; 899 fifo_info = (readw(ioaddr + GPIO) & 0x00C0) >> 6;
906 switch (fifo_info){ 900 switch (fifo_info){
907 case 0 : 901 case 0 :
908 /* No FIFO */ 902 /* No FIFO */
909 writew(0x0000, ioaddr + FIFOcfg); 903 writew(0x0000, ioaddr + FIFOcfg);
910 break; 904 break;
911 case 1 : 905 case 1 :
912 /* Configure the FIFO for 512K external, 16K used for Tx. */ 906 /* Configure the FIFO for 512K external, 16K used for Tx. */
913 writew(0x0028, ioaddr + FIFOcfg); 907 writew(0x0028, ioaddr + FIFOcfg);
914 break; 908 break;
915 case 2 : 909 case 2 :
916 /* Configure the FIFO for 1024 external, 32K used for Tx. */ 910 /* Configure the FIFO for 1024 external, 32K used for Tx. */
917 writew(0x004C, ioaddr + FIFOcfg); 911 writew(0x004C, ioaddr + FIFOcfg);
918 break; 912 break;
919 case 3 : 913 case 3 :
920 /* Configure the FIFO for 2048 external, 32K used for Tx. */ 914 /* Configure the FIFO for 2048 external, 32K used for Tx. */
921 writew(0x006C, ioaddr + FIFOcfg); 915 writew(0x006C, ioaddr + FIFOcfg);
922 break; 916 break;
923 default : 917 default :
924 printk(KERN_WARNING "%s: Unsupported external memory config!\n", 918 printk(KERN_WARNING "%s: Unsupported external memory config!\n",
925 dev->name); 919 dev->name);
926 /* Default to no FIFO */ 920 /* Default to no FIFO */
927 writew(0x0000, ioaddr + FIFOcfg); 921 writew(0x0000, ioaddr + FIFOcfg);
928 break; 922 break;
929 } 923 }
930 924
931 if (dev->if_port == 0) 925 if (dev->if_port == 0)
932 dev->if_port = hmp->default_port; 926 dev->if_port = hmp->default_port;
933 927
934 928
935 /* Setting the Rx mode will start the Rx process. */ 929 /* Setting the Rx mode will start the Rx process. */
936 /* If someone didn't choose a duplex, default to full-duplex */ 930 /* If someone didn't choose a duplex, default to full-duplex */
937 if (hmp->duplex_lock != 1) 931 if (hmp->duplex_lock != 1)
938 hmp->mii_if.full_duplex = 1; 932 hmp->mii_if.full_duplex = 1;
939 933
@@ -946,7 +940,7 @@ static int hamachi_open(struct net_device *dev)
946#endif 940#endif
947 writew(0x8000, ioaddr + MACCnfg); /* Soft reset the MAC */ 941 writew(0x8000, ioaddr + MACCnfg); /* Soft reset the MAC */
948 writew(0x215F, ioaddr + MACCnfg); 942 writew(0x215F, ioaddr + MACCnfg);
949 writew(0x000C, ioaddr + FrameGap0); 943 writew(0x000C, ioaddr + FrameGap0);
950 /* WHAT?!?!? Why isn't this documented somewhere? -KDU */ 944 /* WHAT?!?!? Why isn't this documented somewhere? -KDU */
951 writew(0x1018, ioaddr + FrameGap1); 945 writew(0x1018, ioaddr + FrameGap1);
952 /* Why do we enable receives/transmits here? -KDU */ 946 /* Why do we enable receives/transmits here? -KDU */
@@ -968,16 +962,16 @@ static int hamachi_open(struct net_device *dev)
968 962
969 if (hamachi_debug > 1) { 963 if (hamachi_debug > 1) {
970 printk("max_tx_latency: %d, max_tx_gap: %d, min_tx_pkt: %d\n", 964 printk("max_tx_latency: %d, max_tx_gap: %d, min_tx_pkt: %d\n",
971 tx_int_var & 0x00ff, (tx_int_var & 0x00ff00) >> 8, 965 tx_int_var & 0x00ff, (tx_int_var & 0x00ff00) >> 8,
972 (tx_int_var & 0x00ff0000) >> 16); 966 (tx_int_var & 0x00ff0000) >> 16);
973 printk("max_rx_latency: %d, max_rx_gap: %d, min_rx_pkt: %d\n", 967 printk("max_rx_latency: %d, max_rx_gap: %d, min_rx_pkt: %d\n",
974 rx_int_var & 0x00ff, (rx_int_var & 0x00ff00) >> 8, 968 rx_int_var & 0x00ff, (rx_int_var & 0x00ff00) >> 8,
975 (rx_int_var & 0x00ff0000) >> 16); 969 (rx_int_var & 0x00ff0000) >> 16);
976 printk("rx_int_var: %x, tx_int_var: %x\n", rx_int_var, tx_int_var); 970 printk("rx_int_var: %x, tx_int_var: %x\n", rx_int_var, tx_int_var);
977 } 971 }
978 972
979 writel(tx_int_var, ioaddr + TxIntrCtrl); 973 writel(tx_int_var, ioaddr + TxIntrCtrl);
980 writel(rx_int_var, ioaddr + RxIntrCtrl); 974 writel(rx_int_var, ioaddr + RxIntrCtrl);
981 975
982 set_rx_mode(dev); 976 set_rx_mode(dev);
983 977
@@ -1022,21 +1016,21 @@ static inline int hamachi_tx(struct net_device *dev)
1022 int entry = hmp->dirty_tx % TX_RING_SIZE; 1016 int entry = hmp->dirty_tx % TX_RING_SIZE;
1023 struct sk_buff *skb; 1017 struct sk_buff *skb;
1024 1018
1025 if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn)) 1019 if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn))
1026 break; 1020 break;
1027 /* Free the original skb. */ 1021 /* Free the original skb. */
1028 skb = hmp->tx_skbuff[entry]; 1022 skb = hmp->tx_skbuff[entry];
1029 if (skb != 0) { 1023 if (skb != 0) {
1030 pci_unmap_single(hmp->pci_dev, 1024 pci_unmap_single(hmp->pci_dev,
1031 hmp->tx_ring[entry].addr, skb->len, 1025 hmp->tx_ring[entry].addr, skb->len,
1032 PCI_DMA_TODEVICE); 1026 PCI_DMA_TODEVICE);
1033 dev_kfree_skb(skb); 1027 dev_kfree_skb(skb);
1034 hmp->tx_skbuff[entry] = NULL; 1028 hmp->tx_skbuff[entry] = NULL;
1035 } 1029 }
1036 hmp->tx_ring[entry].status_n_length = 0; 1030 hmp->tx_ring[entry].status_n_length = 0;
1037 if (entry >= TX_RING_SIZE-1) 1031 if (entry >= TX_RING_SIZE-1)
1038 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |= 1032 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |=
1039 cpu_to_le32(DescEndRing); 1033 cpu_to_le32(DescEndRing);
1040 hmp->stats.tx_packets++; 1034 hmp->stats.tx_packets++;
1041 } 1035 }
1042 1036
@@ -1088,7 +1082,7 @@ static void hamachi_tx_timeout(struct net_device *dev)
1088 printk("\n"); 1082 printk("\n");
1089 } 1083 }
1090 1084
1091 /* Reinit the hardware and make sure the Rx and Tx processes 1085 /* Reinit the hardware and make sure the Rx and Tx processes
1092 are up and running. 1086 are up and running.
1093 */ 1087 */
1094 dev->if_port = 0; 1088 dev->if_port = 0;
@@ -1098,7 +1092,7 @@ static void hamachi_tx_timeout(struct net_device *dev)
1098 * -Turn off MAC receiver 1092 * -Turn off MAC receiver
1099 * -Issue Reset 1093 * -Issue Reset
1100 */ 1094 */
1101 1095
1102 for (i = 0; i < RX_RING_SIZE; i++) 1096 for (i = 0; i < RX_RING_SIZE; i++)
1103 hmp->rx_ring[i].status_n_length &= cpu_to_le32(~DescOwn); 1097 hmp->rx_ring[i].status_n_length &= cpu_to_le32(~DescOwn);
1104 1098
@@ -1112,11 +1106,11 @@ static void hamachi_tx_timeout(struct net_device *dev)
1112 hmp->tx_ring[i].status_n_length = cpu_to_le32( 1106 hmp->tx_ring[i].status_n_length = cpu_to_le32(
1113 DescEndRing | 1107 DescEndRing |
1114 (hmp->tx_ring[i].status_n_length & 0x0000FFFF)); 1108 (hmp->tx_ring[i].status_n_length & 0x0000FFFF));
1115 else 1109 else
1116 hmp->tx_ring[i].status_n_length &= 0x0000ffff; 1110 hmp->tx_ring[i].status_n_length &= 0x0000ffff;
1117 skb = hmp->tx_skbuff[i]; 1111 skb = hmp->tx_skbuff[i];
1118 if (skb){ 1112 if (skb){
1119 pci_unmap_single(hmp->pci_dev, hmp->tx_ring[i].addr, 1113 pci_unmap_single(hmp->pci_dev, hmp->tx_ring[i].addr,
1120 skb->len, PCI_DMA_TODEVICE); 1114 skb->len, PCI_DMA_TODEVICE);
1121 dev_kfree_skb(skb); 1115 dev_kfree_skb(skb);
1122 hmp->tx_skbuff[i] = NULL; 1116 hmp->tx_skbuff[i] = NULL;
@@ -1125,20 +1119,20 @@ static void hamachi_tx_timeout(struct net_device *dev)
1125 1119
1126 udelay(60); /* Sleep 60 us just for safety sake */ 1120 udelay(60); /* Sleep 60 us just for safety sake */
1127 writew(0x0002, ioaddr + RxCmd); /* STOP Rx */ 1121 writew(0x0002, ioaddr + RxCmd); /* STOP Rx */
1128 1122
1129 writeb(0x01, ioaddr + ChipReset); /* Reinit the hardware */ 1123 writeb(0x01, ioaddr + ChipReset); /* Reinit the hardware */
1130 1124
1131 hmp->tx_full = 0; 1125 hmp->tx_full = 0;
1132 hmp->cur_rx = hmp->cur_tx = 0; 1126 hmp->cur_rx = hmp->cur_tx = 0;
1133 hmp->dirty_rx = hmp->dirty_tx = 0; 1127 hmp->dirty_rx = hmp->dirty_tx = 0;
1134 /* Rx packets are also presumed lost; however, we need to make sure a 1128 /* Rx packets are also presumed lost; however, we need to make sure a
1135 * ring of buffers is in tact. -KDU 1129 * ring of buffers is in tact. -KDU
1136 */ 1130 */
1137 for (i = 0; i < RX_RING_SIZE; i++){ 1131 for (i = 0; i < RX_RING_SIZE; i++){
1138 struct sk_buff *skb = hmp->rx_skbuff[i]; 1132 struct sk_buff *skb = hmp->rx_skbuff[i];
1139 1133
1140 if (skb){ 1134 if (skb){
1141 pci_unmap_single(hmp->pci_dev, hmp->rx_ring[i].addr, 1135 pci_unmap_single(hmp->pci_dev, hmp->rx_ring[i].addr,
1142 hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1136 hmp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1143 dev_kfree_skb(skb); 1137 dev_kfree_skb(skb);
1144 hmp->rx_skbuff[i] = NULL; 1138 hmp->rx_skbuff[i] = NULL;
@@ -1152,9 +1146,9 @@ static void hamachi_tx_timeout(struct net_device *dev)
1152 break; 1146 break;
1153 skb->dev = dev; /* Mark as being used by this device. */ 1147 skb->dev = dev; /* Mark as being used by this device. */
1154 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1148 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1155 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1149 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1156 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1150 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1157 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn | 1151 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn |
1158 DescEndPacket | DescIntr | (hmp->rx_buf_sz - 2)); 1152 DescEndPacket | DescIntr | (hmp->rx_buf_sz - 2));
1159 } 1153 }
1160 hmp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); 1154 hmp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
@@ -1193,11 +1187,11 @@ static void hamachi_init_ring(struct net_device *dev)
1193#endif 1187#endif
1194 /* My attempt at a reasonable correction */ 1188 /* My attempt at a reasonable correction */
1195 /* +26 gets the maximum ethernet encapsulation, +7 & ~7 because the 1189 /* +26 gets the maximum ethernet encapsulation, +7 & ~7 because the
1196 * card needs room to do 8 byte alignment, +2 so we can reserve 1190 * card needs room to do 8 byte alignment, +2 so we can reserve
1197 * the first 2 bytes, and +16 gets room for the status word from the 1191 * the first 2 bytes, and +16 gets room for the status word from the
1198 * card. -KDU 1192 * card. -KDU
1199 */ 1193 */
1200 hmp->rx_buf_sz = (dev->mtu <= 1492 ? PKT_BUF_SZ : 1194 hmp->rx_buf_sz = (dev->mtu <= 1492 ? PKT_BUF_SZ :
1201 (((dev->mtu+26+7) & ~7) + 2 + 16)); 1195 (((dev->mtu+26+7) & ~7) + 2 + 16));
1202 1196
1203 /* Initialize all Rx descriptors. */ 1197 /* Initialize all Rx descriptors. */
@@ -1213,10 +1207,10 @@ static void hamachi_init_ring(struct net_device *dev)
1213 break; 1207 break;
1214 skb->dev = dev; /* Mark as being used by this device. */ 1208 skb->dev = dev; /* Mark as being used by this device. */
1215 skb_reserve(skb, 2); /* 16 byte align the IP header. */ 1209 skb_reserve(skb, 2); /* 16 byte align the IP header. */
1216 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1210 hmp->rx_ring[i].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1217 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1211 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1218 /* -2 because it doesn't REALLY have that first 2 bytes -KDU */ 1212 /* -2 because it doesn't REALLY have that first 2 bytes -KDU */
1219 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn | 1213 hmp->rx_ring[i].status_n_length = cpu_to_le32(DescOwn |
1220 DescEndPacket | DescIntr | (hmp->rx_buf_sz -2)); 1214 DescEndPacket | DescIntr | (hmp->rx_buf_sz -2));
1221 } 1215 }
1222 hmp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); 1216 hmp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
@@ -1273,7 +1267,7 @@ static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev)
1273 unsigned entry; 1267 unsigned entry;
1274 u16 status; 1268 u16 status;
1275 1269
1276 /* Ok, now make sure that the queue has space before trying to 1270 /* Ok, now make sure that the queue has space before trying to
1277 add another skbuff. if we return non-zero the scheduler 1271 add another skbuff. if we return non-zero the scheduler
1278 should interpret this as a queue full and requeue the buffer 1272 should interpret this as a queue full and requeue the buffer
1279 for later. 1273 for later.
@@ -1288,7 +1282,7 @@ static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev)
1288 if( !(status & 0x0001) || (status & 0x0002)) 1282 if( !(status & 0x0001) || (status & 0x0002))
1289 writew(0x0001, hmp->base + TxCmd); 1283 writew(0x0001, hmp->base + TxCmd);
1290 return 1; 1284 return 1;
1291 } 1285 }
1292 1286
1293 /* Caution: the write order is important here, set the field 1287 /* Caution: the write order is important here, set the field
1294 with the "ownership" bits last. */ 1288 with the "ownership" bits last. */
@@ -1328,15 +1322,15 @@ static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev)
1328 } 1322 }
1329#endif 1323#endif
1330 1324
1331 hmp->tx_ring[entry].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1325 hmp->tx_ring[entry].addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1332 skb->data, skb->len, PCI_DMA_TODEVICE)); 1326 skb->data, skb->len, PCI_DMA_TODEVICE));
1333 1327
1334 /* Hmmmm, could probably put a DescIntr on these, but the way 1328 /* Hmmmm, could probably put a DescIntr on these, but the way
1335 the driver is currently coded makes Tx interrupts unnecessary 1329 the driver is currently coded makes Tx interrupts unnecessary
1336 since the clearing of the Tx ring is handled by the start_xmit 1330 since the clearing of the Tx ring is handled by the start_xmit
1337 routine. This organization helps mitigate the interrupts a 1331 routine. This organization helps mitigate the interrupts a
1338 bit and probably renders the max_tx_latency param useless. 1332 bit and probably renders the max_tx_latency param useless.
1339 1333
1340 Update: Putting a DescIntr bit on all of the descriptors and 1334 Update: Putting a DescIntr bit on all of the descriptors and
1341 mitigating interrupt frequency with the tx_min_pkt parameter. -KDU 1335 mitigating interrupt frequency with the tx_min_pkt parameter. -KDU
1342 */ 1336 */
@@ -1365,7 +1359,7 @@ static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev)
1365 * hence, any packet that got put off because we were in the transmit 1359 * hence, any packet that got put off because we were in the transmit
1366 * routine should IMMEDIATELY get a chance to be re-queued. -KDU 1360 * routine should IMMEDIATELY get a chance to be re-queued. -KDU
1367 */ 1361 */
1368 if ((hmp->cur_tx - hmp->dirty_tx) < (TX_RING_SIZE - 4)) 1362 if ((hmp->cur_tx - hmp->dirty_tx) < (TX_RING_SIZE - 4))
1369 netif_wake_queue(dev); /* Typical path */ 1363 netif_wake_queue(dev); /* Typical path */
1370 else { 1364 else {
1371 hmp->tx_full = 1; 1365 hmp->tx_full = 1;
@@ -1418,27 +1412,27 @@ static irqreturn_t hamachi_interrupt(int irq, void *dev_instance, struct pt_regs
1418 /* This code should RARELY need to execute. After all, this is 1412 /* This code should RARELY need to execute. After all, this is
1419 * a gigabit link, it should consume packets as fast as we put 1413 * a gigabit link, it should consume packets as fast as we put
1420 * them in AND we clear the Tx ring in hamachi_start_xmit(). 1414 * them in AND we clear the Tx ring in hamachi_start_xmit().
1421 */ 1415 */
1422 if (hmp->tx_full){ 1416 if (hmp->tx_full){
1423 for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++){ 1417 for (; hmp->cur_tx - hmp->dirty_tx > 0; hmp->dirty_tx++){
1424 int entry = hmp->dirty_tx % TX_RING_SIZE; 1418 int entry = hmp->dirty_tx % TX_RING_SIZE;
1425 struct sk_buff *skb; 1419 struct sk_buff *skb;
1426 1420
1427 if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn)) 1421 if (hmp->tx_ring[entry].status_n_length & cpu_to_le32(DescOwn))
1428 break; 1422 break;
1429 skb = hmp->tx_skbuff[entry]; 1423 skb = hmp->tx_skbuff[entry];
1430 /* Free the original skb. */ 1424 /* Free the original skb. */
1431 if (skb){ 1425 if (skb){
1432 pci_unmap_single(hmp->pci_dev, 1426 pci_unmap_single(hmp->pci_dev,
1433 hmp->tx_ring[entry].addr, 1427 hmp->tx_ring[entry].addr,
1434 skb->len, 1428 skb->len,
1435 PCI_DMA_TODEVICE); 1429 PCI_DMA_TODEVICE);
1436 dev_kfree_skb_irq(skb); 1430 dev_kfree_skb_irq(skb);
1437 hmp->tx_skbuff[entry] = NULL; 1431 hmp->tx_skbuff[entry] = NULL;
1438 } 1432 }
1439 hmp->tx_ring[entry].status_n_length = 0; 1433 hmp->tx_ring[entry].status_n_length = 0;
1440 if (entry >= TX_RING_SIZE-1) 1434 if (entry >= TX_RING_SIZE-1)
1441 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |= 1435 hmp->tx_ring[TX_RING_SIZE-1].status_n_length |=
1442 cpu_to_le32(DescEndRing); 1436 cpu_to_le32(DescEndRing);
1443 hmp->stats.tx_packets++; 1437 hmp->stats.tx_packets++;
1444 } 1438 }
@@ -1504,9 +1498,9 @@ static int hamachi_rx(struct net_device *dev)
1504 struct hamachi_desc *desc = &(hmp->rx_ring[entry]); 1498 struct hamachi_desc *desc = &(hmp->rx_ring[entry]);
1505 u32 desc_status = le32_to_cpu(desc->status_n_length); 1499 u32 desc_status = le32_to_cpu(desc->status_n_length);
1506 u16 data_size = desc_status; /* Implicit truncate */ 1500 u16 data_size = desc_status; /* Implicit truncate */
1507 u8 *buf_addr; 1501 u8 *buf_addr;
1508 s32 frame_status; 1502 s32 frame_status;
1509 1503
1510 if (desc_status & DescOwn) 1504 if (desc_status & DescOwn)
1511 break; 1505 break;
1512 pci_dma_sync_single_for_cpu(hmp->pci_dev, 1506 pci_dma_sync_single_for_cpu(hmp->pci_dev,
@@ -1546,7 +1540,7 @@ static int hamachi_rx(struct net_device *dev)
1546 } else { 1540 } else {
1547 struct sk_buff *skb; 1541 struct sk_buff *skb;
1548 /* Omit CRC */ 1542 /* Omit CRC */
1549 u16 pkt_len = (frame_status & 0x07ff) - 4; 1543 u16 pkt_len = (frame_status & 0x07ff) - 4;
1550#ifdef RX_CHECKSUM 1544#ifdef RX_CHECKSUM
1551 u32 pfck = *(u32 *) &buf_addr[data_size - 8]; 1545 u32 pfck = *(u32 *) &buf_addr[data_size - 8];
1552#endif 1546#endif
@@ -1582,7 +1576,7 @@ static int hamachi_rx(struct net_device *dev)
1582 PCI_DMA_FROMDEVICE); 1576 PCI_DMA_FROMDEVICE);
1583 /* Call copy + cksum if available. */ 1577 /* Call copy + cksum if available. */
1584#if 1 || USE_IP_COPYSUM 1578#if 1 || USE_IP_COPYSUM
1585 eth_copy_and_sum(skb, 1579 eth_copy_and_sum(skb,
1586 hmp->rx_skbuff[entry]->data, pkt_len, 0); 1580 hmp->rx_skbuff[entry]->data, pkt_len, 0);
1587 skb_put(skb, pkt_len); 1581 skb_put(skb, pkt_len);
1588#else 1582#else
@@ -1594,7 +1588,7 @@ static int hamachi_rx(struct net_device *dev)
1594 hmp->rx_buf_sz, 1588 hmp->rx_buf_sz,
1595 PCI_DMA_FROMDEVICE); 1589 PCI_DMA_FROMDEVICE);
1596 } else { 1590 } else {
1597 pci_unmap_single(hmp->pci_dev, 1591 pci_unmap_single(hmp->pci_dev,
1598 hmp->rx_ring[entry].addr, 1592 hmp->rx_ring[entry].addr,
1599 hmp->rx_buf_sz, PCI_DMA_FROMDEVICE); 1593 hmp->rx_buf_sz, PCI_DMA_FROMDEVICE);
1600 skb_put(skb = hmp->rx_skbuff[entry], pkt_len); 1594 skb_put(skb = hmp->rx_skbuff[entry], pkt_len);
@@ -1625,18 +1619,18 @@ static int hamachi_rx(struct net_device *dev)
1625 p_r = *p; 1619 p_r = *p;
1626 p_r1 = *(p-1); 1620 p_r1 = *(p-1);
1627 switch (inv) { 1621 switch (inv) {
1628 case 0: 1622 case 0:
1629 crc = (p_r & 0xffff) + (p_r >> 16); 1623 crc = (p_r & 0xffff) + (p_r >> 16);
1630 break; 1624 break;
1631 case 1: 1625 case 1:
1632 crc = (p_r >> 16) + (p_r & 0xffff) 1626 crc = (p_r >> 16) + (p_r & 0xffff)
1633 + (p_r1 >> 16 & 0xff00); 1627 + (p_r1 >> 16 & 0xff00);
1634 break; 1628 break;
1635 case 2: 1629 case 2:
1636 crc = p_r + (p_r1 >> 16); 1630 crc = p_r + (p_r1 >> 16);
1637 break; 1631 break;
1638 case 3: 1632 case 3:
1639 crc = p_r + (p_r1 & 0xff00) + (p_r1 >> 16); 1633 crc = p_r + (p_r1 & 0xff00) + (p_r1 >> 16);
1640 break; 1634 break;
1641 default: /*NOTREACHED*/ crc = 0; 1635 default: /*NOTREACHED*/ crc = 0;
1642 } 1636 }
@@ -1654,9 +1648,9 @@ static int hamachi_rx(struct net_device *dev)
1654 * could do the pseudo myself and return 1648 * could do the pseudo myself and return
1655 * CHECKSUM_UNNECESSARY 1649 * CHECKSUM_UNNECESSARY
1656 */ 1650 */
1657 skb->ip_summed = CHECKSUM_HW; 1651 skb->ip_summed = CHECKSUM_COMPLETE;
1658 } 1652 }
1659 } 1653 }
1660 } 1654 }
1661#endif /* RX_CHECKSUM */ 1655#endif /* RX_CHECKSUM */
1662 1656
@@ -1681,15 +1675,15 @@ static int hamachi_rx(struct net_device *dev)
1681 break; /* Better luck next round. */ 1675 break; /* Better luck next round. */
1682 skb->dev = dev; /* Mark as being used by this device. */ 1676 skb->dev = dev; /* Mark as being used by this device. */
1683 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 1677 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
1684 desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev, 1678 desc->addr = cpu_to_leXX(pci_map_single(hmp->pci_dev,
1685 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 1679 skb->data, hmp->rx_buf_sz, PCI_DMA_FROMDEVICE));
1686 } 1680 }
1687 desc->status_n_length = cpu_to_le32(hmp->rx_buf_sz); 1681 desc->status_n_length = cpu_to_le32(hmp->rx_buf_sz);
1688 if (entry >= RX_RING_SIZE-1) 1682 if (entry >= RX_RING_SIZE-1)
1689 desc->status_n_length |= cpu_to_le32(DescOwn | 1683 desc->status_n_length |= cpu_to_le32(DescOwn |
1690 DescEndPacket | DescEndRing | DescIntr); 1684 DescEndPacket | DescEndRing | DescIntr);
1691 else 1685 else
1692 desc->status_n_length |= cpu_to_le32(DescOwn | 1686 desc->status_n_length |= cpu_to_le32(DescOwn |
1693 DescEndPacket | DescIntr); 1687 DescEndPacket | DescIntr);
1694 } 1688 }
1695 1689
@@ -1800,8 +1794,8 @@ static int hamachi_close(struct net_device *dev)
1800 hmp->rx_ring[i].status_n_length = 0; 1794 hmp->rx_ring[i].status_n_length = 0;
1801 hmp->rx_ring[i].addr = 0xBADF00D0; /* An invalid address. */ 1795 hmp->rx_ring[i].addr = 0xBADF00D0; /* An invalid address. */
1802 if (skb) { 1796 if (skb) {
1803 pci_unmap_single(hmp->pci_dev, 1797 pci_unmap_single(hmp->pci_dev,
1804 hmp->rx_ring[i].addr, hmp->rx_buf_sz, 1798 hmp->rx_ring[i].addr, hmp->rx_buf_sz,
1805 PCI_DMA_FROMDEVICE); 1799 PCI_DMA_FROMDEVICE);
1806 dev_kfree_skb(skb); 1800 dev_kfree_skb(skb);
1807 hmp->rx_skbuff[i] = NULL; 1801 hmp->rx_skbuff[i] = NULL;
@@ -1810,8 +1804,8 @@ static int hamachi_close(struct net_device *dev)
1810 for (i = 0; i < TX_RING_SIZE; i++) { 1804 for (i = 0; i < TX_RING_SIZE; i++) {
1811 skb = hmp->tx_skbuff[i]; 1805 skb = hmp->tx_skbuff[i];
1812 if (skb) { 1806 if (skb) {
1813 pci_unmap_single(hmp->pci_dev, 1807 pci_unmap_single(hmp->pci_dev,
1814 hmp->tx_ring[i].addr, skb->len, 1808 hmp->tx_ring[i].addr, skb->len,
1815 PCI_DMA_TODEVICE); 1809 PCI_DMA_TODEVICE);
1816 dev_kfree_skb(skb); 1810 dev_kfree_skb(skb);
1817 hmp->tx_skbuff[i] = NULL; 1811 hmp->tx_skbuff[i] = NULL;
@@ -1835,7 +1829,7 @@ static struct net_device_stats *hamachi_get_stats(struct net_device *dev)
1835 according to ifconfig. It does get incremented in hamachi_tx(), 1829 according to ifconfig. It does get incremented in hamachi_tx(),
1836 so I think I'll comment it out here and see if better things 1830 so I think I'll comment it out here and see if better things
1837 happen. 1831 happen.
1838 */ 1832 */
1839 /* hmp->stats.tx_packets = readl(ioaddr + 0x000); */ 1833 /* hmp->stats.tx_packets = readl(ioaddr + 0x000); */
1840 1834
1841 hmp->stats.rx_bytes = readl(ioaddr + 0x330); /* Total Uni+Brd+Multi */ 1835 hmp->stats.rx_bytes = readl(ioaddr + 0x330); /* Total Uni+Brd+Multi */
@@ -1857,8 +1851,6 @@ static void set_rx_mode(struct net_device *dev)
1857 void __iomem *ioaddr = hmp->base; 1851 void __iomem *ioaddr = hmp->base;
1858 1852
1859 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */ 1853 if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
1860 /* Unconditionally log net taps. */
1861 printk(KERN_NOTICE "%s: Promiscuous mode enabled.\n", dev->name);
1862 writew(0x000F, ioaddr + AddrMode); 1854 writew(0x000F, ioaddr + AddrMode);
1863 } else if ((dev->mc_count > 63) || (dev->flags & IFF_ALLMULTI)) { 1855 } else if ((dev->mc_count > 63) || (dev->flags & IFF_ALLMULTI)) {
1864 /* Too many to match, or accept all multicasts. */ 1856 /* Too many to match, or accept all multicasts. */
@@ -1927,7 +1919,7 @@ static u32 hamachi_get_link(struct net_device *dev)
1927 return mii_link_ok(&np->mii_if); 1919 return mii_link_ok(&np->mii_if);
1928} 1920}
1929 1921
1930static struct ethtool_ops ethtool_ops = { 1922static const struct ethtool_ops ethtool_ops = {
1931 .begin = check_if_running, 1923 .begin = check_if_running,
1932 .get_drvinfo = hamachi_get_drvinfo, 1924 .get_drvinfo = hamachi_get_drvinfo,
1933 .get_settings = hamachi_get_settings, 1925 .get_settings = hamachi_get_settings,
@@ -1936,7 +1928,7 @@ static struct ethtool_ops ethtool_ops = {
1936 .get_link = hamachi_get_link, 1928 .get_link = hamachi_get_link,
1937}; 1929};
1938 1930
1939static struct ethtool_ops ethtool_ops_no_mii = { 1931static const struct ethtool_ops ethtool_ops_no_mii = {
1940 .begin = check_if_running, 1932 .begin = check_if_running,
1941 .get_drvinfo = hamachi_get_drvinfo, 1933 .get_drvinfo = hamachi_get_drvinfo,
1942}; 1934};
@@ -1984,9 +1976,9 @@ static void __devexit hamachi_remove_one (struct pci_dev *pdev)
1984 if (dev) { 1976 if (dev) {
1985 struct hamachi_private *hmp = netdev_priv(dev); 1977 struct hamachi_private *hmp = netdev_priv(dev);
1986 1978
1987 pci_free_consistent(pdev, RX_TOTAL_SIZE, hmp->rx_ring, 1979 pci_free_consistent(pdev, RX_TOTAL_SIZE, hmp->rx_ring,
1988 hmp->rx_ring_dma); 1980 hmp->rx_ring_dma);
1989 pci_free_consistent(pdev, TX_TOTAL_SIZE, hmp->tx_ring, 1981 pci_free_consistent(pdev, TX_TOTAL_SIZE, hmp->tx_ring,
1990 hmp->tx_ring_dma); 1982 hmp->tx_ring_dma);
1991 unregister_netdev(dev); 1983 unregister_netdev(dev);
1992 iounmap(hmp->base); 1984 iounmap(hmp->base);