|
|
@ -1222,6 +1222,9 @@ MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); |
|
|
|
MODULE_PARM_DESC(eeprom_bad_csum_allow, "Allow bad eeprom checksums"); |
|
|
|
#if 1 |
|
|
|
#define DPRINTK(...) |
|
|
|
#define DPRINTK1(nlevel, klevel, fmt, args...) \ |
|
|
|
(void)( printk("%s: %s: " fmt, nic->netdev->name, \ |
|
|
|
__FUNCTION__ , ## args)) |
|
|
|
#else |
|
|
|
#define DPRINTK(nlevel, klevel, fmt, args...) \ |
|
|
|
(void)( printk("%s: %s: " fmt, nic->netdev->name, \ |
|
|
@ -1806,7 +1809,7 @@ static int e100_eeprom_load(struct nic *nic) |
|
|
|
* the sum of words should be 0xBABA */ |
|
|
|
checksum = le16_to_cpu(0xBABA - checksum); |
|
|
|
if(checksum != nic->eeprom[nic->eeprom_wc - 1]) { |
|
|
|
DPRINTK(PROBE, ERR, "EEPROM corrupted\n"); |
|
|
|
DPRINTK1(PROBE, ERR, "EEPROM corrupted\n"); |
|
|
|
if (!eeprom_bad_csum_allow) |
|
|
|
return -EAGAIN; |
|
|
|
} |
|
|
@ -1834,6 +1837,7 @@ static int e100_eeprom_save(struct nic *nic, u16 start, u16 count) |
|
|
|
for(addr = 0; addr < nic->eeprom_wc - 1; addr++) |
|
|
|
checksum += cpu_to_le16(nic->eeprom[addr]); |
|
|
|
nic->eeprom[nic->eeprom_wc - 1] = le16_to_cpu(0xBABA - checksum); |
|
|
|
printf("checksum %x\n",le16_to_cpu(0xBABA - checksum)); |
|
|
|
e100_eeprom_write(nic, addr_len, nic->eeprom_wc - 1, |
|
|
|
nic->eeprom[nic->eeprom_wc - 1]); |
|
|
|
|
|
|
@ -3364,12 +3368,17 @@ static int e100_probe(struct net_device *netdev,struct pci_dev *pdev, |
|
|
|
} |
|
|
|
|
|
|
|
if((err = e100_eeprom_load(nic))) |
|
|
|
goto err_out_free; |
|
|
|
{ |
|
|
|
cmd_wrprom_fxp0(0,0); |
|
|
|
// goto err_out_free;
|
|
|
|
} |
|
|
|
|
|
|
|
e100_phy_init(nic); |
|
|
|
|
|
|
|
memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN); |
|
|
|
memcpy(netdev->perm_addr, nic->eeprom, ETH_ALEN); |
|
|
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
if(!is_valid_ether_addr(netdev->perm_addr)) { |
|
|
|
DPRINTK(PROBE, ERR, "Invalid MAC address from " |
|
|
@ -3389,7 +3398,6 @@ static int e100_probe(struct net_device *netdev,struct pci_dev *pdev, |
|
|
|
if (err) |
|
|
|
DPRINTK(PROBE, ERR, "Error clearing wake event\n"); |
|
|
|
|
|
|
|
strcpy(netdev->name, "eth%d"); |
|
|
|
#if 0 |
|
|
|
if((err = register_netdev(netdev))) { |
|
|
|
DPRINTK(PROBE, ERR, "Cannot register net device, aborting.\n"); |
|
|
@ -3689,6 +3697,8 @@ static void fxp_watchdog( struct ifnet *ifp ) |
|
|
|
ifp->if_timer = 5; |
|
|
|
} |
|
|
|
|
|
|
|
static struct net_device *mynic_fxp; |
|
|
|
|
|
|
|
static void |
|
|
|
fxp_attach(parent, self, aux) |
|
|
|
struct device *parent, *self; |
|
|
@ -3705,6 +3715,7 @@ fxp_attach(parent, self, aux) |
|
|
|
//bus_addr_t iobase;
|
|
|
|
//bus_size_t iosize;
|
|
|
|
#endif |
|
|
|
mynic_fxp = sc ; |
|
|
|
|
|
|
|
/*
|
|
|
|
* Allocate our interrupt. |
|
|
@ -3841,6 +3852,7 @@ fxp_stop(struct net_device *netdev) |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static int |
|
|
|
fxp_ether_ioctl(ifp, cmd, data) |
|
|
|
struct ifnet *ifp; |
|
|
@ -3903,6 +3915,27 @@ fxp_ether_ioctl(ifp, cmd, data) |
|
|
|
fxp_stop(sc); |
|
|
|
} |
|
|
|
break; |
|
|
|
case SIOCETHTOOL: |
|
|
|
{ |
|
|
|
long *p=data; |
|
|
|
mynic_fxp = sc; |
|
|
|
cmd_setmac_fxp0(p[0],p[1]); |
|
|
|
} |
|
|
|
break; |
|
|
|
case SIOCRDEEPROM: |
|
|
|
{ |
|
|
|
long *p=data; |
|
|
|
mynic_fxp = sc; |
|
|
|
cmd_reprom_fxp0(p[0],p[1]); |
|
|
|
} |
|
|
|
break; |
|
|
|
case SIOCWREEPROM: |
|
|
|
{ |
|
|
|
long *p=data; |
|
|
|
mynic_fxp = sc; |
|
|
|
cmd_wrprom_fxp0(p[0],p[1]); |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
error = EINVAL; |
|
|
@ -3919,3 +3952,203 @@ struct cfattach fxp_ca = { |
|
|
|
struct cfdriver fxp_cd = { |
|
|
|
NULL, "fxp", DV_IFNET |
|
|
|
}; |
|
|
|
#define EEPROM_CHECKSUM_REG 0x003F |
|
|
|
|
|
|
|
void fxp_read_eeprom(nic, data, offset, words) |
|
|
|
struct nic *nic; |
|
|
|
u_short *data; |
|
|
|
int offset; |
|
|
|
int words; |
|
|
|
{ |
|
|
|
u16 addr, addr_len = 8, i; |
|
|
|
e100_eeprom_read(nic, &addr_len, addr); |
|
|
|
for(i=0;i<words;i++) |
|
|
|
data[i] = e100_eeprom_read(nic, &addr_len, offset+i); |
|
|
|
} |
|
|
|
|
|
|
|
static long long e100_read_mac(struct fxp_softc *nic) |
|
|
|
{ |
|
|
|
|
|
|
|
int i; |
|
|
|
long long mac_tmp = 0; |
|
|
|
u_int16_t enaddr[3]; |
|
|
|
unsigned short tmp=0; |
|
|
|
|
|
|
|
fxp_read_eeprom(nic, enaddr, 0, 3); |
|
|
|
|
|
|
|
for (i = 0; i < 3; i++) { |
|
|
|
tmp=0; |
|
|
|
tmp = ((enaddr[i] & 0xff) <<8)|((enaddr[i] & 0xff00)>>8); |
|
|
|
mac_tmp <<= 16; |
|
|
|
mac_tmp |= tmp; |
|
|
|
} |
|
|
|
return mac_tmp; |
|
|
|
} |
|
|
|
|
|
|
|
int cmd_setmac_fxp0(int ac, char *av[]) |
|
|
|
{ |
|
|
|
int i; |
|
|
|
unsigned short v; |
|
|
|
struct nic *nic ; |
|
|
|
unsigned short val_fxp = 0; |
|
|
|
|
|
|
|
if(mynic_fxp == NULL){ |
|
|
|
printf("epro100 interface not initialized\n"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
nic = netdev_priv(mynic_fxp); |
|
|
|
|
|
|
|
if(ac != 2){ |
|
|
|
long long macaddr; |
|
|
|
u_int8_t *paddr; |
|
|
|
u_int8_t enaddr[6]; |
|
|
|
macaddr=e100_read_mac(nic); |
|
|
|
paddr=(uint8_t*)&macaddr; |
|
|
|
enaddr[0] = paddr[5- 0]; |
|
|
|
enaddr[1] = paddr[5- 1]; |
|
|
|
enaddr[2] = paddr[5- 2]; |
|
|
|
enaddr[3] = paddr[5- 3]; |
|
|
|
enaddr[4] = paddr[5- 4]; |
|
|
|
enaddr[5] = paddr[5- 5]; |
|
|
|
printf("MAC ADDRESS "); |
|
|
|
for(i=0; i<6; i++){ |
|
|
|
printf("%02x",enaddr[i]); |
|
|
|
if(i==5) |
|
|
|
printf("\n"); |
|
|
|
else |
|
|
|
printf(":"); |
|
|
|
} |
|
|
|
printf("Use \"setmac <mac> \" to set mac address\n"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
for (i = 0; i < 3; i++) { |
|
|
|
val_fxp = 0; |
|
|
|
gethex(&v, av[1], 2); |
|
|
|
val_fxp = v ; |
|
|
|
av[1]+=3; |
|
|
|
gethex(&v, av[1], 2); |
|
|
|
val_fxp = val_fxp | (v << 8); |
|
|
|
av[1] += 3; |
|
|
|
nic->eeprom[i]=val_fxp; |
|
|
|
} |
|
|
|
e100_eeprom_save(nic,0,3); |
|
|
|
printf("Write MAC address successfully!\n"); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
#if 1 |
|
|
|
static unsigned long next = 1; |
|
|
|
|
|
|
|
/* RAND_MAX assumed to be 32767 */ |
|
|
|
static int myrand(void) { |
|
|
|
next = next * 1103515245 + 12345; |
|
|
|
return((unsigned)(next/65536) % 32768); |
|
|
|
} |
|
|
|
|
|
|
|
static void mysrand(unsigned int seed) { |
|
|
|
next = seed; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
int cmd_wrprom_fxp0(int ac,char *av) |
|
|
|
{ |
|
|
|
int i=0; |
|
|
|
unsigned long clocks_num=0; |
|
|
|
unsigned char tmp[4]; |
|
|
|
unsigned short eeprom_data; |
|
|
|
unsigned short rom[EEPROM_CHECKSUM_REG+1]={ |
|
|
|
#if 0
|
|
|
|
0x0a00, 0x5dc4, 0x9b78, 0x0203, 0x0000, 0x0201, 0x4701, 0x0000, |
|
|
|
0xa276, 0x9501, 0x5022, 0x5022, 0x5022, 0x007f, 0x0000, 0x0000, |
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
|
|
0x0000, 0x0000, 0x0000, 0x1229, 0x0000, 0x0000, 0x0000, 0x0000, |
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
|
|
0x0128, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, |
|
|
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x30cc |
|
|
|
#else |
|
|
|
0x0200, 0x00B3, 0x0000, 0x0203, 0xFFFF, 0x0201, 0x4701, 0xFFFF, |
|
|
|
0xA795, 0x7401, 0x5FA2, 0x0070, 0x8086, 0x007F, 0xFFFF, 0xFFFF, |
|
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0x1209, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
|
0x00EC, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, |
|
|
|
0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF |
|
|
|
#endif |
|
|
|
}; |
|
|
|
|
|
|
|
struct nic *nic = netdev_priv(mynic_fxp); |
|
|
|
|
|
|
|
printf("Now beginningwrite whole eprom\n"); |
|
|
|
|
|
|
|
#if 1 |
|
|
|
clocks_num =CPU_GetCOUNT(); // clock();
|
|
|
|
mysrand(clocks_num); |
|
|
|
for( i = 0; i < 4;i++ ) |
|
|
|
{ |
|
|
|
tmp[i]=myrand()%256; |
|
|
|
printf( " tmp[%d]=0x%2x\n", i,tmp[i]); |
|
|
|
} |
|
|
|
eeprom_data =tmp[1] |( tmp[0]<<8); |
|
|
|
rom[1] = eeprom_data ; |
|
|
|
printf("eeprom_data [1] = 0x%4x\n",eeprom_data); |
|
|
|
eeprom_data =tmp[3] |( tmp[2]<<8); |
|
|
|
rom[2] = eeprom_data; |
|
|
|
printf("eeprom_data [2] = 0x%4x\n",eeprom_data); |
|
|
|
#endif |
|
|
|
memcpy(nic->eeprom,rom,EEPROM_CHECKSUM_REG); |
|
|
|
e100_eeprom_save(nic,0,EEPROM_CHECKSUM_REG); |
|
|
|
|
|
|
|
printf("Write the whole eeprom OK!\n"); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int cmd_reprom_fxp0(int ac, char *av) |
|
|
|
{ |
|
|
|
int i; |
|
|
|
unsigned short eeprom_data; |
|
|
|
struct nic *nic = netdev_priv(mynic_fxp); |
|
|
|
e100_eeprom_load(nic); |
|
|
|
printf("dump eprom:\n"); |
|
|
|
|
|
|
|
for(i=0; i <= EEPROM_CHECKSUM_REG;) |
|
|
|
{ |
|
|
|
printf("%04x ", nic->eeprom[i]); |
|
|
|
++i; |
|
|
|
if( i%8 == 0 ) |
|
|
|
printf("\n"); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static const Optdesc netdmp_opts[] = |
|
|
|
{ |
|
|
|
{"<interface>", "Interface name"}, |
|
|
|
{"<netdmp>", "IP Address"}, |
|
|
|
{0} |
|
|
|
}; |
|
|
|
|
|
|
|
static const Cmd Cmds[] = |
|
|
|
{ |
|
|
|
{"fxp"}, |
|
|
|
{"setmac_fxp", "", NULL, |
|
|
|
"Set mac address into E100 eeprom", cmd_setmac_fxp0, 1, 5, 0}, |
|
|
|
{"readrom_fxp", "", NULL, |
|
|
|
"dump E100 eprom content", cmd_reprom_fxp0, 1, 2, 0}, |
|
|
|
{"writerom_fxp", "", NULL, |
|
|
|
"write E100 eprom content", cmd_wrprom_fxp0, 1, 2, 0}, |
|
|
|
{0, 0} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
static void init_cmd __P((void)) __attribute__ ((constructor)); |
|
|
|
|
|
|
|
static void |
|
|
|
init_cmd() |
|
|
|
{ |
|
|
|
cmdlist_expand(Cmds, 1); |
|
|
|
} |
|
|
|
|
|
|
|