aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/dl2k.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/dl2k.c')
-rw-r--r--drivers/net/dl2k.c213
1 files changed, 87 insertions, 126 deletions
diff --git a/drivers/net/dl2k.c b/drivers/net/dl2k.c
index 038447fb5c5..7e95cf1a487 100644
--- a/drivers/net/dl2k.c
+++ b/drivers/net/dl2k.c
@@ -9,54 +9,15 @@
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11*/ 11*/
12/*
13 Rev Date Description
14 ==========================================================================
15 0.01 2001/05/03 Created DL2000-based linux driver
16 0.02 2001/05/21 Added VLAN and hardware checksum support.
17 1.00 2001/06/26 Added jumbo frame support.
18 1.01 2001/08/21 Added two parameters, rx_coalesce and rx_timeout.
19 1.02 2001/10/08 Supported fiber media.
20 Added flow control parameters.
21 1.03 2001/10/12 Changed the default media to 1000mbps_fd for
22 the fiber devices.
23 1.04 2001/11/08 Fixed Tx stopped when tx very busy.
24 1.05 2001/11/22 Fixed Tx stopped when unidirectional tx busy.
25 1.06 2001/12/13 Fixed disconnect bug at 10Mbps mode.
26 Fixed tx_full flag incorrect.
27 Added tx_coalesce paramter.
28 1.07 2002/01/03 Fixed miscount of RX frame error.
29 1.08 2002/01/17 Fixed the multicast bug.
30 1.09 2002/03/07 Move rx-poll-now to re-fill loop.
31 Added rio_timer() to watch rx buffers.
32 1.10 2002/04/16 Fixed miscount of carrier error.
33 1.11 2002/05/23 Added ISR schedule scheme
34 Fixed miscount of rx frame error for DGE-550SX.
35 Fixed VLAN bug.
36 1.12 2002/06/13 Lock tx_coalesce=1 on 10/100Mbps mode.
37 1.13 2002/08/13 1. Fix disconnection (many tx:carrier/rx:frame
38 errs) with some mainboards.
39 2. Use definition "DRV_NAME" "DRV_VERSION"
40 "DRV_RELDATE" for flexibility.
41 1.14 2002/08/14 Support ethtool.
42 1.15 2002/08/27 Changed the default media to Auto-Negotiation
43 for the fiber devices.
44 1.16 2002/09/04 More power down time for fiber devices auto-
45 negotiation.
46 Fix disconnect bug after ifup and ifdown.
47 1.17 2002/10/03 Fix RMON statistics overflow.
48 Always use I/O mapping to access eeprom,
49 avoid system freezing with some chipsets.
50 12
51*/
52#define DRV_NAME "D-Link DL2000-based linux driver" 13#define DRV_NAME "D-Link DL2000-based linux driver"
53#define DRV_VERSION "v1.17b" 14#define DRV_VERSION "v1.18"
54#define DRV_RELDATE "2006/03/10" 15#define DRV_RELDATE "2006/06/27"
55#include "dl2k.h" 16#include "dl2k.h"
56#include <linux/dma-mapping.h> 17#include <linux/dma-mapping.h>
57 18
58static char version[] __devinitdata = 19static char version[] __devinitdata =
59 KERN_INFO DRV_NAME " " DRV_VERSION " " DRV_RELDATE "\n"; 20 KERN_INFO DRV_NAME " " DRV_VERSION " " DRV_RELDATE "\n";
60#define MAX_UNITS 8 21#define MAX_UNITS 8
61static int mtu[MAX_UNITS]; 22static int mtu[MAX_UNITS];
62static int vlan[MAX_UNITS]; 23static int vlan[MAX_UNITS];
@@ -122,7 +83,7 @@ static int mii_read (struct net_device *dev, int phy_addr, int reg_num);
122static int mii_write (struct net_device *dev, int phy_addr, int reg_num, 83static int mii_write (struct net_device *dev, int phy_addr, int reg_num,
123 u16 data); 84 u16 data);
124 85
125static struct ethtool_ops ethtool_ops; 86static const struct ethtool_ops ethtool_ops;
126 87
127static int __devinit 88static int __devinit
128rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent) 89rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
@@ -183,9 +144,9 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
183 if (media[card_idx] != NULL) { 144 if (media[card_idx] != NULL) {
184 np->an_enable = 0; 145 np->an_enable = 0;
185 if (strcmp (media[card_idx], "auto") == 0 || 146 if (strcmp (media[card_idx], "auto") == 0 ||
186 strcmp (media[card_idx], "autosense") == 0 || 147 strcmp (media[card_idx], "autosense") == 0 ||
187 strcmp (media[card_idx], "0") == 0 ) { 148 strcmp (media[card_idx], "0") == 0 ) {
188 np->an_enable = 2; 149 np->an_enable = 2;
189 } else if (strcmp (media[card_idx], "100mbps_fd") == 0 || 150 } else if (strcmp (media[card_idx], "100mbps_fd") == 0 ||
190 strcmp (media[card_idx], "4") == 0) { 151 strcmp (media[card_idx], "4") == 0) {
191 np->speed = 100; 152 np->speed = 100;
@@ -271,7 +232,7 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
271 err = find_miiphy (dev); 232 err = find_miiphy (dev);
272 if (err) 233 if (err)
273 goto err_out_unmap_rx; 234 goto err_out_unmap_rx;
274 235
275 /* Fiber device? */ 236 /* Fiber device? */
276 np->phy_media = (readw(ioaddr + ASICCtrl) & PhyMedia) ? 1 : 0; 237 np->phy_media = (readw(ioaddr + ASICCtrl) & PhyMedia) ? 1 : 0;
277 np->link_status = 0; 238 np->link_status = 0;
@@ -302,11 +263,11 @@ rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
302 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], 263 dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
303 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5], irq); 264 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5], irq);
304 if (tx_coalesce > 1) 265 if (tx_coalesce > 1)
305 printk(KERN_INFO "tx_coalesce:\t%d packets\n", 266 printk(KERN_INFO "tx_coalesce:\t%d packets\n",
306 tx_coalesce); 267 tx_coalesce);
307 if (np->coalesce) 268 if (np->coalesce)
308 printk(KERN_INFO "rx_coalesce:\t%d packets\n" 269 printk(KERN_INFO "rx_coalesce:\t%d packets\n"
309 KERN_INFO "rx_timeout: \t%d ns\n", 270 KERN_INFO "rx_timeout: \t%d ns\n",
310 np->rx_coalesce, np->rx_timeout*640); 271 np->rx_coalesce, np->rx_timeout*640);
311 if (np->vlan) 272 if (np->vlan)
312 printk(KERN_INFO "vlan(id):\t%d\n", np->vlan); 273 printk(KERN_INFO "vlan(id):\t%d\n", np->vlan);
@@ -378,7 +339,7 @@ parse_eeprom (struct net_device *dev)
378 } 339 }
379#ifdef MEM_MAPPING 340#ifdef MEM_MAPPING
380 ioaddr = dev->base_addr; 341 ioaddr = dev->base_addr;
381#endif 342#endif
382 /* Check CRC */ 343 /* Check CRC */
383 crc = ~ether_crc_le (256 - 4, sromdata); 344 crc = ~ether_crc_le (256 - 4, sromdata);
384 if (psrom->crc != crc) { 345 if (psrom->crc != crc) {
@@ -390,7 +351,7 @@ parse_eeprom (struct net_device *dev)
390 for (i = 0; i < 6; i++) 351 for (i = 0; i < 6; i++)
391 dev->dev_addr[i] = psrom->mac_addr[i]; 352 dev->dev_addr[i] = psrom->mac_addr[i];
392 353
393 /* Parse Software Infomation Block */ 354 /* Parse Software Information Block */
394 i = 0x30; 355 i = 0x30;
395 psib = (u8 *) sromdata; 356 psib = (u8 *) sromdata;
396 do { 357 do {
@@ -439,16 +400,16 @@ rio_open (struct net_device *dev)
439 long ioaddr = dev->base_addr; 400 long ioaddr = dev->base_addr;
440 int i; 401 int i;
441 u16 macctrl; 402 u16 macctrl;
442 403
443 i = request_irq (dev->irq, &rio_interrupt, SA_SHIRQ, dev->name, dev); 404 i = request_irq (dev->irq, &rio_interrupt, IRQF_SHARED, dev->name, dev);
444 if (i) 405 if (i)
445 return i; 406 return i;
446 407
447 /* Reset all logic functions */ 408 /* Reset all logic functions */
448 writew (GlobalReset | DMAReset | FIFOReset | NetworkReset | HostReset, 409 writew (GlobalReset | DMAReset | FIFOReset | NetworkReset | HostReset,
449 ioaddr + ASICCtrl + 2); 410 ioaddr + ASICCtrl + 2);
450 mdelay(10); 411 mdelay(10);
451 412
452 /* DebugCtrl bit 4, 5, 9 must set */ 413 /* DebugCtrl bit 4, 5, 9 must set */
453 writel (readl (ioaddr + DebugCtrl) | 0x0230, ioaddr + DebugCtrl); 414 writel (readl (ioaddr + DebugCtrl) | 0x0230, ioaddr + DebugCtrl);
454 415
@@ -479,7 +440,7 @@ rio_open (struct net_device *dev)
479 /* VLAN supported */ 440 /* VLAN supported */
480 if (np->vlan) { 441 if (np->vlan) {
481 /* priority field in RxDMAIntCtrl */ 442 /* priority field in RxDMAIntCtrl */
482 writel (readl(ioaddr + RxDMAIntCtrl) | 0x7 << 10, 443 writel (readl(ioaddr + RxDMAIntCtrl) | 0x7 << 10,
483 ioaddr + RxDMAIntCtrl); 444 ioaddr + RxDMAIntCtrl);
484 /* VLANId */ 445 /* VLANId */
485 writew (np->vlan, ioaddr + VLANId); 446 writew (np->vlan, ioaddr + VLANId);
@@ -498,9 +459,9 @@ rio_open (struct net_device *dev)
498 add_timer (&np->timer); 459 add_timer (&np->timer);
499 460
500 /* Start Tx/Rx */ 461 /* Start Tx/Rx */
501 writel (readl (ioaddr + MACCtrl) | StatsEnable | RxEnable | TxEnable, 462 writel (readl (ioaddr + MACCtrl) | StatsEnable | RxEnable | TxEnable,
502 ioaddr + MACCtrl); 463 ioaddr + MACCtrl);
503 464
504 macctrl = 0; 465 macctrl = 0;
505 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; 466 macctrl |= (np->vlan) ? AutoVLANuntagging : 0;
506 macctrl |= (np->full_duplex) ? DuplexSelect : 0; 467 macctrl |= (np->full_duplex) ? DuplexSelect : 0;
@@ -509,13 +470,13 @@ rio_open (struct net_device *dev)
509 writew(macctrl, ioaddr + MACCtrl); 470 writew(macctrl, ioaddr + MACCtrl);
510 471
511 netif_start_queue (dev); 472 netif_start_queue (dev);
512 473
513 /* Enable default interrupts */ 474 /* Enable default interrupts */
514 EnableInt (); 475 EnableInt ();
515 return 0; 476 return 0;
516} 477}
517 478
518static void 479static void
519rio_timer (unsigned long data) 480rio_timer (unsigned long data)
520{ 481{
521 struct net_device *dev = (struct net_device *)data; 482 struct net_device *dev = (struct net_device *)data;
@@ -560,7 +521,7 @@ rio_timer (unsigned long data)
560 np->timer.expires = jiffies + next_tick; 521 np->timer.expires = jiffies + next_tick;
561 add_timer(&np->timer); 522 add_timer(&np->timer);
562} 523}
563 524
564static void 525static void
565rio_tx_timeout (struct net_device *dev) 526rio_tx_timeout (struct net_device *dev)
566{ 527{
@@ -650,7 +611,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
650 txdesc = &np->tx_ring[entry]; 611 txdesc = &np->tx_ring[entry];
651 612
652#if 0 613#if 0
653 if (skb->ip_summed == CHECKSUM_HW) { 614 if (skb->ip_summed == CHECKSUM_PARTIAL) {
654 txdesc->status |= 615 txdesc->status |=
655 cpu_to_le64 (TCPChecksumEnable | UDPChecksumEnable | 616 cpu_to_le64 (TCPChecksumEnable | UDPChecksumEnable |
656 IPChecksumEnable); 617 IPChecksumEnable);
@@ -671,12 +632,12 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
671 * Work around: Always use 1 descriptor in 10Mbps mode */ 632 * Work around: Always use 1 descriptor in 10Mbps mode */
672 if (entry % np->tx_coalesce == 0 || np->speed == 10) 633 if (entry % np->tx_coalesce == 0 || np->speed == 10)
673 txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag | 634 txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag |
674 WordAlignDisable | 635 WordAlignDisable |
675 TxDMAIndicate | 636 TxDMAIndicate |
676 (1 << FragCountShift)); 637 (1 << FragCountShift));
677 else 638 else
678 txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag | 639 txdesc->status = cpu_to_le64 (entry | tfc_vlan_tag |
679 WordAlignDisable | 640 WordAlignDisable |
680 (1 << FragCountShift)); 641 (1 << FragCountShift));
681 642
682 /* TxDMAPollNow */ 643 /* TxDMAPollNow */
@@ -697,7 +658,7 @@ start_xmit (struct sk_buff *skb, struct net_device *dev)
697 dev->base_addr + TFDListPtr0); 658 dev->base_addr + TFDListPtr0);
698 writel (0, dev->base_addr + TFDListPtr1); 659 writel (0, dev->base_addr + TFDListPtr1);
699 } 660 }
700 661
701 /* NETDEV WATCHDOG timer */ 662 /* NETDEV WATCHDOG timer */
702 dev->trans_start = jiffies; 663 dev->trans_start = jiffies;
703 return 0; 664 return 0;
@@ -716,7 +677,7 @@ rio_interrupt (int irq, void *dev_instance, struct pt_regs *rgs)
716 ioaddr = dev->base_addr; 677 ioaddr = dev->base_addr;
717 np = netdev_priv(dev); 678 np = netdev_priv(dev);
718 while (1) { 679 while (1) {
719 int_status = readw (ioaddr + IntStatus); 680 int_status = readw (ioaddr + IntStatus);
720 writew (int_status, ioaddr + IntStatus); 681 writew (int_status, ioaddr + IntStatus);
721 int_status &= DEFAULT_INTR; 682 int_status &= DEFAULT_INTR;
722 if (int_status == 0 || --cnt < 0) 683 if (int_status == 0 || --cnt < 0)
@@ -732,7 +693,7 @@ rio_interrupt (int irq, void *dev_instance, struct pt_regs *rgs)
732 if (tx_status & 0x01) 693 if (tx_status & 0x01)
733 tx_error (dev, tx_status); 694 tx_error (dev, tx_status);
734 /* Free used tx skbuffs */ 695 /* Free used tx skbuffs */
735 rio_free_tx (dev, 1); 696 rio_free_tx (dev, 1);
736 } 697 }
737 698
738 /* Handle uncommon events */ 699 /* Handle uncommon events */
@@ -745,19 +706,19 @@ rio_interrupt (int irq, void *dev_instance, struct pt_regs *rgs)
745 return IRQ_RETVAL(handled); 706 return IRQ_RETVAL(handled);
746} 707}
747 708
748static void 709static void
749rio_free_tx (struct net_device *dev, int irq) 710rio_free_tx (struct net_device *dev, int irq)
750{ 711{
751 struct netdev_private *np = netdev_priv(dev); 712 struct netdev_private *np = netdev_priv(dev);
752 int entry = np->old_tx % TX_RING_SIZE; 713 int entry = np->old_tx % TX_RING_SIZE;
753 int tx_use = 0; 714 int tx_use = 0;
754 unsigned long flag = 0; 715 unsigned long flag = 0;
755 716
756 if (irq) 717 if (irq)
757 spin_lock(&np->tx_lock); 718 spin_lock(&np->tx_lock);
758 else 719 else
759 spin_lock_irqsave(&np->tx_lock, flag); 720 spin_lock_irqsave(&np->tx_lock, flag);
760 721
761 /* Free used tx skbuffs */ 722 /* Free used tx skbuffs */
762 while (entry != np->cur_tx) { 723 while (entry != np->cur_tx) {
763 struct sk_buff *skb; 724 struct sk_buff *skb;
@@ -783,11 +744,11 @@ rio_free_tx (struct net_device *dev, int irq)
783 spin_unlock_irqrestore(&np->tx_lock, flag); 744 spin_unlock_irqrestore(&np->tx_lock, flag);
784 np->old_tx = entry; 745 np->old_tx = entry;
785 746
786 /* If the ring is no longer full, clear tx_full and 747 /* If the ring is no longer full, clear tx_full and
787 call netif_wake_queue() */ 748 call netif_wake_queue() */
788 749
789 if (netif_queue_stopped(dev) && 750 if (netif_queue_stopped(dev) &&
790 ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE 751 ((np->cur_tx - np->old_tx + TX_RING_SIZE) % TX_RING_SIZE
791 < TX_QUEUE_LEN - 1 || np->speed == 10)) { 752 < TX_QUEUE_LEN - 1 || np->speed == 10)) {
792 netif_wake_queue (dev); 753 netif_wake_queue (dev);
793 } 754 }
@@ -844,11 +805,11 @@ tx_error (struct net_device *dev, int tx_status)
844 /* Let TxStartThresh stay default value */ 805 /* Let TxStartThresh stay default value */
845 } 806 }
846 /* Maximum Collisions */ 807 /* Maximum Collisions */
847#ifdef ETHER_STATS 808#ifdef ETHER_STATS
848 if (tx_status & 0x08) 809 if (tx_status & 0x08)
849 np->stats.collisions16++; 810 np->stats.collisions16++;
850#else 811#else
851 if (tx_status & 0x08) 812 if (tx_status & 0x08)
852 np->stats.collisions++; 813 np->stats.collisions++;
853#endif 814#endif
854 /* Restart the Tx */ 815 /* Restart the Tx */
@@ -901,7 +862,7 @@ receive_packet (struct net_device *dev)
901 np->rx_skbuff[entry] = NULL; 862 np->rx_skbuff[entry] = NULL;
902 } else if ((skb = dev_alloc_skb (pkt_len + 2)) != NULL) { 863 } else if ((skb = dev_alloc_skb (pkt_len + 2)) != NULL) {
903 pci_dma_sync_single_for_cpu(np->pdev, 864 pci_dma_sync_single_for_cpu(np->pdev,
904 desc->fraginfo & 865 desc->fraginfo &
905 DMA_48BIT_MASK, 866 DMA_48BIT_MASK,
906 np->rx_buf_sz, 867 np->rx_buf_sz,
907 PCI_DMA_FROMDEVICE); 868 PCI_DMA_FROMDEVICE);
@@ -919,12 +880,12 @@ receive_packet (struct net_device *dev)
919 PCI_DMA_FROMDEVICE); 880 PCI_DMA_FROMDEVICE);
920 } 881 }
921 skb->protocol = eth_type_trans (skb, dev); 882 skb->protocol = eth_type_trans (skb, dev);
922#if 0 883#if 0
923 /* Checksum done by hw, but csum value unavailable. */ 884 /* Checksum done by hw, but csum value unavailable. */
924 if (np->pci_rev_id >= 0x0c && 885 if (np->pci_rev_id >= 0x0c &&
925 !(frame_status & (TCPError | UDPError | IPError))) { 886 !(frame_status & (TCPError | UDPError | IPError))) {
926 skb->ip_summed = CHECKSUM_UNNECESSARY; 887 skb->ip_summed = CHECKSUM_UNNECESSARY;
927 } 888 }
928#endif 889#endif
929 netif_rx (skb); 890 netif_rx (skb);
930 dev->last_rx = jiffies; 891 dev->last_rx = jiffies;
@@ -984,14 +945,14 @@ rio_error (struct net_device *dev, int int_status)
984 mii_get_media (dev); 945 mii_get_media (dev);
985 if (np->speed == 1000) 946 if (np->speed == 1000)
986 np->tx_coalesce = tx_coalesce; 947 np->tx_coalesce = tx_coalesce;
987 else 948 else
988 np->tx_coalesce = 1; 949 np->tx_coalesce = 1;
989 macctrl = 0; 950 macctrl = 0;
990 macctrl |= (np->vlan) ? AutoVLANuntagging : 0; 951 macctrl |= (np->vlan) ? AutoVLANuntagging : 0;
991 macctrl |= (np->full_duplex) ? DuplexSelect : 0; 952 macctrl |= (np->full_duplex) ? DuplexSelect : 0;
992 macctrl |= (np->tx_flow) ? 953 macctrl |= (np->tx_flow) ?
993 TxFlowControlEnable : 0; 954 TxFlowControlEnable : 0;
994 macctrl |= (np->rx_flow) ? 955 macctrl |= (np->rx_flow) ?
995 RxFlowControlEnable : 0; 956 RxFlowControlEnable : 0;
996 writew(macctrl, ioaddr + MACCtrl); 957 writew(macctrl, ioaddr + MACCtrl);
997 np->link_status = 1; 958 np->link_status = 1;
@@ -1008,7 +969,7 @@ rio_error (struct net_device *dev, int int_status)
1008 get_stats (dev); 969 get_stats (dev);
1009 } 970 }
1010 971
1011 /* PCI Error, a catastronphic error related to the bus interface 972 /* PCI Error, a catastronphic error related to the bus interface
1012 occurs, set GlobalReset and HostReset to reset. */ 973 occurs, set GlobalReset and HostReset to reset. */
1013 if (int_status & HostError) { 974 if (int_status & HostError) {
1014 printk (KERN_ERR "%s: HostError! IntStatus %4.4x.\n", 975 printk (KERN_ERR "%s: HostError! IntStatus %4.4x.\n",
@@ -1030,16 +991,16 @@ get_stats (struct net_device *dev)
1030 991
1031 /* All statistics registers need to be acknowledged, 992 /* All statistics registers need to be acknowledged,
1032 else statistic overflow could cause problems */ 993 else statistic overflow could cause problems */
1033 994
1034 np->stats.rx_packets += readl (ioaddr + FramesRcvOk); 995 np->stats.rx_packets += readl (ioaddr + FramesRcvOk);
1035 np->stats.tx_packets += readl (ioaddr + FramesXmtOk); 996 np->stats.tx_packets += readl (ioaddr + FramesXmtOk);
1036 np->stats.rx_bytes += readl (ioaddr + OctetRcvOk); 997 np->stats.rx_bytes += readl (ioaddr + OctetRcvOk);
1037 np->stats.tx_bytes += readl (ioaddr + OctetXmtOk); 998 np->stats.tx_bytes += readl (ioaddr + OctetXmtOk);
1038 999
1039 np->stats.multicast = readl (ioaddr + McstFramesRcvdOk); 1000 np->stats.multicast = readl (ioaddr + McstFramesRcvdOk);
1040 np->stats.collisions += readl (ioaddr + SingleColFrames) 1001 np->stats.collisions += readl (ioaddr + SingleColFrames)
1041 + readl (ioaddr + MultiColFrames); 1002 + readl (ioaddr + MultiColFrames);
1042 1003
1043 /* detailed tx errors */ 1004 /* detailed tx errors */
1044 stat_reg = readw (ioaddr + FramesAbortXSColls); 1005 stat_reg = readw (ioaddr + FramesAbortXSColls);
1045 np->stats.tx_aborted_errors += stat_reg; 1006 np->stats.tx_aborted_errors += stat_reg;
@@ -1086,7 +1047,7 @@ clear_stats (struct net_device *dev)
1086 long ioaddr = dev->base_addr; 1047 long ioaddr = dev->base_addr;
1087#ifdef MEM_MAPPING 1048#ifdef MEM_MAPPING
1088 int i; 1049 int i;
1089#endif 1050#endif
1090 1051
1091 /* All statistics registers need to be acknowledged, 1052 /* All statistics registers need to be acknowledged,
1092 else statistic overflow could cause problems */ 1053 else statistic overflow could cause problems */
@@ -1099,7 +1060,7 @@ clear_stats (struct net_device *dev)
1099 readl (ioaddr + SingleColFrames); 1060 readl (ioaddr + SingleColFrames);
1100 readl (ioaddr + MultiColFrames); 1061 readl (ioaddr + MultiColFrames);
1101 readl (ioaddr + LateCollisions); 1062 readl (ioaddr + LateCollisions);
1102 /* detailed rx errors */ 1063 /* detailed rx errors */
1103 readw (ioaddr + FrameTooLongErrors); 1064 readw (ioaddr + FrameTooLongErrors);
1104 readw (ioaddr + InRangeLengthErrors); 1065 readw (ioaddr + InRangeLengthErrors);
1105 readw (ioaddr + FramesCheckSeqErrors); 1066 readw (ioaddr + FramesCheckSeqErrors);
@@ -1125,7 +1086,7 @@ clear_stats (struct net_device *dev)
1125#ifdef MEM_MAPPING 1086#ifdef MEM_MAPPING
1126 for (i = 0x100; i <= 0x150; i += 4) 1087 for (i = 0x100; i <= 0x150; i += 4)
1127 readl (ioaddr + i); 1088 readl (ioaddr + i);
1128#endif 1089#endif
1129 readw (ioaddr + TxJumboFrames); 1090 readw (ioaddr + TxJumboFrames);
1130 readw (ioaddr + RxJumboFrames); 1091 readw (ioaddr + RxJumboFrames);
1131 readw (ioaddr + TCPCheckSumErrors); 1092 readw (ioaddr + TCPCheckSumErrors);
@@ -1157,26 +1118,26 @@ set_multicast (struct net_device *dev)
1157 u32 hash_table[2]; 1118 u32 hash_table[2];
1158 u16 rx_mode = 0; 1119 u16 rx_mode = 0;
1159 struct netdev_private *np = netdev_priv(dev); 1120 struct netdev_private *np = netdev_priv(dev);
1160 1121
1161 hash_table[0] = hash_table[1] = 0; 1122 hash_table[0] = hash_table[1] = 0;
1162 /* RxFlowcontrol DA: 01-80-C2-00-00-01. Hash index=0x39 */ 1123 /* RxFlowcontrol DA: 01-80-C2-00-00-01. Hash index=0x39 */
1163 hash_table[1] |= cpu_to_le32(0x02000000); 1124 hash_table[1] |= cpu_to_le32(0x02000000);
1164 if (dev->flags & IFF_PROMISC) { 1125 if (dev->flags & IFF_PROMISC) {
1165 /* Receive all frames promiscuously. */ 1126 /* Receive all frames promiscuously. */
1166 rx_mode = ReceiveAllFrames; 1127 rx_mode = ReceiveAllFrames;
1167 } else if ((dev->flags & IFF_ALLMULTI) || 1128 } else if ((dev->flags & IFF_ALLMULTI) ||
1168 (dev->mc_count > multicast_filter_limit)) { 1129 (dev->mc_count > multicast_filter_limit)) {
1169 /* Receive broadcast and multicast frames */ 1130 /* Receive broadcast and multicast frames */
1170 rx_mode = ReceiveBroadcast | ReceiveMulticast | ReceiveUnicast; 1131 rx_mode = ReceiveBroadcast | ReceiveMulticast | ReceiveUnicast;
1171 } else if (dev->mc_count > 0) { 1132 } else if (dev->mc_count > 0) {
1172 int i; 1133 int i;
1173 struct dev_mc_list *mclist; 1134 struct dev_mc_list *mclist;
1174 /* Receive broadcast frames and multicast frames filtering 1135 /* Receive broadcast frames and multicast frames filtering
1175 by Hashtable */ 1136 by Hashtable */
1176 rx_mode = 1137 rx_mode =
1177 ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast; 1138 ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast;
1178 for (i=0, mclist = dev->mc_list; mclist && i < dev->mc_count; 1139 for (i=0, mclist = dev->mc_list; mclist && i < dev->mc_count;
1179 i++, mclist=mclist->next) 1140 i++, mclist=mclist->next)
1180 { 1141 {
1181 int bit, index = 0; 1142 int bit, index = 0;
1182 int crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr); 1143 int crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr);
@@ -1206,7 +1167,7 @@ static void rio_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info
1206 strcpy(info->driver, "dl2k"); 1167 strcpy(info->driver, "dl2k");
1207 strcpy(info->version, DRV_VERSION); 1168 strcpy(info->version, DRV_VERSION);
1208 strcpy(info->bus_info, pci_name(np->pdev)); 1169 strcpy(info->bus_info, pci_name(np->pdev));
1209} 1170}
1210 1171
1211static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1172static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1212{ 1173{
@@ -1216,10 +1177,10 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1216 cmd->supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE; 1177 cmd->supported = SUPPORTED_Autoneg | SUPPORTED_FIBRE;
1217 cmd->advertising= ADVERTISED_Autoneg | ADVERTISED_FIBRE; 1178 cmd->advertising= ADVERTISED_Autoneg | ADVERTISED_FIBRE;
1218 cmd->port = PORT_FIBRE; 1179 cmd->port = PORT_FIBRE;
1219 cmd->transceiver = XCVR_INTERNAL; 1180 cmd->transceiver = XCVR_INTERNAL;
1220 } else { 1181 } else {
1221 /* copper device */ 1182 /* copper device */
1222 cmd->supported = SUPPORTED_10baseT_Half | 1183 cmd->supported = SUPPORTED_10baseT_Half |
1223 SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half 1184 SUPPORTED_10baseT_Full | SUPPORTED_100baseT_Half
1224 | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full | 1185 | SUPPORTED_100baseT_Full | SUPPORTED_1000baseT_Full |
1225 SUPPORTED_Autoneg | SUPPORTED_MII; 1186 SUPPORTED_Autoneg | SUPPORTED_MII;
@@ -1230,7 +1191,7 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1230 cmd->port = PORT_MII; 1191 cmd->port = PORT_MII;
1231 cmd->transceiver = XCVR_INTERNAL; 1192 cmd->transceiver = XCVR_INTERNAL;
1232 } 1193 }
1233 if ( np->link_status ) { 1194 if ( np->link_status ) {
1234 cmd->speed = np->speed; 1195 cmd->speed = np->speed;
1235 cmd->duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF; 1196 cmd->duplex = np->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
1236 } else { 1197 } else {
@@ -1241,9 +1202,9 @@ static int rio_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1241 cmd->autoneg = AUTONEG_ENABLE; 1202 cmd->autoneg = AUTONEG_ENABLE;
1242 else 1203 else
1243 cmd->autoneg = AUTONEG_DISABLE; 1204 cmd->autoneg = AUTONEG_DISABLE;
1244 1205
1245 cmd->phy_address = np->phy_addr; 1206 cmd->phy_address = np->phy_addr;
1246 return 0; 1207 return 0;
1247} 1208}
1248 1209
1249static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 1210static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
@@ -1256,22 +1217,22 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1256 else { 1217 else {
1257 np->an_enable = 1; 1218 np->an_enable = 1;
1258 mii_set_media(dev); 1219 mii_set_media(dev);
1259 return 0; 1220 return 0;
1260 } 1221 }
1261 } else { 1222 } else {
1262 np->an_enable = 0; 1223 np->an_enable = 0;
1263 if (np->speed == 1000) { 1224 if (np->speed == 1000) {
1264 cmd->speed = SPEED_100; 1225 cmd->speed = SPEED_100;
1265 cmd->duplex = DUPLEX_FULL; 1226 cmd->duplex = DUPLEX_FULL;
1266 printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n"); 1227 printk("Warning!! Can't disable Auto negotiation in 1000Mbps, change to Manual 100Mbps, Full duplex.\n");
1267 } 1228 }
1268 switch(cmd->speed + cmd->duplex) { 1229 switch(cmd->speed + cmd->duplex) {
1269 1230
1270 case SPEED_10 + DUPLEX_HALF: 1231 case SPEED_10 + DUPLEX_HALF:
1271 np->speed = 10; 1232 np->speed = 10;
1272 np->full_duplex = 0; 1233 np->full_duplex = 0;
1273 break; 1234 break;
1274 1235
1275 case SPEED_10 + DUPLEX_FULL: 1236 case SPEED_10 + DUPLEX_FULL:
1276 np->speed = 10; 1237 np->speed = 10;
1277 np->full_duplex = 1; 1238 np->full_duplex = 1;
@@ -1287,7 +1248,7 @@ static int rio_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1287 case SPEED_1000 + DUPLEX_HALF:/* not supported */ 1248 case SPEED_1000 + DUPLEX_HALF:/* not supported */
1288 case SPEED_1000 + DUPLEX_FULL:/* not supported */ 1249 case SPEED_1000 + DUPLEX_FULL:/* not supported */
1289 default: 1250 default:
1290 return -EINVAL; 1251 return -EINVAL;
1291 } 1252 }
1292 mii_set_media(dev); 1253 mii_set_media(dev);
1293 } 1254 }
@@ -1300,7 +1261,7 @@ static u32 rio_get_link(struct net_device *dev)
1300 return np->link_status; 1261 return np->link_status;
1301} 1262}
1302 1263
1303static struct ethtool_ops ethtool_ops = { 1264static const struct ethtool_ops ethtool_ops = {
1304 .get_drvinfo = rio_get_drvinfo, 1265 .get_drvinfo = rio_get_drvinfo,
1305 .get_settings = rio_get_settings, 1266 .get_settings = rio_get_settings,
1306 .set_settings = rio_set_settings, 1267 .set_settings = rio_set_settings,
@@ -1313,7 +1274,7 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1313 int phy_addr; 1274 int phy_addr;
1314 struct netdev_private *np = netdev_priv(dev); 1275 struct netdev_private *np = netdev_priv(dev);
1315 struct mii_data *miidata = (struct mii_data *) &rq->ifr_ifru; 1276 struct mii_data *miidata = (struct mii_data *) &rq->ifr_ifru;
1316 1277
1317 struct netdev_desc *desc; 1278 struct netdev_desc *desc;
1318 int i; 1279 int i;
1319 1280
@@ -1321,7 +1282,7 @@ rio_ioctl (struct net_device *dev, struct ifreq *rq, int cmd)
1321 switch (cmd) { 1282 switch (cmd) {
1322 case SIOCDEVPRIVATE: 1283 case SIOCDEVPRIVATE:
1323 break; 1284 break;
1324 1285
1325 case SIOCDEVPRIVATE + 1: 1286 case SIOCDEVPRIVATE + 1:
1326 miidata->out_value = mii_read (dev, phy_addr, miidata->reg_num); 1287 miidata->out_value = mii_read (dev, phy_addr, miidata->reg_num);
1327 break; 1288 break;
@@ -1506,7 +1467,7 @@ mii_get_media (struct net_device *dev)
1506 /* Auto-Negotiation not completed */ 1467 /* Auto-Negotiation not completed */
1507 return -1; 1468 return -1;
1508 } 1469 }
1509 negotiate.image = mii_read (dev, phy_addr, MII_ANAR) & 1470 negotiate.image = mii_read (dev, phy_addr, MII_ANAR) &
1510 mii_read (dev, phy_addr, MII_ANLPAR); 1471 mii_read (dev, phy_addr, MII_ANLPAR);
1511 mscr.image = mii_read (dev, phy_addr, MII_MSCR); 1472 mscr.image = mii_read (dev, phy_addr, MII_MSCR);
1512 mssr.image = mii_read (dev, phy_addr, MII_MSSR); 1473 mssr.image = mii_read (dev, phy_addr, MII_MSSR);
@@ -1558,9 +1519,9 @@ mii_get_media (struct net_device *dev)
1558 printk ("Half duplex\n"); 1519 printk ("Half duplex\n");
1559 } 1520 }
1560 } 1521 }
1561 if (np->tx_flow) 1522 if (np->tx_flow)
1562 printk(KERN_INFO "Enable Tx Flow Control\n"); 1523 printk(KERN_INFO "Enable Tx Flow Control\n");
1563 else 1524 else
1564 printk(KERN_INFO "Disable Tx Flow Control\n"); 1525 printk(KERN_INFO "Disable Tx Flow Control\n");
1565 if (np->rx_flow) 1526 if (np->rx_flow)
1566 printk(KERN_INFO "Enable Rx Flow Control\n"); 1527 printk(KERN_INFO "Enable Rx Flow Control\n");
@@ -1600,7 +1561,7 @@ mii_set_media (struct net_device *dev)
1600 pscr.image = mii_read (dev, phy_addr, MII_PHY_SCR); 1561 pscr.image = mii_read (dev, phy_addr, MII_PHY_SCR);
1601 pscr.bits.mdi_crossover_mode = 3; /* 11'b */ 1562 pscr.bits.mdi_crossover_mode = 3; /* 11'b */
1602 mii_write (dev, phy_addr, MII_PHY_SCR, pscr.image); 1563 mii_write (dev, phy_addr, MII_PHY_SCR, pscr.image);
1603 1564
1604 /* Soft reset PHY */ 1565 /* Soft reset PHY */
1605 mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET); 1566 mii_write (dev, phy_addr, MII_BMCR, MII_BMCR_RESET);
1606 bmcr.image = 0; 1567 bmcr.image = 0;
@@ -1678,7 +1639,7 @@ mii_get_media_pcs (struct net_device *dev)
1678 /* Auto-Negotiation not completed */ 1639 /* Auto-Negotiation not completed */
1679 return -1; 1640 return -1;
1680 } 1641 }
1681 negotiate.image = mii_read (dev, phy_addr, PCS_ANAR) & 1642 negotiate.image = mii_read (dev, phy_addr, PCS_ANAR) &
1682 mii_read (dev, phy_addr, PCS_ANLPAR); 1643 mii_read (dev, phy_addr, PCS_ANLPAR);
1683 np->speed = 1000; 1644 np->speed = 1000;
1684 if (negotiate.bits.full_duplex) { 1645 if (negotiate.bits.full_duplex) {
@@ -1705,9 +1666,9 @@ mii_get_media_pcs (struct net_device *dev)
1705 printk ("Half duplex\n"); 1666 printk ("Half duplex\n");
1706 } 1667 }
1707 } 1668 }
1708 if (np->tx_flow) 1669 if (np->tx_flow)
1709 printk(KERN_INFO "Enable Tx Flow Control\n"); 1670 printk(KERN_INFO "Enable Tx Flow Control\n");
1710 else 1671 else
1711 printk(KERN_INFO "Disable Tx Flow Control\n"); 1672 printk(KERN_INFO "Disable Tx Flow Control\n");
1712 if (np->rx_flow) 1673 if (np->rx_flow)
1713 printk(KERN_INFO "Enable Rx Flow Control\n"); 1674 printk(KERN_INFO "Enable Rx Flow Control\n");
@@ -1733,9 +1694,9 @@ mii_set_media_pcs (struct net_device *dev)
1733 /* Advertise capabilities */ 1694 /* Advertise capabilities */
1734 esr.image = mii_read (dev, phy_addr, PCS_ESR); 1695 esr.image = mii_read (dev, phy_addr, PCS_ESR);
1735 anar.image = mii_read (dev, phy_addr, MII_ANAR); 1696 anar.image = mii_read (dev, phy_addr, MII_ANAR);
1736 anar.bits.half_duplex = 1697 anar.bits.half_duplex =
1737 esr.bits.media_1000BT_HD | esr.bits.media_1000BX_HD; 1698 esr.bits.media_1000BT_HD | esr.bits.media_1000BX_HD;
1738 anar.bits.full_duplex = 1699 anar.bits.full_duplex =
1739 esr.bits.media_1000BT_FD | esr.bits.media_1000BX_FD; 1700 esr.bits.media_1000BT_FD | esr.bits.media_1000BX_FD;
1740 anar.bits.pause = 1; 1701 anar.bits.pause = 1;
1741 anar.bits.asymmetric = 1; 1702 anar.bits.asymmetric = 1;
@@ -1793,14 +1754,14 @@ rio_close (struct net_device *dev)
1793 synchronize_irq (dev->irq); 1754 synchronize_irq (dev->irq);
1794 free_irq (dev->irq, dev); 1755 free_irq (dev->irq, dev);
1795 del_timer_sync (&np->timer); 1756 del_timer_sync (&np->timer);
1796 1757
1797 /* Free all the skbuffs in the queue. */ 1758 /* Free all the skbuffs in the queue. */
1798 for (i = 0; i < RX_RING_SIZE; i++) { 1759 for (i = 0; i < RX_RING_SIZE; i++) {
1799 np->rx_ring[i].status = 0; 1760 np->rx_ring[i].status = 0;
1800 np->rx_ring[i].fraginfo = 0; 1761 np->rx_ring[i].fraginfo = 0;
1801 skb = np->rx_skbuff[i]; 1762 skb = np->rx_skbuff[i];
1802 if (skb) { 1763 if (skb) {
1803 pci_unmap_single(np->pdev, 1764 pci_unmap_single(np->pdev,
1804 np->rx_ring[i].fraginfo & DMA_48BIT_MASK, 1765 np->rx_ring[i].fraginfo & DMA_48BIT_MASK,
1805 skb->len, PCI_DMA_FROMDEVICE); 1766 skb->len, PCI_DMA_FROMDEVICE);
1806 dev_kfree_skb (skb); 1767 dev_kfree_skb (skb);
@@ -1810,7 +1771,7 @@ rio_close (struct net_device *dev)
1810 for (i = 0; i < TX_RING_SIZE; i++) { 1771 for (i = 0; i < TX_RING_SIZE; i++) {
1811 skb = np->tx_skbuff[i]; 1772 skb = np->tx_skbuff[i];
1812 if (skb) { 1773 if (skb) {
1813 pci_unmap_single(np->pdev, 1774 pci_unmap_single(np->pdev,
1814 np->tx_ring[i].fraginfo & DMA_48BIT_MASK, 1775 np->tx_ring[i].fraginfo & DMA_48BIT_MASK,
1815 skb->len, PCI_DMA_TODEVICE); 1776 skb->len, PCI_DMA_TODEVICE);
1816 dev_kfree_skb (skb); 1777 dev_kfree_skb (skb);
@@ -1854,7 +1815,7 @@ static struct pci_driver rio_driver = {
1854static int __init 1815static int __init
1855rio_init (void) 1816rio_init (void)
1856{ 1817{
1857 return pci_module_init (&rio_driver); 1818 return pci_register_driver(&rio_driver);
1858} 1819}
1859 1820
1860static void __exit 1821static void __exit
@@ -1867,9 +1828,9 @@ module_init (rio_init);
1867module_exit (rio_exit); 1828module_exit (rio_exit);
1868 1829
1869/* 1830/*
1870 1831
1871Compile command: 1832Compile command:
1872 1833
1873gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -c dl2k.c 1834gcc -D__KERNEL__ -DMODULE -I/usr/src/linux/include -Wall -Wstrict-prototypes -O2 -c dl2k.c
1874 1835
1875Read Documentation/networking/dl2k.txt for details. 1836Read Documentation/networking/dl2k.txt for details.