--- /home/tm/smap.c.original Sat Jun 15 21:05:06 2002 +++ linux/drivers/ps2/smap.c Mon Jul 1 21:58:44 2002 @@ -83,26 +83,29 @@ if ((smap->flags & SMAP_F_LINKVALID) == 0) { printk("%s: xmit: link not valid\n", net_dev->name); retval = -EINVAL; - goto end; + printk("Misty: Resetting card.\n"); + (void)set_bit(0, (void *)&smap->net_dev->tbusy); + (void)smap_reset(smap, RESET_ONLY); + goto end_smap_start_xmit; } if (skb == NULL) { printk("%s: xmit: skb NULL\n", net_dev->name); - goto end; + goto end_smap_start_xmit; } if (skb->len > SMAP_TXMAXSIZE) { printk("%s: xmit: length error(%d)\n", net_dev->name,skb->len); retval = -EINVAL; - goto end; + goto end_smap_start_xmit; } if (smap->txbdusedcnt >= (SMAP_BD_MAX_ENTRY-1)) { printk("%s: xmit: txbd is full\n", net_dev->name); retval = -EBUSY; - goto end; + goto end_smap_start_xmit; } if (txbd->ctrl_stat & SMAP_BD_TX_READY) { printk("%s: xmit: all txbd is used\n", net_dev->name); retval = -EBUSY; - goto end; + goto end_smap_start_xmit; } /* check datalen and free buffer space */ @@ -114,14 +117,20 @@ if (txlen > smap->txfreebufsize) { printk("%s: xmit: no space, txlen(%d), free space(%d)\n", net_dev->name,txlen,smap->txfreebufsize); + printk("Misty: If you see the system freeze after this TELL ME\n"); + printk("Misty: at misty-@charter.net\n"); + printk("Misty: Dropping packet and resetting variables.\n"); + txlen = 0; + skb->len = 0; + smap->txfreebufsize = SMAP_TXBUFSIZE; retval = -ENOSPC; - goto end; + goto end_smap_start_xmit; } txmode0 = EMAC3REG_READ(smap, SMAP_EMAC3_TxMODE0); if (txmode0 & E3_TX_GNP_0) { retval = -EBUSY; - goto end; + goto end_smap_start_xmit; } if (test_and_set_bit(0, (void *)&net_dev->tbusy) != 0) { int tickssofar = jiffies - net_dev->trans_start; @@ -129,7 +138,7 @@ printk("%s: xmit timeout ticks = %d\n", net_dev->name, tickssofar); net_dev->trans_start = jiffies; /* save new timestamp */ retval = -EBUSY; - goto end; + goto end_smap_start_xmit; } /* clear padding bytes */ @@ -153,6 +162,7 @@ smap->txfreebufsize -= txlen; /* send from FIFO to ethernet */ +// printk ("*send from fifo* txbd->length=%d skb->len=%d txlen=%d\n", txbd->length, skb->len, txlen); txbd->length = skb->len; txbd->pointer = smap->txbwp; @@ -177,7 +187,7 @@ net_dev->trans_start = jiffies; /* save the timestamp */ -end: +end_smap_start_xmit: restore_flags(flags); if ((retval == 0) && (skb != NULL)) dev_kfree_skb(skb); @@ -197,6 +207,7 @@ txbd = &smap->txbd[smap->txbdi]; txstat = txbd->ctrl_stat; +// printk("txfreebufsize before loop is %d\n", smap->txfreebufsize); while (((txstat & SMAP_BD_TX_READY) == 0) && (smap->txbdusedcnt > 0)) { if (smap->flags & SMAP_F_PRINT_PKT) { printk("%s: tx intr: process packet," @@ -209,7 +220,10 @@ txlen = txbd->length; else txlen = txbd->length + (4 - (txbd->length%4)); + +// printk("*just before buffer sizeup* txbd->length=%d txlen=%d\n", txbd->length, txlen); smap->txfreebufsize += txlen; +// printk("txfreebufsize after addition is %d\n", smap->txfreebufsize); error = 0; if (txstat & 0x7FFF) { @@ -247,6 +261,8 @@ error++; if (smap->flags & SMAP_F_PRINT_MSG) { printk("%s:tx intr: late collision\n", net_dev->name); + printk("txfreebufsize during suspect collide code is %d\n", smap->txfreebufsize); + printk("*during collide code* txbd->length=%d txlen=%d\n", txbd->length, txlen); } } if (txstat & SMAP_BD_TX_MCOLL) { @@ -294,6 +310,10 @@ SMAP_BD_NEXT(smap->txbdi); txbd = &smap->txbd[smap->txbdi]; txstat = txbd->ctrl_stat; + + if (smap->txfreebufsize < 4096) + printk("Misty: WARNING: xmit buffer < 4096! (smap->txfreebufsize=%d)\n", smap->txfreebufsize); + } return; @@ -374,7 +394,7 @@ printk("%s:Rx intr: [%d]=stat(0x%04x, 0x%04x), len(%d, 0x%04x), ptr(0x%04x)\n", net_dev->name, smap->rxbdi, rxstat,rxbd->ctrl_stat,rxbd->length,rxbd->length,rxbd->pointer); } pkt_err = SET; - goto next; + goto next_smap_rx_intr; } pkt_len = rxbd->length; @@ -385,7 +405,7 @@ net_dev->name, pkt_len); } pkt_err = SET; - goto next; + goto next_smap_rx_intr; } /* rxlen is multiple of 4 */ @@ -415,7 +435,7 @@ if (skb == NULL) { printk("%s:rx intr: skb alloc error\n",net_dev->name); end = SET; - goto next; + goto next_smap_rx_intr; } skb_reserve(skb, 2); /* 16 byte align the data fields */ #if 1 @@ -428,7 +448,7 @@ skb->protocol = eth_type_trans(skb, net_dev); net_dev->last_rx = jiffies; netif_rx(skb); -next: +next_smap_rx_intr: SMAPREG8(smap,SMAP_RXFIFO_FRAME_DEC) = 1; rx_pkt_cnt++; @@ -583,7 +603,7 @@ ena = SMAPREG16(smap,SMAP_INTR_ENABLE) & INTR_BITMSK; stat &= ena; if (stat == 0) - goto end; + goto end_smap_interrupt; if (stat & INTR_TXDNV) { /* disable TXDNV interrupt */ @@ -626,7 +646,7 @@ if (stat & INTR_EMAC3) { (void)smap_emac3_intr(net_dev); } -end: +end_smap_interrupt: net_dev->interrupt = 0; restore_flags(flags); return; @@ -828,7 +848,7 @@ struct smap_chan *smap = net_dev->priv; u_int32_t txmode0; int i; - + int a; if (smap->flags & SMAP_F_PRINT_MSG) { printk("%s: PlayStation 2 SMAP close\n", net_dev->name); } @@ -843,13 +863,27 @@ /* confirm E3_TX_GNP_0 bit in TxMODE0 is inactivated */ i = 0; + a = 10; + do { txmode0 = EMAC3REG_READ(smap, SMAP_EMAC3_TxMODE0); - if ( ((++i%SMAP_LOOP_COUNT) == 0) && (txmode0 & E3_TX_GNP_0) ) + if ( ((++i%SMAP_LOOP_COUNT) == 0) && (txmode0 & E3_TX_GNP_0) ) { + printk("%s: close: TxMAC is still running(%d,0x%08x)\n", net_dev->name, i, txmode0); + printk("Misty: This annoying error message should only be seen %d more times.\n", a); + printk("Misty: If you see this more than that, or there are other problems associated with this\n"); + printk("Misty: Email misty-@charter.net with details...\n"); + a -= 1; + if (a == 0) { + printk("Misty: Attempt to send all the remaining packets failed, sorry. Unloading driver...\n"); + goto smap_closeERROR; + } + } } while (txmode0 & E3_TX_GNP_0); +smap_closeERROR: + (void)smap_txrx_XXable(smap, DISABLE); (void)smap_interrupt_XXable(smap, DISABLE); @@ -1294,17 +1328,30 @@ if (reset_only) /* this flag may be set when unloading */ return 0; - /* auto-negotiation */ - val = smap_auto_negotiation(smap, ENABLE); - if (val == 0) { - /* wait 1 second ?? probably need not */ - smap->flags |= SMAP_F_LINKESTABLISH; - (void)smap_phy_set_dsp(smap); - return(0); /* auto-negotiation is succeeded */ - } + // auto-negotiation + // No, we DON'T want to do this. Using 100Mbit fubars. + // If you want to turn auto negotiate back on, set it to if 1 and 10Mbit's if to 0 + // Don't turn this on unless you want to fix it! + +#if 0 + val = smap_auto_negotiation(smap, ENABLE); + if (val == 0) { + /* wait 1 second ?? probably need not */ + smap->flags |= SMAP_F_LINKESTABLISH; + (void)smap_phy_set_dsp(smap); + return(0); /* auto-negotiation is succeeded */ + } +#endif /* force 100Mbps(HDX) or 10Mbps(HDX) */ + /* Don't turn this on unless you want to fix it! */ +#if 0 (void)smap_force_spd_100M(smap); +#endif + +#if 1 + (void)smap_force_spd_10M(smap); +#endif return(0); } @@ -1341,6 +1388,8 @@ { int i, val; + printk ("Misty: autodetect is not recommended! Do not complain about errors!\n"); + if (enable_auto_nego) { /* set auto-negotiation */ smap_write_phy(smap, DsPHYTER_ADDRESS, DsPHYTER_BMCR, @@ -1425,6 +1474,8 @@ static void smap_force_spd_100M(struct smap_chan *smap) { + printk("Misty: 100Mbps force speed mode is not recommended! Do not complain about errors!\n"); + printk("%s: try 100Mbps Half duplex mode...\n", smap->net_dev->name); /* set 100Mbps, half duplex */ @@ -1442,6 +1493,7 @@ static void smap_force_spd_10M(struct smap_chan *smap) { + printk("Misty: ps2 smap driver version 0.1.0\n"); printk("%s: try 10Mbps Half duplex mode...\n", smap->net_dev->name); /* set 10Mbps, half duplex */ @@ -1473,7 +1525,7 @@ interruptible_sleep_on_timeout(&smap->wait_linknego, HZ/100); /* wait 10ms */ } if (i) { -validlink: +validlink_smap_confirm_force_spd: e3v = EMAC3REG_READ(smap, SMAP_EMAC3_MODE1); e3v &= ~(E3_FDX_ENABLE|E3_FLOWCTRL_ENABLE|E3_ALLOW_PF|E3_MEDIA_MSK); if (smap->flags & SMAP_F_CHECK_FORCE100M) { @@ -1501,7 +1553,7 @@ if (phyval & PHY_STS_LINK) { /* valid link */ smap->flags |= SMAP_F_CHECK_FORCE10M; - goto validlink; + goto validlink_smap_confirm_force_spd; } else { printk("%s: fail force speed mode." " link not valid. phystat=0x%04x\n", @@ -1914,8 +1966,16 @@ if (smap->flags & SMAP_F_LINKVALID) { smap->flags &= ~(SMAP_F_LINKESTABLISH|SMAP_F_LINKVALID); printk("%s: link down\n", smap->net_dev->name); + printk("Misty: Investigating what the driver is doing.\n"); + printk("Misty: Please report the below values immediately.\n"); + printk("phyval is %d , PHY_STS_LINK is %d \n", phyval, PHY_STS_LINK); + printk("smap->flags is %d, SMAP_F_LINKVALID is %d\n", smap->flags, SMAP_F_LINKVALID); + printk("smap->net_dev->tbusy = %ld\n", smap->net_dev->tbusy); + printk("Misty: If you see this message often, email misty-@charter.net with the data reported, as well as your ifconfig eth0 output.\n"); + printk("Misty: Resetting card.\n"); (void)set_bit(0, (void *)&smap->net_dev->tbusy); (void)smap_reset(smap, RESET_ONLY); + } } if (phyval & PHY_STS_LINK) { @@ -2071,7 +2131,7 @@ net_dev = init_etherdev(NULL, 0); if (net_dev == NULL) { printk("PlayStation 2 SMAP: init_etherdev error\n"); - goto error; + goto error_smap_probe; } smap->net_dev = net_dev; net_dev->priv = smap; @@ -2092,7 +2152,7 @@ if ((smap->dtxbuf == NULL) || (smap->drxbuf == NULL)){ printk("PlayStation 2 SMAP: tx(%x)/rx(%x) buffer alloc error\n", smap->dtxbuf, smap->drxbuf); - goto error; + goto error_smap_probe; } if (((int)smap->dtxbuf & (SMAP_ALIGN-1)) == 0) smap->txbuf = smap->dtxbuf; @@ -2115,7 +2175,7 @@ smap_base_init(smap); r = smap_get_node_addr(smap); if (r < 0) - goto error; + goto error_smap_probe; smap_chan = smap; /* create and start thread */ @@ -2128,7 +2188,7 @@ return(0); /* success */ -error: +error_smap_probe: if (smap) { if (smap->dtxbuf) { kfree(smap->dtxbuf); @@ -2181,7 +2241,7 @@ } if (smap->net_dev == NULL) - goto end; + goto end_cleanup_module; net_dev = smap->net_dev; printk("%s: unloading...", net_dev->name); @@ -2191,7 +2251,7 @@ unregister_netdev(net_dev); -end: +end_cleanup_module: if (smap) { (void)smap_reset(smap, RESET_ONLY);