diff -u -r1.1.1.6 pcnet32.c --- linux/drivers/net/pcnet32.c 2001/01/20 11:10:30 1.1.1.6 +++ linux/drivers/net/pcnet32.c 2001/02/14 23:30:51 @@ -281,6 +281,7 @@ #endif }; +static int is_valid_ether_addr( char* ); int pcnet32_probe(struct device *); static int pcnet32_probe1(struct device *, unsigned long, unsigned char, int, int); static int pcnet32_open(struct device *); @@ -442,6 +443,18 @@ +/* Check that the ethernet station address is not 00:00:00:00:00:00 and is also + * not a multicast address + * Return true if the address is valid. + */ +int is_valid_ether_addr( char* address ) +{ + int i,isvalid=0; + for( i=0; i<6; i++) + isvalid |= address[i]; + return isvalid && !(address[0]&1); +} + int __init pcnet32_probe (struct device *dev) { unsigned long ioaddr = dev ? dev->base_addr: 0; @@ -648,10 +661,33 @@ printk(KERN_INFO "%s: %s at %#3lx,", dev->name, chipname, ioaddr); - /* There is a 16 byte station address PROM at the base address. - The first six bytes are the station address. */ - for (i = 0; i < 6; i++) - printk(" %2.2x", dev->dev_addr[i] = inb(ioaddr + i)); + /* In most chips, there is a station address PROM at the base address. + * However, if that does not have a valid address, try the "Physical + * Address Registers" CSR12-CSR14 + */ + { + /* There is a 16 byte station address PROM at the base address. + The first six bytes are the station address. */ + for (i = 0; i < 6; i++) { + dev->dev_addr[i] = inb(ioaddr + i); + } + if( !is_valid_ether_addr(dev->dev_addr) ) { + /* also double check this station address */ + for (i = 0; i < 3; i++) { + unsigned int val; + val = a->read_csr(ioaddr, i+12) & 0x0ffff; + /* There may be endianness issues here. */ + dev->dev_addr[2*i] = val & 0x0ff; + dev->dev_addr[2*i+1] = (val >> 8) & 0x0ff; + } + /* if this is not valid either, force to 00:00:00:00:00:00 */ + if( !is_valid_ether_addr(dev->dev_addr) ) + for (i = 0; i < 6; i++) + dev->dev_addr[i]=0; + } + for (i = 0; i < 6; i++) + printk(" %2.2x", dev->dev_addr[i] ); + } if (((chip_version + 1) & 0xfffe) == 0x2624) { /* Version 0x2623 or 0x2624 */ i = a->read_csr(ioaddr, 80) & 0x0C00; /* Check tx_start_pt */ @@ -796,6 +832,10 @@ lp->shared_irq ? SA_SHIRQ : 0, lp->name, (void *)dev)) { return -EAGAIN; } + + /* Check for a valid station address */ + if( !is_valid_ether_addr(dev->dev_addr) ) + return -EINVAL; /* Reset the PCNET32 */ lp->a.reset (ioaddr);