Commit ae0f9f56 authored by Go Taniguchi's avatar Go Taniguchi Committed by Jeff Garzik

Update pcnet32 net driver with the following changes:

v1.27   improved CSR/PROM address detection, lots of cleanups,
       new pcnet32vlb module option, HP-PARISC support,
       added module parameter descriptions, 
       initial ethtool support - Helge Deller <deller@gmx.de>
v1.27a  Sun Feb 10 2002 Go Taniguchi <go@turbolinux.co.jp>
       use alloc_etherdev and register_netdev
       fix pci probe not increment cards_found
       FD auto negotiate error workaround for xSeries250
       clean up and using new mii module
parent 9e819345
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
*************************************************************************/ *************************************************************************/
#define DRV_NAME "pcnet32" #define DRV_NAME "pcnet32"
#define DRV_VERSION "1.25kf" #define DRV_VERSION "1.27a"
#define DRV_RELDATE "17.11.2001" #define DRV_RELDATE "10.02.2002"
#define PFX DRV_NAME ": "
static const char *version = static const char *version =
DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " tsbogend@alpha.franken.de\n"; DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " tsbogend@alpha.franken.de\n";
...@@ -54,8 +55,6 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " tsbogend@alpha.franken.de\n"; ...@@ -54,8 +55,6 @@ DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " tsbogend@alpha.franken.de\n";
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
static unsigned int pcnet32_portlist[] __initdata = {0x300, 0x320, 0x340, 0x360, 0};
/* /*
* PCI device identifiers for "new style" Linux PCI Device Drivers * PCI device identifiers for "new style" Linux PCI Device Drivers
*/ */
...@@ -65,13 +64,26 @@ static struct pci_device_id pcnet32_pci_tbl[] __devinitdata = { ...@@ -65,13 +64,26 @@ static struct pci_device_id pcnet32_pci_tbl[] __devinitdata = {
{ 0, } { 0, }
}; };
MODULE_DEVICE_TABLE (pci, pcnet32_pci_tbl);
int cards_found __initdata;
/*
* VLB I/O addresses
*/
static unsigned int pcnet32_portlist[] __initdata =
{ 0x300, 0x320, 0x340, 0x360, 0 };
static int pcnet32_debug = 1; static int pcnet32_debug = 1;
static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */ static int tx_start = 1; /* Mapping -- 0:20, 1:64, 2:128, 3:~220 (depends on chip vers) */
static int pcnet32vlb; /* check for VLB cards ? */
static struct net_device *pcnet32_dev; static struct net_device *pcnet32_dev;
static const int max_interrupt_work = 80; static int max_interrupt_work = 80;
static const int rx_copybreak = 200; static int rx_copybreak = 200;
#define PCNET32_PORT_AUI 0x00 #define PCNET32_PORT_AUI 0x00
#define PCNET32_PORT_10BT 0x01 #define PCNET32_PORT_10BT 0x01
...@@ -94,21 +106,21 @@ static unsigned char options_mapping[] = { ...@@ -94,21 +106,21 @@ static unsigned char options_mapping[] = {
PCNET32_PORT_AUI, /* 1 BNC/AUI */ PCNET32_PORT_AUI, /* 1 BNC/AUI */
PCNET32_PORT_AUI, /* 2 AUI/BNC */ PCNET32_PORT_AUI, /* 2 AUI/BNC */
PCNET32_PORT_ASEL, /* 3 not supported */ PCNET32_PORT_ASEL, /* 3 not supported */
PCNET32_PORT_10BT | PCNET32_PORT_FD, /* 4 10baseT-FD */ PCNET32_PORT_10BT | PCNET32_PORT_FD, /* 4 10baseT-FD */
PCNET32_PORT_ASEL, /* 5 not supported */ PCNET32_PORT_ASEL, /* 5 not supported */
PCNET32_PORT_ASEL, /* 6 not supported */ PCNET32_PORT_ASEL, /* 6 not supported */
PCNET32_PORT_ASEL, /* 7 not supported */ PCNET32_PORT_ASEL, /* 7 not supported */
PCNET32_PORT_ASEL, /* 8 not supported */ PCNET32_PORT_ASEL, /* 8 not supported */
PCNET32_PORT_MII, /* 9 MII 10baseT */ PCNET32_PORT_MII, /* 9 MII 10baseT */
PCNET32_PORT_MII | PCNET32_PORT_FD, /* 10 MII 10baseT-FD */ PCNET32_PORT_MII | PCNET32_PORT_FD, /* 10 MII 10baseT-FD */
PCNET32_PORT_MII, /* 11 MII (autosel) */ PCNET32_PORT_MII, /* 11 MII (autosel) */
PCNET32_PORT_10BT, /* 12 10BaseT */ PCNET32_PORT_10BT, /* 12 10BaseT */
PCNET32_PORT_MII | PCNET32_PORT_100, /* 13 MII 100BaseTx */ PCNET32_PORT_MII | PCNET32_PORT_100, /* 13 MII 100BaseTx */
PCNET32_PORT_MII | PCNET32_PORT_100 | PCNET32_PORT_FD, /* 14 MII 100BaseTx-FD */ PCNET32_PORT_MII | PCNET32_PORT_100 | PCNET32_PORT_FD, /* 14 MII 100BaseTx-FD */
PCNET32_PORT_ASEL /* 15 not supported */ PCNET32_PORT_ASEL /* 15 not supported */
}; };
#define MAX_UNITS 8 #define MAX_UNITS 8 /* More are supported, limit only on options */
static int options[MAX_UNITS]; static int options[MAX_UNITS];
static int full_duplex[MAX_UNITS]; static int full_duplex[MAX_UNITS];
...@@ -187,7 +199,19 @@ static int full_duplex[MAX_UNITS]; ...@@ -187,7 +199,19 @@ static int full_duplex[MAX_UNITS];
* v1.25kf Added No Interrupt on successful Tx for some Tx's <kaf@fc.hp.com> * v1.25kf Added No Interrupt on successful Tx for some Tx's <kaf@fc.hp.com>
* v1.26 Converted to pci_alloc_consistent, Jamey Hicks / George France * v1.26 Converted to pci_alloc_consistent, Jamey Hicks / George France
* <jamey@crl.dec.com> * <jamey@crl.dec.com>
* v1.26p Fix oops on rmmod+insmod; plug i/o resource leak - Paul Gortmaker * - Fixed a few bugs, related to running the controller in 32bit mode.
* 23 Oct, 2000. Carsten Langgaard, carstenl@mips.com
* Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
* v1.26p Fix oops on rmmod+insmod; plug i/o resource leak - Paul Gortmaker
* v1.27 improved CSR/PROM address detection, lots of cleanups,
* new pcnet32vlb module option, HP-PARISC support,
* added module parameter descriptions,
* initial ethtool support - Helge Deller <deller@gmx.de>
* v1.27a Sun Feb 10 2002 Go Taniguchi <go@turbolinux.co.jp>
* use alloc_etherdev and register_netdev
* fix pci probe not increment cards_found
* FD auto negotiate error workaround for xSeries250
* clean up and using new mii module
*/ */
...@@ -201,13 +225,13 @@ static int full_duplex[MAX_UNITS]; ...@@ -201,13 +225,13 @@ static int full_duplex[MAX_UNITS];
#define PCNET32_LOG_RX_BUFFERS 5 #define PCNET32_LOG_RX_BUFFERS 5
#endif #endif
#define TX_RING_SIZE (1 << (PCNET32_LOG_TX_BUFFERS)) #define TX_RING_SIZE (1 << (PCNET32_LOG_TX_BUFFERS))
#define TX_RING_MOD_MASK (TX_RING_SIZE - 1) #define TX_RING_MOD_MASK (TX_RING_SIZE - 1)
#define TX_RING_LEN_BITS ((PCNET32_LOG_TX_BUFFERS) << 12) #define TX_RING_LEN_BITS ((PCNET32_LOG_TX_BUFFERS) << 12)
#define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS)) #define RX_RING_SIZE (1 << (PCNET32_LOG_RX_BUFFERS))
#define RX_RING_MOD_MASK (RX_RING_SIZE - 1) #define RX_RING_MOD_MASK (RX_RING_SIZE - 1)
#define RX_RING_LEN_BITS ((PCNET32_LOG_RX_BUFFERS) << 4) #define RX_RING_LEN_BITS ((PCNET32_LOG_RX_BUFFERS) << 4)
#define PKT_BUF_SZ 1544 #define PKT_BUF_SZ 1544
...@@ -222,7 +246,7 @@ static int full_duplex[MAX_UNITS]; ...@@ -222,7 +246,7 @@ static int full_duplex[MAX_UNITS];
#define PCNET32_DWIO_RESET 0x18 #define PCNET32_DWIO_RESET 0x18
#define PCNET32_DWIO_BDP 0x1C #define PCNET32_DWIO_BDP 0x1C
#define PCNET32_TOTAL_SIZE 0x20 #define PCNET32_TOTAL_SIZE 0x20
/* The PCNET32 Rx and Tx ring descriptors. */ /* The PCNET32 Rx and Tx ring descriptors. */
struct pcnet32_rx_head { struct pcnet32_rx_head {
...@@ -270,37 +294,36 @@ struct pcnet32_access { ...@@ -270,37 +294,36 @@ struct pcnet32_access {
*/ */
struct pcnet32_private { struct pcnet32_private {
/* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */ /* The Tx and Rx ring entries must be aligned on 16-byte boundaries in 32bit mode. */
struct pcnet32_rx_head rx_ring[RX_RING_SIZE]; struct pcnet32_rx_head rx_ring[RX_RING_SIZE];
struct pcnet32_tx_head tx_ring[TX_RING_SIZE]; struct pcnet32_tx_head tx_ring[TX_RING_SIZE];
struct pcnet32_init_block init_block; struct pcnet32_init_block init_block;
dma_addr_t dma_addr; /* DMA address of beginning of this object, returned by pci_alloc_consistent */ dma_addr_t dma_addr; /* DMA address of beginning of this object,
struct pci_dev *pci_dev; /* Pointer to the associated pci device structure */ returned by pci_alloc_consistent */
const char *name; struct pci_dev *pci_dev; /* Pointer to the associated pci device structure */
const char *name;
/* The saved address of a sent-in-place packet/buffer, for skfree(). */ /* The saved address of a sent-in-place packet/buffer, for skfree(). */
struct sk_buff *tx_skbuff[TX_RING_SIZE]; struct sk_buff *tx_skbuff[TX_RING_SIZE];
struct sk_buff *rx_skbuff[RX_RING_SIZE]; struct sk_buff *rx_skbuff[RX_RING_SIZE];
dma_addr_t tx_dma_addr[TX_RING_SIZE]; dma_addr_t tx_dma_addr[TX_RING_SIZE];
dma_addr_t rx_dma_addr[RX_RING_SIZE]; dma_addr_t rx_dma_addr[RX_RING_SIZE];
struct pcnet32_access a; struct pcnet32_access a;
spinlock_t lock; /* Guard lock */ spinlock_t lock; /* Guard lock */
unsigned int cur_rx, cur_tx; /* The next free ring entry */ unsigned int cur_rx, cur_tx; /* The next free ring entry */
unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */ unsigned int dirty_rx, dirty_tx; /* The ring entries to be free()ed. */
struct net_device_stats stats; struct net_device_stats stats;
char tx_full; char tx_full;
int options; int options;
int shared_irq:1, /* shared irq possible */ int shared_irq:1, /* shared irq possible */
ltint:1, ltint:1, /* enable TxDone-intr inhibitor */
#ifdef DO_DXSUFLO dxsuflo:1, /* disable transmit stop on uflo */
dxsuflo:1, /* disable transmit stop on uflo */ mii:1; /* mii port available */
#endif struct net_device *next;
mii:1; /* mii port available */
struct net_device *next;
struct mii_if_info mii_if; struct mii_if_info mii_if;
}; };
static int pcnet32_probe_vlbus(int cards_found); static void pcnet32_probe_vlbus(void);
static int pcnet32_probe_pci(struct pci_dev *, const struct pci_device_id *); static int pcnet32_probe_pci(struct pci_dev *, const struct pci_device_id *);
static int pcnet32_probe1(unsigned long, unsigned char, int, int, struct pci_dev *); static int pcnet32_probe1(unsigned long, unsigned char, int, struct pci_dev *);
static int pcnet32_open(struct net_device *); static int pcnet32_open(struct net_device *);
static int pcnet32_init_ring(struct net_device *); static int pcnet32_init_ring(struct net_device *);
static int pcnet32_start_xmit(struct sk_buff *, struct net_device *); static int pcnet32_start_xmit(struct sk_buff *, struct net_device *);
...@@ -319,15 +342,6 @@ enum pci_flags_bit { ...@@ -319,15 +342,6 @@ enum pci_flags_bit {
PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3, PCI_ADDR0=0x10<<0, PCI_ADDR1=0x10<<1, PCI_ADDR2=0x10<<2, PCI_ADDR3=0x10<<3,
}; };
struct pcnet32_pci_id_info {
const char *name;
u16 vendor_id, device_id, svid, sdid, flags;
int io_size;
int (*probe1) (unsigned long, unsigned char, int, int, struct pci_dev *);
};
MODULE_DEVICE_TABLE (pci, pcnet32_pci_tbl);
static u16 pcnet32_wio_read_csr (unsigned long addr, int index) static u16 pcnet32_wio_read_csr (unsigned long addr, int index)
{ {
...@@ -375,13 +389,13 @@ static int pcnet32_wio_check (unsigned long addr) ...@@ -375,13 +389,13 @@ static int pcnet32_wio_check (unsigned long addr)
} }
static struct pcnet32_access pcnet32_wio = { static struct pcnet32_access pcnet32_wio = {
pcnet32_wio_read_csr, read_csr: pcnet32_wio_read_csr,
pcnet32_wio_write_csr, write_csr: pcnet32_wio_write_csr,
pcnet32_wio_read_bcr, read_bcr: pcnet32_wio_read_bcr,
pcnet32_wio_write_bcr, write_bcr: pcnet32_wio_write_bcr,
pcnet32_wio_read_rap, read_rap: pcnet32_wio_read_rap,
pcnet32_wio_write_rap, write_rap: pcnet32_wio_write_rap,
pcnet32_wio_reset reset: pcnet32_wio_reset
}; };
static u16 pcnet32_dwio_read_csr (unsigned long addr, int index) static u16 pcnet32_dwio_read_csr (unsigned long addr, int index)
...@@ -430,82 +444,61 @@ static int pcnet32_dwio_check (unsigned long addr) ...@@ -430,82 +444,61 @@ static int pcnet32_dwio_check (unsigned long addr)
} }
static struct pcnet32_access pcnet32_dwio = { static struct pcnet32_access pcnet32_dwio = {
pcnet32_dwio_read_csr, read_csr: pcnet32_dwio_read_csr,
pcnet32_dwio_write_csr, write_csr: pcnet32_dwio_write_csr,
pcnet32_dwio_read_bcr, read_bcr: pcnet32_dwio_read_bcr,
pcnet32_dwio_write_bcr, write_bcr: pcnet32_dwio_write_bcr,
pcnet32_dwio_read_rap, read_rap: pcnet32_dwio_read_rap,
pcnet32_dwio_write_rap, write_rap: pcnet32_dwio_write_rap,
pcnet32_dwio_reset reset: pcnet32_dwio_reset
}; };
/* only probes for non-PCI devices, the rest are handled by pci_register_driver via pcnet32_probe_pci*/
static int __init pcnet32_probe_vlbus(int cards_found) /* only probes for non-PCI devices, the rest are handled by
* pci_register_driver via pcnet32_probe_pci */
static void __devinit
pcnet32_probe_vlbus(void)
{ {
unsigned long ioaddr = 0; // FIXME dev ? dev->base_addr: 0; unsigned int *port, ioaddr;
unsigned int irq_line = 0; // FIXME dev ? dev->irq : 0;
int *port;
printk(KERN_INFO "pcnet32_probe_vlbus: cards_found=%d\n", cards_found);
#ifndef __powerpc__
if (ioaddr > 0x1ff) {
if (check_region(ioaddr, PCNET32_TOTAL_SIZE) == 0)
return pcnet32_probe1(ioaddr, irq_line, 0, 0, NULL);
else
return -ENODEV;
} else
#endif
if (ioaddr != 0)
return -ENXIO;
/* now look for PCnet32 VLB cards */ /* search for PCnet32 VLB cards at known addresses */
for (port = pcnet32_portlist; *port; port++) { for (port = pcnet32_portlist; (ioaddr = *port); port++) {
unsigned long ioaddr = *port; if (!check_region(ioaddr, PCNET32_TOTAL_SIZE)) {
if ( check_region(ioaddr, PCNET32_TOTAL_SIZE) == 0) {
/* check if there is really a pcnet chip on that ioaddr */ /* check if there is really a pcnet chip on that ioaddr */
if ((inb(ioaddr + 14) == 0x57) && if ((inb(ioaddr + 14) == 0x57) && (inb(ioaddr + 15) == 0x57))
(inb(ioaddr + 15) == 0x57) && pcnet32_probe1(ioaddr, 0, 0, NULL);
(pcnet32_probe1(ioaddr, 0, 0, 0, NULL) == 0))
cards_found++;
} }
} }
return cards_found ? 0: -ENODEV;
} }
static int __devinit static int __devinit
pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent) pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int card_idx; unsigned long ioaddr;
long ioaddr; int err;
int err = 0;
printk(KERN_INFO "pcnet32_probe_pci: found device %#08x.%#08x\n", ent->vendor, ent->device);
if ((err = pci_enable_device(pdev)) < 0) { err = pci_enable_device(pdev);
printk(KERN_ERR "pcnet32.c: failed to enable device -- err=%d\n", err); if (err < 0) {
printk(KERN_ERR PFX "failed to enable device -- err=%d\n", err);
return err; return err;
} }
pci_set_master(pdev); pci_set_master(pdev);
ioaddr = pci_resource_start (pdev, 0); ioaddr = pci_resource_start (pdev, 0);
printk(KERN_INFO " ioaddr=%#08lx resource_flags=%#08lx\n", ioaddr, pci_resource_flags (pdev, 0));
if (!ioaddr) { if (!ioaddr) {
printk (KERN_ERR "no PCI IO resources, aborting\n"); printk (KERN_ERR PFX "card has no PCI IO resources, aborting\n");
return -ENODEV; return -ENODEV;
} }
if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) { if (!pci_dma_supported(pdev, PCNET32_DMA_MASK)) {
printk(KERN_ERR "pcnet32.c: architecture does not support 32bit PCI busmaster DMA\n"); printk(KERN_ERR PFX "architecture does not support 32bit PCI busmaster DMA\n");
return -ENODEV; return -ENODEV;
} }
return pcnet32_probe1(ioaddr, pdev->irq, 1, card_idx, pdev); return pcnet32_probe1(ioaddr, pdev->irq, 1, pdev);
} }
...@@ -514,41 +507,44 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -514,41 +507,44 @@ pcnet32_probe_pci(struct pci_dev *pdev, const struct pci_device_id *ent)
* pdev will be NULL when called from pcnet32_probe_vlbus. * pdev will be NULL when called from pcnet32_probe_vlbus.
*/ */
static int __devinit static int __devinit
pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int card_idx, struct pci_dev *pdev) pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared,
struct pci_dev *pdev)
{ {
struct pcnet32_private *lp; struct pcnet32_private *lp;
struct resource *res; struct resource *res;
dma_addr_t lp_dma_addr; dma_addr_t lp_dma_addr;
int i,media,fdx = 0, mii = 0, fset = 0; int i, media;
#ifdef DO_DXSUFLO int fdx, mii, fset, dxsuflo, ltint;
int dxsuflo = 0;
#endif
int ltint = 0;
int chip_version; int chip_version;
char *chipname; char *chipname;
struct net_device *dev; struct net_device *dev;
struct pcnet32_access *a = NULL; struct pcnet32_access *a = NULL;
u8 promaddr[6];
/* reset the chip */ /* reset the chip */
pcnet32_dwio_reset(ioaddr); pcnet32_dwio_reset(ioaddr);
pcnet32_wio_reset(ioaddr); pcnet32_wio_reset(ioaddr);
/* NOTE: 16-bit check is first, otherwise some older PCnet chips fail */ /* NOTE: 16-bit check is first, otherwise some older PCnet chips fail */
if (pcnet32_wio_read_csr (ioaddr, 0) == 4 && pcnet32_wio_check (ioaddr)) { if (pcnet32_wio_read_csr(ioaddr, 0) == 4 && pcnet32_wio_check(ioaddr)) {
a = &pcnet32_wio; a = &pcnet32_wio;
} else { } else {
if (pcnet32_dwio_read_csr (ioaddr, 0) == 4 && pcnet32_dwio_check(ioaddr)) { if (pcnet32_dwio_read_csr(ioaddr, 0) == 4 && pcnet32_dwio_check(ioaddr)) {
a = &pcnet32_dwio; a = &pcnet32_dwio;
} else } else
return -ENODEV; return -ENODEV;
} }
chip_version = a->read_csr (ioaddr, 88) | (a->read_csr (ioaddr,89) << 16); chip_version = a->read_csr(ioaddr, 88) | (a->read_csr(ioaddr,89) << 16);
if (pcnet32_debug > 2) if (pcnet32_debug > 2)
printk(KERN_INFO " PCnet chip version is %#x.\n", chip_version); printk(KERN_INFO " PCnet chip version is %#x.\n", chip_version);
if ((chip_version & 0xfff) != 0x003) if ((chip_version & 0xfff) != 0x003)
return -ENODEV; return -ENODEV;
/* initialize variables */
fdx = mii = fset = dxsuflo = ltint = 0;
chip_version = (chip_version >> 12) & 0xffff; chip_version = (chip_version >> 12) & 0xffff;
switch (chip_version) { switch (chip_version) {
case 0x2420: case 0x2420:
chipname = "PCnet/PCI 79C970"; /* PCI */ chipname = "PCnet/PCI 79C970"; /* PCI */
...@@ -587,23 +583,24 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -587,23 +583,24 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
* mode by which the card should operate * mode by which the card should operate
*/ */
/* switch to home wiring mode */ /* switch to home wiring mode */
media = a->read_bcr (ioaddr, 49); media = a->read_bcr(ioaddr, 49);
#if 0 #if 0
if (pcnet32_debug > 2) if (pcnet32_debug > 2)
printk(KERN_DEBUG "pcnet32: pcnet32 media value %#x.\n", media); printk(KERN_DEBUG PFX "media value %#x.\n", media);
media &= ~3; media &= ~3;
media |= 1; media |= 1;
#endif #endif
if (pcnet32_debug > 2) if (pcnet32_debug > 2)
printk(KERN_DEBUG "pcnet32: pcnet32 media reset to %#x.\n", media); printk(KERN_DEBUG PFX "media reset to %#x.\n", media);
a->write_bcr (ioaddr, 49, media); a->write_bcr(ioaddr, 49, media);
break; break;
case 0x2627: case 0x2627:
chipname = "PCnet/FAST III 79C975"; /* PCI */ chipname = "PCnet/FAST III 79C975"; /* PCI */
fdx = 1; mii = 1; fdx = 1; mii = 1;
break; break;
default: default:
printk(KERN_INFO "pcnet32: PCnet version %#x, no PCnet32 chip.\n",chip_version); printk(KERN_INFO PFX "PCnet version %#x, no PCnet32 chip.\n",
chip_version);
return -ENODEV; return -ENODEV;
} }
...@@ -618,17 +615,15 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -618,17 +615,15 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
{ {
a->write_bcr(ioaddr, 18, (a->read_bcr(ioaddr, 18) | 0x0800)); a->write_bcr(ioaddr, 18, (a->read_bcr(ioaddr, 18) | 0x0800));
a->write_csr(ioaddr, 80, (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00); a->write_csr(ioaddr, 80, (a->read_csr(ioaddr, 80) & 0x0C00) | 0x0c00);
#ifdef DO_DXSUFLO
dxsuflo = 1; dxsuflo = 1;
#endif
ltint = 1; ltint = 1;
} }
dev = init_etherdev(NULL, 0); dev = alloc_etherdev(0);
if(dev==NULL) if(!dev)
return -ENOMEM; return -ENOMEM;
printk(KERN_INFO "%s: %s at %#3lx,", dev->name, chipname, ioaddr); printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr);
/* In most chips, after a chip reset, the ethernet address is read from the /* In most chips, after a chip reset, the ethernet address is read from the
* station address PROM at the base address and programmed into the * station address PROM at the base address and programmed into the
...@@ -644,31 +639,28 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -644,31 +639,28 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
dev->dev_addr[2*i] = val & 0x0ff; dev->dev_addr[2*i] = val & 0x0ff;
dev->dev_addr[2*i+1] = (val >> 8) & 0x0ff; dev->dev_addr[2*i+1] = (val >> 8) & 0x0ff;
} }
{
u8 promaddr[6]; /* read PROM address and compare with CSR address */
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++)
promaddr[i] = inb(ioaddr + i); promaddr[i] = inb(ioaddr + i);
}
if( memcmp( promaddr, dev->dev_addr, 6) ) if( memcmp( promaddr, dev->dev_addr, 6)
{ || !is_valid_ether_addr(dev->dev_addr) ) {
printk(" warning PROM address does not match CSR address\n"); #ifndef __powerpc__
#if defined(__i386__) if( is_valid_ether_addr(promaddr) ){
printk(KERN_WARNING "%s: Probably a Compaq, using the PROM address of", dev->name); #else
memcpy(dev->dev_addr, promaddr, 6); if( !is_valid_ether_addr(dev->dev_addr)
#elif defined(__powerpc__) && is_valid_ether_addr(promaddr)) {
if (!is_valid_ether_addr(dev->dev_addr)
&& is_valid_ether_addr(promaddr)) {
printk("\n" KERN_WARNING "%s: using PROM address:",
dev->name);
memcpy(dev->dev_addr, promaddr, 6);
}
#endif #endif
} printk(" warning: CSR address invalid,\n");
printk(KERN_INFO " using instead PROM address of");
memcpy(dev->dev_addr, promaddr, 6);
}
} }
/* if the ethernet address is not valid, force to 00:00:00:00:00:00 */ /* if the ethernet address is not valid, force to 00:00:00:00:00:00 */
if( !is_valid_ether_addr(dev->dev_addr) ) if( !is_valid_ether_addr(dev->dev_addr) )
for (i = 0; i < 6; i++) memset(dev->dev_addr, 0, sizeof(dev->dev_addr));
dev->dev_addr[i]=0;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
printk(" %2.2x", dev->dev_addr[i] ); printk(" %2.2x", dev->dev_addr[i] );
...@@ -698,7 +690,7 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -698,7 +690,7 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
dev->base_addr = ioaddr; dev->base_addr = ioaddr;
res = request_region(ioaddr, PCNET32_TOTAL_SIZE, chipname); res = request_region(ioaddr, PCNET32_TOTAL_SIZE, chipname);
if (res == NULL) if (!res)
return -EBUSY; return -EBUSY;
/* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */ /* pci_alloc_consistent returns page-aligned memory, so we do not have to check the alignment */
...@@ -710,7 +702,6 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -710,7 +702,6 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
memset(lp, 0, sizeof(*lp)); memset(lp, 0, sizeof(*lp));
lp->dma_addr = lp_dma_addr; lp->dma_addr = lp_dma_addr;
lp->pci_dev = pdev; lp->pci_dev = pdev;
printk("\n" KERN_INFO "pcnet32: pcnet32_private lp=%p lp_dma_addr=%#08x", lp, lp_dma_addr);
spin_lock_init(&lp->lock); spin_lock_init(&lp->lock);
...@@ -718,24 +709,23 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -718,24 +709,23 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
lp->name = chipname; lp->name = chipname;
lp->shared_irq = shared; lp->shared_irq = shared;
lp->mii_if.full_duplex = fdx; lp->mii_if.full_duplex = fdx;
#ifdef DO_DXSUFLO
lp->dxsuflo = dxsuflo; lp->dxsuflo = dxsuflo;
#endif
lp->ltint = ltint; lp->ltint = ltint;
lp->mii = mii; lp->mii = mii;
if (options[card_idx] > sizeof (options_mapping)) if ((cards_found >= MAX_UNITS) || (options[cards_found] > sizeof(options_mapping)))
lp->options = PCNET32_PORT_ASEL; lp->options = PCNET32_PORT_ASEL;
else else
lp->options = options_mapping[options[card_idx]]; lp->options = options_mapping[options[cards_found]];
lp->mii_if.dev = dev; lp->mii_if.dev = dev;
lp->mii_if.mdio_read = mdio_read; lp->mii_if.mdio_read = mdio_read;
lp->mii_if.mdio_write = mdio_write; lp->mii_if.mdio_write = mdio_write;
if (fdx && !(lp->options & PCNET32_PORT_ASEL) && full_duplex[card_idx]) if (fdx && !(lp->options & PCNET32_PORT_ASEL) &&
((cards_found>=MAX_UNITS) || full_duplex[cards_found]))
lp->options |= PCNET32_PORT_FD; lp->options |= PCNET32_PORT_FD;
if (a == NULL) { if (!a) {
printk(KERN_ERR "pcnet32: No access methods\n"); printk(KERN_ERR PFX "No access methods\n");
pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
release_resource(res); release_resource(res);
return -ENODEV; return -ENODEV;
...@@ -790,8 +780,6 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -790,8 +780,6 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
} }
} }
if (pcnet32_debug > 0)
printk(KERN_INFO "%s", version);
/* The PCNET32-specific entries in the device structure. */ /* The PCNET32-specific entries in the device structure. */
dev->open = &pcnet32_open; dev->open = &pcnet32_open;
...@@ -807,11 +795,13 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car ...@@ -807,11 +795,13 @@ pcnet32_probe1(unsigned long ioaddr, unsigned char irq_line, int shared, int car
pcnet32_dev = dev; pcnet32_dev = dev;
/* Fill in the generic fields of the device structure. */ /* Fill in the generic fields of the device structure. */
ether_setup(dev); register_netdev(dev);
printk(KERN_INFO "%s: registered as %s\n",dev->name, lp->name);
cards_found++;
return 0; return 0;
} }
static int static int
pcnet32_open(struct net_device *dev) pcnet32_open(struct net_device *dev)
{ {
...@@ -856,6 +846,9 @@ pcnet32_open(struct net_device *dev) ...@@ -856,6 +846,9 @@ pcnet32_open(struct net_device *dev)
val |= 1; val |= 1;
if (lp->options == (PCNET32_PORT_FD | PCNET32_PORT_AUI)) if (lp->options == (PCNET32_PORT_FD | PCNET32_PORT_AUI))
val |= 2; val |= 2;
} else if (lp->options & PCNET32_PORT_ASEL) {
/* workaround for xSeries250 */
val |= 3;
} }
lp->a.write_bcr (ioaddr, 9, val); lp->a.write_bcr (ioaddr, 9, val);
} }
...@@ -888,6 +881,7 @@ pcnet32_open(struct net_device *dev) ...@@ -888,6 +881,7 @@ pcnet32_open(struct net_device *dev)
lp->a.write_csr (ioaddr, 3, val); lp->a.write_csr (ioaddr, 3, val);
} }
#endif #endif
if (lp->ltint) { /* Enable TxDone-intr inhibitor */ if (lp->ltint) { /* Enable TxDone-intr inhibitor */
val = lp->a.read_csr (ioaddr, 5); val = lp->a.read_csr (ioaddr, 5);
val |= (1<<14); val |= (1<<14);
...@@ -922,7 +916,7 @@ pcnet32_open(struct net_device *dev) ...@@ -922,7 +916,7 @@ pcnet32_open(struct net_device *dev)
if (pcnet32_debug > 2) if (pcnet32_debug > 2)
printk(KERN_DEBUG "%s: pcnet32 open after %d ticks, init block %#x csr0 %4.4x.\n", printk(KERN_DEBUG "%s: pcnet32 open after %d ticks, init block %#x csr0 %4.4x.\n",
dev->name, i, (u32) (lp->dma_addr + offsetof(struct pcnet32_private, init_block)), dev->name, i, (u32) (lp->dma_addr + offsetof(struct pcnet32_private, init_block)),
lp->a.read_csr (ioaddr, 0)); lp->a.read_csr(ioaddr, 0));
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
...@@ -1032,7 +1026,7 @@ pcnet32_tx_timeout (struct net_device *dev) ...@@ -1032,7 +1026,7 @@ pcnet32_tx_timeout (struct net_device *dev)
/* Transmitter timeout, serious problems. */ /* Transmitter timeout, serious problems. */
printk(KERN_ERR "%s: transmit timed out, status %4.4x, resetting.\n", printk(KERN_ERR "%s: transmit timed out, status %4.4x, resetting.\n",
dev->name, lp->a.read_csr (ioaddr, 0)); dev->name, lp->a.read_csr(ioaddr, 0));
lp->a.write_csr (ioaddr, 0, 0x0004); lp->a.write_csr (ioaddr, 0, 0x0004);
lp->stats.tx_errors++; lp->stats.tx_errors++;
if (pcnet32_debug > 2) { if (pcnet32_debug > 2) {
...@@ -1068,7 +1062,7 @@ pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1068,7 +1062,7 @@ pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev)
if (pcnet32_debug > 3) { if (pcnet32_debug > 3) {
printk(KERN_DEBUG "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n", printk(KERN_DEBUG "%s: pcnet32_start_xmit() called, csr0 %4.4x.\n",
dev->name, lp->a.read_csr (ioaddr, 0)); dev->name, lp->a.read_csr(ioaddr, 0));
} }
spin_lock_irqsave(&lp->lock, flags); spin_lock_irqsave(&lp->lock, flags);
...@@ -1135,8 +1129,9 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -1135,8 +1129,9 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
int boguscnt = max_interrupt_work; int boguscnt = max_interrupt_work;
int must_restart; int must_restart;
if (dev == NULL) { if (!dev) {
printk (KERN_DEBUG "pcnet32_interrupt(): irq %d for unknown device.\n", irq); printk (KERN_DEBUG "%s(): irq %d for unknown device\n",
__FUNCTION__, irq);
return; return;
} }
...@@ -1207,7 +1202,8 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -1207,7 +1202,8 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
/* We must free the original skb */ /* We must free the original skb */
if (lp->tx_skbuff[entry]) { if (lp->tx_skbuff[entry]) {
pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[entry], lp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE); pci_unmap_single(lp->pci_dev, lp->tx_dma_addr[entry],
lp->tx_skbuff[entry]->len, PCI_DMA_TODEVICE);
dev_kfree_skb_irq(lp->tx_skbuff[entry]); dev_kfree_skb_irq(lp->tx_skbuff[entry]);
lp->tx_skbuff[entry] = 0; lp->tx_skbuff[entry] = 0;
lp->tx_dma_addr[entry] = 0; lp->tx_dma_addr[entry] = 0;
...@@ -1215,13 +1211,12 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -1215,13 +1211,12 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
dirty_tx++; dirty_tx++;
} }
#ifndef final_version
if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) { if (lp->cur_tx - dirty_tx >= TX_RING_SIZE) {
printk(KERN_ERR "out-of-sync dirty pointer, %d vs. %d, full=%d.\n", printk(KERN_ERR "%s: out-of-sync dirty pointer, %d vs. %d, full=%d.\n",
dirty_tx, lp->cur_tx, lp->tx_full); dev->name, dirty_tx, lp->cur_tx, lp->tx_full);
dirty_tx += TX_RING_SIZE; dirty_tx += TX_RING_SIZE;
} }
#endif
if (lp->tx_full && if (lp->tx_full &&
netif_queue_stopped(dev) && netif_queue_stopped(dev) &&
dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) { dirty_tx > lp->cur_tx - TX_RING_SIZE + 2) {
...@@ -1262,7 +1257,7 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs) ...@@ -1262,7 +1257,7 @@ pcnet32_interrupt(int irq, void *dev_id, struct pt_regs * regs)
/* Clear any other interrupt, and set interrupt enable. */ /* Clear any other interrupt, and set interrupt enable. */
lp->a.write_csr (ioaddr, 0, 0x7940); lp->a.write_csr (ioaddr, 0, 0x7940);
lp->a.write_rap(ioaddr,rap); lp->a.write_rap (ioaddr,rap);
if (pcnet32_debug > 4) if (pcnet32_debug > 4)
printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n", printk(KERN_DEBUG "%s: exiting interrupt, csr0=%#4.4x.\n",
...@@ -1315,7 +1310,9 @@ pcnet32_rx(struct net_device *dev) ...@@ -1315,7 +1310,9 @@ pcnet32_rx(struct net_device *dev)
skb_put (skb, pkt_len); skb_put (skb, pkt_len);
lp->rx_skbuff[entry] = newskb; lp->rx_skbuff[entry] = newskb;
newskb->dev = dev; newskb->dev = dev;
lp->rx_dma_addr[entry] = pci_map_single(lp->pci_dev, newskb->tail, newskb->len, PCI_DMA_FROMDEVICE); lp->rx_dma_addr[entry] =
pci_map_single(lp->pci_dev, newskb->tail,
newskb->len, PCI_DMA_FROMDEVICE);
lp->rx_ring[entry].base = le32_to_cpu(lp->rx_dma_addr[entry]); lp->rx_ring[entry].base = le32_to_cpu(lp->rx_dma_addr[entry]);
rx_in_place = 1; rx_in_place = 1;
} else } else
...@@ -1446,13 +1443,13 @@ static void pcnet32_load_multicast (struct net_device *dev) ...@@ -1446,13 +1443,13 @@ static void pcnet32_load_multicast (struct net_device *dev)
/* set all multicast bits */ /* set all multicast bits */
if (dev->flags & IFF_ALLMULTI){ if (dev->flags & IFF_ALLMULTI){
ib->filter [0] = 0xffffffff; ib->filter[0] = 0xffffffff;
ib->filter [1] = 0xffffffff; ib->filter[1] = 0xffffffff;
return; return;
} }
/* clear the multicast filter */ /* clear the multicast filter */
ib->filter [0] = 0; ib->filter[0] = 0;
ib->filter [1] = 0; ib->filter[1] = 0;
/* Add addresses */ /* Add addresses */
for (i = 0; i < dev->mc_count; i++){ for (i = 0; i < dev->mc_count; i++){
...@@ -1649,20 +1646,28 @@ static int pcnet32_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -1649,20 +1646,28 @@ static int pcnet32_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
} }
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static struct pci_driver pcnet32_driver = { static struct pci_driver pcnet32_driver = {
name: DRV_NAME, name: DRV_NAME,
probe: pcnet32_probe_pci, probe: pcnet32_probe_pci,
remove: NULL, id_table: pcnet32_pci_tbl,
id_table: pcnet32_pci_tbl,
}; };
MODULE_PARM(debug, "i"); MODULE_PARM(debug, "i");
MODULE_PARM_DESC(debug, DRV_NAME " debug level (0-6)");
MODULE_PARM(max_interrupt_work, "i"); MODULE_PARM(max_interrupt_work, "i");
MODULE_PARM_DESC(max_interrupt_work, DRV_NAME " maximum events handled per interrupt");
MODULE_PARM(rx_copybreak, "i"); MODULE_PARM(rx_copybreak, "i");
MODULE_PARM_DESC(rx_copybreak, DRV_NAME " copy breakpoint for copy-only-tiny-frames");
MODULE_PARM(tx_start_pt, "i"); MODULE_PARM(tx_start_pt, "i");
MODULE_PARM_DESC(tx_start_pt, DRV_NAME " transmit start point (0-3)");
MODULE_PARM(pcnet32vlb, "i");
MODULE_PARM_DESC(pcnet32vlb, DRV_NAME " Vesa local bus (VLB) support (0/1)");
MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i"); MODULE_PARM(options, "1-" __MODULE_STRING(MAX_UNITS) "i");
MODULE_PARM_DESC(options, DRV_NAME " initial option setting(s) (0-15)");
MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i"); MODULE_PARM(full_duplex, "1-" __MODULE_STRING(MAX_UNITS) "i");
MODULE_PARM_DESC(full_duplex, DRV_NAME " full duplex setting(s) (1)");
MODULE_AUTHOR("Thomas Bogendoerfer"); MODULE_AUTHOR("Thomas Bogendoerfer");
MODULE_DESCRIPTION("Driver for PCnet32 and PCnetPCI based ethercards"); MODULE_DESCRIPTION("Driver for PCnet32 and PCnetPCI based ethercards");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
...@@ -1673,36 +1678,25 @@ static int tx_start_pt = -1; ...@@ -1673,36 +1678,25 @@ static int tx_start_pt = -1;
static int __init pcnet32_init_module(void) static int __init pcnet32_init_module(void)
{ {
int cards_found = 0; printk(KERN_INFO "%s", version);
int err;
if (debug > 0) if (debug > 0)
pcnet32_debug = debug; pcnet32_debug = debug;
if ((tx_start_pt >= 0) && (tx_start_pt <= 3)) if ((tx_start_pt >= 0) && (tx_start_pt <= 3))
tx_start = tx_start_pt; tx_start = tx_start_pt;
pcnet32_dev = NULL;
/* find the PCI devices */ /* find the PCI devices */
#define USE_PCI_REGISTER_DRIVER pci_module_init(&pcnet32_driver);
#ifdef USE_PCI_REGISTER_DRIVER
if ((err = pci_module_init(&pcnet32_driver)) < 0 ) /* should we find any remaining VLbus devices ? */
return err; if (pcnet32vlb)
#else pcnet32_probe_vlbus();
{
struct pci_device_id *devid = pcnet32_pci_tbl; if (cards_found)
for (devid = pcnet32_pci_tbl; devid != NULL && devid->vendor != 0; devid++) { printk(KERN_INFO PFX "%d cards_found.\n", cards_found);
struct pci_dev *pdev = pci_find_subsys(devid->vendor, devid->device, devid->subvendor, devid->subdevice, NULL);
if (pdev != NULL) { return cards_found ? 0 : -ENODEV;
if (pcnet32_probe_pci(pdev, devid) >= 0) {
cards_found++;
}
}
}
}
#endif
return 0;
/* find any remaining VLbus devices */
return pcnet32_probe_vlbus(cards_found);
} }
static void __exit pcnet32_cleanup_module(void) static void __exit pcnet32_cleanup_module(void)
...@@ -1711,13 +1705,13 @@ static void __exit pcnet32_cleanup_module(void) ...@@ -1711,13 +1705,13 @@ static void __exit pcnet32_cleanup_module(void)
/* No need to check MOD_IN_USE, as sys_delete_module() checks. */ /* No need to check MOD_IN_USE, as sys_delete_module() checks. */
while (pcnet32_dev) { while (pcnet32_dev) {
struct pcnet32_private *lp = pcnet32_dev->priv; struct pcnet32_private *lp = pcnet32_dev->priv;
next_dev = lp->next; next_dev = lp->next;
unregister_netdev(pcnet32_dev); unregister_netdev(pcnet32_dev);
release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE); release_region(pcnet32_dev->base_addr, PCNET32_TOTAL_SIZE);
if (lp->pci_dev != NULL) if (lp->pci_dev)
pci_unregister_driver(&pcnet32_driver); pci_unregister_driver(&pcnet32_driver);
pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr); pci_free_consistent(lp->pci_dev, sizeof(*lp), lp, lp->dma_addr);
kfree(pcnet32_dev); kfree(pcnet32_dev);
pcnet32_dev = next_dev; pcnet32_dev = next_dev;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment